I am writing a legal document with numbered paragraphs and I would like the table of contents to list paragraph numbers, not page numbers. I am using linguex.sty to count the paragraphs (in the MWE below, the command \ex. generates sequentially numbered paragraphs, using the internal counter ExNo).

For example, if section 1 runs from paragraphs 1 to 13 and section 2, from paragraphs 14 to 19 and section 3, from 20 to 24, then I'd like the table of contents to look like:

Section 1 ........... 1

Section 2 ........... 14

Section 3 ........... 20

At the start of each section, the paragraph counter is 1 less that the number that I wish to have in the table of contents. If I could replace the page number with:

then I should get the right result. I’ve used tocloft.sty for various other tweaking in the MWE below, but can’t find a parameter with the package that allows me to make this particular change. (I thought that this answer would work, but it has no effect at all.)

\documentclass[12pt]{report}
\usepackage{mathptmx}
\usepackage{linguex}
\usepackage{tocloft}
\renewcommand{\cftsecfont}{\scshape}
\renewcommand*\thesection{\sc\roman{section}}
\renewcommand*\thechapter{\sc PART \Roman{chapter}}

\usepackage{titlesec}
\titleformat{\chapter}[hang]{\normalfont\scshape\filcenter}{PART \thechapter    }{0em}{}
\titlespacing{\chapter}{0pt}{0pt}{1.5ex}
\titleformat{\section}[hang]{\normalfont\scshape\filcenter}{\roman{section}.}{0.35em}{}

\usepackage{chngcntr}
\counterwithout{ExNo}{chapter}

\begin{document}

\setlength{\Exlabelsep}{0pt}
\setlength{\Exindent}{-2em}
\setlength{\Exlabelwidth}{2em}
\renewcommand{\ExLBr}{}
\renewcommand{\ExRBr}{.}
\renewcommand{\SubExLBr}{(}
\renewcommand{\SubExRBr}{)}
\setlength{\SubExleftmargin}{1.75em}%
\renewcommand{\theExRBr}{}
\renewcommand{\theExLBr}{}
\renewcommand{\firstrefdash}{}

\tableofcontents

\chapter{}

\section{hier geht's los}

\ex. Sauerkraut

\ex. Senfgurken

\section{hier geht's weiter}

\ex. Kaffee \dots

\ex. \dots\ und Kuchen!

\chapter{}

\section{was folgt}

\ex. Bauch-

\ex. -krampf

\end{document}
• @egreg I’ve added in a sketched example. If you think screen shots would make it clearer, let me know. – Daniel Harbour Oct 10 '13 at 7:14

Here's a possible solution. Every \section command writes on the .toc file the state of the ExNo counter and \l@section is redefined to use this value instead of the page number.

\documentclass[12pt]{report}

\usepackage{linguex}
\usepackage{tocloft}
\usepackage{etoolbox}
\usepackage{titlesec}

\makeatletter
\def\l@parnum#1{\def\current@parnum{#1}}
\def\current@parnum{}
\let\tocloft@l@section\l@section
\def\l@section#1#2{\tocloft@l@section{#1}{\current@parnum}}
\makeatother

\renewcommand{\cftsecfont}{\scshape}
\renewcommand{\cftchapfont}{\scshape}
\renewcommand{\cftchappresnum}{Part~}

\titleformat{\chapter}[hang]
{\normalfont\scshape\filcenter}
{PART \thechapter}
{0em}
{}
\titlespacing{\chapter}
{0pt}
{0pt}
{1.5ex}
\titleformat{\section}[hang]
{\normalfont\scshape\filcenter}
{\roman{section}.}
{0.35em}
{}

\usepackage{chngcntr}
\counterwithout{ExNo}{chapter}

\begin{document}

\setlength{\Exlabelsep}{0pt}
\setlength{\Exindent}{-2em}
\setlength{\Exlabelwidth}{2em}
\renewcommand{\ExLBr}{}
\renewcommand{\ExRBr}{.}
\renewcommand{\SubExLBr}{(}
\renewcommand{\SubExRBr}{)}
\setlength{\SubExleftmargin}{1.75em}%
\renewcommand{\theExRBr}{}
\renewcommand{\theExLBr}{}
\renewcommand{\firstrefdash}{}

\tableofcontents

\chapter{}

\section{hier geht's los}

\ex. Sauerkraut

\ex. Senfgurken

\section{hier geht's weiter}

\ex. Kaffee \dots

\ex. \dots\ und Kuchen!

\chapter{}

\section{was folgt}

\ex. Bauch-

\ex. -krampf

\end{document}

It's better not to add formatting instructions to commands such as \thechapter or \thesection. In any case, don't use \sc but \scshape.

• Thanks, that's working perfect. The other tweaks and pointers noted and appreciated as well. – Daniel Harbour Oct 11 '13 at 9:08

Here's an MWE that can do natively numbered (logical) paragraphs, like a sort of legal-essay template, and (if it is required) a rudimentary TOC using them. ("rudimentary", because a list of tables and statutes, like bl-OSCOLA already describes the method, would be more practical than a traditional non-legal TOC (for legal essays and similar, anyway).)

Basically, it's just a counter, advanced by rerfstepcounter whenever used. So very simplistic.

It uses fontspec for system fonts, so compile with xelatex.

Personal preference: interestingly, having two numerical navigation reference systems (numbered headings vs numbered text) on different scales and methods was too confusing and I had to actively ignore one to use the other, so I switched off heading labels. Feel free to comment out those parts of the code and switch them back on again, if you use numbered headings.

\documentclass[12pt,a4paper]{article}

\title{Numbered Paragraphs}
\author{MWE}
\date{23-Nov-2019}

\usepackage{graphicx}
\usepackage[svgnames]{xcolor}
\usepackage{fontspec}
\usepackage{mdframed}
\usepackage{capt-of}

%change fonts as desired
\setmainfont{Noto Serif}%TeXGyreTermes}
\setmonofont{Noto Sans Mono}[Colour=blue]

%sample text
\newcommand\sampletext{This is some sample text. }

%numbered paragraphs
\newcounter{parno}% numbered paragraph (logical paragraph)

%default format = nothing
\newcommand\parnumformat[1][]{#1}
\renewcommand{\theparno}{\arabic{parno}}%

\newcommand\p[1][\par]{%
#1%
\refstepcounter{parno}%
{\parnumformat\noindent [\theparno ]}%
\ %
}%

%numbered paragraphs cross-referencing method, automatic and manual
\newcommand\definnametext{para}
\newcommand\definnamea{para}
\newcommand\definnameb{:}
\newcommand\definnamec{ref}
%auto label is done inside the \p command
%manual label:
%manual reference:
\newcommand\pararef[1]{\definnametext\ [\ref{#1}]}
%auto reference:
\newcommand\pararefauto[1]{\definnametext\ [\ref{\definnamea\definnameb\definnamec#1}]}

%for legibility
\setlength{\parskip}{1.5ex plus 0.8ex minus 0.8ex}

%colophon]
\newcommand\colophon{%
\vspace{5pt}
\bigskip
\hrule
\par \
\begin{center}
{\small * End of Document *}
\par
\end{center}
}

%blank out the number (and spacing)
%paragraph numbers will carry the ref load
\usepackage{titlesec}
\titlelabel{}

\titleformat{name=\section}
{\normalfont\Large\bfseries}
{}%prefix to text: empty means no numbers appear
{1ex}%sep
{\color{red}}%formatting to apply to text

\usepackage{titletoc}
%stop heading numbers appearing in ordinary TOC
\renewcommand{\thesection}{}
\renewcommand{\thesubsection}{}
\renewcommand{\thesubsubsection}{}

\newcommand\doshortrule{\vspace{1ex}\noindent\hfil\rule{0.4\textwidth}{0.4pt}\hfil}

%===================================
%Create tc2 entries: alternative TOC, using (current) parno

%open the file and prepare it
\newcommand\openxtoc{
\newwrite\fb
\immediate\openout\fb=\jobname.tc2
\immediate\write\fb{\string\section*{Contents}}
\immediate\write\fb{\string\hfill\string\textsc{[Para]}\string\par}
}

% put tc2 TOC (if any) into the text stream
\newcommand\doprinttoc{%
\IfFileExists{\jobname.tc2}{%
\input{\jobname.tc2}% read in info from previous run
}%true
{\typeout{Nothing there: \jobname.tc2}%
}% false
\openxtoc %prepare for output on this run
}%doprintindex

%update tc2 TOC when a heading is activated
\newcommand\ssection[1]{%
\section{#1}
\immediate\write\fb{#1 \string\dotfill\string\hspace{1pc} [\theparno]\string\par}
}

\newcommand\ssubsection[1]{%
\subsection{#1}
\immediate\write\fb{\string\small \string\hspace{1pc}#1 \string\dotfill\string\hspace{1pc} [\theparno]\string\par}
}

\newcommand\ssubsubsection[1]{%
\subsubsection{#1}
\immediate\write\fb{\string\small \string\hspace{2pc}#1 \string\dotfill\string\hspace{1pc} [\theparno]\string\par}
}

%close off the tc2 TOC
\newcommand\closextoc{
\immediate\closeout\fb
}

\AtEndDocument{\closextoc}

%===================================
\begin{document}
\maketitle
\doshortrule
%%\tableofcontents
\doprinttoc
\listoffigures

\doshortrule

\ssection{Introduction}
\p Numbered headings and a flow of unadorned text are sufficient for most technical and professional material.
\p For legal matters, to save time in locating a word or phrase or sentence, more precision in pinpointing text is required, so paragraph numbering has come into play\footnote{And numbered paragraphs also form part of the Medium Neutral Citation (MNC) method.}. And headings are not so important (in fact, unless the tract is extremely long, they are often dispensed with altogether).

\ssection{Numbered paragraphs}
\p With a new command\footnote{Short, to save typing.}, \verb|\p|, the paragraphs are now numbered, logical style.

Physical paragraphs (like this one) remain as they are\footnote{Note the indentation, as well.} ...

\p ... but logical paragraphs are numbered. (Note that the paragraph numbering is sequential for the whole document.)
\p The \verb|\par| command is still available for use: occasionally, after a long citation, a concluding observation might be needed, and that can be visibly set off from the quotation by a par, without making a new numbered paragraph out of it.
\p \paradef{sec} To facilitate with building the table of contents (see \pararef{toc}), three sectioning commands have been augmented, to do the usual heading work, plus output TOC data -- they are:
\begin{itemize}
\item \verb|\ssection|
\item \verb|\ssubsection|
\item \verb|\ssubsubsection|
\end{itemize}

\ssubsubsection{The \textbackslash p command}
\p\paradef{xys} As a sidenote, this paragraph has a cross-reference label set\footnote{With the \texttt{\textbackslash paradef\{\}} command}. Remember this for when we get to \pararef{train}.
\p The \texttt{\textbackslash p} command complex has the following structure:

%no float
%\begin{figure}
\begin{mdframed}[%
outerlinewidth = 2 ,%
roundcorner = 10 pt ,%
leftmargin = 10 ,%
rightmargin = 10 ,%
backgroundcolor = yellow!40 ,%
outerlinecolor = blue!70!black ,%
innertopmargin = \topskip ,%
splittopskip = \topskip ,%
]
\begin{verbatim}
% Numbered Paragraphs =============
%define a new counter
\newcounter{parno}
%typeset with square brackets
\renewcommand{\theparno}{\arabic{parno}}
%default format hook = nothing
\newcommand\parnumformat[1][]{#1}
%\p command for logical paragraphs:
% 1. insert a \par (default logical separator)
% 2. step the counter
% 3. typeset the formatted version
%            (with no indent)
% 4. with a space
\newcommand\p[1][\par]{%
#1%
\refstepcounter{parno}%for cross-referencing
{\parnumformat\noindent[\theparno ]}%
\ %space
%auto cross-ref label
}%
%            for legibility
\setlength{\parskip}{1.5ex plus 0.8ex minus 0.8ex}
\end{verbatim}
\end{mdframed}
%\caption{Numbered Paragraphs}
%\end{figure}
\captionof{figure}{Numbered Paragraphs}
\p To make the parnums bold red, we can \texttt{\textbackslash renewcommand} the format hook, \texttt{\textbackslash parnumformat\{\}}, with \texttt{\textbackslash bfseries\textbackslash color\{red\}}.
\renewcommand\parnumformat{\bfseries\color{red}}
\p To specify a separator other than \texttt{\textbackslash par}, -- for example. to make run-in pars' --, put the code as an option to \verb|\p|, like this: \verb|\p[ $\to$\ ]|:
\noindent\p[ $\to$ ]\sampletext Run-in text.
\noindent\p[ $\to$ ]\sampletext More run-in text.
\p\sampletext
\noindent\p[ *~]\sampletext
\noindent\p[ *~]\sampletext
\par
\renewcommand\parnumformat{}
\p\sampletext\p\sampletext

\ssection{Cross-referencing}
\p After numbered paragraphs, the next requirement is cross referencing.
\p The \texttt{\textbackslash p} command automatically labels the paragraphs. Auto-labelling gives each paragraph a unique label of the form\\[1ex] \indent\texttt{\definnamea\definnameb\definnamec\textbackslash theparno}\\[1ex]
and, knowing the paragraph number, these can be referenced manually, if desired, with \verb|\pararefauto{}|. For example, to refer to paragraph 5, the code\\[1ex]
\indent\verb|see \pararefauto{5}|\\[1ex]
produces \\[1ex]
\indent see \pararefauto{5} \\[1ex]
There is no practical purpose in manually referring to auto-labels.
\p \paradef{train} Manual-labelling and referencing is done as usual: the label is arbitrary text. For example, a label (xys'') was set in a previous paragraph with \texttt{\textbackslash paradef\{xys\}}, and referencing that label here with \texttt{\textbackslash pararef\{xys\}} produces \pararef{xys}''.
\p Cross-referencing requires at least two or three compilation runs for the references to resolve and settle''.

\p Now, the idea of page' as the navigational reference point is so fundamental (from the time period when Tex was developed), that it is deep in the internals of the routines and often assumed by other routines, such that it will take time to ferret out in the context of generating a table of contents (and probably will need only one line of code to repoint it to \texttt{parno}).
\p In the meantime, a workaround solution for the table of contents is provided, where modified sectioning commands (see \pararef{sec}) output some basic formatting code and the \texttt{parno} \textit{with the value it has at that moment in the text processing stream} to an external file (\texttt{.tc2}). The file is then read back in again (with \verb|\doprinttoc|, see \pararef{printtoc}) on a subsequent compilation run.
\p The basic nature of the \texttt{.tc2} file  means that embedding sophisticated commands into section headings (like \texttt{\textbackslash verb} or \texttt{\textbackslash texttt}) will cause compilation errors. Delete the \texttt{.tc2} file and readjust the section heading contents. Careful thinking about whether the command, or the \textit{contents} of the command, should go into the \texttt{.tc2} file may be required.
\p For example, in the case of the heading The \textbackslash p command'' back at \pararef{xys}, \\[1ex]
\indent\texttt{The \textbackslash verb|\textbackslash p| command}\\[1ex]
didn't work, but \\[1ex]
\indent\verb|The \textbackslash p command|\\[1ex]
did.

\colophon
\end{document}

Perhaps the question should be tagged legal or law, rather than with linguistics matter, to reflect better the more general field of usage, as well as just the mechanics of what was specifically adapted to that usage? (In any case, I found this question by looking for 'numbering paragraphs').

• Tag legal-style added. – Una Sep 18 at 4:44