Weird page numbering problem in LaTeX

  • Context: LaTeX 
  • Thread starter Thread starter kb03y
  • Start date Start date
  • Tags Tags
    Latex Weird
Click For Summary
SUMMARY

The issue with page numbering in LaTeX arises from the incorrect placement of the \setcounter{page}{#} command. To ensure the first "real" page is numbered correctly, the \setcounter{page}{2} and \setcounter{section}{0} commands must be placed after the \begin{document} statement. This adjustment resolves the problem, allowing for proper page numbering in the document.

PREREQUISITES
  • Familiarity with LaTeX document structure
  • Understanding of LaTeX commands and environments
  • Basic knowledge of page layout and formatting in LaTeX
  • Experience with LaTeX packages such as fancyhdr and geometry
NEXT STEPS
  • Review LaTeX documentation on the \setcounter command
  • Explore the fancyhdr package for advanced header and footer customization
  • Learn about document classes and their impact on page formatting
  • Investigate common LaTeX errors and troubleshooting techniques
USEFUL FOR

This discussion is beneficial for LaTeX users, document authors, and anyone involved in typesetting academic papers or reports who seeks to understand page numbering issues and their solutions.

kb03y
Messages
1
Reaction score
0
Hello people.
I seem to have run into an odd problem with my page numbering. Whatever I do to the \setcounter{page}{#} command, it just won't let my first "real" page be number 1. Can you find the problem?

Here is the code:

Code:
\documentclass[10pt,a4paper,danish]{article}
\usepackage{ucs} 
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} 
\usepackage{siunitx}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{graphicx}
\usepackage[top=4cm, bottom=4cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{caption}
  \DeclareCaptionLabelSeparator{tilpasning}{:\quad}
  \captionsetup{font=footnotesize,labelfont=sc,labelsep=tilpasning,width=.9\textwidth}

\setcounter{page}{2}		
\setcounter{section}{0}			
 
\lhead{}		
\chead{}		
\rhead{}		
\lfoot{} 	
\cfoot{\rule{\linewidth}{0.5pt}\\Side \thepage}		
\rfoot{}	

 
\begin{document}
\begin{titlepage}
  This is title
\end{titlepage}

\tableofcontents
\thispagestyle{empty}

\newpage

\section{section}
Yeah, man.
\subsection{cool}
Hello world

\end{document}
 
Physics news on Phys.org
The two statements,
[CODE lang="latex"]\setcounter{page}{2}
\setcounter{section}{0}[/CODE] should always come after \begin{document}. This should solve the problem.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 8 ·
Replies
8
Views
13K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
1
Views
8K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K