0

Trying to add space around an arrow with \qquad leads to an asymmetrical result. This can be prevented with additional braces, but why are they needed?

1. The resulting image:

enter image description here

In the first line, the arrow is close to the left expression. In the second line, it is about centered.

2. The code:

\documentclass{scrartcl}
\usepackage{chemfig}

\newcommand{\Beispiel}{
    \schemestart \chemfig{A-B} \qquad \arrow \qquad \chemfig{A-B} \schemestop
    \vspace{1em}\par
    \schemestart \chemfig{A-B} \qquad {} \arrow \qquad \chemfig{A-B} \schemestop
}

\begin{document}
    \par without debug mode:
    \par
    \Beispiel

    \bigskip
    \par with debug mode:
    \par
    \setchemfig{scheme debug=true}
    \Beispiel
\end{document}

The code difference is the additional braces ({}) between \qquad and \arrow.

3. Questions:

Why is that?

What would be recommended to add space around an arrow?

2 Answers 2

1
\documentclass{scrartcl}
\usepackage{chemfig}

\newcommand{\Beispiel}{
    \setchemfig{compound sep=15em, arrow offset=6em}
    \schemestart \chemfig{A-B} \arrow \chemfig{A-B} \schemestop
    \setchemfig{compound sep=5em, arrow offset=1em}
}

\begin{document}
    \schemestart \chemfig{A-B} \arrow \chemfig{A-B} \schemestop
    
    \par without debug mode:
    \par
    \Beispiel
    
    \bigskip
    \par with debug mode:
    \par
    \setchemfig{scheme debug=true}
    \Beispiel
    
    \schemestart \chemfig{A-B} \arrow \chemfig{A-B} \schemestop
\end{document}

enter image description here

2
  • Very helpful. And by enclosing the \setchemfig expression together with the scheme by braces, I don't change the variables for the rest of the document.
    – Wolfram
    Commented Dec 9, 2023 at 20:54
  • compound sep (default: 5 em) seems to equal twice the arrow offset (default: 1 em) plus the arrow length (about 3 em). So your lengths preserve the arrow length of 3 em (15 - 2*6).
    – Wolfram
    Commented Dec 9, 2023 at 21:05
0

Don't use \qquad, use \hspace{}

Only define a "newcommand" if you are going to use it multiple times.

\documentclass{scrartcl}
\usepackage{chemfig}
\begin{document}
\schemestart \chemfig{A-B} \arrow \chemfig{A-B} \schemestop

\schemestart \chemfig{A-B} \hspace{2cm} \arrow \hspace{2cm} \chemfig{A-B} \schemestop
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .