3

chemfig offers the \chemname command that allows us to add an annotation (name, number,...) to a chemical compound. To save space and avoid repetition when dealing with similar compounds, "R" is often used instead of a more specific substituent. "R" is usually defined below the compound. For this, I tried to use the \chemname{<compound>}{>name>} command, but with a tabular in the <name> part of the command.

While the horizontal alignment looks as expected, the vertical alignment is off, if compared to compounds that are named without using a tabular. (See image below, left: with tabular, middle and right: without tabular). An alternative, that does not alter the vertical position of the text would be using a \parbox, but this approach requires determining the width of the text in order to get it centered below the molecule and it does not allow for the same column-like alignment of substituents and numbers, that a tabular does.

enter image description here

What causes this additional white space above text inside of a tabular and is there a better way to achieve the desired output?

Here is the code used to create the screenshot shown above.

\documentclass{report}
\usepackage{chemfig}

\begin{document}

\schemestart
    \chemname{\chemfig{R-OH}}
             {{\begin{tabular}[t]{l@{\;}l}
               R = \textit{n}-Bu: & 1a\\
               R = Et: & 1b\\
             \end{tabular}}}
    \chemname{\chemfig{Me-OH}}
             {2}  
    \chemname{\chemfig{R-OH}}
             {\parbox{2.25cm}{R = \textit{n}-Bu:  1a\\ R = Et:  1b\\}}
\schemestop

\end{document}

Related: https://tex.stackexchange.com/a/605961/134144

1
  • Maybe it is due to the strut. What about {\def\arraystretch{0}\begin{tabular}...\\[5pt]...\end{tabular}}?
    – L.J.R.
    Jul 24 at 11:10
5

How about this? enter image description here

\documentclass{report}
\usepackage{chemfig}
\begin{document}
\schemestart
\begin{tabular}{ccc}
\chemfig{R-OH}
&
\chemfig{Me-OH}
&
\chemfig{R-OH}
\\
\begin{tabular}[t]{l@{\;}l}
 R = \textit{n}-Bu: & 1a\\
 R = Et: & 1b
\end{tabular}
&
2
&
\parbox[t]{2.25cm}{
 R = \textit{n}-Bu: 1a\\
 R = Et: 1b
}
\end{tabular}
\schemestop
\end{document}
2
  • Thanks for your suggestion. While it does work in this particular simplified example, as far as I can tell, it will however lead to inconsistent (horizontal) spacing if used inside of a actual reaction scheme which also includes \+ and \arrow. Especially, if there are other "traditional" schemes using \chemname for the naming/numbering part in the same document.
    – leandriis
    Jul 24 at 16:22
  • @leandriis, you are welcome. My impression is that alignment behavior of chemical reactions involving \chemname is somewhat inconsistent and unstable in the current version of \chemfig. If you need perfect control of everything in the picture, then you might want to avoid it.
    – citsahcots
    Jul 24 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.