2

I have an issue with my project in which the last page of the appendices does not maintain intended page numbering format. I have tried \cleardoublepage command but I am guessing its some other malfunction (probably my fault). Below is my preamble and MWE. My apologies for the length of the preamble, in case it has to do with an option here.

\documentclass[12pt]{book}

\usepackage[spanish,es-nodecimaldot,es-lcroman,es-noquoting]{babel} %Hyphen
    \addto\captionsspanish{\renewcommand\contentsname{ÍNDICE GENERAL}}
    \addto\captionsspanish{\renewcommand\listfigurename{ÍNDICE DE FIGURAS}}
    \addto\captionsspanish{\renewcommand{\listtablename}{ÍNDICE DE TABLAS}}
    \addto\captionsspanish{\renewcommand{\figurename}{Figura}}
    \addto\captionsspanish{\renewcommand{\tablename}{Tabla}}
    \addto\captionsspanish{%
        \renewcommand\appendixname{ANEXO}
        \renewcommand\appendixpagename{Anexos}
        }
    \addto\captionsspanish{\renewcommand{\refname}{Referencias}}

\usepackage{wrapfig}                    %Texto alrededor de imágenes.
\usepackage{fancyhdr}                   %Encabezado.
%\usepackage[nottoc]{tocbibind}         %Referencias no aparece numerada
\usepackage[titletoc,title]{appendix}   %Simple modificacion apendices
\renewcommand{\addappheadtotoc}{%
  \phantomsection\addcontentsline{toc}{chapter}{\appendixtocname}%
}
\usepackage{float}                      %Posiciona figuras en lugar deseado.
    \setlength{\intextsep}{10pt}                %Float environment spacing before and after.
\usepackage{etoolbox}                   %For Appendix page number A.1...D.1
\usepackage{tocloft}
    \renewcommand\cftsubsecafterpnum{\vskip1pt}
    \renewcommand\cftsecafterpnum{\vskip2pt}
    \renewcommand\cftchapafterpnum{\vskip2pt}
    \setlength{\cftbeforesecskip}{2pt}
    \setlength{\cftbeforesubsecskip}{1pt}
    \renewcommand\cftloftitlefont{\Large \bfseries}
    \renewcommand\cftlottitlefont{\Large \bfseries}
    \renewcommand\cfttoctitlefont{\Large \bfseries}
    \setlength{\cftbeforetoctitleskip}{0em}
    \setlength{\cftbeforelottitleskip}{0em}
    \setlength{\cftbeforeloftitleskip}{0em}
    \setlength{\cftaftertoctitleskip}{1.5em}
    \setlength{\cftafterlottitleskip}{1.5em}
    \setlength{\cftafterloftitleskip}{1.5em}
    \cftsetindents{figure}{0em}{3.3em}
    \cftsetindents{table}{0em}{3.3em}

%%% Patching the kernel \@sect command
\usepackage{regexpatch}
\makeatletter
\xpatchcmd*{\@sect}{\fi#7}{\fi\@nameuse{format#1}{#7}}{}{}

%%% for sections and subsections we want uppercase
\protected\def\formatsection{\MakeUppercase}
\protected\def\formatsubsection{\MakeUppercase}

%%% the other titles are left unchanged
\let\formatsubsubsection\@firstofone
\let\formatparagraph\@firstofone
\let\formatsubparagraph\@firstofone

%%% the following is necessary only if hyperref is used
\AtBeginDocument{%
  \pdfstringdefDisableCommands{%
    \let\formatsection\@firstofone
    \let\formatsubsection\@firstofone
  }%
}
\makeatother
%\renewcommand{\cfttoctitlefont}{\normalfont\normalsize\bfseries\MakeUppercase}
\usepackage[export]{adjustbox}
%\newcommand{\appendixpagenumbering}{
%  \break
%  \pagenumbering{arabic}
%  \renewcommand{\thepage}{\thechapter-\arabic{page}}}
\usepackage{amsmath}             %To write equations and math symbols.
    \let\hbar\relax              %Conflicting issue with fontspec and mtpro2.
\usepackage[mtpcal,subscriptcorrection,slantedGreek,nofontinfo,amssymbols]{mtpro2} %MathTime Professional 2 for fluency with Times font and Times math.
\usepackage{mathtools}           %For equation with cases.
\usepackage{siunitx}             %For SI units
\usepackage{caption}             %All lines left aligned.
    \captionsetup{format=hang}
\usepackage[bibstyle=apa,citestyle=authoryear-comp,maxcitenames=2,uniquelist=false,giveninits=true,uniquename=init,doi=false,isbn=false,url=false,dashed=true,sorting=nyt,backend=biber]{biblatex}
    \DeclareNameAlias{sortname}{last-first}
    \DeclareLanguageMapping{spanish}{spanish-apa}
    \AtEveryBibitem{\clearfield{month}}
    \usepackage{csquotes}
    %\addbibresource{R.bib}
    \DefineBibliographyStrings{spanish}{%
  andothers = {et\addabbrvspace al\adddot},
  bibliography = {Referencias},
    }
    \DeclareCiteCommand{\citeyearpar}     %Use hyperef with citeryearpar command.
    {}
    {\mkbibparens{\bibhyperref{\printdate}}}
    {\multicitedelim}
    {}
    \DefineBibliographyExtras{spanish}{\protected\def\bibrangedash{\textendash}}
\usepackage{rotating, booktabs}           %Better hline commands.
\usepackage{enumitem}                 %Spacing in list items.
    \renewcommand{\labelitemi}{$\circ$}
\usepackage{scrextend}                %Margin indentation.
\usepackage{multicol,multirow}        %Can make cells in tables with multiple rows or columns.
\usepackage{sectsty}                  %Hooks to change section header styles.
    \sectionfont{\normalsize}
    \subsectionfont{\normalsize}
    \subsubsectionfont{\normalsize}
    %\paragraphfont{\small \MakeUppercase}
\usepackage{subcaption}
\newtheorem{theorem}{Teorema}
\usepackage{listings}
\lstset{language=Matlab,numbers=left,numbersep=1.1em,xleftmargin=3em,frame=single,framexleftmargin=2.9em,columns=flexible,showstringspaces=false,breaklines=true}
\usepackage{matlab-prettifier}
\usepackage{arydshln}
\usepackage{chngcntr}               %Per-section numbering in article class.
    \counterwithin{figure}{section}
    \counterwithin{table}{section}
    \counterwithin{equation}{section}
    \renewcommand{\theequation}{\arabic{chapter}.\arabic{section}.\arabic{equation}}
\usepackage{tablefootnote}            %Footnotes in table environments

\usepackage{titlesec}
    \titleformat{\chapter}[hang]   
    {\normalfont\Large\bfseries}{\chaptertitlename\ \thechapter:}{1em}{}   
    \titlespacing*{\chapter}{0pt}{-15pt}{25pt}

\setcounter{secnumdepth}{3}           %Number to subsubsection and in TOC
\setcounter{tocdepth}{3}

\setlength\parindent{0.5in}           %Paragraph indentation.

\captionsetup{belowskip=1pt,aboveskip=4pt}

\usepackage[bookmarks,hypertexnames=false,debug]{hyperref}

\usepackage[letterpaper,margin=1in,footskip=1.2cm,headheight=2cm,headsep=0.5cm]{geometry}

\usepackage{fancyhdr}                 %Encabezado.
\pagestyle{fancy}
\fancyhf{}                            % clear all header and footer fields
\fancyhead[LO,RE]{}
\fancyhead[LE]{School}
\fancyhead[RO]{Department}
\fancyfoot[LO,RE]{\small \thepage}
\fancyfoot[RO]{{\small\scshape\nouppercase{\leftmark}}}
\fancyfoot[LE]{{\small\scshape\nouppercase{\rightmark}}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\fancypagestyle{plain}{               %  the preset of fancyhdr 
    \fancyhf{}
    \fancyhead[LO]{}
    \fancyhead[RO]{School}
    \fancyfoot[C]{\small \thepage}
    \renewcommand{\headrulewidth}{0.4pt}
    \renewcommand{\footrulewidth}{0.4pt}}

\usepackage[spanish,tight]{minitoc}          %Table of Contents per Chapter
%\addto{\captionsspanish}{\renewcommand{\mtctitle}{Another Title}}

\usepackage{bookmark}
    \hypersetup{linkcolor=black}

\usepackage{fontspec}                   %Set a main font.
    \setmainfont{Times New Roman}[SmallCapsFont=TeX Gyre Termes,SmallCapsFeatures={Letters=SmallCaps}]

\usepackage[spanish]{cleveref}          %Fancy pantsy ref.
    \Crefname{section}{Sección}{Secciones}
    \Crefname{chapter}{Capítulo}{Capítulos}
    \Crefname{table}{Tabla}{Tablas}
    \Crefname{app}{Anexo}{Anexos}
    \Crefname{graph}{Gráfico}{Gráficos}

%Hyphenation not included
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
\usepackage{lipsum}
\begin{document}

\begin{appendices}
\pretocmd{\chapter}{%
  \clearpage
  \pagenumbering{arabic}%
  \renewcommand*{\thepage}{\thechapter-\arabic{page}}%
}{}{}
\renewcommand\thetable{\thesection.\arabic{table}}
\renewcommand\thefigure{\thesection.\arabic{figure}}
\renewcommand\theequation{\thesection.\arabic{equation}}
\addtocontents{toc}{\cftpagenumbersoff{chapter}}

\chapter{Chapter 1}
\section{Section 1}
\lipsum[1-10]
\clearpage

\chapter{Chapter 2}
\section{Section 1}
\lipsum[10-30]

\end{appendices}

\end{document}

Thank in advance for any help, Regards.

1 Answer 1

1

You can add \clearpage before issuing \end{appendices}.

Just do \preto{\endappendices}{\clearpage}, as you are already using etoolbox.

However, minitoc will add a spurious page and I don't know what could be a remedy for this other than adding material after the appendices, such as acknowledgments or whatever.

2
  • Thank you, this solved the problem. Regards,
    – Claudio
    Commented Apr 9, 2019 at 20:21
  • @Claudio Sorry for the additional page, but minitoc is quite a mess and delving into its internal is very difficult. You might want to look at etoc.
    – egreg
    Commented Apr 9, 2019 at 20:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .