Wie steuert man die Seitenzahl in einem mehrseitigen Inhaltsverzeichnis?

Wie steuert man die Seitenzahl in einem mehrseitigen Inhaltsverzeichnis?

Ich arbeite an der Seitennummerierung im Inhaltsverzeichnis und brauche Seitenzahlen, die mit dem Inhaltsverzeichnis beginnen. Im unten angegebenen Beispiel gibt es zwei Seiten für das Inhaltsverzeichnis, gefolgt von zwei leeren Seiten. Aber ich stelle fest, dass die Seitenzahl im Inhaltsverzeichnis 3 ist. Wie kann ich sie auf 1 bringen?

\documentclass{article}
\usepackage{etoolbox,graphicx}% http://ctan.org/pkg/{etoolbox,graphicx}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{lipsum}
\definecolor{myblue}{RGB}{146,243,224}

\newcommand{\addstufftotoc}[2][toc]{% \addimagetotoc[<toc>]{<stuff>}
\addtocontents{#1}{#2}}

\makeatletter
\patchcmd{\l@section}% <cmd>
{\begingroup}% <search>
{\begingroup\normalfont\Large\bfseries}% <replace>
{}{}% <success><failure>
\newcommand\mdframedintoc{\par\bigskip%  
\begin{mdframed}[hidealllines=true,backgroundcolor=myblue]
Some contents for the \texttt{mdframed} environment.
\end{mdframed}\par\bigskip
\begin{mdframed}% mdframed for the image
\centering
\includegraphics[height=2\baselineskip]{example-image-a}
\end{mdframed}%
}
\patchcmd{\tableofcontents}{\@starttoc{toc}}{\@starttoc{toc} \mdframedintoc}  {}{}
\makeatother

\begin{document}

\mbox{}
\thispagestyle{empty}
\newpage

\mbox{}
\thispagestyle{empty}
\newpage


\tableofcontents
\thispagestyle{empty}
\clearpage
\setcounter{page}{1}
\section{First section}
\addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2    \baselineskip]{example-image-a}\par}
 \section{Second section}
  \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2 \baselineskip]{example-image-b}\par}
 \section{Third section}
 \section*{Fourth section}
 \addcontentsline{toc}{section}{\protect\numberline{}Fourth section}
 \section{Last section}
 \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2 \baselineskip]{example-image-c}\par}
 \section{First section}
 \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2   \baselineskip]{example-image-a}\par}
 \section{Second section}
 \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2    \baselineskip]{example-image-b}\par}
 \section{Third section}
 \section*{Fourth section}
 \addcontentsline{toc}{section}{\protect\numberline{}Fourth section}
 \section{Last section}
 \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2   \baselineskip]{example-image-c}\par}
 \section{First section}
  \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2  \baselineskip]{example-image-a}\par}
 \section{Second section}
 \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2 \baselineskip]{example-image-b}\par}
 \section{Third section}
 \section*{Fourth section}
 \addcontentsline{toc}{section}{\protect\numberline{}Fourth section}
 \section{Last section}
 \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2  \baselineskip]{example-image-c}\par}
 \section{First section}
 \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2 \baselineskip]{example-image-a}\par}
 \section{Second section}
 \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2  \baselineskip]  {example-image-b}\par}
 \section{Third section}
 \section*{Fourth section}
 \addcontentsline{toc}{section}{\protect\numberline{}Fourth section}
 \section{Last section}
 \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2 \baselineskip]{example-image-c}\par}
  \section{First section}
 \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2   \baselineskip]{example-image-a}\par}
 \section{Second section}
 \addstufftotoc{\nobreak\smallskip\protect\includegraphics[height=2   \baselineskip]{example-image-b}\par}
 \section{Third section}
 \section*{Fourth section}
 \end{document}

Bildbeschreibung hier eingeben

Antwort1

Sie haben 2 explizite

\mbox{}
\thispagestyle{empty}
\newpage

Einträge vor \tableofcontents. Dadurch werden die beiden leeren Seiten eingefügt. Wenn Sie diese behalten und dennoch auf Seite eins beginnen möchten, fügen Sie sie \pagenumbering{arabic}unmittelbar nach dem zweiten Eintrag ein. Andernfalls entfernen Sie die ersten beiden doppelten Einträge, und Ihr Inhaltsverzeichnis beginnt automatisch auf Seite 1.

Dies funktioniert, weil dadurch \pagenumberingder Seitenzähler auf eins zurückgesetzt wird (über \global\c@page \@ne):

\def\pagenumbering#1{%
  \global\c@page \@ne \gdef\thepage{\csname @#1\endcsname
   \c@page}}

\setcounter{page}{1}Die Ausgabe wäre natürlich ähnlich.

verwandte Informationen