6

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}
lockstep
  • 250,273
MYaseen208
  • 8,587
  • 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 01 '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 01 '14 at 15:28
  • Yes, but simply loading minitoc before lastpage solves it. Doesn't it? – Gonzalo Medina Aug 01 '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 01 '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 01 '14 at 15:42
  • Sorry @GonzaloMedina for any inconvenience. I don't why this is not working in LyX 2.1.1. – MYaseen208 Aug 01 '14 at 15:45
  • @GonzaloMedina: It is also working in LyX 2.1.1 if I remove \includepdf[pages={1},scale=1]{Back.pdf}. However if I include \includepdf[pages={1},scale=1]{Back.pdf} it adds extra page. Any thoughts. – MYaseen208 Aug 01 '14 at 16:27
  • @MYaseen208 it is always useful for LyX questions if you post two MWEs, one that is the .lyx file (it is just a text file) and one that is the exported LaTeX. – scottkosty Aug 01 '14 at 20:49
  • Please @GonzaloMedina and scottkosty see my updates. Looking forward for your help. – MYaseen208 Aug 01 '14 at 22:51
  • Please @scottkosty see my updates. Looking forward to your help. – MYaseen208 Aug 01 '14 at 22:52
  • @MYaseen208 I do not see a .lyx file. – scottkosty Aug 02 '14 at 00:18

1 Answers1

5

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.

Werner
  • 603,163