3

Back again, with more questions. This time, I need to align a reaction scheme involving benzene. This is what I currently have:

\diagram[1.0]{
    \schemestart[0, 1.5, thick]
    \chemfig{**6(------)}
    \arrow{0}[,0]       % used for alignment
    \hspace{5mm} + \hspace{5mm}
    \chemfig{E}
    \arrow
    \arrow{0}[,0]
    \chemfig{**[60,-240]6(----(-[:135]H)(-[:45]E)--)(-[:30,,,,draw=none]+)}
    \schemestop
}

The \diagram simply sets up some spacing and centring, and doesn't really affect this. Using this example, I get this output:

Rather, what I want is to have the first benzene, the +, the E, the arrow, and the centre of the second benzene be in a single row. I've tried playing around with invisible arrows and such, and the example above lets me have the first 4 -- benzene 1, +, E and arrow aligned.

Thanks.


Edit

I have slightly more troubles, and since it's highly related I don't think it would be good to create an entirely new question.

Now I have this code:

\diagram[1.0]{
    \schemestart[0, 1.5, thick]
    \chemfig{**[60,-240]6(----(-[:135]H)(-[:45]E)--)(-[:30,,,,draw=none]+)}
    \arrow{0}[,0]
    \hspace{5mm} + \hspace{5mm}
    \chemfig{@{el}E}
    \arrow
    \schemestop
    \schemestart[0, 1.5, thick]
    \chemfig{**6(----(-[:90]E)--)}
    \schemestop
}

And I get this output:

Sadly, nothing is aligned now. I went with Guho's solution, but I couldn't get unbonpetit's solution to produce a satisfactory result either.

Also, I noticed that I can't actually find a way to get chemfig to use the centre of the atom as the anchor point, even when I start in the centre, and use phantom atoms and bonds like so:

\chemfig{\phantom{+}-[:90,,,,draw=none]([:270]**6((-[:90]E)------))}

It still somehow insists on misaligning things (the atom is anchored somewhere in the middle of the centre and the top edge, it seems)

Anyway, thanks for the continued help. Both answers worked for the basic case, so there's that.

2 Answers 2

4

Another approach:

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\schemestart[0,1.5,thick]
    \chemfig{**6(------)}
    \arrow{0}[,0]
    \+
    \chemfig{E}
    \arrow(--.base west)
    \chemfig[yshift=\the\dimexpr-1.5em\relax]{**[60,-240]6(----(-[:135]H)(-[:45]E)--)(-[:30,,,,draw=none]+)}
\schemestop
\end{document}

enter image description here

EDIT Here is 3 solutions to align molecules properly:

\documentclass{article}
\usepackage{chemfig}
\begin{document}
Solution 1: invisible bond starting from middle of left bond (this midpoint becomes the baseline point)

\schemestart[0, 1.5, thick]
    \chemfig{(-[:90,-0.5,,,draw=none]){}**[60,-240]6([:30]----(-[:135]H)(-[:45]E)--)(-[:30,,,,draw=none]+)}
    \arrow(.base east--){0}[,0]
    \+{2em,2em,}
    \chemfig{@{el}E}
    \arrow(--.base west)
    \chemfig{(-[:90,-0.5,,,draw=none]){}**6([:30]----(-[:90]E)--)}
\schemestop
\medbreak

Solution 2: yshift the baseline anchor

\schemestart[0, 1.5, thick]
    \chemfig[baseline={([yshift=1.5em]current bounding box.base)}]{**[60,-240]6(----(-[:135]H)(-[:45]E)--)(-[:30,,,,draw=none]+)}
    \arrow(.base east--){0}[,0]
    \+{2em,2em,}
    \chemfig{@{el}E}
    \arrow(--.base west)
    \chemfig[baseline={([yshift=1.5em]current bounding box.base)}]{**6(----(-[:90]E)--)}
\schemestop
\medbreak

Solution 3: yshift molecule

\schemestart[0, 1.5, thick]
    \chemfig[yshift=-1.5em]{**[60,-240]6(----(-[:135]H)(-[:45]E)--)(-[:30,,,,draw=none]+)}
    \arrow(.base east--){0}[,0]
    \+{2em,2em,}
    \chemfig{@{el}E}
    \arrow(--.base west)
    \chemfig[yshift=-1.5em]{**6(----(-[:90]E)--)}
\schemestop
\end{document}

enter image description here

4
  • I edited my question as I faced more problems, and couldn't get this to produce a good result, do you mind taking another look? Thanks!
    – zhiayang
    Jan 30, 2016 at 9:23
  • Thanks for your comprehensive solution! I ended up going with yshifting the entire molecule, since that's less hassle. This entire ordeal was quite ridiculous, just to achieve proper alignment...
    – zhiayang
    Jan 31, 2016 at 2:03
  • 1
    I tried compiling this code and it wouldn't work anymore, it gives an error about baseline and yshift not being defined. Do you know if there is another way to do this?
    – ralk912
    Jun 20, 2019 at 4:19
  • Same issue as @ralk912: ! Key "baseline" is not defined: nothing is modified and ! Key "yshift" is not defined: nothing is modified. Any updates on this problem?
    – andselisk
    Jan 1, 2020 at 21:05
2

An easy way is to split up the schemes. Since the two rings are the same size and drawn from the same starting atom, the centers will be aligned. I've also made use of the \+ command:

\documentclass{article}
\usepackage{chemfig}

\begin{document}
    \schemestart[0, 1.5, thick]
    \chemfig{**6(------)}
    \arrow{0}[,0]% used for alignment
    \+{5mm,5mm}
    \chemfig{E}
    \arrow
    \schemestop
    \schemestart[0, 1.5, thick]
    \chemfig{**[60,-240]6(----(-[:135]H)(-[:45]E)--)(-[:30,,,,draw=none]+)}
    \schemestop
\end{document}

aligned by center

Note that the first + does not align vertically with the second + nor the arrow (use of + directly as in your MWE produces the same result). This can be fudged with the third argument of \+, which is the vertical shift (0.4 mm looked pretty good to me):

\documentclass{article}
\usepackage{chemfig}

\begin{document}
    \schemestart[0, 1.5, thick]
    \chemfig{**6(------)}
    \arrow{0}[,0]% used for alignment
    \+{5mm,5mm,0.4mm}
    \chemfig{E}
    \arrow
    \schemestop
    \schemestart[0, 1.5, thick]
    \chemfig{**[60,-240]6(----(-[:135]H)(-[:45]E)--)(-[:30,,,,draw=none]+)}
    \schemestop
\end{document}

aligned both +

1
  • I edited my question as I faced more problems, and couldn't get this to produce a good result, do you mind taking another look? Thanks!
    – zhiayang
    Jan 30, 2016 at 9:23

You must log in to answer this question.

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