6

I know I can change a counter style as this:

\renewcommand\thechapter{\Roman{chapter}}

(The above command will make chapter numbers be written in upper case roman numerals)

However, according to Wikibooks and an answer to this question, I can only choose among arabic, roman, greek and footnote symbols:

  • \arabic 1, 2, 3 ...
  • \alph a, b, c ...
  • \Alph A, B, C ...
  • \roman i, ii, iii ...
  • \Roman I, II, III ...
  • \fnsymbol Aimed at footnotes; prints a sequence of symbols.

Is there a way I can define my own symbol sequence for a counter?

Jay
  • 2,895
  • 2
  • 27
  • 38

1 Answers1

13

You can easily adapt the definition of \alph which is defined like this in latex.ltx:

\def\alph#1{\expandafter\@alph\csname c@#1\endcsname}
\def\@alph#1{%
  \ifcase#1\or a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or
   k\or l\or m\or n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or
    y\or z\else\@ctrerr\fi}

So here is a MWE for a custom sequence.

\documentclass{article}
\makeatletter
\def\mysequence#1{\expandafter\@mysequence\csname c@#1\endcsname}
\def\@mysequence#1{%
  \ifcase#1\or AAA\or BBB\or CCC\else\@ctrerr\fi}
\makeatother
\renewcommand\thesection{\mysequence{section}}
\begin{document}
\section{Section}
\section{Section}
\section{Section}
%\section{Section} % --> LaTeX Error: Counter too large
\end{document}

Be aware, that this implementation stops working if the counter value is too high (in my example 4). So make sure you define enough symbols.

Benjamin
  • 4,781