Key concept: LaTeX separates content (what appears) from style (how it looks). Understanding page styles lets you create consistent, professional headers and footers across your document.Related topics: Page numbering | Document design | Cross-referencing
Understanding Page Styles
Default Page Styles
LaTeX provides four built-in page styles:Style | Description | Header | Footer |
---|---|---|---|
plain | Default for chapters | Empty | Page number |
empty | Completely blank | Empty | Empty |
headings | Automatic headers | Section/chapter names | Page number |
myheadings | Manual headers | User-defined content | Page number |
The fancyhdr Package
Thefancyhdr
package provides complete control over headers and footers.
Basic Setup
Position Specifiers
Advanced Header Customization
Dynamic Content
Conditional Headers
Multi-line Headers
Graphics in Headers
Chapter and Section Information
Automatic Section Headers
Custom Section Marking
Special Page Styles
Title Page Style
Bibliography Style
Headers with Boxes and Borders
Troubleshooting Common Issues
Header Height Problems
Page Break Issues
Best Practices
Header and footer guidelines:
- Keep it simple - Too much information clutters the page
- Be consistent - Use the same style throughout similar documents
- Consider your audience - Academic vs. business documents have different conventions
- Test thoroughly - Check headers on all page types (first, last, odd, even)
- Mind the margins - Ensure headers don’t overlap with main content
- Use semantic marking - Let LaTeX generate section names automatically when possible
Professional Formatting
Quick Reference
Essential fancyhdr Commands
Command | Purpose | Example |
---|---|---|
\pagestyle{fancy} | Activate fancy headers | Required for customization |
\fancyhf{} | Clear all headers/footers | Start with clean slate |
\fancyhead[L]{text} | Set left header | \fancyhead[L]{\leftmark} |
\fancyfoot[C]{text} | Set center footer | \fancyfoot[C]{\thepage} |
\thispagestyle{style} | Set style for current page | Override default style |
Position Codes
Code | Meaning | Code | Meaning |
---|---|---|---|
L | Left | E | Even pages |
C | Center | O | Odd pages |
R | Right | LE | Left on even pages |
Common Variables
Variable | Content |
---|---|
\thepage | Current page number |
\leftmark | Chapter name (book) or section name (article) |
\rightmark | Section name (book) or subsection name (article) |
\today | Current date |
Next: Learn about Page numbering for advanced numbering schemes, or explore Document design for overall layout principles.