3

I have a problem with alignment of two chemical reactions

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\begin{figure*}
\begin{flushleft}
\schemedebug{true}
\schemestart
A\arrow{->}B\arrow{->}
\schemestop
\bigskip

\schemestart
\arrow{->}C\arrow{->}D
\schemestop
\end{flushleft}
\end{figure*}
\end{document}

How I can delete the space at the begin of the second line? Space between green and red markers?

enter image description here

3
  • First guess for an idea: shift the arrow using the optional argument which is meant for styling compounds
    – cgnieder
    Sep 1, 2016 at 11:26
  • If I move the arrow, I don't move the reaction, is not it? I think there is way way to reduce/delete the space fields around or at the left of the arrow in the \arrow settings. But I don't find it.
    – EvgenyChem
    Sep 1, 2016 at 12:09
  • Do you only want both lines aligned or do you also need both lines flush left with the margin?
    – cgnieder
    Sep 1, 2016 at 15:05

2 Answers 2

3

You can shift the line left by adding some negative horizontal space before the scheme. First you have to tell LaTeX to get out of vertical mode, using for example \leavemode. In your case you then want to backup the empty node and the arrow offset, so you need \hspace{\dimexpr-1em-4pt}:

Sample output

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\begin{figure*}
\begin{flushleft}
\schemedebug{true}
\schemestart
A\arrow{->}B\arrow{->}
\schemestop
\bigskip

\leavevmode\hspace{\dimexpr-1em-4pt}
\schemestart
\arrow{->}C\arrow{->}D
\schemestop
\end{flushleft}
\end{figure*}
\end{document}

The function of \leavevmode is to start a new paragraph if necessary. If we are not in paragraph mode, any following horizontal spacing command will have no effect.

The expression \dimexpr-1em-4pt calculates a length from the two given quantities. 1em is a font related dimension, nominally the width of a letter m in the current font, and corresponds to the default arrow offset (according to the chemfig code, not its documentation). The 4pt comes from the empty node and seems to be built in to the chemfig code.

3
  • Many thanks. It really works. And please tell us how it works. I do not quite understand what is vmode and what is {\dimexpr-1em-4pt}? And -1em and -4pt shift the line left.
    – EvgenyChem
    Sep 1, 2016 at 19:44
  • \leavevmode deletes the matgin of that line, doesn't it? Or not?
    – EvgenyChem
    Sep 1, 2016 at 19:50
  • @EvgenyChem I have added some extra explanation to the question. \leavevmode does not delete the margin, you still get the normal indent. Sep 2, 2016 at 14:52
2

In the following, I have just changed the margin of the page for this single line. Not really pretty, I fear, but if you need it just once, it might be ok:

% arara: lualatex

\documentclass{article}
\usepackage{chemfig}
\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}
\let\endchangemargin=\endlist % credits to Vivi
\usepackage{lua-visual-debug}

\begin{document}
\begin{figure*}
\schemedebug{true}
    \schemestart
        A\arrow{->}B\arrow{->}
    \schemestop
    \medskip
    \begin{changemargin}{-0.38cm}{0cm}
    \schemestart
        \arrow{->}C\arrow{->}D
    \schemestop
    \end{changemargin}
\end{figure*}
\end{document}

enter image description here

2
  • 1
    Why would printing c1 be a problem? It is only debugging information and invisible in the real case.
    – cgnieder
    Sep 1, 2016 at 11:28
  • Wow! Unexpected approach . It looks at how you move an entire city to be your home became the center. It might be ok at once. But is there other way to delete that space. I really need shift whole the second line. And the printing of debuggin iformation is no problem: \schemedebug{false}
    – EvgenyChem
    Sep 1, 2016 at 11:57

You must log in to answer this question.

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