I'd like to know how to set up custom counters. It seems that every counter I create has a section number attached. I'd like to be able to create a counter that doesn't have additional numbers attached.
I'd also like to know how to display counters by themselves. I've only been able to use them in conjunction with other objects, but I'd like to display counters alone.
Any example code would be greatly appreciated.
Links to information on counters would also help.
General ⇒ Understanding Counters
NEW: TikZ book now 40% off at Amazon.com for a short time.

Understanding Counters
Hi,
the following example contains the definition of a counter and illustrates the basic commands for manipulation of counters (the comments are explanatory):
the following example contains the definition of a counter and illustrates the basic commands for manipulation of counters (the comments are explanatory):
Code: Select all
\documentclass{article}
% declare a new counter
\newcounter{MyCount}
% a command to report the value of the counter
% using \the as prefix you can get the value of the counter
\newcommand\MyCValue{\noindent The value of \texttt{MyCount} is \theMyCount\par}
\begin{document}
\MyCValue
% increase the value of the counter
\stepcounter{MyCount}
\MyCValue
% add some value to a counter
\addtocounter{MyCount}{5}
\MyCValue
% change the representation of the counter from arabic to Alphabetic
% you can use \alph, \Alph, \Roman, \roman, and \arabic (default)
\renewcommand\theMyCount{\Alph{MyCount}}
\MyCValue
% set the value of a counter
\setcounter{MyCount}{3}
\MyCValue
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Re: Understanding Counters
Thanks! That solves my problems 

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Understanding Counters
Now that the problem is solved, please be so kind and mark the topic accordingly as clearly written in Section 3 of the Board Rules (to be read before posting). Please keep that in mind for the future so that further reminders will not be necessary.
Thorsten
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10