4

I have a book class, I'm trying to add a pdf page at the very last page of my book. At the end of my latex I have :

\includepdf[pages={1}]{mylastpdf}
\end{document}

However I don't know why but after I compile the latex I still have an empty page at the end of my book and my pdf is included just before that. How can I include my pdf at the very last page ?

Edit

I realized that it is causes only when I have the following package in my tex file : chapterbib , float and minitoc . But I need these packages. Could you help me with this ?

Here a full example :

\documentclass[12pt,twoside,a4paper]{book}
\usepackage{chapterbib} %% Required
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}  
\usepackage{float}%% Required
\usepackage{lipsum}
\usepackage{pdfpages}
\usepackage{minitoc} %% Required
\begin{document}
    \chapter{Conclusion générale.}
    \lipsum[50]
    \includepdf[pages={1}]{backcover/resume}
\end{document}
  • We need a complete example. What you describe is not the default behaviour. – cfr Oct 4 '16 at 23:20
  • @cfr I though it was the default behaviour, thanks to your remark I found it is cause when I have three others packages - see my edit – Malick Oct 4 '16 at 23:44
  • 1
    That's why you should always include an MWE. – cfr Oct 5 '16 at 0:06
5

\AtEndDocument can be used to place the included page a little later after the possible additions of other packages:

\documentclass[12pt,twoside,a4paper]{book}
\usepackage{chapterbib} %% Required
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{float}%% Required
\usepackage{lipsum}
\usepackage{pdfpages}
\usepackage{minitoc} %% Required
\begin{document}
    \chapter{Conclusion générale.}
    \lipsum[50]
    \AtEndDocument{\includepdf[pages={1}]{example-image-a}}
\end{document}

The reason are several bugs in minitoc. At some point it executes \mtc@hints@checklongext in \AtEndDocument. It contains lots of:

\if@mtc@<package>Loaded\else
  \if@mtc@<package>Loaded@a@
    \mtc@PackageWarningNoLine[...]{...}{...}
  \fi
\fi

The line end after the last argument of \mtc@PackageWarningNoLine should be commented to prevent a potential white space leaking in.

The real problem, however, is the following pattern:

\if@mtc@<package>Loaded@\
   \mtcPackageInfo[...]{...}{...}
\fi

It looks like a copy/paste error. The intention was to delete the \else, but the backslash remains. Combined with the normal end of line it becomes \␣ (backslash and space), which forces a space, which is not ignored in vertical mode, but it forces a new paragraph with this space. The vertical list is now no longer empty and TeX sets an additional page with some spaces.

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.