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](=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}

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

5
  • 2
    Like you said, it seems shifted but it isn't at all.
    – SebGlav
    Jun 21 at 13:39
  • 1
    Oh, yeah, that makes sense now... Jun 21 at 17:23
  • There is still the first question about the text width, so please do not close it. Jun 21 at 19:01
  • You're right. One possible solution is to place each one in a scalebox.
    – SebGlav
    Jun 21 at 19:29
  • With a smaller bond length such as \setchemfig{atom sep=2.25em} you should be able to fit all 4 molecules into the same line.
    – leandriis
    Jul 21 at 17:30
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](=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}

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](=O)-[::60]Me)=-)}
      &\chemfig{(-[:-150]Me)(-[:330,,,1]OH)=[:90]O}
      &\chemfig{(-[:-150]Me)(=[:90]O)-[:330]O-[:30](-[:330]Me)} \\\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](=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}
6
  • 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. Jul 21 at 17:37
  • Isn't that vertical alignment issue also present in your original example?
    – leandriis
    Jul 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. Jul 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 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... Jul 21 at 18:00
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

0

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.