You can add arbitrary TikZ keys that are passed on to the tikzpicture
created by \chemfig
using the key chemfig style
. Using baseline=(current bounding box.center)
you can easily center the molecule on the baseline (see a.
and b.
below (I relabeled the atoms alphabetically)).
However, you probably want to center them with respect to the ring part of the molecule. Since you did not use chemfig
's ring molecule syntax (see below) there is no automatic way to access its center, so you will have to calculate it yourself. The default baseline (i.e. the one given by the first atom) is at 0pt
. I did this for c.
and d.
below and shifted the baseline down another .5ex
to make it appear centered (approximately) with the letters rather than their baseline. The macro \setmychemshift[⟨offset⟩]{⟨atom sep factor⟩}
does the calculation and stores the result in \mychemfig
.
On the other hand, you could input your molecules using the ring syntax described in section 12 of the chemfig
manual. In this case, the package makes available the ring center coordinates and you can easily use them as a baseline, see e.
and f.
below. I use the calc
library to again shift the baseline down an additional .5ex
. (In my opinion, this input syntax is simpler even if you don't need the alignment.)
\documentclass{article}
\usepackage{chemfig}
\usetikzlibrary{calc}
\newlength\mychemshift
\newcommand*\setmychemshift[2][-.5ex]{\pgfmathsetlength\mychemshift{#2*\csname CF_atomsep\endcsname+#1}}
\begin{document}
\begingroup\setchemfig{chemfig style={baseline=(current bounding box.center)}}
a. \chemfig{-[,.8]-[::72,.8](-[:18,.6]CH_2CH_3)-[::72,.8](-[2,.6,1]CH_3)-[::72,.8]-[::72,.8]}\qquad
b. \chemfig{-[,.6]-[::51.43,.6](-[:-12.86,.6]CH_3)-[::51.43,.6](-[::-64.28,.6]CH_2CH_3)-[::51.43,.6]-[::51.43,.6](-[::-64.28,.6]Br)-[::51.43,.6]-[::51.43,.6]}\vskip 4ex
\endgroup
\begingroup\setchemfig{chemfig style={baseline=\mychemshift}}
\setmychemshift{-.3}
c. \chemfig{-[6,.6]-[::60,.6]-[::60,.6](-[:-30,.6]CH_3)-[::60,.6]-[::60,.6](-[2,.6]CH_3)-[::60,.6]}\qquad
d. \chemfig{-[6,.6]-[::60,.6]-[::60,.6](-[::-60,.6]Cl)-[::60,.6](-[::-60,.6]CH(-[:90,.6,1]CH_3)-[::-60,.6,1]CH_3)-[::60,.6]-[::60,.6]}\vskip 4ex
\endgroup
\begingroup\setchemfig{chemfig style={baseline={($(cyclecenter1)-(0,.5ex)$)}}}
\setchemfig{atom sep=2.4em}
e. \chemfig{[:18]*5(--(-CH_2CH_3)-(-CH_3)--)}\qquad
\setchemfig{atom sep=1.8em}
f. \chemfig{*6(--(-Cl)-(-CH(-[::60]CH_3)(-[::-60]CH_3))---)}
\endgroup
\end{document}
