[texhax] Cross-referencing paragraphs not in the Table of Contents

Philip G. Ratcliffe philipratcliffe at tiscali.it
Mon Nov 14 00:12:48 CET 2005


> I am writing on a document for some 'rules and regulations'
> in pdfTex where I use the paragraph sectioning command a lot.
> It is not practical to include these paragraphs in the Table
> of Content since they are numerous and without heading (but
> I include them as bookmarks). However, it is 'a must' to be
> able cross-referencing the individual paragraphs. So far, I
> have used a LaTex-structure like this for each paragraph:
> %..................................................
> \addtocounter{paragraph}{1}
> \paragraph*{\theparagraph\hspace{-1em}}
> \pdfbookmark[4]{\theparagraph}{\theparagraph}
> \label{key}
> %..................................................
> Text of the paragraph ....
> This works fine for the bookmark, and also for the hyperlink
> when I write '\ref{key}' or '\pageref{key}' (I jump to the
> correct paragraph). However, the problem is that '\ref{key}'
> yields the overlaying subsection-number (which is in ToC),
> instead of the actual paragraph-number.
> I understand that this is not a bug in LaTex, just the way
> it is meant to work. However, what I miss here is the
> following extention of the ref-command: \ref[counter]{key},
> with a counter optional (in my case paragraph). Maybe this
> can be enabled using the \renewcommand, but I don't have the
> skills.
> COan you help me finding a way around this problem?

Ok, what is and what isn't _generally_ included in the ToC should be
controlled by the counter \tocdepth rather than using the starred version of
the sectioning commands (these should merely be one-offs), just as what is
as what isn't _generally_ numbered should be controlled by the counter
\secnumdepth. This both solves your problem and allows for rapid inclusion
in the ToC as and when you should change your mind.

The article class defaults are:

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

I presume what you need is simply to add

\setcounter{secnumdepth}{4}

and elimination of the superfluos lines stars and and \theparagraph's etc.

Cheers,  Phil Ratcliffe



More information about the texhax mailing list