How do you determine a chemical formula given the molecule's crystal structure?
Knowledge of the crystal structure implies that you are also able to describe the unit cell of the compound. To determine its formula, count all sorts of atoms inside the unit cell, also considering fractional atoms which belong to more than one unit cell. For example, an atom at the corner of the unit cell counts as $\frac{1}{8}$ atom because it is shared between 8 adjacent unit cells. Likewise, an atom at the edge of the unit cell counts as $\frac{1}{4}$ as it belongs to 4 unit cells etc. When you obtain fractional values for the atom numbers, multiply the values of all atoms with a certain number so that all values are integers.

Let us take sodium chloride ($\ce{NaCl}$) as a simple example. Its unit cell, which is shown below, contains $\ce{Na+}$ (violet) and $\ce{Cl-}$ ions (green).



Counting the number of chloride ions in the unit cell gives

$$12 \cdot \frac{1}{4}+1=4 \ \ce{Cl-}$$

because there are 12 $\ce{Cl-}$ on the edges and 1 $\ce{Cl-}$ in the center of the unit cell. For the sodium ions, which are situated at the corners and on the faces (count as $\frac{1}{2}$ because they are shared between 2 cells) of the unit cell, we obtain

$$8 \cdot \frac{1}{8}+6 \cdot \frac{1}{2}=4 \ \ce{Na+}$$

The composition of the unit cell is therefore $\ce{Na4Cl4}$. Since the number of formula units per unit cell is 4, the formula of the compound is $\ce{NaCl}$.

For compounds in which the building blocks of the crystal structure are molecules, the procedure is essentially the same.