考虑以下 LaTeX 代码,其下半部分由MarkDown经过潘多克。
\documentclass{article}
\usepackage{mwe}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
\else\Gin@nat@width\fi}
\makeatother
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
\setlength{\parindent}{0pt}
% begin preamble.tex
\usepackage{wrapfig}
\renewenvironment{description}{}{}
\renewcommand{\item}[1][]{%
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=4cm]{##1}}%
\begin{wrapfigure}{l}{4cm}%
#1%
\end{wrapfigure}%
}
% end preamble.tex
\begin{document}
\begin{wrapfigure}{l}{4cm}%
\Oldincludegraphics[width=4cm]{example-image-a}%
\end{wrapfigure}%
A.0 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis
sem. Nullam nec mi et neque pharetra sollicitudin.
A.1 \blindtext
\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[\includegraphics{example-image-b}]
B.0 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis
sem. Nullam nec mi et neque pharetra sollicitudin.
\end{description}
B.1 \blindtext
\end{document}
我想要做的是将description
环境和\item
命令重新定义为普通文本,以使其wrapfigure
正常工作。
\renewenvironment{description}{}{}
看起来效果不错。但块\renewcommand{\item}[1][]
似乎仍然会引发意外行为。用wrapfig
替换时也会发生类似情况。wrapfig
picins
注意:由于我们在这里处理的是潘多克生成的文档,上述内容只能通过更改序言和/或添加页眉和/或页脚来实现document
。
答案1
原本打算对这个问题进行编辑,但这是一个使用floatflt
包的解决方案;我还没有尝试过浮动包。诀窍就在 中\hspace{0pt}
。
\documentclass{article}
\usepackage{mwe}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
\else\Gin@nat@width\fi}
\makeatother
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
\setlength{\parindent}{0pt}
% begin preamble.tex
\usepackage{floatflt}
\renewenvironment{description}{%
\renewcommand{\includegraphics}[1]{\vspace{-1ex}\Oldincludegraphics[width=4cm]{##1}}
\renewcommand{\item}[1][]{##1\end{floatingfigure}}%
\hspace{0pt}%
\begin{floatingfigure}[l]{4cm}}%
{}
% end preamble.tex
\begin{document}
\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[\includegraphics{example-image-a}]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis
sem. Nullam nec mi et neque pharetra sollicitudin.
\end{description}
\blindtext
\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[\includegraphics{example-image-b}]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis
sem. Nullam nec mi et neque pharetra sollicitudin.
\end{description}
\blindtext
\end{document}