번호 매기기 섹션, 하위 섹션, 하위 섹션

번호 매기기 섹션, 하위 섹션, 하위 섹션

나는 클래스를 사용하고 book있으며 각 장, 섹션, 하위 섹션 등에 대해 번호 매기기가 다음과 같이 시작됩니다.

제1장

섹션 1.1

섹션 1.2

섹션 1.3. . .

대신에 다음과 같은 것을 갖고 싶습니다.

제1장

섹션 1.0

섹션 1.1

섹션 1.2

어떤 제안이 있으십니까? 도와 주셔서 정말로 고맙습니다.

답변1

\thesection현재 숫자에서 1을 뺀 값을 발행하도록 재정의할 수 있습니다 .

\documentclass{book}

\makeatletter
\renewcommand{\thesection}{%
  \thechapter.\@arabic{\numexpr\c@section-1}%
}
\makeatother

\begin{document}
\tableofcontents

\chapter{First chapter}

\section{First section}
\section{Second section}
\section{Third section}

\chapter{Second chapter}

\section{First section}
\section{Second section}
\section{Third section}

\end{document}

여기에 이미지 설명을 입력하세요

답변2

\chaptercall \@chapter, 이는 \refstepcounter(모드에서 mainmatter) 수행됩니다. 이는 챕터 카운터의 재설정 목록에 있는 모든 카운터가 0으로 재설정됨을 의미하며, 이는 section물론 카운터에도 해당됩니다.

재정의 되거나 refstepping이 완료된 후 \@chapter섹션 카운터를 설정하는 추가 코드를 추가할 수 있습니다 .-1

참고: 이는~ 아니다subsection카운터를 -1 등으로 설정합니다 .

\documentclass{book}
\usepackage{xpatch}

\makeatletter
\AtBeginDocument{%
\xpatchcmd{\@chapter}{%
  \refstepcounter{chapter}%
}{%
  \refstepcounter{chapter}%
  \setcounter{section}{-1}%
}{\typeout{Success}}{}
}
\makeatother

\begin{document}
\tableofcontents

\chapter{First chapter}

\section{First section}

\section{Second section}
\section{Third section}

\chapter{Second chapter}

\section{First section}

\section{Second section}

\section{Third section}


\end{document}

여기에 이미지 설명을 입력하세요

계단식으로 이어지는 버전은 다음과 같습니다 \subparagraph.

\documentclass{book}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@sect}{%
  \refstepcounter{#1}%
}{%
  \refstepcounter{#1}%
  % Now use the \@elt - trick to set all depending counters to -1 (well even that one that shouldn't, most likely :-()
  \def\@elt##1{\setcounter{##1}{-1}}
  \csname cl@#1\endcsname%
}{}{}


\AtBeginDocument{%
  \xpatchcmd{\@chapter}{%
    \refstepcounter{chapter}%
  }{%
    \refstepcounter{chapter}%
    \setcounter{section}{-1}%
   }{\typeout{Success}}{\typeout{Failed!}}
}
\makeatother

\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}
\begin{document}
\tableofcontents

\chapter{First chapter}

\section{First section}
\subsection{First subsection}
\subsubsection{First subsubsection}
\paragraph{First paragraph}
\subparagraph{First subparagraph}


\section{Second section}
\subsection{First subsection}
\subsubsection{First subsubsection}
\paragraph{First paragraph}
\subparagraph{First subparagraph}

\section{Third section}

\chapter{Second chapter}

\section{First section}

\section{Second section}

\section{Third section}


\end{document}

답변3

각 섹션에 대해 다음과 같이 할 수 있습니다.

\setcounter{section}{-1}

참고: 원래 답변할 때 썼습니다 \setcounter{section}{0}.

관련 정보