(自指)XeLaTeX 中同一文档某一页的缩略图

(自指)XeLaTeX 中同一文档某一页的缩略图

在一本书中,我想在书的末尾添加一小段关于书的结构的文字。我想添加书本身一页的图以供参考。引用的页面将不同于引用它的页面。这可以通过首先使用占位符编译 pdf、从 pdf 中提取页面然后将其作为小页面包含来完成。这可以一次性完成吗,即让引擎本身在一次编译运行中在小页面环境中渲染页面?

答案1

您可以在页面框发货前将其抓取,例如

在此处输入图片描述

这里我用了\AddToHook{shipout/before}其他钩子,效果会有所不同,你也可以尝试新的 shipout钩子将在下一版本中添加目前(2022 年)可使用 latex-dev

\documentclass[a4paper]{article}

\usepackage{graphicx}

\newbox\savedpage
\AddToHook{shipout/before}{%
  \ifnum\value{page}=1
   \global\setbox\savedpage\copy\ShipoutBox
  \fi}

\begin{document}

\section{aa}
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 


\begin{figure}[htp]
  \centering
  \includegraphics{example-image}
  \caption{abc}
\end{figure}

\section{aaa}
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 

\section{bbb}

xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 

\begin{figure}[htp]
  \centering
  \includegraphics{example-image-a}
  \caption{abc}
\end{figure}

xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 


\section{aa}
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 
xxx yyy xxx yyy xxx yyy xxx yyy 

\section{hmm}

And page 1 looked like

\begin{center}
  \fbox{\scalebox{0.25}{\makebox[\paperwidth][l]{%
    \hspace{1in}\usebox\savedpage}}}
\end{center}

\end{document}

相关内容