Document Classes ⇒ Creating custom counters by example
-
untexnixal
- Posts: 3
- Joined: Sun Feb 01, 2009 2:12 am
Creating custom counters by example
So could somebody provide me with the shortest code fragment that I could paste in my class file (which patches the article class via LoadClass) to produce the following output:
Let's count 1 and 2 and 3!
(with the numbers 1, 2 and 3 being produced via the repeated invocation of a counter command called \foo).
The best I output I could come up with is:
Let's count 1 and 1 and 1!
(with the number 1 being produced by \setcounter or \stepcounter).
Thanks!
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Creating custom counters by example
Here's a simple code doing that:
Code: Select all
\documentclass{article}
\newcounter{bar}
\newcommand{\foo}{%
\stepcounter{bar}%
\thebar}
\begin{document}
Let's count \foo\ and \foo\ and \foo\
\end{document}- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Creating custom counters by example
For the present you can start with lshort as a general beginners guide and the clsguide as a manual for writing classes.untexnixal wrote:Since I don't have any access to good documentation, I'm trying to learn how to write a LaTeX class by googling for class and style files. […]
Best regards and welcome to the board
Thorsten¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
untexnixal
- Posts: 3
- Joined: Sun Feb 01, 2009 2:12 am
Re: Creating custom counters by example
@localhost Thanks. The references as you said seem quite basic, though they clarify a lot of general points such as the meaning of all those @'s. I had been hoping to find something that would walk me thru such details as changing character mapping.