Key concept: LaTeX uses counters to track numbers for sections, figures, tables, equations, and more. Understanding counters lets you create custom numbering schemes and control how elements are numbered throughout your document.Related topics: Page numbering | Cross-referencing | Document structure
Understanding LaTeX Counters
Built-in Counters
LaTeX provides many predefined counters:Counter | Purpose | Example |
---|---|---|
page | Page numbers | 1, 2, 3… |
chapter | Chapter numbers | 1, 2, 3… |
section | Section numbers | 1.1, 1.2, 2.1… |
subsection | Subsection numbers | 1.1.1, 1.1.2… |
figure | Figure numbers | Figure 1, Figure 2… |
table | Table numbers | Table 1, Table 2… |
equation | Equation numbers | (1), (2), (3)… |
footnote | Footnote numbers | ¹, ², ³… |
Counter Operations
Creating Custom Counters
Basic Counter Creation
Counter Display Formats
Advanced Counter Techniques
Conditional Counter Reset
Counter Dependencies
Custom Numbering Environments
Creating Numbered Environments
Shared Counter Systems
List Numbering Customization
Custom List Counters
Multi-Level Custom Numbering
Cross-Counter References
Referencing Custom Counters
Counter-Based Indexing
Specialized Numbering Systems
Legal Document Numbering
Scientific Paper Numbering
Best Practices
Counter management guidelines:
- Plan your numbering scheme - Design consistent hierarchy before implementation
- Use descriptive counter names -
problem
is better thanprob
orp
- Reset appropriately - Child counters should reset when parent increments
- Document your system - Comment complex counter relationships
- Test thoroughly - Check numbering across document sections
- Consider references - Ensure counter formats work well with
\ref{}
Professional Counter Setup
Troubleshooting Counters
Common Counter Issues
Quick Reference
Essential Counter Commands
Command | Purpose | Example |
---|---|---|
\newcounter{name} | Create new counter | \newcounter{example} |
\newcounter{name}[parent] | Create with reset dependency | \newcounter{sub}[main] |
\setcounter{name}{value} | Set counter to value | \setcounter{page}{1} |
\addtocounter{name}{value} | Add to counter | \addtocounter{page}{5} |
\stepcounter{name} | Increment by 1 | \stepcounter{section} |
\value{name} | Get counter value | \value{page} |
\thename | Display counter | \thepage |
Counter Display Formats
Format | Command | Output Example |
---|---|---|
Arabic | \arabic{counter} | 1, 2, 3, 4… |
Roman (lower) | \roman{counter} | i, ii, iii, iv… |
Roman (upper) | \Roman{counter} | I, II, III, IV… |
Alphabetic (lower) | \alph{counter} | a, b, c, d… |
Alphabetic (upper) | \Alph{counter} | A, B, C, D… |
Next: Learn about Advanced code listings and minted for displaying source code, or explore Footnotes and margin notes for additional content placement.