Consider the following document:
\documentclass[11pt,a4paper,twoside]{book}
\usepackage[titletoc,toc,page]{appendix}
\begin{document}
\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{3}
\tableofcontents
\chapter{First chapter}
\begin{appendices}
\chapter[]{Name of appendix}
\label{ap1}
blah blah
\end{appendices}
\end{document}
This produces in the TOC
:
Contents
1 First chapter......3
Appendices...........5
Appendix A...........7
and in the body of the document:
Chapter 1
First chapter
Appendices
Appendix A
Name of appendix
blah blah
I don't want to give a name to the appendix, I find it irrelevant. But I'm forced to do it with the \chapter[]{Name of appendix}
command.
Is there a way not to have to give each appendix a name? This is the result I want in the body of the document (the TOC
stays the same):
Chapter 1
First chapter
Appendices
Appendix A
blah blah
Now, I know I can just leave the \chapter[]{}
command empty and so the title won't show, but I'm looking for a more integral solution and not just an ugly hack.
PD: this question originated here.
EDIT
I'm sorry but I'd forgotten my document is in spanish so I didn't add the specific packages. This is what the document looks like now with Werner's new definitions added:
\documentclass[11pt,a4paper,twoside]{book}
\makeatletter
\newcommand{\nonameappendix}{%
\def\@makechapterhead##1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
%\vskip 20\p@ % <--- Removed
\fi
\fi
%\interlinepenalty\@M % <--- Removed
%\Huge \bfseries ##1\par\nobreak % <--- Removed
\vskip 40\p@
}}%
\def\chaptermark##1{%
\markboth {\MakeUppercase{%
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\@chapapp\ \thechapter%
\fi
\fi
}}{}}}
\makeatother
\newcommand{\newappendix}{\chapter[]{}}%
\usepackage[titletoc,toc,page]{appendix}
\usepackage[latin1]{inputenc}
\usepackage[spanish,activeacute]{babel}
\begin{document}
\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{3}
\tableofcontents
\chapter{First chapter}
\renewcommand{\appendixtocname}{Ap\'endices}
\renewcommand{\appendixpagename}{Ap\'endices}
\begin{appendices}
\nonameappendix
\newappendix
\label{ap1}
\include{apendiceA}
\end{appendices}
\end{document}
where the apendiceA.tex
file has nothing but text (ie: no chapter commands, no labels, etc..)
The issues I'm having with this is:
1-I get Apéndice A.
in the TOC (notice the dot at the end). This is really minor but it still bugs me.
2- In the body of the document, after the Apéndice A
title is displayed the text only begins in the next page. This is more serious.
Best Answer
Here's an option that provides
\nonameappendix
and\newappendix
. The first command sets up the chapter heading macros (removing the inclusion of a name in the chapter title), effectively treating it like a\chapter*
. The second command does\chapter[]{}
for convenience.There's also the requirement modification to
\chaptermark
which typically setsAPPENDIX <num>.\ TITLE
in the header. It now just setsAPPENDIX <num>
. This is also modified by\nonameappendix
, with definitions taken frombook.cls
.