Hi,
I was wondering how I could change \section{section title} output from
"1 section title"
to
"001 section title"
I tried asking around a bit, and titlesec + fmtcount should do the job (somehow). I can not figure out how to do it though.
Anyone got a clue how to achieve it?
Page Layout ⇒ Changing section number formatting
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Changing section number formatting
It requires a redefinition of the command that formats the section counter. See code below for a complete example.
Best regards and welcome to the board
Thorsten
Code: Select all
\documentclass{article}
\makeatletter
\renewcommand{\thesection}{%
\ifnum \c@section<100 0\fi \ifnum \c@section<10 0\fi \@arabic\c@section
}
\makeatother
\begin{document}
\section{Test}
\setcounter{section}{9}
\section{Test}
\setcounter{section}{99}
\section{Test}
\end{document}
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Changing section number formatting
wow, worked perfectly! =D
thanks for the welcome and help, that was a very good solution and a quick reply. I feel that I am going to love it here =)
thanks for the welcome and help, that was a very good solution and a quick reply. I feel that I am going to love it here =)