
ドキュメント内の図があるすべてのページのリストを取得したいです。具体的には、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