以下将图像定位在指定的页面坐标处。
\documentclass{article}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\usepackage[absolute,overlay]{textpos}
\setlength{\TPHorizModule}{1mm}
\setlength{\TPVertModule}{1mm}
\begin{document}
\lipsum[1-3]
\begin{textblock}{20}(80,100)
\includegraphics{foo}
\end{textblock}
\end{document}
但是,在这种情况下,图像将覆盖在文本之上。这不是我想要的。我想要的是看起来更像您从此代码中获得的内容。
\documentclass{article}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\begin{document}
\lipsum[1]
Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at,
tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec nonummy
pellentesque ante. Phasellus adipiscing semper elit. Proin fermentum massa
ac quam. Sed diam turpis, molestie vitae, placerat a, molestie nec, leo. Mae-
cenas lacinia. Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum.
Morbi blandit ligula feugiat magna. Nunc eleifend consequat lorem. Sed lacinia nulla
\begin{center}
\includegraphics{foo}
\end{center}
vitae enim. Pellentesque tincidunt purus vel magna. Integer non enim.
Praesent euismod nunc eu purus. Donec bibendum quam in tellus. Nullam cur-
sus pulvinar lectus. Donec et mi. Nam vulputate metus eu enim. Vestibulum
pellentesque felis eu massa.
\end{document}
在这种情况下,图像不会覆盖文本,而是拆分段落并清除以适合图像。
我想做一些事情来产生这种效果,但要使用更像什么的东西textpos
。换句话说,我想告诉 LaTeX 将图像放在页面上的特定位置,但在图像周围产生一个不允许文本的空地。
答案1
它有太多的限制和未记录的功能,我不知道从哪里开始列出它们,但它重新定义b
为在页面下方定位浮动\middlefloatpos
,只要页面有足够的文本可以在该点拆分。
\documentclass{article}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\setcounter{bottomnumber}{1}% don't even think of setting this higher
\newlength\middlefloatpos
\setlength\middlefloatpos{4cm} % space above the inserted float
\makeatletter
\def \@cflb {%
\let\@elt\@comflelt
\setbox\@tempboxa \vbox{}%
\@botlist
\setbox\@outputbox \vbox{\vbadness\@M
\setbox\z@\vsplit\@outputbox to \middlefloatpos
\unvbox\z@
\vskip .5\textfloatsep plus \baselineskip
\unvbox\@tempboxa
\vskip .5\textfloatsep plus \baselineskip
\vskip -\floatsep
\unvbox\@outputbox
}%
\let\@elt\relax
\xdef\@freelist{\@freelist\@botlist}%
\global \let \@botlist\@empty
}
\makeatother
\begin{document}
\lipsum[1]
\begin{figure}[!b]\centering
\includegraphics{foo}
\end{figure}
Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at,
tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec nonummy
pellentesque ante. Phasellus adipiscing semper elit. Proin fermentum massa
ac quam. Sed diam turpis, molestie vitae, placerat a, molestie nec, leo. Mae-
cenas lacinia. Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum.
Morbi blandit ligula feugiat magna. Nunc eleifend consequat lorem. Sed lacinia nulla
vitae enim. Pellentesque tincidunt purus vel magna. Integer non enim.
Praesent euismod nunc eu purus. Donec bibendum quam in tellus. Nullam cur-
sus pulvinar lectus. Donec et mi. Nam vulputate metus eu enim. Vestibulum
pellentesque felis eu massa.
\end{document}