Several conditions need to be fulfilled for a photochemical reaction to proceed in crystals. Some of these conditions, for example, geometrical conditions, depend on the particular type of photochemical reaction, but the rest are common for all reactions. The mutual directionality of two neighbouring molecules determines the kind of product obtained. The influence of temperature on the probability of a photochemical reaction occurring varies for different types of photochemical reaction and different compounds. High pressure imposed on crystals also has a big influence on the free space and the reaction cavity. The wavelength of the applied UV light is another factor which can initiate a reaction and sometimes determine the structure of a product. It is possible, to a certain degree, to control the packing of molecules in stacks by using fluoro substituents on benzene rings. The crystal and molecular structure of 2,6-difluorocinnamic acid [systematic name: 3-(2,6-difluorophenyl)prop-2-enoic acid], C9H6F2O2, (I), was determined and analysed in terms of a photochemical [2 + 2] dimerization. The molecules are arranged in stacks along the a axis and the values of the intermolecular geometrical parameters indicate that they may undergo this photochemical reaction. The reaction was carried out in situ and the changes of the unit-cell parameters during crystal irradiation by a UV beam were monitored. The values of the unit-cell parameters change in a different manner, viz. cell length a after an initial increase starts to decrease, b after a decrease starts to increase, c increases and the unit-cell volume V after a certain increase starts to decrease. The structure of a partially reacted crystal, i.e. containing both the reactant and the product, namely 2,6-difluorocinnamic acid-3,4-bis(2,6-difluorophenyl)cyclobutane-1,2-dicarboxylic acid (0.858/0.071), 0.858C9H6F2O2·0.071C18H12F4O4, obtained in situ, is also presented. The powder of compound (I) was irradiated with UV light and afterwards crystallized [as 3,4-bis(2,6-difluorophenyl)cyclobutane-1,2-dicarboxylic acid toluene hemisolvate, C18H12F4O4·0.5C7H8] in a space group different from that of the crystal containing the in-situ dimer.