
TOC에서 페이지 번호 매기기 작업을 하고 있는데 페이지 번호가 TOC부터 시작해야 합니다. 아래의 예에서는 TOC에 대한 2페이지와 그 뒤에 2개의 공백 페이지가 있습니다. 하지만 내가 관찰한 바에 따르면, toc의 페이지 번호는 3입니다. 어떻게 1로 만들 수 있나요?
\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}
답변1
당신은 2 명시적인
\mbox{}
\thispagestyle{empty}
\newpage
이전 항목 \tableofcontents
. 이것이 빈 두 페이지를 삽입하는 것입니다. 첫 번째 페이지부터 시작하는 항목을 유지하려면 \pagenumbering{arabic}
두 번째 항목 바로 뒤에 삽입하세요. 그렇지 않은 경우 처음 두 개의 중복 항목을 제거하면 ToC가 자연스럽게 1페이지부터 시작됩니다.
이것이 작동하는 이유는 \pagenumbering
(를 통해) 페이지 카운터를 1로 재설정하기 때문입니다 \global\c@page \@ne
.
\def\pagenumbering#1{%
\global\c@page \@ne \gdef\thepage{\csname @#1\endcsname
\c@page}}
물론 발급도 \setcounter{page}{1}
비슷할 것이다.