Generalpages range of a section

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
zwierz
Posts: 5
Joined: Thu Jan 20, 2011 2:22 am

pages range of a section

Post by zwierz »

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?
Last edited by zwierz on Thu Mar 31, 2011 10:37 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Frits
Posts: 169
Joined: Wed Feb 02, 2011 6:02 pm

pages range of a section

Post by Frits »

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
zwierz
Posts: 5
Joined: Thu Jan 20, 2011 2:22 am

Re: pages range of a section

Post by zwierz »

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 :)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

pages range of a section

Post by localghost »

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.

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}
Note that you at least need two compiler runs to get the references right.


Thorsten
zwierz
Posts: 5
Joined: Thu Jan 20, 2011 2:22 am

Re: pages range of a section

Post by zwierz »

Thank you, it works perfectly well.
Post Reply