Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to format a legal document so that it follows this format.

  Article 1.

1.01 First section

  bla bla bla

1.02 Second section

  bla bla bla

etcetera.

I tried using this to get things working the way I wanted:

\usepackage{etoolbox}  %needed to make chapters continuous on page
%% Need with {etoolbox} package
\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother

% change % chapter to article and center it
\renewcommand{\chaptername}{Article}
\renewcommand{\thechapter}{\Alph{chapter}}
\titleformat{\chapter}[hang]{\LARGE\bfseries\centering}{\chaptertitlename\ \thechapter}{0.125in}{\LARGE}

%Format section numbering
\def\thesection{\arabic{section}.}
\def\thesubsection{\arabic{section}.0\arabic{subsection}}
\def\thesubsubsection{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}

% Set section number depth to level 3
\setcounter{secnumdepth}{3}

Now, the problem is how to get a leading zero in the section and then have it increment correctly. Once I reach the 10 level, the section is shown as: "1.010", which is wrong. It should read "1.10". I can accomplish this in MS Word; however, I can find no way to do it in LaTeX. Does anyone have a solution?

share|improve this question
    
Welcome to TeX.sx! –  Peter Jansson Mar 9 '13 at 23:51

1 Answer 1

The kernel macro \two@digits is what you're looking for. It produces the number given as its argument with a padding zero, if needed.

\makeatletter
\renewcommand\thesubsection{\thesection.\two@digits{\value{subsection}}}
\renewcommand\thesubsubsection{\thesubsection.\two@digits{\value{subsubsection}}}
\makeatother

Surrounding the code with \makeatletter and \makeatother is necessary when using kernel macros with @ in their name.

The redefinition of \thesubsubsection seems in line with that of \thesubsection.

Thanks to Qrrbrbirlbel for having suggested \value instead of \arabic, which is indeed better because it stops expansion in search for digit, because \two@digits uses \number.

share|improve this answer
    
Is \arabic safe or should \value used instead? –  Qrrbrbirlbel Mar 9 '13 at 23:48
    
@Qrrbrbirlbel You're right; I forgot about \number and so \value is better. –  egreg Mar 10 '13 at 0:06
    
@Qrrbrbirlbel \value or \two@digits{\@arabic\c@subsection} –  Yiannis Lazarides Mar 10 '13 at 1:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.