1

How do I modify or adjust the vertical and horizontal alignment of the labels? If I add spaces before or after the desired label, I can make a horizontal adjustment. But, I can't figure out the vertical adjustment. Is there a way? Please let me know and thank you.

\usepackage{chemfig,chemmacros}
\chemsetup{modules=all}
\begin{document}
\chemname{\setbondoffset{0pt}
  \chemsetup[orbital]{
    overlay ,
    opacity = .75 ,
    s/color = blue!50 ,
    s/scale = 1.6
  }
  \chemfig{
    {\orbital{s}}
    -[:30]
    (-[:-30]\orbital{s})
}}{ $A_1$} \hspace{1cm} \chemname{\setbondoffset{0pt}
  \chemsetup[orbital]{
    overlay ,
    opacity = .75 ,
    p/color = blue!50, 
    p/scale = 1.3 ,
    s/color = blue!50 ,
    s/scale = 1.6
  }
  \chemfig{
    {\orbital[phase=-]{s}}
    -[:30]
    (-[:-30]\orbital{s})
}}{$B_2$ too long of a name interfere with image}

\end{document}

Furthermore, is there a way to center the said label relative to the image? And is there a way to align the left most image on the second row with the others?

enter image description here

\usepackage{chemfig,chemmacros}
\chemsetup{modules=all}
\begin{document}

\noindent Matching the above orbitals with the valence orbitals from C, we obtain the following series of ``molecular" orbitals:


\[\chemname[0.5cm]{\setbondoffset{0pt}
  \chemsetup[orbital]{
    overlay ,
    opacity = .75 ,
    s/color = blue!50 ,
    s/scale = 1.6
  }
  \chemfig{
    {\orbital{s}}
    -[:30]
           {\orbital[scale=2]{s}}
    (-[:-30]\orbital{s})
}}{$a_1$} \hspace{2cm} \chemname[0.5cm]{\setbondoffset{0pt}
  \chemsetup[orbital]{
    overlay ,
    opacity = .75 ,
    p/color = blue!50, 
    p/scale = 1.2 ,
    s/color = blue!50 ,
    s/scale = 1.6
  }
  \chemfig{
    {\orbital[phase=-]{s}}
    -[:30]
           {\orbital[angle=180,phase=-]{p}}
    (-[:-30]\orbital{s})
}}{$b_1$} \hspace{2cm} \chemname[0.5cm]{\setbondoffset{0pt}
  \chemsetup[orbital]{
    overlay ,
    opacity = .75 ,
    p/color = blue!50, 
    p/scale = 1.3 ,
    s/color = blue!50 ,
    s/scale = 1.6
  }
  \chemfig{
    {\orbital{s}}
    -[:30]
           {\orbital[angle=90,phase=-,scale=1.2]{p}}
    (-[:-30]\orbital{s})
}}{$a_1$}\]

\vspace{2cm}

\[\chemname[0.5cm]{\setbondoffset{0pt}
  \chemsetup[orbital]{
    overlay ,
    opacity = .75 ,
    p/color = blue!50,
    p/scale = 1.2 ,
    s/color = blue!50 ,
    s/scale = 1.6
  }
  \chemfig{
    -[:-20]{\orbital[angle=90]{p}}
    (-[:-150])
}}{$b_2$} \hspace{2cm} \chemname[0.5cm]{\setbondoffset{0pt}
  \chemsetup[orbital]{
    overlay ,
    opacity = .75 ,
    p/color = blue!50, 
    p/scale = 1.2 ,
    s/color = blue!50 ,
    s/scale = 1.6
  }
  \chemfig{
    {\orbital{s}}
    -[:30]
           {\orbital[angle=90]{p}}
    (-[:-30]\orbital{s})
}}{$a_1$} \hspace{2cm} \chemname[0.5cm]{\setbondoffset{0pt}
  \chemsetup[orbital]{
    overlay ,
    opacity = .75 ,
    p/color = blue!50, 
    p/scale = 1.2 ,
    s/color = blue!50 ,
    s/scale = 1.6
  }
  \chemfig{
    {\orbital[phase=-]{s}}
    -[:30]
           {\orbital[angle=180]{p}}
    (-[:-30]\orbital{s})
}}{$b_1$}\]
\end{document}
  • Could you please show a sketch of the desired alignment? Is this close to what you want to achieve? i.stack.imgur.com/WI5h7.png – leandriis Mar 2 at 9:18
  • 1
    If you want to increase the vertical distance between the image and the label text, you could use the optional argument of \chemname[<dim>]{\chemfig{<code of the molecule>}}{<name>}. – leandriis Mar 2 at 9:23
  • Thanks @leandriis I got it to do exactly what I wanted. But, is there a way to center the text relative to the image? And is there a way to align the left most image with the right ones? As shown above. Please and thank you. – Dave2343 Mar 2 at 18:57
  • I unfortunately don't seem to understand what exactly you want your output to look like. With both suggestions that I made, the images are vertically aligned with respect to each other and the text is horizontally centered with respect to the corresponding chemfig. Could you therefor please add a sketch of the desired output? – leandriis Mar 2 at 19:01
  • Sorry @leandriis I was in the middle of editing this post. I tried to clarify it more. – Dave2343 Mar 2 at 19:04
1

The vertical alignment of different chemfigs depends on the point from where you start to draw your molecules. This point is taken as the baseline to which the molecules are aligned. In your case you can fix the alignment by using the lower instead of the upper CH3 group as the starting point:

\documentclass{article}
\usepackage{chemfig,chemmacros}
\chemsetup{modules=all}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\noindent Matching the above orbitals with the valence orbitals from C, we obtain the following series of ``molecular" orbitals. Please note that I have used the `\chemsetup` command before the first `\chemname` command. This way you only need it once.



\chemsetup[orbital]{
    overlay ,
    opacity = .75 ,
    p/color = blue!50, 
    p/scale = 1.2 ,
    s/color = blue!50 ,
    s/scale = 1.6
  }
\setbondoffset{0pt}
\vspace{2cm}
\chemname[0.5cm]{
  \chemfig{
    -[:30]{\orbital[angle=90]{p}}
    (-[:150])
}}{$b_2$} \hspace{2cm} \chemname[0.5cm]{
  \chemfig{
    {\orbital{s}}
    -[:30]
           {\orbital[angle=90]{p}}
    (-[:-30]\orbital{s})
}}{$a_1$} \hspace{2cm} 
\chemname[0.5cm]{
  \chemfig{
    {\orbital[phase=-]{s}}
    -[:30]
           {\orbital[angle=180]{p}}
    (-[:-30]\orbital{s})
}}{$b_1$}
\end{document}

enter image description here

However, the texts are stil not really horizontally centered under their corresponding images. I would therefor suggest to use a table in oder to allow for preciser control of the positioning of images and figures:

\documentclass{article}
\usepackage{chemfig,chemmacros}
\chemsetup{modules=all}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\noindent Matching the above orbitals with the valence orbitals from C, we obtain the following series of ``molecular" orbitals:

\setbondoffset{0pt}
\noindent\begin{tabular}{*{3}{C{0.333\textwidth-2\tabcolsep}}}
  \\[0.5cm]
  \chemfig{
    {\orbital{s}}
    -[:30]
           {\orbital[scale=2]{s}}
    (-[:-30]\orbital{s})
} &
  \chemfig{
    {\orbital[phase=-]{s}}
    -[:30]
           {\orbital[angle=180,phase=-]{p}}
    (-[:-30]\orbital{s})
} &
  \chemfig{
    {\orbital{s}}
    -[:30]
           {\orbital[angle=90,phase=-,scale=1.2]{p}}
    (-[:-30]\orbital{s})
} \\[0.5cm]
$a_1$ & $b_1$ & $a_1$ \\[1cm]
  \chemfig{
    -[:30]{\orbital[angle=90]{p}}
    (-[:150])
} & 
  \chemfig{
    {\orbital{s}}
    -[:30]
           {\orbital[angle=90]{p}}
    (-[:-30]\orbital{s})
} &
  \chemfig{
    {\orbital[phase=-]{s}}
    -[:30]
           {\orbital[angle=180]{p}}
    (-[:-30]\orbital{s})
}\\[0.5cm]
$b_2$ & $a_1$ & $b_1$ \\[1cm]
\end{tabular}
\end{document}

enter image description here

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.