1

I am trying to use custom counters in the titles of several sections, but I am not talking about the numbering system Latex uses for sections, that's ok. I just want to use a counter in the title.

Better explained with an example:

2.1.2. Title 1
2.1.3. Title 2
2.1.4. Title 3

I just want those 1, 2 and 3 after Title to be a variable I can increment. I have tried using \newcounter and \stepcounter but I must have been using them wrong because they did nothing.

This is what I tried:

\newcounter{ntitle}
\subsection{Title \value{ntitle}}

\stepcounter{ntitle}
...
  • Can you show what you did? – Werner Oct 20 '16 at 16:33
  • @Werner Sure. Check the update. – dabadaba Oct 20 '16 at 16:36
  • 1
    \thentitle not \value{ntitle} – David Carlisle Oct 20 '16 at 16:39
1

\value{<cntr>} is an internal presentation of a counter and typically used in calculations, not presentation. For that, you may want to use \the<cntr> or redefine \the<cntr> to suit your needs (using \alph, \Alph, \roman, \Roman, ...).

Here's an example:

enter image description here

\documentclass{article}

\newcounter{ntitle}% Counter
\renewcommand{\thentitle}{\alph{ntitle}}% Counter representation

\begin{document}

\tableofcontents

\setcounter{ntitle}{3}% Start value

\section{Title \thentitle}

\stepcounter{ntitle}% Next value

\section{Title \thentitle}

\stepcounter{ntitle}% Next value

\section{Title \thentitle}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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