5

After careful consultation of the chemfig documentation and looking up a couple of questions here, I am struggling to find a solution to get thesealignment problems in a scheme with different height molecules correctly aligned. They are inside a box which is inside a figure float, 80% textwidth wide and positioned in the middle via hfills. My reason for using the scheme-scheme so far is, that aligning the bodys works like a charm, but as it seems, chemname doesn't align correctly anymore. You find the code here:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{chemfig}

\usepackage{lipsum}% dummy text
\begin{document}

\lipsum[1]

\begin{figure}[!tph]
\hfill{}%
\begin{minipage}[t]{0.9\textwidth}%
\begin{center}
\schemestart
\chemnameinit{\definesubmol{R1}{-R_1}\definesubmol{R2}{-R_2}\definesubmol{R3}{-[,0.5]R_3}\chemfig{([:-18]N*5((!{R1})-(!{R3})=\chemabove{N}{\quad\scriptstyle\oplus}([:342]!{R2})-=-))}}
\definesubmol{R1}{-R_1} \definesubmol{R2}{-R_2} \definesubmol{R3}{-[,0.5]R_3} \chemname{\chemfig{([:-18]N*5((!{R1})-(!{R3})=\chemabove{N}{\quad\scriptstyle\oplus}([:342]!{R2})-=-))}}{Imidazolium}
\arrow{0}
\chemname{\chemfig{[:60]\chemabove{N}{\oplus}*6((([:342]-R_1)([:198]-R_2))------)}}{Piperidinium}
\arrow{0}
\definesubmol{R1}{R_1}
\chemname{\chemfig{[:54]\chemabove{N}{\oplus}*5((([:198]-!{R1})([:342]-R_2))-----)}}{Pyrrolidinium}
\schemestop
\chemnameinit{}
\par\end{center}%
\end{minipage}\hfill{}

\protect\caption{Gängige Kationen ionischer Flüssigkeiten.}


\end{figure}

\end{document}

Other questions related but which didn't enable me to solve the problem:

Would be very glad if someone knows a solution.

Update 13.08.14: Updated with a MWE.

  • Please provide a MWE instead of code snippets. A MWE should start with \documentclass{}, loading the required packages, \begin{document}, the code, and \end{document} – AboAmmar Aug 13 '14 at 1:52
  • I updated it so it should now be an MWE. Thx for the notice – Hug Aug 13 '14 at 10:12
5

Here's a crazy idea: use a tabular.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{array,chemfig}

\usepackage{lipsum}% dummy text
\begin{document}

\lipsum[1]

\begin{figure}[htbp]
  \centering
  \begin{tabular}{c@{\qquad}c@{\qquad}c}
    \chemfig{
      [:54]*5(=N(-R_2)(-[1,.3,,,draw=none]\scriptstyle\oplus)-=-N(-R_1)-)
      -[6,.7]R|_3
    }
    &
    \chemfig{
      [:60]\chemabove{N}{\oplus}*6(------)
      (-[:-30]R_2)
      -[:-150]R_1
    }
    &
    \chemfig{
      [:54]\chemabove{N}{\oplus}*5(-----)
      (-[:-30]R_2)
      -[:-150]R_1
    }
    \\ \\
    Imidazolium & Piperidinium & Pyrrolidinium
  \end{tabular}
  \caption{Gängige Kationen ionischer Flüssigkeiten.}
\end{figure}

\lipsum[2]

\end{document}

enter image description here

  • Thx for the quick reply! I thought you would come up with an arrow based solution. ;-) One remark: Is there a way to vertically move the piperidinium and pyrrolidinium down? Doesn't look vertically centered to me. Aside from that, tabular looks great! Thx – Hug Aug 13 '14 at 9:30
  • 1
    They're aligned on the baseline of course. But you probably know that m{<width>} type table columns align cell contents vertically, don't you? – cgnieder Aug 13 '14 at 9:32
  • I looked into it and got it working in Lyx (and using theiur tex code). I wrote it up as an answer and will accept my own as it also aligns the molecules correctly. Thank you very much for the quick help and also for the little code change with the positive charge at the imidazole ;-) – Hug Aug 13 '14 at 11:09
1

Thanks to the tip of cgnieder with using tabular, I was able to produce the desired result. His suggestion was close but didn't yet align the individual molecules vertically. I did that using a Lyx table (and getting the resulting LaTeX code here), so it is possibly easier to achieve good looking layout with m{} type columns as mentioned in the comments from cgnieder under the original question.

However, the desired result: desired result successfully gets produced. Here is the (due to Lyx possibly uggly) code:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{array,chemfig}

\usepackage{lipsum}% dummy text
\begin{document}

\lipsum[1]
\begin{figure}[!tph]
\noindent \begin{centering}
\begin{tabular*}{1\textwidth}{@{\extracolsep{\fill}}>{\centering}m{0.36\textwidth}>{\centering}m{0.27\textwidth}>{\centering}m{0.27\textwidth}}
\chemfig{
      [:54]*5(=N(-R_2)(-[1,.38,,,draw=none]\oplus)-=-N(-R_1)-)
      -[6,.7]R|_3
    } & \chemfig{
      [:60]\chemabove{N}{\oplus}*6(------)
      (-[:-30]R_2)
      -[:-150]R_1
    } & \chemfig{
      [:54]\chemabove{N}{\oplus}*5(-----)
      (-[:-30]R_2)
      -[:-150]R_1}\tabularnewline
\addlinespace
Imidazolium & Piperidinium & Pyrrolidinium\tabularnewline
\addlinespace
\end{tabular*}
\par\end{centering}

\begin{centering}
\protect\caption{Einige gängige Kationen ionischer Flüssigkeiten.}

\par\end{centering}

\end{figure}
\lipsum[2]

\end{document}

I also wanted to thank cgnieder without whom and his fast response this hadn't been possible.

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.