# Generate pdf document consisting in just one figure

Related to this question I am trying to generate a figure using package chemfig. Actually, my problem is that the lower part of the figure is cropped, specifically the H under the N.

This is the code:

\documentclass{standalone}
\usepackage{chemfig}
\begin{document}
\chemfig{*6(-\chembelow{\color{blue}N}{H}-(={\color{red}O})-{\color{blue}N}=(-{\color{blue}N}H_2)-=)}
\end{document}


Below, you see the figure as I got:

and as it should be:

• Is there an environment version of \chemfig? e.g. \begin{chemfig}... \end{chemfig}? If so, use that and add \standaloneenv{chemfig} to the preamble. – cfr Aug 16 '15 at 14:07
• @cfr I'm curious: why would or should that help? – clemens Aug 16 '15 at 14:31
• @clements In fact, it does not help. – werty Aug 16 '15 at 14:56
• @clemens It might not but it does with e.g. forest. If you are using forest, setting \standaloneenv{forest helps standalone get the cropping etc. correct. Especially if you are using multi because standalone starts a new page for each standaloneenv, which does not include forest by default. But I don't know if there is a macro equivalent e.g. \standalonecmd{} - I've never seen this. Then again, maybe I've just not looked in the right place? – cfr Aug 16 '15 at 16:17
• @cfr Ah OK. I never used forest so I can't compare if the problems are anywhere similar to \chembelow in this case… – clemens Aug 16 '15 at 16:31

Use \Chembelow (upper case!) instead of \chembelow. From the manual (emphasis by me):

The macro[...]

\chembelow[<dim>]{<code>}{<stuff>}


place[s] the <stuff> [...] below the <code> [...] without changing the bounding box of <code>.

The uppercase version on the other hand does extend the bounding box. (\lewis and \Lewis have the same relationship, by the way.)

• It works! Great! – werty Aug 16 '15 at 14:57

The Chembelow macro can be used but the result is not perfect since the bounding box (too high) modifies the position of bonds coming and leaving N:

\Chembelow cannot give a good result and \chembelow sends H outside the croping. A solution is to use an invisible bond (the .25 lenght found with try/error):

\documentclass{standalone}
\usepackage{chemfig}
\begin{document}
\chemfig{*6(-\color{blue}{N}(-[,.25,,,draw=none]H)-(={\color{red}O})-{\color{blue}N}=(-{\color{blue}N}H_2)-=)}
\end{document}


Pershaps the better solution, but more verbose, is to use \chemfig* (with a star) since it the length of the invisible bond can be set to 0 (0 is 0.0001 for tikz):

\chemfig*{*6(-\color{blue}{N}(-[,.0001,,,draw=none]{\lower0.25ex\hbox{H}})-(={\color{red}O})-{\color{blue}N}=(-{\color{blue}N}H_2)-=)}