2

I want in a document of mine to keep a lot of notes so I would like to create a custom counter so every note to be numbered like this:

0001

0002

0003

0004

(They are deliberately bold as this is the style I would like)

I would like the counter to work like the enumerate environment so to add a keyword in front of the note I want to number and also to be able to reset it.

The reasons I don't use the enumerate environment are:

  1. I want the numbers to be bold

  2. I want custom formatting of the numbers i.e. 0001 etc...

  3. I really want to see how I can create something like that.

Adam
  • 4,684

1 Answers1

7

For example, with including the boldness into the appearance of the counter:

\documentclass{article}

\newcounter{custom}
\renewcommand*{\thecustom}{%
  \textbf{%
    \ifnum\value{custom}<1000 0\fi
    \ifnum\value{custom}<100 0\fi
    \ifnum\value{custom}<10 0\fi
    \arabic{custom}%
  }%
}

\begin{document}
\thecustom,
\refstepcounter{custom}\thecustom,
\refstepcounter{custom}\thecustom
\label{abc}

\setcounter{custom}{123}\thecustom,
\setcounter{custom}{7654}\thecustom,
ref: \ref{abc}
\end{document}

Result

An alternative would be to make the numbers bold in the markup macros for the notes only. Then the referenced numbers would appear in normal font.

Heiko Oberdiek
  • 271,626
  • Thank you! Every time I have to increase the counter I have to right \refstepcounter{custom}\thecustom? – Adam Aug 24 '16 at 05:35
  • @Adam The value of the counter can also be changed by \stepcounter{<counter>} or \addtocounter{<counter>}{<amount>}. Only \refstepcounter allows the counter to be referenced and \label with \ref will work for this counter. – Heiko Oberdiek Aug 24 '16 at 05:50