TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to Latex, tentatively using it to prepare a complicated industrial document (laboratory test report). This document contains numerous test groups, and I have found convenient , for both the writer and the reader, to number the section of the test results of each group (and the tables and figures) with the group number. I have managed to find a way that suits my need. However, when I use a starred version of the chapters, the resulting structure of the .pdf document is altered, in a way that on the attached sample, the chapter "test results" is shown as a branch of section 1 and not on the same level as other chapters... Is there a way to correct this behavior? Thanks.

\documentclass[a4paper, oneside,11pt, english]{report} % Mode production
\usepackage[utf8]{inputenc} % UTF-8 encoding for code editing
\usepackage[T1]{fontenc} % Usual fonts
\usepackage{tgheros,textcomp}% Fonts
\usepackage{lastpage} % Handling last page numbering 
\usepackage{hyperref} %enabling hyper references

% --[SECTION NUMBERING FIRST PAGES]---------------------------------
%  --[END SECTION NUMBERING FIRST PAGES]---------------------------------
\renewcommand{\familydefault}{\sfdefault}%selecting default font (clone of helvetica)


\tableofcontents %  [CREATING TABLE OF CONTENTS]---

\chapter*{Summary of test results}
\addcontentsline{toc}{chapter}{Summary of test results}
A table.

\chapter*{Test specimen}
\addcontentsline{toc}{chapter}{Test specimen}
\section{section 1}
Some text.
\section{Section 2}
Some text.

 \chapter*{Test results}
\addcontentsline{toc}{chapter}{Test results}

\renewcommand{\thefigure}{\ifnum \c@section>\z@ \thesection.\fi 
\@addtoreset{figure}{section} \makeatother 
\renewcommand{\thetable}{\ifnum \c@section>\z@ \thesection.\fi 
\@addtoreset{table}{section} \makeatother 


\setcounter{section}{-1} % setting counter to assign  number 0 to group 0 
\setcounter{figure}{-1} % setting counter to assign  number 0 to figures of group 0
\setcounter{table}{-1} % setting counter to assign  number 0 to figures group 0

\section{Group 0}
\subsection{Visual examination} 
No defect observed. 
\subsection{Examination of dimensions and mass} 
The results meet the requirements stated on the drawings.
\subsection{Magnetic permeability}
The results meet the requirements. 
\subsection{Mating and un-mating forces }
The results meet the requirements.

\section {Group 1} 

some text
\subsection{Visual examination}  
some text
\subsection{Measurement of insulation resistance} 
some text
share|improve this question
The problem lies with you resetting the \setcounter{section}{-1}. Can you please post a sample of what you want to achieve? – Yiannis Lazarides Jan 29 '12 at 16:36
up vote 6 down vote accepted

This is fixed with the addition of the bookmark package

\usepackage{bookmark}% http://ctan.org/pkg/bookmark

to your document preamble (no load order restriction with hyperref, so before or after):

Correct bookmark organization with the inclusion of bookmark package

share|improve this answer
Thanks a lot... I had been trying to understand the problem for a while.... – Yves Jan 29 '12 at 16:48

The easiest way is to use \chapter and avoid printing "Chapter n"; however, this needs also fixing the table of contents:


Then the simple \chapter{Summary of test results}, without adding \addcontentsline will do.

The package bookmark is recommended anyway. However, loading it and leaving your code unchanged will produce warnings and possible incorrect links:

pdfTeX warning (ext4): destination with the same identifier 
(name{section.0.1}) has been already used, duplicate ignored
<to be read again> 
l.79 \section {Group 1}

This doesn't happen with the patches I suggest.

The line \let\@makechapterhead\@makeschapterhead makes \chapter behave, as far as printing is concerned, like its unnumbered sibling (but the chapter number will be stepped nevertheless).

The \patchcmd line tells LaTeX to ignore the \numberline{n} bit in the ToC entry (n stands for the actual chapter number) by exploiting the fact that the entry is typeset inside a group: so in that group we redefine \numberline to be the same as \@gobble that makes its argument disappear.

share|improve this answer
Thanks a lot. I had also noticed the warning, but had not understood how to get rid of it. I must admit I do not understand everything in your code either, but I am going to study. Your code brings the additional benefit of keeping the chapters numbered, and this is preferred in such a document..... – Yves Jan 29 '12 at 19:48

Your Answer


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.