Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there any good method to get section related page and figure numbering which also allows a consistant TOC/TOF?

I am using the article class to write a technical manual.

Section 1, Page numbering shall start with 1-1, 1-2 and so on. Section 2, 2-1, 2-2 etc. Same for figures.

I found a lot of references to the chappg package but it doesn't seems to fit the requirements. on}

Update: Code example modified based on David's help.

\documentclass[12pt]{article} % use larger type; default would be 10pt
\usepackage{fontspec} % Font selection for XeLaTeX; see fontspec.pdf for documentation
\defaultfontfeatures{Mapping=tex-text} % to support TeX conventions like ``---''
\usepackage{xunicode} % Unicode support for LaTeX character names (accents, European chars, etc)
\usepackage{xltxtra} % Extra customizations for XeLaTeX
\usepackage{lipsum}% for dummy text of 150 paragraphs
%*******************************HEADER LAYOUT*******************************
\usepackage{fancyhdr}
%Rewriting thepage to show section related numbering
\renewcommand\thepage{\thesection--\arabic{page}}
\rfoot{\thepage}
%*******************************SECTION OPTIONS*******************************
%Begin each section with a new page & reset numbering on each section.
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage\setcounter{page}{1}}
\begin{document}
\section{Getting started}
\subsection{Subsection}
\lipsum
\section{Operational Principles}
\subsection{Subsection}
\lipsum[1]
\subsubsection{Subsubsection}
\lipsum[1]
\paragraph{Paragraph}
\lipsum
\section{Forms}
\subsection{Subsection}
\lipsum[1-50]
\subsubsection{Subsubsection}
\lipsum[1]
\paragraph{Paragraph}
\lipsum
\end{document}
share|improve this question
1  
Do your sections start a new page? (article class sections by default do not) –  David Carlisle Jun 11 '13 at 8:41
    
Yes I got some code in my doc for this. –  Bax Jun 11 '13 at 8:53
add comment

1 Answer

up vote 4 down vote accepted

Well this is why questions should always include a complete small document that shows the problem.

For the page number case you need to modify the code that forces a page break to add \setcounter{page}{1} I can't show exactly where as it depends on your local code.

Then add

\renewcommand\thepage{\thesection--\arabic{page}}

For figures you can use

\renewcommand\thefigure{\thesection--\arabic{figure}}
 \makeatletter
 \@addtoreset {figure}{section}
 \makeatletter

In the example you added, the page break is coming too late, the section counter has already been incremented so the last page of each section is wrong.

titlesec doesn't seem to help much in this case (but I left it in in case your real example uses more of the package features) it is simpler just to add the \clearpage directly to \section:

\usepackage{titlesec}
\let\oldsection\section
\renewcommand{\section}{\clearpage\setcounter{page}{1}\oldsection}
share|improve this answer
    
Added a small example what I am doing above. Very close to the solution, but still does some strange numbering. Section 1: 1-1 then 2-2, Section 2: 2-1, 2-2 which is fine, but then 3-3. Section 3 looks good. –  Bax Jun 11 '13 at 20:45
    
@Bax see updated answer –  David Carlisle Jun 11 '13 at 21:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.