1

I'd like to align these two chemfig structures, seen below, horizontally but I cannot get my head around how.

\documentclass{article}
\usepackage{chemfig}

\begin{document}
\begingroup

\centering
\setatomsep{3em}\chemname{\chemfig{C(-[:180]H)*6(-C(-H)=C(-H)-C(-H)=C(-H)-C(-H)=)}}{Lewis
structure\\of benzene}
\qquad
\setatomsep{3em}\chemname{\chemfig{**6(------)}}{Cyclic compound\\of benzene}

\endgroup
\end{document}

Example output: Chemfig structure

2

Putting the chemfigs into \raisebox{\depth-\totalheight/2}{...} centres them vertically by moving the box reference point to the half of the totalheight. Requires the calc LaTeX package:

\documentclass{article}
\usepackage{chemfig}
\usepackage{calc}

\begin{document}
\begingroup

\centering
\setatomsep{3em}\chemname{\raisebox{\depth-\totalheight/2}{\chemfig{C(-[:180]H)*6(-C(-H)=C(-H)-C(-H)=C(-H)-C(-H)=)}}}{Lewis
structure\\of benzene}
\qquad
\setatomsep{3em}\chemname{\raisebox{\depth-\totalheight/2}{\chemfig{**6(------)}}}{Cyclic compound\\of benzene}

\endgroup
\end{document}

enter image description here

|improve this answer|||||
  • 1
    Yes, it is an old trick. For boxes with zero depth it is simply \raisebox{-0.5\height}{...}. – AlexG Jan 23 '17 at 8:49
  • Great info, I'm fairly new to TeX :) – Jimmy Westberg Jan 23 '17 at 8:50

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.