我正在制作一张海报,使用 a0poster 样式,我试图将 itemize 列表包裹在图形周围。我尝试了 wrapfigure 包,但我发现它不适用于 itemize 列表,所以我尝试了 floatflt,它应该可以很好地与列表配合使用(前提是您使用 \fltitem)。我的 MWE 如下:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{floatflt}
\usepackage{multicol}
\usepackage{lipsum}
\usepackage[margin=2cm]{geometry}
\setlength\parindent{0pt}
\begin{document}
\lipsum[1]
\begin{multicols}{2}
\section{Introduction}
\lipsum[2-3]
\begin{floatingfigure}[r]{0.5\columnwidth}
\centering
\includegraphics[width=0.48\columnwidth]{universe.jpg}
\caption{very very very very very very very very very very very very very very very very long caption}
\label{fig:example}
\end{floatingfigure}
\begin{itemize}
\fltitem{one very very very very very long text}
\fltitem{two very very very very very long text}
\fltitem{three very very very very very long text}
\end{itemize}
\lipsum[4-7]
\end{multicols}
\end{document}
结果是(请注意列表旁边没有图像):
谢谢您的帮助!
答案1
以下内容基于https://tex.stackexchange.com/a/417571/117050但对其进行了大量扩展。它定义了宏:
\InsertListR[<correction>]{<skip>}{<contents>}
参数<correction>
是所使用的校正因子insbox
(使用它来扩展受影响的行数)、<skip>
插入前要跳过的行数以及<contents>
要插入的框。\wrapitem
用于启动第一个项目,之后使用\InsertListR
\contitem
使用后的另一个项目\InsertListR
也应受到影响。它需要一个可选参数来指定受影响的行数(默认为 100)\EndInsert
\InsertListR
手动停止或任何其他宏的效果insbox
。它还会开始一个新段落。如果要抑制缩进,您可以使用带星号的版本。
梅威瑟:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{duckuments}% funnier than lipsum
\usepackage[margin=2cm]{geometry}
\usepackage{capt-of}
\usepackage{enumitem}
\input{insbox.tex}
\usepackage{etoolbox}
\newcommand*\wrapitem
{%
\apptocmd\labelitemi{\hskip\leftmargin}{}{}% add a correction
\item
\patchcmd\labelitemi{\hskip\leftmargin}{}{}{}% remove the added hskip
}
\newsavebox\InsertListRbox
\newlength\InsertListPrevWidth
\makeatletter
\newcommand{\InsertListR}[3][]
{%
\mbox{}%
\vspace*{-\baselineskip}%
\setlength{\leftskip}{\leftmargin}%
\setbox\InsertListRbox\hbox{#3}%
\global\InsertListPrevWidth
\dimexpr
\wd\InsertListRbox+\@InsertBoxMargin
\relax
\InsertBoxR{#2}{\hskip-\leftmargin\box\InsertListRbox\hskip\leftmargin}[#1]%
}%
\newcommand*\contitem[1][100]
{%
\item
\ParShape=3
{0} 0cm 0cm
{#1} 0cm {\the\InsertListPrevWidth}
1 0cm 0cm
}
\newcommand*\EndInsert
{
\@restore@
\@ifstar{\@afterindentfalse\@afterheading}{}%
}
\makeatother
\begin{document}
\blindduck[1]
\begin{multicols}{0}
\section{Introduction}
\blindduck[-5]
\begin{itemize}
\wrapitem
\InsertListR{0}
{%
\parbox{.48\columnwidth}
{%
\includegraphics[width=.48\columnwidth]{example-image-duck}%
\captionof{figure}{foo}%
}%
}%
one very very very very very long text
\contitem two very very very very very long text
\contitem three very very very very very long text
\end{itemize}
\EndInsert*
\blindduck[1-5]
\end{multicols}
\end{document}
结果:
编辑:更合理的默认值\contitem
。默认情况下,此版本执行insbox
与计算受影响行数相同的计算。如果您对结果不满意,可以明确给出数字。它还将的默认值更改\InsertListR
为合理的0
(空的默认参数将与 1 相同,这不是预期的行为insbox
)。
出于我还不理解的原因, 的效果在环境\InsertListR
之后的下一个新段落结束itemize
。因此,我添加了一个宏\MoreInsert
,它将当前段落中应受影响的行数作为参数(仅在当前段落中,另一个新段落会结束其效果)。
新代码(在完整的 MWE 中):
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{duckuments}% funnier than lipsum
\usepackage[margin=2cm]{geometry}
\usepackage{capt-of}
\usepackage{enumitem}
\input{insbox.tex}
\usepackage{etoolbox}
\newcommand*\wrapitem
{%
\apptocmd\labelitemi{\hskip\leftmargin}{}{}% add a correction
\item
\patchcmd\labelitemi{\hskip\leftmargin}{}{}{}% remove the added hskip
}
\newlength\InsertListPrevWidth
\makeatletter
\newcommand{\InsertListR}[3][0]
{%
\mbox{}%
\vspace*{-\baselineskip}%
\setlength{\leftskip}{\leftmargin}%
\InsertBoxR{#2}{\hskip-\leftmargin#3\hskip\leftmargin}[#1]%
\global\InsertListPrevWidth\@framewidth
}%
\newcommand*\contitem[1][\the\count1]
{%
\item
\bgroup % to keep some changes local
% let's calculate parameters for \ParShape
\def\reserved@a{#1}%
\def\reserved@b{\the\count1}%
\ifx\reserved@a\reserved@b
% Below calculation is copied from \@@InsertBox of insbox
\dimen0 = \@wherebottom
\advance \dimen0 by -\pagetotal
\divide \dimen0 by \baselineskip
\count1 = \dimen0
\advance \count1 by 1
\advance \count1 by -\@numnormal
\fi
\MoreInsert{#1}%
\egroup
}
\newcommand*\EndInsert
{%
\@restore@
\@ifstar{\@afterindentfalse\@afterheading}{}%
}
\newcommand*\MoreInsert[1]
{%
\ParShape = 2
{#1} 0cm {\the\InsertListPrevWidth}
1 0cm 0cm
}
\makeatother
\begin{document}
\blindduck[1]
\begin{multicols}{0}
\section{Introduction}
\blindduck[-5]
\begin{itemize}
\wrapitem
\InsertListR{0}
{%
\parbox{.48\columnwidth}
{%
\includegraphics[width=.48\columnwidth]{example-image-duck}%
\captionof{figure}{foo}%
}%
}%
one very very very very very long text
\contitem two very very very very very long text
\contitem three very very very very very long text
\end{itemize}
\MoreInsert{1}
\blindduck[1-5]
\blindduck[1-5]
\end{multicols}
\end{document}