# Can I give predefined values to section numbers?

I want to include three sections in my document, but I want the section numbers to be 3, 5 and 6. Can I somehow give predefined values to sections?

\documentclass[11pt]{article}
\begin{document}

\section{Third}
\section{Fifth}
\section{Sixth}

\end{document}


The above code will as usual create 3 sections numbered 1, 2, 3. Any way to change them?

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Oct 22 '16 at 14:01

Use a couple of \setcounter intructions, operating on the counter variable called section.

\documentclass[11pt]{article}
\begin{document}

\setcounter{section}{2} % so that the next section is numbered "3"
\section{Third}

\setcounter{section}{4} % so that the next section is numbered "5"
\section{Fifth}
\section{Sixth} % no need to set the 'section' counter variable for this section

\end{document}


Expand this to your needs adding more \or<number> bits as needed.

\documentclass{article}

\makeatletter
\newcommand{\fancynumbering}[1]{\expandafter\@fancynumbering\csname c@#1\endcsname}
\newcommand{\@fancynumbering}[1]{%
\ifcase#1\or3\or5\or6\else\@ctrerr\fi
}
\makeatother

\renewcommand{\thesection}{\fancynumbering{section}}

\begin{document}

\section{Third}
\section{Fifth}
\section{Sixth}

\end{document}


A possibly cleaner interface:

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\setupfancycounter}{mm}
{
\clist_const:cn { c_typos_#1_clist } { #2 }
}
\DeclareExpandableDocumentCommand{\fancynumbering}{mm}
{
\int_compare:nTF
{ \int_use:c { c@#2 } > \clist_count:c { c_typos_#1_clist } }
{ \use:c { @ctrerr } }
{ \clist_item:cn { c_typos_#1_clist } { \int_use:c { c@#2 } } }
}
\ExplSyntaxOff

\setupfancycounter{fancynumbers}{3,5,6}
\renewcommand{\thesection}{\fancynumbering{fancynumbers}{section}}

\begin{document}

\section{Third}
\section{Fifth}
\section{Sixth}
\section{Oops}

\end{document}


The last section will raise an error.

There's an easier method, but the above ones have the advantage of using the standard markup.

\documentclass{article}

\newcommand{\fixedsection}[1]{%
\setcounter{section}{#1}%