0

I am in the progress of creating a small book with music notes. I have documents in PDF, which then I import to latex using pdfpages; I found it very useful as it takes multi page documents and import everything using one command. It also provides options to specify general layout style, footnote style, margines, etc. Also, possibility to use fancyhdr is great.

One thing I cannot figure out is adding footnotes to specific pages, such as adding footnotes to already generated pages by pdfpages. It is not anything repetitive like pages. I'd like to add a comment to page 23, for instance. My mind tells me this is "not possible" but perhaps there is a workaround and I though it would be worth asking.

Thanks

PS. I know latex let us add individual pages but I would like to avoid it. I need to add footnotes only to a couple of pages out of tens.


Edit.

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[utf8]{inputenc}
\usepackage[usernames,dvipsnames,svgnames,table]{xcolor}
\usepackage{pdfpages}
\usepackage{graphicx}
\usepackage[inner=2.5cm,outer=2cm,top=3cm,bottom=3cm]{geometry}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{lipsum}

\titleformat
{\chapter}[hang]
{\bfseries\Huge}
{\thechapter.\quad}
{0pt}
{}[]

%width=0.99\textwidth
\includepdfset{
    scale=0.88,
    offset=0.3cm 0cm,
    keepaspectratio
}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE]{\leftmark}
\fancyhead[RO]{Exercises 1-20}
\fancyfoot[RO,LE]{Page\ \thepage}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}

\renewcommand{\chaptermark}[1]{\markboth{\large{\thechapter.\ #1}}{}}

\newcounter{d}
\makeatletter
\def\test{\stepcounter{d}
  \ifnum\value{d}=3
  \refstepcounter{footnote}
  \footnotetext{Blah blah}
  \fi
}
\newcommand\resetD{\setcounter{d}{0}}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\chapter{Hanon in C}

\resetD
\includepdf[pages=-,pagecommand=\test]{hanon-in-C-1-20.pdf}

%\thispagestyle{empty}
%\includepdf[pages=-, pagecommand={\pagestyle{fancy}}]{hanon-in-C-1-20.pdf}

\clearpage{\pagestyle{empty}\cleardoublepage}

%\chapter{Hanon in F}
%\thispagestyle{empty}
%\includepdf[pages=-, pagecommand={\pagestyle{fancy}}]{hanon-in-F-1-20.pdf}

\end{document}
  • Standard footnotes are implemented as bottom floats (except inside a minipage). You basically want to overlay a fake footnote on top af an image (pdfpages is implemented using \includegraphics). – John Kormylo Jan 17 '18 at 4:20
  • @JohnKormylo Thanks for your comment. Perhaps I should try standard \includegraphic and then add a footnote. – Celdor Jan 17 '18 at 10:14
  • \includegraphics has an undocumented [page=...] option, and of course you will need to fit the image into the text area with enough spare room for the \footnotetext. – John Kormylo Jan 17 '18 at 16:13
1

Not particularly elegant, but it works. You can use pagecommand= to run a command on each included page. Have this command manage a counter that counts along the included pages, and then adjust the command to trigger on the relevant pages

Here memoir is irrelevant (just the default class in my editor) and 1-8-black.pdf is an 8 page PDF listing the numbers 1-8.

\documentclass{memoir}
\usepackage{pdfpages}
\newcounter{d}
\makeatletter
\def\test{\stepcounter{d}
  \ifnum\value{d}=3
  \refstepcounter{footnote}
  \footnotetext{Blah blah}
  \fi
}
\newcommand\resetD{\setcounter{d}{0}}
\makeatother
\begin{document}
\resetD
\includepdf[pages=-,pagecommand=\test]{1-8-black.pdf}

\resetD
\includepdf[pages=-,pagecommand=\test]{1-8-black.pdf}

\end{document}

I'm using \refstepcounter and \footnotetext such that the \footnotemark is not added to the page (as it could disturb the included contents.

  • Hi. Thanks for your answer. It is complicated. I understand d is defined as a counter for a page number (?), then \resetD resets it to 0. I assume \stepcounter increment a counter by 1 but still I don't know what \refstepcounter{} does :/. Also, I tried to add a part of your code to mine and it produces overlapping footnotes and pages. I added my code and the output. I forgot to mention I include fancyhdr as well. Can footnotes be centred? Thanks. – Celdor Jan 16 '18 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.