自動確定帶有圖表的頁數

自動確定帶有圖表的頁數

我想取得文件中所有包含數字的頁面的清單。具體來說,是從我的 LaTeX 文件創建的 PDF 文件中的頁碼。這將使我能夠僅以彩色列印那些頁面,而將其餘頁面保留為黑白,從而節省列印成本。不幸的是,印表機本身只允許為整個列印作業選擇彩色或黑白,因此我需要手動分隔頁面範圍(某些型號能夠逐頁決定,但這個不行)。

我在 Linux(基於 Debian)上使用 TeX Live。

有沒有辦法使用某些工具或選項自動確定這一點?

答案1

範例複製egreg的答案,但這次使用\makeindex.

\documentclass{article}
\usepackage{graphicx}
\usepackage{makeidx}
\makeindex

\let\oldincludegraphics\includegraphics
\renewcommand\includegraphics{\index{~@Pages containing figures}\oldincludegraphics}
\newwrite\listofgraphics

\begin{document}
A page without graphics
\clearpage
A page with graphics\\
\includegraphics{example-image}
\clearpage
A float
\begin{figure}[htp]
\includegraphics{example-image}
\end{figure}
and a delayed float
\begin{figure}[p]
    \includegraphics{example-image}
\end{figure}
\clearpage
A page without graphics
\clearpage
Again page with graphics\\
\includegraphics{example-image}
\clearpage

\printindex

\end{document}

答案2

這是一個可能過於簡單的方法

\documentclass{article}
\usepackage{graphicx}

\let\ORIincludegraphics\includegraphics
\renewcommand{\includegraphics}{%
  \write\listofgraphics{\thepage}%
  \ORIincludegraphics
}
\newwrite\listofgraphics
\AtBeginDocument{\immediate\openout\listofgraphics=\jobname.lis }
\AtEndDocument{\closeout\listofgraphics}

\begin{document}

A page without graphics
\clearpage

A page with graphics

\includegraphics{example-image}

\clearpage

A float

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

and a delayed float

\begin{figure}[p]
\includegraphics{example-image}
\end{figure}

\clearpage

A page without graphics
\clearpage

\end{document}

.lis創建的文件的內容是

2
3
4

相關內容