我在化学论文实验部分的格式方面遇到了问题。我描述了一个分子的合成和光谱值,以将其包裹在一个小的图形表示中。一开始我使用了 wrapfiqure,如下例所示:
\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}
它运行良好,直到我开始意识到,非常简短的描述会导致部分光谱数据与图片对齐,如下所示:
因此,我尝试解决这个问题的方法是使用窗口环境(相同的包):
\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}
但这却给我留下了以下类型的错误:
/TestExp2.tex:19:LaTeX 错误:出现错误 - 可能缺少 \item。[ \NMR(500)[CDCl3]]
因此,显然窗口和实验环境不兼容。如果 i\end{window}
位于 之前\begin{experimental}
,则运行正常,但是图形有时会被后面的文本覆盖,具体取决于其大小。
所以我的问题是:有没有解决方法,这样我就可以实际定义一个包含实验环境的窗口?或者这是不可能的?
我也愿意接受不使用wrapfigure
OR的替代解决方案window
提前致谢!
答案1
这种方法基于此处发布的答案:https://tex.stackexchange.com/a/309454,可用于在各种环境中灵活放置人物。
该方法的关键部分使用:
一个支柱,将第一行文本的基线放置在距离顶部指定距离的位置
minipage
。然后adjustbox
将小页面的顶部放置在外基线上方正好该距离的位置。
在本例中,由于使用了experimental
来自spectroscopy
包模块的环境chemmacros
,因此必须将两个调整框并排放置。这是通过使用minipage
作为内部环境的 来完成的adjustbox
,其中一个小页面设置在0.8\linewidth
,另一个设置在0.2\linewidth
(请参阅手册第 4.10 节adjustbox
)。
以下示例显示了化学分子图及其附带的光谱数据的两种可能的布局。
2017 年 4 月 19 日更新,删除了 NMR 规范中的空格。请参阅 Clemens 的评论。
这是代码:
\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}
答案2
距离我发布这个问题已经有一段时间了,我只是想添加我当前的解决方法,因为这似乎是一个无法正确解决的普遍问题。这可能会给有类似问题的人一个想法。所以我现在所做的是,无论我在实验部分中哪里出现这种错误的对齐,我都会在实验之前引入一个表格环境。代码如下所示:
\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}
这使得结果看起来符合我的要求,所以我会坚持这个解决方案,尽管它不是很优雅,除非有人提出了一种更好的方法......