我有一些文本,我想在第 2 页和第 4 页的顶部以及第 7 页的底部添加一些图像。我尝试了下面的代码,但无法获得正确的格式。如果您能帮助我,我将不胜感激。
\documentclass[10pt,a4paper]{extarticle}
\usepackage{lipsum}
\begin{document}
\begin{figure}[p=2,t]
\centering
\includegraphics{a.pdf}
\end{figure}
\begin{figure}[p=4,t]
\centering
\includegraphics{b.pdf}
\end{figure}
\begin{figure}[p=7,b]
\centering
\includegraphics{c.pdf}
\end{figure}
\lipsum[1-500]
\end{document}
答案1
您也可以打包\onpage
到以前的\onpage
,但这种方式不太令人困惑。
\documentclass[10pt,a4paper]{extarticle}
\usepackage{afterpage}
\usepackage{mwe}
\def\bottomfraction{0.5}% allows bigger figures on bottom of page
\newcommand{\onpage}[2]% #1 = page, #2 = code
{\ifnum\value{page}<#1\relax\afterpage{\onpage{#1}{#2}}%
\else#2\fi}
\begin{document}
\onpage{2}{%
\begin{figure}[t]
\centering
\includegraphics{example-image-a}
\end{figure}}}%
\onpage{4}{%
\begin{figure}[t]
\centering
\includegraphics{example-image-b}
\end{figure}}}%
\onpage{7}{%
\begin{figure}[b]
\centering
\includegraphics{example-image-c}
\end{figure}}}%
\lipsum[1-40]
\end{document}