Document Classes ⇒ Creating custom counters by example
-
- 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!
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
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
-
- 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.