我需要在文档中按特定顺序列出由 pdf 和图像组成的封闭项目。我解决这个问题的方法是使用带有选项 H[ere] 的浮点数来表示图像和includepdf
pdf,并newlistof
列出项目。无论如何,我无法正确获得页码。代码中提到了其他缺陷。此外,有人可能知道更好的方法。
PS:Foo.pdf 是一页的 pdf
\documentclass{article}
\usepackage{tocloft}
\usepackage{keyfloat}
\usepackage{pdfpages}
\usepackage{xparse}
\newcommand{\listenclosedname}{List of enclosed items}
\newlistof[chapter]{enclosed}{encl}{\listenclosedname}
\NewDocumentCommand{\enclosedlabel}
{}
{
%\protect something? TODO
E{\small NCL.} \theenclosed.
}
\NewDocumentCommand{\addenclosed}
{m}
{
\stepcounter{enclosed}
\addcontentsline{encl}{enclosed}
{
%TODO: Replace
E{\small NCL.} \theenclosed.
% with:
% % \enclosedlabel
#1
}
}
\begin{document}
\listofenclosed % BUG: Foo's page = 1 instead of 2.
\addenclosed{Baz}
\keyfigbox[H]{
cstar={
% enclosedlabel % TODO
}
}{\LARGE Baz}
\addenclosed{Foo}
\includepdf{Foo.pdf}
\addenclosed{Bar}
\keyfigbox[H]{
cstar={}
}{\LARGE Bar}
\end{document}
答案1
问题是\includepdf
会开始新的一页并填满它。如果你把它\addenclosed
放在前面,它将在前一页。如果你把它放在后面,它将在下一页。但是,你可以使用它\afterpage
把它放在正确的页面上。
\documentclass{article}
\usepackage{tocloft}
\usepackage{keyfloat}
\usepackage{pdfpages}
\usepackage{xparse}
\usepackage{afterpage}
\newcommand{\listenclosedname}{List of enclosed items}
\newlistof[chapter]{enclosed}{encl}{\listenclosedname}
\NewDocumentCommand{\enclosedlabel}
{}
{
%\protect something? TODO
E{\small NCL.} \theenclosed.
}
\NewDocumentCommand{\addenclosed}
{m}
{
\stepcounter{enclosed}
\addcontentsline{encl}{enclosed}
{
%TODO: Replace
E{\small NCL.} \theenclosed.
% with:
% % \enclosedlabel
#1
}
}
\begin{document}
\listofenclosed % BUG: Foo's page = 1 instead of 2.
\addenclosed{Baz}
\keyfigbox[H]{
cstar={
% enclosedlabel % TODO
}
}{\LARGE Baz}
\afterpage{\addenclosed{Foo}}
\includepdf{twopages}
\addenclosed{Bar}
\keyfigbox[H]{
cstar={}
}{\LARGE Bar}
\end{document}