2

How do I manage to shrink the structural formulas to the width of the text below so that they are still on one line? If necessary, you can distribute the structural formulas on two or more lines, the main thing is that they are adapted to the text width

\documentclass[english]{scrartcl}

\usepackage{babel} \usepackage{chemfig} \usepackage{blindtext}

\begin{document}

\section{Structural formula}

\begin{center} \schemestart \chemname{ \chemfig{6(=-=(-OH)-(-(=[::60]O)-[::-60]OH)=-)} }{Salicylic acid} \chemname{ \chemfig{6(=-=(-(=[::60]O)-[::-60]OH)-(-O-::60-[::60]Me)=-)} }{Acetylsalicylic acid} \chemname{ \chemfig{(-[:-150]Me)(-[:330,,,1]OH)=[:90]O} }{Acetic acid} \chemname{ \chemfig{(-[:-150]Me)(=[:90]O)-[:330]O-:30} }{Ethyl acetate} \schemestop \end{center}

\section{Experimental procedure}

\blindtext

\end{document}

What bothers me a little is that the chemname of salicylic acid is not exactly in the middle of the structural formula. It looks like it's shifted to the right.

enter image description here

2 Answers2

3

How about wrapping the picture with \resizebox as follows:

\documentclass[english]{scrartcl}
\usepackage{babel}
\usepackage{chemfig}
\usepackage{blindtext}
\begin{document}
\section{Structural formula}
\begin{center}
\resizebox{\textwidth}{!}{         % <--
\schemestart
    \chemname{
        \chemfig{*6(=-=(-OH)-(-(=[::60]O)-[::-60]OH)=-)}
        }{Salicylic acid}
    \chemname{
        \chemfig{*6(=-=(-(=[::60]O)-[::-60]OH)-(-O-[::60](=O)-[::60]Me)=-)}
        }{Acetylsalicylic acid}
    \chemname{
        \chemfig{(-[:-150]Me)(-[:330,,,1]OH)=[:90]O}
        }{Acetic acid}
    \chemname{
        \chemfig{(-[:-150]Me)(=[:90]O)-[:330]O-[:30](-[:330]Me)}
        }{Ethyl acetate}
    \schemestop
    }
\end{center}
\section{Experimental procedure}
\blindtext
\end{document}

enter image description here

citsahcots
  • 7,992
1

Resizing the entire scheme (using resizebox, scalebox or a similar approach) can make sure all molecules fit into the textwidth. However, if you have multiple schemes in your document, this approach will lead to inconsistent font sizes, bond length and line widths throughout the document. If you want to avoid that, you might be satisfied with an approach that is based on globally altering the bond length. By adding \setchemfig{atom sep=2.25em} (or any other length that suits your needs) to the preamble of the document, your scheme should easily fit into the textwidth of your document:

enter image description here

\documentclass[english]{scrartcl}

\usepackage{babel} \usepackage{chemfig} \usepackage{blindtext} \setchemfig{atom sep=2.25em} \begin{document}

\section{Structural formula}

\begin{center} \schemestart \chemname{ \chemfig{6(=-=(-OH)-(-(=[::60]O)-[::-60]OH)=-)} }{Salicylic acid} \chemname{ \chemfig{6(=-=(-(=[::60]O)-[::-60]OH)-(-O-::60-[::60]Me)=-)} }{Acetylsalicylic acid} \chemname{ \chemfig{(-[:-150]Me)(-[:330,,,1]OH)=[:90]O} }{Acetic acid} \chemname{ \chemfig{(-[:-150]Me)(=[:90]O)-[:330]O-:30} }{Ethyl acetate} \schemestop \end{center}

\section{Experimental procedure}

\blindtext

\end{document}


Here is an alternativer version that attempts to solve the uneven vertical placement of the compound's names using a tabular or chemfig's \chenmameinit command:

enter image description here

\documentclass[english]{scrartcl}

\usepackage{babel} \usepackage{chemfig} \usepackage{blindtext} \usepackage{booktabs} \setchemfig{atom sep=2.25em} \begin{document}

\section{Structural formula}

\begin{center} \setlength{\tabcolsep}{0pt} \schemestart \begin{tabular}{\linewidth}{@{\extracolsep{\fill}}cccc} \chemfig{6(=-=(-OH)-(-(=[::60]O)-[::-60]OH)=-)} &\chemfig{6(=-=(-(=[::60]O)-[::-60]OH)-(-O-::60-[::60]Me)=-)} &\chemfig{(-[:-150]Me)(-[:330,,,1]OH)=[:90]O} &\chemfig{(-[:-150]Me)(=[:90]O)-[:330]O-:30} \\addlinespace Salicylic acid & Acetylsalicylic acid & Acetic acid & Ethyl acetate \end{tabular} \schemestop \end{center}

\begin{center} \chemnameinit{\chemfig{(-[:-150]Me)(-[:330,,,1]OH)=[:90]O}} \schemestart \chemname{ \chemfig{6(=-=(-OH)-(-(=[::60]O)-[::-60]OH)=-)} }{Salicylic acid}
\chemname{ \chemfig{
6(=-=(-(=[::60]O)-[::-60]OH)-(-O-::60-[::60]Me)=-)} }{Acetylsalicylic acid} \chemname{ \chemfig{(-[:-150]Me)(-[:330,,,1]OH)=[:90]O} }{Acetic acid} \chemname{ \chemfig{(-[:-150]Me)(=[:90]O)-[:330]O-:30} }{Ethyl acetate} \schemestop \end{center}

\section{Experimental procedure}

\blindtext

\end{document}

leandriis
  • 62,593
  • Wow, this looks even better! Thanks! Same question as before: Is it intentional that the name of the compounds are not on the same level? The names of the last two compounds are slightly lower than the first two. – Schubladenzieher Jul 21 '21 at 17:37
  • Isn't that vertical alignment issue also present in your original example? – leandriis Jul 21 '21 at 17:38
  • The issue with the names also occurs in the original example. I don't know if it looks that good if the names of the compounds are at different heights when I insert multiple compounds. – Schubladenzieher Jul 21 '21 at 17:43
  • @Schubladenzieher: I just updated my answer and included a second alternative approach using a tabular*. This should also solve the mentioned alignment issue. – leandriis Jul 21 '21 at 17:48
  • Probably sounds like a stupid question: If you are inserting a lot of compounds by using chemfig, should you always use the tabular* environment for the chemnames, or would it be typographically okay if the names of the compounds have an uneven vertical placement? It could be that the unevenness isn't that bad after all... – Schubladenzieher Jul 21 '21 at 18:00
  • @Schubladenzieher: I have updated my answer again to show how you could use \chenmameinit in order to fix the vertical alignment of the names when using \chenmame. – leandriis Jul 21 '21 at 18:18