선행 0으로 채워지도록 섹션을 어떻게 설정합니까?

선행 0으로 채워지도록 섹션을 어떻게 설정합니까?

나는 누군가를 위해 문서의 서식을 지정하고 있는데 그 사람은 각 섹션 번호가 000으로 시작하고 필요할 때 패딩 0으로 시작하는 세 자리 숫자가 되기를 원합니다.

비슷한 질문을 발견하고 예시를 적용해 보았습니다., 하지만 그것은 나에게

! TeX capacity exceeded, sorry [input stack size=5000].
\thesection ->\thesection 
                          .\three@digits {\value {section}}
l.11 \section{Synopsis}

If you really absolutely need more capacity,
you can ask a wizard to enlarge me.

내 MNWE는 다음과 같습니다.

 \documentclass[letterpaper]{article}

 %Padding the leading zeros \makeatletter
 \renewcommand\thesection{\thesection.\three@digits{\value{section}}}
 \makeatother

 \begin{document} \setcounter{section}{-1} \tableofcontents
 \section{Synopsis} foo

 \section{Language} bar

 \section{Legal} baz

 \end{document}

답변1

\three@digits에는 존재하지 않습니다.핵심기본적으로. 그러나 이를 정의할 수 있으며 섹션의 ToC 관련 번호 간격도 조정해야 합니다.

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

\documentclass[letterpaper]{article}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox

%Padding the leading zeros
\makeatletter
\patchcmd{\l@section}{1.5em}{2em}{}{}% Adjust section ToC number width
%\def\two@digits#1{\ifnum#1<10 0\fi\number#1}% http://mirrors.ctan.org/macros/latex/unpacked/latex.ltx
\def\three@digits#1{\ifnum#1>99\else\ifnum#1>9 0\else00\fi\fi\number#1}
\renewcommand\thesection{\three@digits{\value{section}}}
\makeatother

\begin{document} 
\setcounter{section}{-1}
\tableofcontents
\section{Synopsis} foo

\section{Language} bar

\section{Legal} baz

\end{document}

ToC 관련 간격은 다음을 사용하여 조정됩니다.etoolbox반점. \subsection다음과 같이 정의된 간격을 조정할 수도 있습니다.

\newcommand*\l@subsection{\@dottedtocline{2}{1.5em}{2.3em}}

기본적으로 (에서article.cls). 여기에 1.5em들여쓰기와 2.3em숫자를 위한 공간이 있습니다. 그래서 당신은 함께 갈 수 있습니다

\renewcommand*\l@subsection{\@dottedtocline{2}{2em}{3em}}

말하다.


0이 있는 패딩 카운터에 대한 자세한 내용은 다음을 참조하세요.앞에 0이 있는 카운터를 출력하는 방법은 무엇입니까?

관련 정보