![将 wrapfigure 放在以下段落旁边](https://linux22.com/image/425401/%E5%B0%86%20wrapfigure%20%E6%94%BE%E5%9C%A8%E4%BB%A5%E4%B8%8B%E6%AE%B5%E8%90%BD%E6%97%81%E8%BE%B9.png)
我想在文本右侧放置一张浮动图片,而不仅仅是文本的右侧,特别是后面的文本。问题是,这wrapfigure
似乎选择了后面的段落。
在以下 Pandoc 示例中,我希望图片紧挨着职业/驾驶/理智的支柱部分;相反,它会显示在看过欧洲之后...部分。
---
header-includes:
\usepackage{graphicx,wrapfig}
---
# Clarence Merriweather
\begin{wrapfigure}{r}{0.3\textwidth}
\includegraphics[width=\linewidth]{portrait.jpg}
\end{wrapfigure}
* Occupation: Professor
* Drive: Scholarship
* Pillars of Sanity:
* Positivism: the world can be understood via science
* Enlightenment will prevail over primitive barbarism
* The world changes, but I'll always have the family house in Abingdon
After seeing Europe sink into the death cult that was the Great War,
Prof. Merriweather, himself spared of experiencing combat first-hand
by his academic standing and his asthma, decided to leave his faculty
position in Oxford to pursue a new career in NYU.
His interest in primitive cultures and the occult is purely
academical. He is happy to lend his expertise to the FBI to help with
cases involving "crazies who imitate the primitive savages".
我怎样才能强制wrapfigure
将内容放在当前段落,即“职业”、“动力”和“支柱”部分旁边?
答案1
我不知道 pandoc 的 markdown(?) 和 LaTeX 输入之间到底发生了什么,但 wrapfigure 拒绝被放在列表中。“立即”开始的答案是
\indent \vspace*{-\baselineskip}\vspace{-\parskip}\par
在列表开头之前。
此外,wrapfigure 的内容上方有一个空白边框,因此它不会接触上方的文本。要使图像从该行开始,您应该撤消 wrapfigure 内的边框。总共(实际上是“部分”)
# Clarence Merriweather
\begin{wrapfigure}{r}{0.3\textwidth}
\vspace{-\intextsep}
\includegraphics[width=\linewidth]{portrait.jpg}
\end{wrapfigure}
\indent \vspace*{-\baselineskip}\vspace{-\parskip}\par
* Occupation: Professor
* Drive: Scholarship
答案2
我不熟悉 pandoc,但在 LaTeX 代码(由 pandoc 产生)中,代码应该是这样的:
\documentclass{article}
\usepackage{graphicx,wrapfig}
\begin{document}
\section*{Clarence Merriweather} % this is LaTeX emulation of pandoc
\begin{itemize}
\item Occupation: Professor
\item Drive: Scholarship
\item Pillars of Sanity:
\begin{itemize}
\item Positivism: the world can be understood via science
\item Enlightenment will prevail over primitive barbarism
\item The world changes, but I'll always have the family house in Abingdon
\end{itemize}
\end{itemize}
\begin{wrapfigure}{r}{0.3\textwidth} % <--- had to be inserted here
\vspace{-\baselineskip}
\includegraphics[height=\linewidth, % in real document remove this option
width=\linewidth]{example-image-duck}%{portrait.jpg}
\end{wrapfigure}
After seeing Europe sink into the death cult that was the Great War,
Prof. Merriweather, himself spared of experiencing combat first-hand
by his academic standing and his asthma, decided to leave his faculty
position in Oxford to pursue a new career in NYU.
His interest in primitive cultures and the occult is purely
academical. He is happy to lend his expertise to the FBI to help with
cases involving ''crazies who imitate the primitive savages''.
\end{document}
产生
正如您所看到的,wrapfigure
必须位于段落的开头,即需要插入图像的位置。
附录:
不幸的是,wrapfig 不适用于 itemize。一个可能的解决方案是将列表封装在和中minipage
,而不是wrapfigure
使用\InsertBoxR
普通 TeX 宏包中的定义insbox
\documentclass{article}
\usepackage{graphicx}
\usepackage{enumitem}
\input{insbox}%%%%%%%%%%%%%% TeX macro, very useful
\begin{document}
\section*{Clarence Merriweather}
\InsertBoxR{0}{%
\includegraphics[height=0.4\linewidth, % in real document remove this option
width =0.3\linewidth]{example-image-duck}%{portrait.jpg}
}
\noindent\begin{minipage}[t]{0.65\linewidth}
\setlist[itemize]{topsep=0pt, itemsep=0.2ex, leftmargin=*}
\begin{itemize}
\item Occupation: Professor
\item Drive: Scholarship
\item Pillars of Sanity:
\begin{itemize}
\item Positivism: the world can be understood via science
\item Enlightenment will prevail over primitive barbarism
\item The world changes, but I'll always have the family house in Abingdon
\end{itemize}
\end{itemize}
\end{minipage}
After seeing Europe sink into the death cult that was the Great War,
Prof. Merriweather, himself spared of experiencing combat first-hand
by his academic standing and his asthma, decided to leave his faculty
position in Oxford to pursue a new career in NYU.
His interest in primitive cultures and the occult is purely
academical. He is happy to lend his expertise to the FBI to help with
cases involving ''crazies who imitate the primitive savages''.
\end{document}
(红线表示文字边框)
答案3
我越来越喜欢用 paracol 代替 wrapfig。它更加健壮,但需要手动分段落(\nopar
和\noindent
)。
\documentclass{article}
\usepackage{graphicx}
\usepackage{paracol}
\newcommand{\nopar}{{\parfillskip=0pt\parskip=0pt\par}}
\begin{document}
\section*{Clarence Merriweather}
\setcolumnwidth{\dimexpr 0.7\textwidth-\columnsep}% right column is 0.3\textwidth
\begin{paracol}{2}
\begin{itemize}
\item Occupation: Professor
\item Drive: Scholarship
\item Pillars of Sanity:
\begin{itemize}
\item Positivism: the world can be understood via science
\item Enlightenment will prevail over primitive barbarism
\item The world changes, but I'll always have the family house in Abingdon
\end{itemize}
\end{itemize}
After seeing Europe sink into the death cult that was the Great War,
Prof. Merriweather, himself spared of experiencing combat first-hand
by his academic\nopar
\switchcolumn
\includegraphics[height=2.5in, % in real document remove this option
width=\linewidth]{example-image}%{portrait.jpg}
\end{paracol}
\noindent standing and his asthma, decided to leave his faculty
position in Oxford to pursue a new career in NYU
His interest in primitive cultures and the occult is purely
academical. He is happy to lend his expertise to the FBI to help with
cases involving ''crazies who imitate the primitive savages''.
\end{document}