5

The minitoc package adds extra page when used with float and lastpage packages. I figured out that this problem can be resolved by loading minitoc package before float and lastpage packages. In LyX the float package is loaded automatically and could not figure out how to force LyX use minitoc package before loading float and lastpage packages. Thanks in advance for your help.

\documentclass[a4paper,12pt]{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage{minitoc}
\begin{document}
\dominitoc
\tableofcontents
\mainmatter
\chapter{First Chapter}
\minitoc
\section{Introduction}
\blindtext[1]
\section{Material \& Method}
\blindmathpaper
\chapter{Second Chapter}
\minitoc
\section{Introduction}
\blindtext[1]
\section{Material \& Method}
\blindmathpaper
\end{document}

Edited

It is also working in LyX 2.1.1 if I remove \includepdf[pages={1},scale=1]{Back.pdf} at the end of the document. However if I include \includepdf[pages={1},scale=1]{Back.pdf} at the end of the document it adds extra page. Any thoughts.

Updated

I've narrow downed the problem. My following MWE in .Rnw format adds extra page at the end of document when using minitoc package. Thanks again for your help.

\documentclass[a4paper,12pt]{book}
\usepackage{minitoc}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage{pdfpages}
\begin{document}
\dominitoc
\tableofcontents
\mainmatter

\chapter{First Chapter}
\minitoc
\section{Introduction}
<< Test >>=
1:50
@ 
\blindtext[1]
\section{Material \& Method}
\blindmathpaper
\includepdf[pages={1},scale=1]{Back.pdf}
\end{document}
  • According to my tests, it is enough to load minitoc before lastpage only (float can be loaded before of after), and since apparently LyX only loads float, then you shouldn't have any troubles; simply load minitoc before lastpage. – Gonzalo Medina Aug 1 '14 at 15:27
  • Thanks @GonzaloMedina for your interest in my problem. It adds an extra page at the end of the document. – MYaseen208 Aug 1 '14 at 15:28
  • Yes, but simply loading minitoc before lastpage solves it. Doesn't it? – Gonzalo Medina Aug 1 '14 at 15:34
  • As I mentioned in my question, putting minitoc before lastpage solves the issue in LaTeX but not in LyX. – MYaseen208 Aug 1 '14 at 15:39
  • Why not? In your post, you mention that LyX loads float automatically, not lastpage, so lastpage should not be a problem. – Gonzalo Medina Aug 1 '14 at 15:42
4
+50

By default, minitoc provides the user with a number of hints (a package option). These hints are printed to the console or executed \AtEndDocument, and there's a spurious space somewhere in the definition of the hints-printing macro (a definite bug). In your particular example, the page Back.pdf is inserted before \AtEndDocument, causing the spurious space to insert an additional (unwanted) page, even though it has nothing on it.

To avoid this, call minitoc with the nohints package option:

\usepackage[nohints]{minitoc}% http://ctan.org/pkg/minitoc

This empty-last-page problem is very specific to your usage, since the spurious space might otherwise go unnoticed at the end of a "regular" document.

  • (+1): Thanks @Werner for your helpful answer. Much appreciated. – MYaseen208 Aug 2 '14 at 5:13

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.