3

For a given work, I have to number some selected paragraphs, with a continuous numerotation throughout all the book. I can do it using this tip.

I need the index entries refer to the paragraph numbers and not to the pages. I've seen this post, but I'm not able to customize it for my need, as I am quite a newbie to LaTeX and I don't understand which part of the implemantation I should change to refer to the numbered paragraphes...

Till now, I've not choosen the document class -- as the tip for numbering some selected paragraphs is for memoir, I think I will use it.

Thanks for your help.

2
  • Welcome to TeX.SX! We should know how you provide the paragraph numbers in order to help you.
    – egreg
    Jul 17, 2012 at 20:49
  • Ok, sorry for the URL links and not the complete solutions I've used, I will not them directly in the message the next time. Jul 18, 2012 at 13:02

1 Answer 1

2

Following the example you give, using the memoir class, here is a simple way to implement what you want. Memoir may be a good option if you have precise, complex needs, because it is very comprehensive, especially for long documents.

Because memoir's \frontmatter, \mainmatter and friends alter the way section numbering is done, I suggest you create a whole new counter, since you are not really using it as a sectioning command anyway. If you need to add the paragraphs to the table of contents, it is possible too, so no worries there (just ask).

Here is the example document:

\documentclass{memoir}

% Load dummy text
\usepackage{lipsum}

% We create a counter
\newcounter{paracount}

% We create the paragraph command
\def\para{%
    \refstepcounter{paracount}%
    \noindent\textbf{\theparacount.\quad}}

% We create an index
\makeindex

% We tell memoir to index paragraphs and not pages
\renewcommand{\index}[1]{\specialindex{\jobname}{paracount}{#1}}


\begin{document}

\frontmatter

\para \index{Front matter entry} \lipsum[4]

\mainmatter

\para \index{First entry} \lipsum[1]

\para \index{Second entry} \lipsum[2]

\para \index{Third entry} \lipsum[3]

\printindex

\end{document}

Note that you can tell memoir to index things based on any counter, you just need to specify it in the \specialindex{\jobname}{<counter>}{#1} line.

Now, all you need to do is run LaTeX, then MakeIndex, then LaTeX again.

7
  • Thanks a lot, @ienissei, it's exactly what I wanted to do. I will study better the Memoir class, which seems really powerful... Jul 18, 2012 at 13:04
  • Just a question more about that special way of numbering paragraphs : it does not work using \frontmatter, \mainmatter and \backmatter. I've tried to add a \setsecnumdepth{paragraph} command, as it is suggested in this other discussion : tex.stackexchange.com/questions/3327/…, but there is no effect. Jul 18, 2012 at 14:24
  • @Ratoune2008 Ah… yes, that will be memoir messing up with section numbering within the \frontmatter and \mainmatter commands. I have edited my answer, I suggest you just use a new counter, as you don't actually need your entries to be \paragraph sections as such.
    – ienissei
    Jul 18, 2012 at 17:27
  • Thanks a lot, you're an expert... and thanks for the explanations of the commands you define, it helps to understand better both LaTeX and 'memoir' class ... Jul 18, 2012 at 19:04
  • @Ratoune2008 Glad it helped :)
    – ienissei
    Jul 18, 2012 at 20:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .