I don't know memoir
jargon, but if I understood you correctly, you want to insert a PDF that stretches to the normal \textwidth
on an otherwise empty page. This can be achieved by defining a customized page style (unless redefined, plain
would include a page number) and using the \includegraphics
options width
and height
, which are passed on by pdfpages
.
As pointed out by @egreg, with memoir
and no pagestyle customizations needed, rather \thispagestyle{empty}
should be used. Further, graphicx
provides a parameter keepaspectratio
which ensures that if both width and height of the PDF are specified, it is scaled such that the aspect ratio is kept and neither width nor height are exceeded.
\documentclass{article}
\usepackage{pdfpages}
\usepackage{fancyhdr}
\fancypagestyle{mystyle}{%
\fancyhf{}% %clear headers, footers
\renewcommand{\headrulewidth}{0pt}% %and remove header rule
}
\begin{document}
\includepdf[pages=1,
pagecommand={\thispagestyle{empty}}, %is default, only mentioned to show alternative usage of customized mystyle
width=\textwidth,
height=\textheight,
keepaspectratio,
frame]{yourfile.pdf}
\end{document}
Wow ! Right on the spot ! Thanks very much, cyberSingularity !
- Main error = not all my PDF documents had 2 pages, whereas
sometimes the command
\IncludeMyPDFThatBugs
called for the first,
and sometimes it called for the second page.
- Many missing closing braces:
{\FirstLanguageSecondLanguage{first language}{second language}}
had
some missing closing braces.
{\FirstLanguageSecondLanguage{\textbf{first}\textbf{language}}{\textbf{second}\textbf{language}}}
had some missing closing braces.
- Elsewhere, in my main code, I had
\hyperlink{name-target}{\FirstLanguageSecondLanguage{}{}}
with some missing closing braces.
- Some missing closing braces at the end of the last argument of another of my "home-made" command, not related to \includepdf.
TextWrangler / View / Balance or Balance and fold can help in looking for the "missing closing braces". But, be sure to close TeXShop when doing that.
Here is my final code without bug: \IncludeMyPDF
%!TEX TS-program = pdflatex
\PassOptionsToPackage{table,x11names,svgnames}{xcolor}
\documentclass[10pt,twoside,openright,usletter]{book}
\usepackage{lipsum}
\usepackage{pdfpages}
\usepackage{hyperref}
\usepackage{minitoc}
\usepackage{url}
\usepackage{fancyhdr}
\hypersetup{
backref=true,
pagebackref=true,
hyperindex=true,
colorlinks=true,
breaklinks=true,
urlcolor= blue,
linkcolor= purple,
bookmarks=true,
pdftoolbar=true,
pdfmenubar=true,
bookmarksopen=true,
pdftitle={title of book},
pdfauthor={author of book},
pdfsubject={subject of book}
}
%---------------------------- begin selection of language
% 2 languages, here = second language selected
\mtcselectlanguage{english} % for minitoc
\newcommand{\FirstLanguageSecondLanguage}[2]{#2}
%---------------------------- begin macro for including a PDF document
% includepdf syntax:
% addtotoc={⟨page number⟩,⟨section⟩, ⟨level⟩,⟨heading⟩,⟨label⟩}
% addtolist={⟨page number⟩,⟨type⟩,⟨heading⟩,⟨label⟩}
%
% \IncludeMyPDF
% {1} % page number to be included
% {0.9} % scale
% {true} % landscape = true or false
% {false} % turn = true or false
% {subsection,2} % level in TOC: section, subsection, subsubsection + level 1,2,3
% {TitleTOC} % heading for TOC / list
% {Label} % label: label-toc-#7, label-list-#7, #7-target for hyperlinks
% {table} % addtolist = table or figure
% {mindmaps.pdf} % file
\newcommand{\IncludeMyPDF}[9]{%
\newpage\hypertarget{#7-target}
{\includepdf[pages={#1},nup=1x1,
scale=#2,landscape=#3,turn=#4,
pagecommand={\thispagestyle{fancy}},
addtotoc={#1,#5,#6,label-toc-#7},
addtolist={#1,#8,#6,label-list-#7}]
{#9}}}
%---------------------------- end macro for including a PDF document
\title{Title of book}
\author{Author of book}
\date{\today}
\begin{document}
\frontmatter
\maketitle
\cleardoublepage
\dominitoc
\dominilof
\tableofcontents
\mainmatter
\cleardoublepage
\chapter{Chapter one}
\minitoc
\cleardoublepage
\section{Section one Chapter one}
\lipsum
\IncludeMyPDF
{2}
{1}
{false}
{false}
{subsection,2}
{\FirstLanguageSecondLanguage{Nam dui ligula, fringilla}{Hamlet speaks this on his entry to Act 3 scene 1}}
{table-mind-one}
{table}
{mindmaps.pdf}
\IncludeMyPDF
{1}
{0.9}
{false}
{true}
{subsection,2}
{\FirstLanguageSecondLanguage{Nam dui ligula, fringilla a}{Hamlet speaks this on his entry to Act 3 scene 1}}
{figure-mind-one}
{figure}
{mindmaps.pdf}
\chapter{Chapter two}
\minitoc
\cleardoublepage
\section{Section one Chapter two}
\lipsum
\section{Section two Chapter two}
\lipsum
\IncludeMyPDF
{1}
{0.9}
{false}
{true}
{subsection,2}
{\FirstLanguageSecondLanguage{Nam dui ligula, fringilla}{To be, or not to be, that is the question}}
{figure-mind-two}
{figure}
{mindmaps.pdf}
\IncludeMyPDF
{1}
{0.9}
{false}
{true}
{subsection,2}
{\FirstLanguageSecondLanguage{Nam dui ligula, fringilla}{To be, or not to be, that is the question}}
{table-mind-two}
{table}
{mindmaps.pdf}
\IncludeMyPDF
{2}
{0.9}
{false}
{true}
{subsection,2}
{\FirstLanguageSecondLanguage{Nam dui ligula, fringilla}{To be, or not to be, that is the question}}
{nrp-algo}
{figure}
{mindmaps.pdf}
\cleardoublepage
\listoftables
\addcontentsline{toc}{chapter}{List of Tables}
\cleardoublepage
\listoffigures
\addcontentsline{toc}{chapter}{List of Figures}
\cleardoublepage
\end{document}
Best Answer
There are some errors in the MWE:
pagecommand={\label{tab:UserRoles}}
: This is executed on each builded page. In case of more than one page the result are warnings because of multiply defined labels. Also the label setting is already done by your option setting foraddtolist
. (Edit: Fix of PolGab applied, thanks)addtolist
expects four parameters, the page number, the type, the title and the label. However there is a fifth elementlot
in the MWE. The package pdfpages sets the list entry by calling\caption
, where\@makecaption
is a dummy. Thus the caption is not actually typeset, but the counter is incremented and the entry for the list is done.addtolist
the manual\addcontentsline
is not longer needed. Also it should be called at the right page to get the correct page number.The corrected MWE:
The result:
The first page contains the list of tables and the "table section title". The third page of the included pages gets the entry in the list of tables, that is the fourth page.