[Tex/LaTex] How to insert a pdf page at the very last page of a book

bookspdfpages

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}

Best Answer

\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.

Related Question