如何将图形放置在枚举的文本内?

如何将图形放置在枚举的文本内?

我有一个充满文本的列表,但也需要在其中的右侧放置一个图形,并让文本环绕它。

我一直四处寻找,并没有发现任何有用的东西,当我找到它时,它只是将它放在底部。

前言:

\documentclass{article}

\usepackage[letterpaper, portrait, margin=2cm]{geometry}
\usepackage[english]{babel}
\usepackage[protrusion=true,expansion=true]{microtype}  
\usepackage{amsmath,amsfonts,amsthm,amssymb}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[svgnames,table,xcdraw,dvipsnames]{xcolor} 
\usepackage[version=3]{mhchem}
\usepackage{chemfig}
\usepackage{gensymb}
\usepackage[most]{tcolorbox}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{array}
\usepackage{xparse}
\usepackage{tikz}
\usepackage{makecell}
\usepackage{floatflt}
\usepackage{wrapfig}
\usetikzlibrary{calc,shadings,patterns}
\pagenumbering{roman}

剪辑...文档

\section*{Procedure}

\noindent \textbf{Directions:}
    \begin{enumerate}
        \itemsep 0em
        \item Place the following into a 250 ml round-bottomed flask:
        \begin{enumerate}
            \item 27.0 g of sodium bromide
            \item 20.0 ml of \textit{n}-butyl alcohol
            \item 30 ml of water
        \end{enumerate}
        \item Place into an ice-water bath
        \item Cool briefly
        \item Slowly add 23 ml of concentrated sulphuric acid while stirring using the magnetic stirring apparatus
        \item Fit the flask with a water-cooled condenser 
        \begin{wrapfigure}{R}{0.3\textwidth}
        \centering
        \includegraphics[width=0.25\textwidth]{exp14_fig1.pdf}
        \caption{Condenser}
        \end{wrapfigure}
        \item Heat the flask using the magnetic stirrer until the reaction mixture is boiling and note the time
        \item Adjust the stirring hot plate to maintain a brisk, steady reflux with \textit{vigorous} stirring 
        \item Note the separation due to density differences
        \item Reflux for fifty minutes
        \item Cool to room temperature
        \item Set up a steam distillation apparatus using a 100 ml round bottom flask as a receiver

我的版本在这里

eps 文件

答案1

这里的问题具体到wrapfig在列表中。

解决这个问题的一种方法是手动调整列表内的边距,并将图形放置在适当的位置。下面我使用了 LaTeX3 的强大功能xgalley在 内设置一些相对边距enumerate。图像被放置在零高度内tabular(使用\hfill\smash{..})。

由于构造的原因,需要进行一些调整才能获得理想的结果。例如,计数器figure需要手动调整,以便\caption放置典型的类似标题。此外,还引入了垂直支柱以增加图像和“标题”之间的间隙。

最后,将(相对)边际调整放在组内,以限制变化的范围。

在此处输入图片描述

\documentclass{article}

\usepackage{graphicx}
% http://river-valley.zeeba.tv/media/conferences/tug-2015/0302-Joseph-Wright/
\usepackage{xgalley}

\ExplSyntaxOn
\cs_new_eq:NN \SetAbsMargins \galley_margins_set_absolute:nn % {<left margin>}{<right margin>}
\cs_new_eq:NN \SetRelMargins \galley_margins_set_relative:nn % {<left margin>}{<right margin>}
\ExplSyntaxOff

\begin{document}

\section*{Procedure}

\noindent
\textbf{Directions:}
\begin{enumerate}
  \itemsep 0em
  \item Place the following into a 250 ml round-bottomed flask:
  \begin{enumerate}
    \item 27.0 g of sodium bromide
    \item 20.0 ml of \textit{n}-butyl alcohol
    \item 30 ml of water
  \end{enumerate}
  \item Place into an ice-water bath
  \item Cool briefly
  \item Slowly add 23 ml of concentrated sulphuric acid while stirring using the magnetic stirring apparatus
  \item Fit the flask with a water-cooled condenser
  \hfill\smash{\begin{tabular}[t]{c@{}}
    \raisebox{\dimexpr-\height+\normalbaselineskip}{%
      \includegraphics[width=.25\textwidth]{example-image}} \\
    \refstepcounter{figure}%
    \rule{0pt}{\normalbaselineskip}% Vertical strut
    Figure~\thefigure:~Condenser
  \end{tabular}}

  \begingroup
  \SetRelMargins{0pt}{.3\textwidth}
  \item Heat the flask using the magnetic stirrer until the reaction mixture is boiling and note the time
  \item Adjust the stirring hot plate to maintain a brisk, steady reflux with \textit{vigorous} stirring 
  \item Note the separation due to density differences
  \item Reflux for fifty minutes
  \endgroup
  \item Cool to room temperature
  \item Set up a steam distillation apparatus using a 100 ml round bottom flask as a receiver
\end{enumerate}

\end{document}

列表项本身非常短,因此,使用 等功能强大的工具进行(相对)边距调整的必要性值得怀疑xgalley。然而,在更一般的设置中,上述方法同样有效。

也就是说,您可以通过一些手动换行和\item[]在没有枚举的地方使用 s 来获得类似的结果。

答案2

这是一个使用包resume*功能的解决方案enumitem。它包括在enumerate包含图像之前关闭环境,并创建两个并排的minipage环境,顶部对齐。左侧小页面包含恢复枚举,右侧包含图像及其标题。在这些环境的末尾,是另一个恢复枚举。\documentclass{article} \usepackage[showframe]{geometry} \usepackage{graphicx} \usepackage{array, tabularx, enumitem, caption}

\begin{document}

\section*{Procedure}
\noindent \textbf{Directions:}
\begin{enumerate}[nosep]
  \itemsep 0em
  \item Place the following into a 250 ml round-bottomed flask:
        \begin{enumerate}[noitemsep]
          \item 27.0 g of sodium bromide
          \item 20.0 ml of \textit{n}-butyl alcohol
          \item 30 ml of water
        \end{enumerate}
  \item Place into an ice-water bath
  \item Cool briefly
  \item Slowly add 23 ml of concentrated sulphuric acid while stirring using the magnetic stirring apparatus
\end{enumerate}
\noindent\begin{minipage}[t]{0.7\textwidth}
\begin{enumerate}[resume*]
  \item Fit the flask with a water-cooled condenser
  \item Heat the flask using the magnetic stirrer until the reaction mixture is boiling and note the time
  \item Adjust the stirring hot plate to maintain a brisk, steady reflux with \textit{vigorous} stirring
  \item Note the separation due to density differences
  \item Reflux for fifty minutes
  \item Cool to room temperature
  \item Set up a steam distillation apparatus using a 100 ml round bottom flask as a receiver
  \item Add 50 ml of water and and distil adding water as needed to keep volume constant until no more water-insoluble droplets come over (can be tested by collecting a few drops of distillate in a\emph{dry} test tube to see if any oily droplets are still present)
  \item Pour the distillate into a separatory funnel
\end{enumerate}
\end{minipage}
\hfill
\begin{minipage}[t]{0.3\textwidth}
  \centering\captionsetup{labelfont=sc}\renewcommand\figurename{Fig.}
  \raisebox{-0.95\height}{\includegraphics[width=0.75\textwidth]{exp14_fig1}}
  \captionof{figure}{Condenser}\label{cond}
\end{minipage} \vspace*{-3pt}
\begin{enumerate}[resume*]
  \item Add 20 ml of water, stopper, and shake (the butyl bromide now forms the \emph{lower} layer since water and $ n $-butyl bromide have densities of $1.0$ g/ml and $ 1.3 $ g/ml, respectively)
\end{enumerate}
\end{document} 

在此处输入图片描述

相关内容