0

The following MWE is a skeleton of the formatting I am using for the chapters, sections and appendices in my book.

\documentclass[a4paper]{book}
\usepackage{emptypage}
\usepackage[tmargin=2in, bmargin=2in, lmargin=1.5in, rmargin=1.5in]{geometry}
\usepackage[inline]{enumitem}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[toc, page]{appendix}
\let\plainappendixpage\appendixpage
\makeatletter
\renewcommand{\appendixpage}{%
    \begingroup
    \let\ps@plain\ps@empty
    \plainappendixpage
    \endgroup}
\makeatother


%====================================================================================================
% Chapter title format
%
\setcounter{secnumdepth}{3}
\usepackage{titlesec}
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{20pt}}
\titleformat{\chapter}[hang]{\filleft\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{$\mid$}\hsp}{0pt}{\Huge\bfseries}
\titlespacing*{\chapter}{0pt}{0pt}{3in}
\titleformat{\subsubsection}{\large\bfseries}{\thesubsubsection}{1em}{\large\bfseries}
\renewcommand{\thesubsubsection}{\large\bfseries{\ensuremath{\bullet}}}
%====================================================================================================

%====================================================================================================
% Section symbol in TOC and in text
%
\usepackage{tocloft}
\renewcommand\cftsecpresnum{\S}
\titleformat{\section}{\normalfont\Large\bfseries}{\S\thesection}{1em}{}
%====================================================================================================


%====================================================================================================
% Header-Footer
%
\usepackage[english]{babel}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\rightmark}
\fancyhead[LO,RE]{\leftmark}
\fancyfoot[C]{\thepage}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter.\ #1}}{}}
\renewcommand{\sectionmark}[1]{\markright{\S\thesection.\ #1}}
%====================================================================================================

%====================================================================================================
% Cross-references
%
\usepackage{varioref}
\usepackage{hyperref}
\hypersetup
{
    colorlinks=true, 
    linktoc=all,     
    linkcolor=black, 
    citecolor=teal,
}
\usepackage{cleveref} 


\begin{document}
    \tableofcontents
    \hypersetup{linkcolor=blue}
    \chapter{First}
    \lipsum\\
    \vref{A1}
    \section{title}
    \lipsum[1]
    \chapter{Second}
    \lipsum
    \begin{appendices}
    %====================================================================================================
    % Local formatting
        \titleformat{\chapter}[hang]{\filleft\LARGE\bfseries}{Appendix \thechapter\hsp\textcolor{gray75}{$\mid$}\hsp}{0pt}{\LARGE\bfseries}
        \fancyhead[LO,RE]{\rightmark}
        \fancyhead[LE,RO]{\leftmark}
        \renewcommand{\chaptermark}[1]{\markboth{Appendix \MakeUppercase{\thechapter.\ #1}}{}}
        \renewcommand{\sectionmark}[1]{\markright{}}
        \addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
        \crefname{chapter}{appendix}{appendices}
    %====================================================================================================

        \chapter{One}\label{A1}
        \lipsum
        \section{First section}
        \lipsum[1]
        \chapter{Two}\label{A2}
        \lipsum
    \end{appendices}
\end{document}

My goals are:

  1. The "Appendices" header in the TOC should not have a page reference.enter image description here
  2. The separator page "Appendices" should be there (as it is there now) after the usual chapters without a page number on it.
  3. The appendices part should behave like a (partially) one-sided document. First, like an one-sided document, the first appendix chapter should start on right (odd numbered page) and the next appendix chapters should start on the next new pages (even or odd numbered page). Secondly, the chapter marks in the header of a page should behave like a two-sided document (as it is there now, with no section mark in the header).
  4. \vref to chapters in appendices (only) should produce the pre-string "appendix" instead of "chapter".
  5. The formatting behaviour outside appendices should stay exactly how they are now.

Please help how to achieve these goals. Thanks in advance.

EDIT

PS: (getting intrigued by this plea), Please feel free to change the title of my question to a more meaningful one.

1
+50

I have revised your MWE to give what I think you want. My changes are marked with % PW -----

% appendixprob.tex  SE 543637

\documentclass[a4paper]{book}
\usepackage{emptypage}
\usepackage[tmargin=2in, bmargin=2in, lmargin=1.5in, rmargin=1.5in]{geometry}
\usepackage[inline]{enumitem}
\usepackage{lipsum}
\usepackage{xcolor}
%\usepackage[toc, page]{appendix} % PW -------------------------
\usepackage[page]{appendix} % PW -----------------------------
\let\plainappendixpage\appendixpage
\makeatletter
\renewcommand{\appendixpage}{%
    \begingroup
    \let\ps@plain\ps@empty
    \plainappendixpage
    \endgroup}
\makeatother


%====================================================================================================
% Chapter title format
%
\setcounter{secnumdepth}{3}
\usepackage{titlesec}
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{20pt}}
\titleformat{\chapter}[hang]{\filleft\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{$\mid$}\hsp}{0pt}{\Huge\bfseries}
\titlespacing*{\chapter}{0pt}{0pt}{3in}
\titleformat{\subsubsection}{\large\bfseries}{\thesubsubsection}{1em}{\large\bfseries}
\renewcommand{\thesubsubsection}{\large\bfseries{\ensuremath{\bullet}}}
%====================================================================================================

%====================================================================================================
% Section symbol in TOC and in text
%
\usepackage{tocloft}
\renewcommand\cftsecpresnum{\S}
\titleformat{\section}{\normalfont\Large\bfseries}{\S\thesection}{1em}{}
%====================================================================================================


%====================================================================================================
% Header-Footer
%
\usepackage[english]{babel}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\rightmark}
\fancyhead[LO,RE]{\leftmark}
\fancyfoot[C]{\thepage}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter.\ #1}}{}}
\renewcommand{\sectionmark}[1]{\markright{\S\thesection.\ #1}}
%====================================================================================================

%====================================================================================================
% Cross-references
%
\usepackage{varioref}
\usepackage{hyperref}
\hypersetup
{
    colorlinks=true, 
    linktoc=all,     
    linkcolor=black, 
    citecolor=teal,
}
\usepackage{cleveref} 


\begin{document}
    \tableofcontents
    \hypersetup{linkcolor=blue}
    \chapter{First}
    \lipsum\\
    \vref{A1}
    \section{title}
    \lipsum[1]
    \chapter{Second}
    \lipsum
    \begin{appendices}
    \addtocontents{toc}{\addvspace{10pt}\bfseries Appendices\par} % PW --------------
    %====================================================================================================
    % Local formatting
        \titleformat{\chapter}[hang]{\filleft\LARGE\bfseries}{Appendix \thechapter\hsp\textcolor{gray75}{$\mid$}\hsp}{0pt}{\LARGE\bfseries}
        \fancyhead[LO,RE]{\rightmark}
        \fancyhead[LE,RO]{\leftmark}
        \renewcommand{\chaptermark}[1]{\markboth{Appendix \MakeUppercase{\thechapter.\ #1}}{}}
        \renewcommand{\sectionmark}[1]{\markright{}}
        \addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
        \crefname{chapter}{appendix}{appendices}
    %====================================================================================================

        \chapter{One}\label{A1}
        \let\cleardoublepage\clearpage % PW --------------------------------
        \lipsum 
        \section{First section}
        \lipsum[1]
        \chapter{Two}\label{A2}
        \lipsum
    \end{appendices}
\end{document}

I don't know the \vref command so that is up to you. With my changes you might find that you can eliminate some of your code but I'm not going there.

| improve this answer | |
  • Thank you so much. In this particular document, I have not called \vref for a chapter outside the Appendices. So I have defined \crefname for a chapter as appendix. Though this hack does not solve the problem in general, it serves my purpose in this particular document. Thanks again for the rest of your efforts. – Subhajit Paul May 19 at 17:52
  • 1
    @SubhajitPaul: You can add \crefalias{section}{appendix} right after \begin{appendices} to get your \vrefs in order. See e.g. this answer. (Note that while \vref is from the varioref package, cleveref redefines it, which is why this works.) – Circumscribe May 19 at 21:12
  • Thanks for your effort. From the tagged answer, the following piece of code worked: \AtBeginEnvironment{appendices}{\crefalias{chapter}{appendix}}. I don't know why your suggested piece didn't work. – Subhajit Paul May 19 at 21:30
  • @SubhajitPaul: Sorry, it didn't work because I should've written chapter instead of section. – Circumscribe May 20 at 13:51
  • 1
    @SubhajitPaul: Did you compile twice? (The reference type name is written to the aux file on the first run and will only be used from the next run onward.) – Circumscribe May 20 at 14:16

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.