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.

I'm writing a report that needs some annoying formatting. The \chapters and \paragraphs need to be numbered using arabic numbers.

The paragraph numbering needs to be reset at the commencement of each new chapter. The \section, \subsection, and \subsubsection headings should not be numbered, nor should they have any effect on the \paragraph numbering.

I can't figure out how to:

  1. Reset the \paragraph numbering to 1 at the start of each \chapter.
  2. Prevent the \paragraph numbering from being reset at the start of a new \subsubsection.

Bearing in mind I have used the titlesec package to change the appearance of my titles, what is the easiest way to achieve the desired outcome?

\documentclass[a4paper,11pt,twoside]{report}
%  Paragraph counter
\setcounter{secnumdepth}{5}
\renewcommand\theparagraph{\arabic{paragraph}}
\usepackage{graphicx,amssymb,amstext,amsmath,calc}
% Section headings
\usepackage[noindentafter,calcwidth]{titlesec}
\titleformat{\chapter}
    [hang]
    {\normalfont\uppercase}
    {\bf{\thechapter.}}
    {1em}
    {\bfseries\filcenter}
    []
\titleformat{\section}
    [hang]
    {\normalfont\uppercase}
    {}
    {0pt}
    {\bfseries}
    []
\titleformat{\subsection}
    [hang]
    {\normalfont}
    {}
    {0pt}
    {\bfseries}
    []
\titleformat{\subsubsection}
    [hang]
    {\normalfont}
    {}
    {0pt}
    {}
    [{\titleline*[l]{\titlerule}}]
\titleformat{\paragraph}
    [runin]
    {\normalfont}
    {\theparagraph.} 
    {1em}
    {}
    []
\titlespacing*{\paragraph}
    {0pc}
    {11pt}
    {11pt}
    []
\begin{document}
\chapter{First Chapter}
\paragraph{}First paragraph, numbered 1.
\section{First Section}
\paragraph{}Second paragraph, numbered 2.
\subsection{First Subsection}
\paragraph{}Third paragraph, numbered 3.
\subsubsection{First Subsubsection}
\paragraph{}Fourth paragraph, should be numbered 4.
\chapter{Second chapter, numbered 2.}
\paragraph{}This paragraph should be numbered 1.
\end{document}
share|improve this question

2 Answers 2

up vote 7 down vote accepted

The chngcntr package is perfect for doing this sort of thing:

\usepackage{chngcntr}
\counterwithout{paragraph}{subsubsection} % removes paragraph from the subsubsections
\counterwithin{paragraph}{chapter} % makes paragraph depend on chapter
\renewcommand{\theparagraph}{\arabic{paragraph}} % redefine the display of the paragraph
share|improve this answer
    
Perfect. Thank you. I've been faffing around with new counters and all kinds of rubbish this evening. I knew it didn't have to be that hard! –  Charlie May 2 '11 at 21:39

Alan Munn's solution can be improved by using the starred version \counterwithin* -- hereby, the paragraph counter will be made dependend on the chapter counter without changing the definition of \theparagraph.

\usepackage{chngcntr}
\counterwithout{paragraph}{subsubsection}% makes paragraph independend from subsubsection;
%     redefines \theparagraph as \arabic{paragraph}
\counterwithin*{paragraph}{chapter}% makes paragraph depend on chapter;
%     does not change definition of \theparagraph
share|improve this answer

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.