我的代码如下:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{booktabs}
\input{insbox}
\makeatletter
\@InsertBoxMargin = 12pt
\makeatother
\usepackage{nccmath}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{etoolbox}
\usepackage{graphicx}
\newcommand*{\wrapitem}{\apptocmd{\labelenumi}{\hskip\leftmargin}{}{}\item\apptocmd{\labelenumi}{\hskip-\leftmargin}{}{}}
%
\newcommand{\InsertListL}[3][]{%
\setlength{\leftskip}{\leftmargin}\mbox{}\vspace*{-\baselineskip}%
\InsertBoxL{#2}{#3}[#1]\par \hspace{\itemindent}
}%
\newcommand{\InsertListR}[3][]{%
\mbox{}\vspace*{-\baselineskip}\setlength{\leftskip}{\leftmargin}%
\InsertBoxR{#2}{\hskip-\leftmargin#3\hskip\leftmargin}[#1]
}%
\begin{document}
\begin{enumerate}%
\wrapitem%
\InsertListL[2]{2}{\includegraphics{./images/c01uf006.pdf}}%
\lipsum[1]
\item
\InsertListR[12]{-40}{\includegraphics{./images/c01uf007.pdf}}
\lipsum[2]
\wrapitem%
\InsertListL[2]{2}{\includegraphics{./images/c01uf006.pdf}}%
\lipsum[1]
\end{enumerate}
\end{document}
请提出以下建议:
- 我怎样才能垂直移动包装图像(上下移动)?
- 我如何控制不必要的垂直空白?
此外,请纠正编码中的任何错误。
答案1
您应该将其括\includegraphics
在 中\parbox
,我认为这样效果更好。此外,在一个环境\wrapitem
中仅使用一次(至少在这种情况下效果更好)。您可以使用第一个强制参数来控制垂直偏移,该参数控制在插入框之前正常排版的行数(这里不要使用太多)。可选参数可以操纵插入框周围的空白。enumerate
\InsertList<R/L>
通过此我得到以下内容。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{booktabs}
\input{insbox}
\usepackage{nccmath}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{etoolbox}
\usepackage{graphicx}
\makeatletter
\@InsertBoxMargin = 12pt
\makeatother
\newcommand*{\wrapitem}
{%
\apptocmd{\labelenumi}{\hskip\leftmargin}{}{}%
\item
\apptocmd{\labelenumi}{\hskip-\leftmargin}{}{}%
}
\newcommand{\InsertListL}[3][]
{%
\setlength{\leftskip}{\leftmargin}\mbox{}\vspace*{-\baselineskip}%
\InsertBoxL{#2}{#3}[#1]\par \hspace{\itemindent}% this \hspace doesn't do anything does it?
}%
\newcommand{\InsertListR}[3][]
{%
\mbox{}\vspace*{-\baselineskip}\setlength{\leftskip}{\leftmargin}%
\InsertBoxR{#2}{\hskip-\leftmargin#3\hskip\leftmargin}[#1]%
}%
\begin{document}
\begin{enumerate}%
\wrapitem%
\InsertListL[2]{3}{%
\parbox{8em}{\includegraphics[width=8em]{example-image-a}}}%
\lipsum[1]
\item
\InsertListR[2]{1}{%
\parbox{8em}{\includegraphics[width=8em]{example-image-b}}}
\lipsum[2]
\item%
\InsertListL[2]{3}{%
\parbox{8em}{\includegraphics[width=8em]{example-image-c}}}%
\lipsum[1]
\end{enumerate}
\end{document}