1

I got a lil question regarding the chapters in the appendix. Already read many entries but couldn't find a satisfying solution.

In my document I have two sidewaysfigures in the appendix. As this is the whole content of the appendix and there is no text in it I do not want to squander a whole page for the heading of the chapter. As a sidewaysfigure is a minipage of the width \textheight it won't fit under the heading but starts on a new page. I tried to clear the chapterhead by redefining it:

\def\@makechapterhead#1{}

This works exactly the way I want it to, the only problem, the part "Appendix" does not get shown in the ToC anymore although I define it explicitly. Somehow the chapterhead needs an entry to be shown in the ToC. When I just put a blank command into the chapterhead

\def\@makechapterhead#1{\ }

it is shown in the ToC. Moreover the entry of the chapter appears (which is actually not desired). But the sidewaysfigure does not fit on the same page anymore and there's the problem again. Anybody any idea how to fix this? I'd appreciate any advice solving this little annoying problem.

In the following a small example:

\documentclass[listof=totoc]{scrreprt} %technical report

\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}

\usepackage[english]{babel}
\usepackage{blindtext}

% --- Pictures: ---
\usepackage[pdftex]{graphicx}
    \graphicspath{{elements/}} % path, where the pictures are stored
\usepackage[list=true,format=hang,justification=justified]{subcaption}
\usepackage{rotating}
\usepackage{pdfpages}
\usepackage{float}

\makeatletter
\makeindex
\makeatother

%----------------------------------------------------------
\begin{document}

\tableofcontents{}
\newpage
\listoffigures
\begingroup
\let\clearpage\relax
\listoftables
\endgroup
\newpage

\chapter{First chapter}
\blindtext

\chapter{last chapter}
\blindtext

\pagestyle{plain}
\appendix
\clearpage
\newpage
\part*{Appendix}\label{prt:appendix}
\addcontentsline{toc}{part}{Appendix}

\makeatletter
\def\@makechapterhead#1{}
\makeatother

\chapter{Heading that should not be visible}

\begin{sidewaysfigure}[htb]
    \centering
    \includegraphics*[trim=0mm 0mm 0mm 0mm,width=0.9\textwidth]{dummy.pdf}
    \caption{caption of the sidewaysfigure}
\end{sidewaysfigure}

\end{document}

My table of contents shold look like this:

Contents

  1. First chapter

  2. last chapter

Appendix

  • Maybe you want \addpart{\appendixname}\label{prt:appendix} for the unnumbered part with ToC entry and\stepcounter{chapter} to get chapter number A in the captions of the appendix. – esdd Jan 4 '18 at 0:22
  • thank you so much @esdd for your recommandations. they work perfectly. just the referencing does not (see my answer). in order to understand why it works could you please explain why \addpart adds the partname to the ToC but when I explicitly define it by \addcontentsline{toc}{part}{Appendix} (for the starred part in my first MWE) it does not get added? it seems to me that a part if there is no chapter in it but just content like figures etc. does not get treated as a proper part... any explanation for this? – Immanuel Jan 5 '18 at 18:21
1

I would suggest to use something like:

\documentclass[listof=totoc]{scrreprt}
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{blindtext}% only for dummy text

\usepackage{pdfpages}% loads package graphicx
%\graphicspath{{elements/}} % not needed in this example
\usepackage{rotating}

\usepackage[backref,hidelinks]{hyperref}

\begin{document}
\tableofcontents
\listoffigures
\RedeclareSectionCommands[style=section,indent=0pt]{chapter}
\listoftables
\RedeclareSectionCommand[style=chapter]{chapter}

\chapter{First chapter}
\Blindtext[2]

goto chapter~\ref{chp:appendix} on page~\pageref{chp:appendix}

\chapter{Last chapter}
\blindtext

\appendix
\clearpage
\pagestyle{plain}
\RedeclareSectionCommand[
  beforeskip=\fill,
  afterskip=\fill
]{chapter}
\renewcommand*\raggedchapter{\centering}
\chapter{\appendixname}\label{chp:appendix}

\begin{sidewaysfigure}[htb]
  \centering
  \includegraphics*[trim=0mm 0mm 0mm 0mm,width=0.9\textwidth]{example-image}
  \caption{caption of the sidewaysfigure}
\end{sidewaysfigure}

%\KOMAoptions{headings=big}
%\renewcommand*\raggedchapter{\raggedright}
%\addchap{Test}
%\Blindtext
\end{document}

results in

enter image description here

enter image description here


Note that \part executes a \clearpage at its end. So the \addcontentsline{toc}{part}{Appendix} in your MWE is not on the same page as the part title. If it is only followed by floating environments it gets lost. The same happens to the \label{prt:appendix}:

\documentclass{report}
\usepackage{blindtext}% only for dummy text
\usepackage{hyperref}
\begin{document}
\tableofcontents
\chapter{First chapter}
goto \ref{prt:appendix} on page \pageref{prt:appendix}

\blindtext
\chapter{Second chapter}
\blindtext
\appendix
\part*{An unnumbered part}\label{prt:appendix}
\addcontentsline{toc}{part}{An unnumbered part}
\begin{figure}%
\rule{5cm}{\linewidth}
\caption{Dummy}
\end{figure}
%Test% <- uncomment this line to see the difference
\end{document}

If you uncomment the line with "Test" there will be an appendix entry in ToC with the same wrong page number as for \pageref{prt:appendix}. Because \part* does not change a counter the result of \ref{prt:appendix} is the last chapter number.

You could set the \label inside the part argument and use \nameref. And you have to ensure that \addcontentsline is executed on the same page as the part title:

\documentclass{report}
\usepackage{blindtext}% only for dummy text
\usepackage{hyperref}
\begin{document}
\tableofcontents
\chapter{First chapter}
goto \nameref{prt:appendix} on page \pageref{prt:appendix}

\blindtext
\chapter{Second chapter}
\blindtext
\appendix
\cleardoublepage
\addcontentsline{toc}{part}{An unnumbered part}
\part*{An unnumbered part\label{prt:appendix}}
\begin{figure}%
\rule{5cm}{\linewidth}
\caption{Dummy}
\end{figure}
\end{document}
0

The recommandations of @esdd work perfectly and solve the problem.

Just the referencing of the part does not work as I'd expect it to. When I refer to the part somewhere earlier in the document (in the MWE in the first chapter) I don't get a reference. As soon as I put another reference in the appendix both work (commented out in the MWE). Why does it behave like this? And why does the reference counter then has a value of 2 since it's the first part in the document?

\documentclass[listof=totoc]{scrreprt} %technical report

\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}

\usepackage[english]{babel}
\usepackage{blindtext}

% --- Pictures: ---
\usepackage[pdftex]{graphicx}
    \graphicspath{{elements/}} % path, where the pictures are stored
\usepackage[list=true,format=hang,justification=justified]{subcaption}
\usepackage{rotating}
\usepackage{pdfpages}
\usepackage{float}
\usepackage[backref]{hyperref} %hyperrefs, option backref for references in the document
\hypersetup{colorlinks,
    urlcolor=black,
    filecolor=black,
    allcolors=black,
}

\makeatletter
\makeindex
\makeatother

%----------------------------------------------------------
\begin{document}

\tableofcontents{}
\newpage
\listoffigures
\begingroup
\let\clearpage\relax
\listoftables
\endgroup
\newpage

\chapter{First chapter}
\blindtext
go to part~\ref{prt:appendix}

\chapter{last chapter}
\blindtext
figure~\ref{fig:sidewaysfigure}

\pagestyle{plain}
\appendix
\clearpage
\newpage
\addpart{\appendixname}\label{prt:appendix}
%go to part~\ref{prt:appendix}
\stepcounter{chapter}

\begin{sidewaysfigure}[htb]
    \centering
    \includegraphics*[trim=0mm 0mm 0mm 0mm,width=0.9\textwidth]{dummy}
    \caption{caption of the sidewaysfigure}
    \label{fig:sidewaysfigure}
\end{sidewaysfigure}

\end{document}
  • You should switch the order of \addpart and \stepcounter and replace \stepcounter by \refstepcounter → your reference issue should vanish then. Also \makeindex does not need to be in a \makeatletter...\makeatother sandwich ;-) – user31729 Jan 6 '18 at 5:32

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.