Hi,
I have a document containing several sections and I need to print at the beginning of each section it's pages rage. I know that I can get current page number with \thepage command but how can I know what is a number of the last page of a section when I'm at beginning of the section?
General ⇒ pages range of a section
pages range of a section
Last edited by zwierz on Thu Mar 31, 2011 10:37 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

pages range of a section
The lastpage package might help you, but that package is mainly made to indicate the number of pages of your entire document.
howtoTeX.com - Your LaTeX resource site (Tips, Tricks, Templates and more!)
Follow howtoTeX on twitter
Follow howtoTeX on twitter
Re: pages range of a section
Unfortunately lastpage package works only for a last page. Of course information that this can't be done in TeX will be valuable too. At least it will give me some kind of peace of mind 

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
pages range of a section
Simply put a \label command at the very beginning and the very end of a section and refer to both with the \pageref command. This should give you the page range of a section.
Note that you at least need two compiler runs to get the references right.
Thorsten
Code: Select all
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{blindtext}
\begin{document}
\section{Section Title}\label{sec:first}
This Section goes from Page \pageref{sec:first} to Page \pageref{sec:first-end}
\medskip
\blindtext[6]\label{sec:first-end}
\end{document}
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: pages range of a section
Thank you, it works perfectly well.