2

I am having a problem with the formatting of the experimental part of my chemistry thesis. I describe the synthesis and the spectroscopic values of a molecule to wrap around a small graphic representation of it. In the beginning I used wrapfiqure like in the following example:

\documentclass[a4paper, 12pt, twoside]{book}
\usepackage{wrapfig}
\usepackage{picinpar}                       
\usepackage{chemmacros}                     
\usechemmodule{spectroscopy}    
\begin{document}
\section{Experimental}
    \subsection{Ferrocene}
        \begin{wrapfigure}{r}{0.1\textwidth}
            \vspace{-10pt}
            \includegraphics{Fc.eps}
        \end{wrapfigure}        
        Ferrocene was prepared by slow addition of a solution of \ch{FeCl3} in DMSO to a mixture of freshly cracked cycopentadiene and potassium hydroxide in THF at \SI{-78}{\celsius}. %After complete addition the mixture was quenched with water and extracted with \ch{Et2O}, the org. layer was dried over \ch{MgSO4} and the solvent evaporated to leave an orange solid that could be purified by sublimation.
        \\
        \begin{experimental}[format=\bfseries, coupling-unit={},list=true]
            \NMR(500)[CDCl3] = 
                \val{9.25}  (   s,  \#{1},  \pos{1}     ),
                \val{8.23}  (   s,  \#{1},  \pos{2}     ),
                \val{8.01}  (   s,  \#{1},  \pos{3}     ),
                \val{7.77}  (   s,  \#{1},  \pos{3}     ),
                \val{6.20}  (   s,  \#{2},  \pos{4}     ),
                \val{5.48}  (   s,  \#{2},  \pos{6}     ),
                \val{4.26}  (   s,  \#{2},  \pos{5}     ),
                \val{2.71}  (   s,  \#{1},  \pos{8}     ),
                \val{1.80}  (   s,  \#{1},  \pos{9}     ).
        \\
            \NMR{13,C[^1H]}(126, MHz)[CDCl3] = 
                \val{165.0} (   s,  \#{1},  \pos{1}     ),
                \val{120.6} (   s,  \#{1},  \pos{2}     ),
                \val{119.0} (   s,  \#{1},  \pos{3}     ),
                \val{89.6}  (   s,  \#{1},  \pos{3}     ),
                \val{88.2}  (   s,  \#{2},  \pos{4}     ),
                \val{73.4}  (   s,  \#{2},  \pos{6}     ),
                \val{62.8}  (   s,  \#{2},  \pos{5}     ),
                \val{56.0}  (   s,  \#{1},  \pos{8}     ),
                \val{40.5}  (   s,  \#{1},  \pos{9}     ).
        \end{experimental}
\end{document}

It and it worked fine, until I started to realize, that very short descriptions lead to parts of the spectroscopy data aligning with the picture like this:

Test

So the way I was trying to circumvent this problem was by using a window environment (same packages):

\begin{document}
\section{Experimental}
    \subsection{Ferrocene}
    \begin{window}[0,r,\includegraphics[scale=0.9]{Fc.eps},{}]
        Ferrocene was prepared by slow addition of a solution of \ch{FeCl3} in DMSO to a mixture of freshly cracked cycopentadiene and potassium hydroxide in THF at \SI{-78}{\celsius}. %After complete addition the mixture was quenched with water and extracted with \ch{Et2O}, the org. layer was dried over \ch{MgSO4} and the solvent evaporated to leave an orange solid that could be purified by sublimation.
        \\

        \begin{experimental}[format=\bfseries, coupling-unit={},list=true]
            \NMR(500)[CDCl3] = 
                %same data as before
        \\
            \NMR{13,C[^1H]}(126, MHz)[CDCl3] = 
                %same data as before
        \end{experimental}
    \end{window}
\end{document}

which, however leaves me with the following type of errors:

/TestExp2.tex:19: LaTeX Error: Something's wrong--perhaps a missing \item. [ \NMR(500)[CDCl3]]

So obviously there seems to be an incompatibility of the window and experimental environment. If i \end{window} before \begin{experimental}, then it works fine, however the graphic then sometimes ends up being covered up by the text that follows, depending on its size.

So my question is: Is there a workaround, such that I can actually define a window that includes the experimental environment? Or is this impossible?

I am also open to alternative solutions that do not use wrapfigure OR window

Thanks in advance!

4
  • Would placing the small figure in the margin be a suitable result? \marginpar{\includegraphics{graphicname}}
    – Johannes_B
    Sep 22, 2016 at 6:43
  • Thanks for the suggestion, it would however not be a suitable solution for all possible figures, since some of them are quite broad (maybe three times as broad as in the example). So I'd rather find a solution that places the figure within the text.
    – siggg
    Sep 22, 2016 at 7:20
  • For scientific reports, it is common to place figures with a caption as an independent entity and allow them to float around a little. This is much easier to handle and oriented to the big publishers around the world. Hard fixing a picture inside the text is rather uncommon because it is an incredible amount of work.
    – Johannes_B
    Sep 22, 2016 at 7:26
  • This happens with other lists (e.g. description), too, so it is not an issue of chemmacros, strictly speaking
    – cgnieder
    Sep 22, 2016 at 9:10

2 Answers 2

1

This approach is based on the answer posted here: https://tex.stackexchange.com/a/309454, which is versatile for placement of figures in a range of environments.

The essential part of this method uses:

a strut that places the baseline of the first text line at a specified distance from the top of a minipage. Then adjustbox to place the top of the minipage exactly that amount above the outer baseline.

In this instance, because of the use of the experimental environment from the spectroscopy module of the chemmacros package, it was necessary to place the two adjustboxes side by side. This is done using minipage as an inner environment to adjustbox, with one minipage set at 0.8\linewidth and the other at 0.2\linewidth (see section 4.10 of the adjustbox manual).

The following example shows two possible layouts for a drawing of the chemical molecule alongside the accompanying spectroscopic data.

Updated 19 April 2017 to remove spaces from NMR specifications. See Clemens comment.

enter image description here

This is the code:

\documentclass[a4paper, 12pt, twoside]{book}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage{chemmacros}
\usechemmodule{spectroscopy} 
\usepackage[margin=3cm]{geometry}
\usepackage{adjustbox}

\newlength{\strutheight}
\settoheight{\strutheight}{\strut}

\begin{document}
\section{Experimental}
\subsection{Ferrocene layout 1}
Ferrocene was prepared by slow addition of a solution of \ch{FeCl3} in DMSO to a mixture of freshly cracked cycopentadiene and potassium hydroxide in THF at \SI{-78}{\celsius}.

%https://tex.stackexchange.com/a/309454    
    \begin{adjustbox}{valign=T,raise=\strutheight,minipage={0.8\linewidth}}
        \begin{experimental}[format=\bfseries, coupling-unit={},list=true]
            \NMR(500)[CDCl3] = 
            \val{9.25}  (s,\#{1},\pos{1}),
            \val{8.23}  (s,\#{1},\pos{2}),
            \val{8.01}  (s,\#{1},\pos{3}),
            \val{7.77}  (s,\#{1},\pos{3}),
            \val{6.20}  (s,\#{2},\pos{4}),
            \val{5.48}  (s,\#{2},\pos{6}),
            \val{4.26}  (s,\#{2},\pos{5}),
            \val{2.71}  (s,\#{1},\pos{8}),
            \val{1.80}  (s,\#{1},\pos{9}).
            \NMR{13,C[^1H]}(126, MHz)[CDCl3] = 
            \val{165.0} (s,\#{1},\pos{1}),
            \val{120.6} (s,\#{1},\pos{2}),
            \val{119.0} (s,\#{1},\pos{3}),
            \val{89.6}  (s,\#{1},\pos{3}),
            \val{88.2}  (s,\#{2},\pos{4}),
            \val{73.4}  (s,\#{2},\pos{6}),
            \val{62.8}  (s,\#{2},\pos{5}),
            \val{56.0}  (s,\#{1},\pos{8}),
            \val{40.5}  (s,\#{1},\pos{9}).
        \end{experimental}   
\end{adjustbox}%
\begin{adjustbox}{valign=T,raise=\strutheight,minipage={0.2\linewidth}}
    \begin{wrapfigure}{r}{2cm}
        \centering
        \includegraphics[height=2cm]{fc.png}
    \end{wrapfigure}% 
    \strut{}
\end{adjustbox} 

\subsection{Ferrocene layout 2}
\begin{adjustbox}{valign=T,raise=\strutheight,minipage={0.8\linewidth}}
Ferrocene was prepared by slow addition of a solution of \ch{FeCl3} in DMSO to a mixture of freshly cracked cycopentadiene and potassium hydroxide in THF at \SI{-78}{\celsius}.

\begin{experimental}[format=\bfseries, coupling-unit={},list=true]
    \NMR(500)[CDCl3] = 
    \val{9.25}  (s,\#{1},\pos{1}),
    \val{8.23}  (s,\#{1},\pos{2}),
    \val{8.01}  (s,\#{1},\pos{3}),
    \val{7.77}  (s,\#{1},\pos{3}),
    \val{6.20}  (s,\#{2},\pos{4}),
    \val{5.48}  (s,\#{2},\pos{6}),
    \val{4.26}  (s,\#{2},\pos{5}),
    \val{2.71}  (s,\#{1},\pos{8}),
    \val{1.80}  (s,\#{1},\pos{9}).
\end{experimental}   
\end{adjustbox}%
\begin{adjustbox}{valign=T,raise=\strutheight,minipage={0.2\linewidth}}
    \begin{wrapfigure}{r}{2cm}
        \centering
        \includegraphics[height=2cm]{fc.png}
    \end{wrapfigure}% 
    \strut{}
\end{adjustbox}%
\begin{experimental}[format=\bfseries, coupling-unit={},list=true]
    \NMR{13,C[^1H]}(126, MHz)[CDCl3] = 
    \val{165.0} (s,\#{1},\pos{1}),
    \val{120.6} (s,\#{1},\pos{2}),
    \val{119.0} (s,\#{1},\pos{3}),
    \val{89.6}  (s,\#{1},\pos{3}),
    \val{88.2}  (s,\#{2},\pos{4}),
    \val{73.4}  (s,\#{2},\pos{6}),
    \val{62.8}  (s,\#{2},\pos{5}),
    \val{56.0}  (s,\#{1},\pos{8}),
    \val{40.5}  (s,\#{1},\pos{9}).
\end{experimental} 
\end{document}
1
  • You (and the OP) shouldn't have those spaces in ( s, \#{2}, \pos{6} ), (look at the second to last line in the image of your code…)
    – cgnieder
    Apr 19, 2017 at 12:21
0

It has been a while since I posted the question and I just wanted to add my current work-around, since this seems to be a general problem that cannot be properly resolved. This may give an idea to people with a similar problem. So what I did now is, wherever I got this wrong alignment in my experimental parts, I introduced a tabular environment before the experimental. This is how the code then looks:

    \begin{table}[h!]
            \begin{tabular}{@{} p{0.8\textwidth} p{0.2\textwidth} @{}}
            Ferrocene was prepared by slow addition of a solution of \ch{FeCl3} in DMSO to a mixture of freshly cracked cycopentadiene and potassium hydroxide in THF at \SI{-78}{\celsius}.  & \\raisebox{-0.8\height}{\includegraphics[width=0.2\textwidth]{Fc.eps}} \\
            \end{tabular}
    \end{table}
    \begin{experimental}[format=\bfseries, coupling-unit={},list=true]
        \NMR(500)[CDCl3] = 
            %same data as before
        \\
        \NMR{13,C[^1H]}(126, MHz)[CDCl3] = 
            %same data as before
    \end{experimental}

This makes the result look the way I wanted it, so I will stick with this solution although it is not very elegant, except somebody proposes a much better way of doing it...

You must log in to answer this question.

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