4

I'd like the letters to be in the middle of structures. I know that the letters are in the place where the code of each structures begins, but I have no idea how to change it, without changing the code :/. Can someone help me, please?

\documentclass{article}
\usepackage{chemfig}
\begin{document}
a. \chemfig{-[,.8]-[::72,.8](-[:18,.6]CH_2CH_3)-[::72,.8](-[2,.6,1]CH_3)-[::72,.8]-[::72,.8]} \vspace{0.5cm} \\
c. \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]} \vspace{0.5cm} \\
b. \chemfig{-[6,.6]-[::60,.6]-[::60,.6](-[:-30,.6]CH_3)-[::60,.6]-[::60,.6](-[2,.6]CH_3)-[::60,.6]} \vspace{0.9cm}\\
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]}
\end{document}

enter image description here

1
  • 1
    As an aside: You may want to have a look at section 12 of the chemfig manual.
    – schtandard
    Jul 5 at 15:00

3 Answers 3

3

A suggestion

\documentclass{article}
\usepackage{amsmath}
\usepackage{chemfig}
\begin{document}
\begin{align*}
    & \schemestart
     a. \arrow{0} \chemfig{-[,.8]-[::72,.8](-[:18,.6]CH_2CH_3)-[::72,.8](-[2,.6,1]CH_3)-[::72,.8]-[::72,.8]}
    \schemestop \\ 
    & \\
     %
&   \schemestart
    c. \arrow{0} \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]}
    \schemestop \\
        & \\
     %
&    \schemestart
    b. \arrow{0} \chemfig{-[6,.6]-[::60,.6]-[::60,.6](-[:-30,.6]CH_3)-[::60,.6]-[::60,.6](-[2,.6]CH_3)-[::60,.6]} 
    %
    \schemestop \\
        & \\
    %
&   \schemestart
    d. \arrow{0} \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]}
\schemestop
\end{align*}
\end{document}

I used an invisible arrow (\arrow{0}) to create an empty space. You can vary this space by varying the length of the arrow.

enter image description here

3

A simple solution with nicematrix

\documentclass{article}
\usepackage{chemfig}
\usepackage{nicematrix}
\begin{document}
    \begin{NiceTabular}{c @{\hspace{1cm}}c}[cell-space-top-limit=14pt]
        \Block[v-center]{}{a.} & \chemfig{-[,.8]-[::72,.8](-[:18,.6]CH_2CH_3)-[::72,.8](-[2,.6,1]CH_3)-[::72,.8]-[::72,.8]} \\
        \Block[v-center]{}{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]} \vspace{0.5cm} \\
        \Block[v-center]{}{c.} & \chemfig{-[6,.6]-[::60,.6]-[::60,.6](-[:-30,.6]CH_3)-[::60,.6]-[::60,.6](-[2,.6]CH_3)-[::60,.6]} \vspace{0.9cm}\\
        \Block[v-center]{}{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]}
    \end{NiceTabular}
\end{document}

enter image description here

2

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}

MWE output

2
  • Hey, I have another question, is there any way to vertically align the second points (b, d, f), or do I have to do it automatically with \hspace? Jul 13 at 7:41
  • @MichałSzymankiewicz Use a table, that's what those are for.
    – schtandard
    Jul 13 at 15:34

You must log in to answer this question.

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