Is it possible to number sections by binary numbers, starting at 0? So \section{First Section} would render as "0. First Section", and the next instance would render "1. Second Section" and the third, "10. Third Section"?
Asked
Active
Viewed 517 times
5
Addem
- 867
2 Answers
11
The fmtcount package provides a simple way to get the binary numbers. To begin counting at zero you need to set the section counter initially to -1. You can also pad the values with zeroes if you wish.
\documentclass{article}
\usepackage{fmtcount}
\renewcommand{\thesection}{\binary{section}.}
\setcounter{section}{-1}% To begin at 0
\begin{document}
\section{First section}
\section{Second section}
\section{Third section}
\section{Fourth section}
\section{Fifth section}
\renewcommand{\thesection}{\padzeroes[4]\binary{section}}
\setcounter{section}{-1}
\section{First section}
\section{Second section}
\section{Third section}
\section{Fourth section}
\section{Fifth section}
\end{document}
Alan Munn
- 218,180
9
Sure.
\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
\cs_set:Npn \thesection {\int_to_bin:n{\value{section}-1}}
\ExplSyntaxOff
\begin{document}
\section{one}
\section{two}
\section{three}
\end{document}
Note that I only changed the displayed number here, so the section counter still has the value 1 for the first section, we only print 0. If you want the section to "really" have the number 0, you need to remove the -1 from the definition of \thesection and set the counter to -1 at the start of the document.
schtandard
- 14,892


fmtcountpackage seems the most appropriate. – Alan Munn Jun 08 '19 at 17:06