1

I need to list in a document enclosed items that are comprised of pdf's and images, in a certain order. The way I have approached this, is to use floats with option H[ere] for the images, and includepdf for the pdfs, and newlistof to list the items. In any case, I'm unable to get the page numbers right. Other imperfections mentioned in the code. Also, someone may know of a better approach altogether.

PS: Foo.pdf is a one page 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}

output

1

1 Answer 1

1

The problem is that \includepdf starts a new page and fills it. If you put \addenclosed in front, it will be on the preceding page. If you put it after, it will be on the next page. You can, however, use \afterpage to put it on the correct page.

\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}
3
  • Thanks. Also, y doesn’t enclosedlabel work? I would like to label the included pdf’s with a watermark using the pkg by the same name. For that I need the cmd to get the page number of a given enclosed item. What is it?
    – Erwann
    Commented Aug 28, 2018 at 16:10
  • autopageref, I guess.
    – Erwann
    Commented Aug 28, 2018 at 17:46
  • If you use \refstepcounter and \label, you print the page number using \pageref. See also \getpagerefnumber from refcount. Commented Aug 29, 2018 at 3:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .