views:

5112

answers:

2

Given a bunch of paragraphs:

Para. A ...

Para. B ...

Para. C ...

How can one have LaTeX automatically number them, i.e.

1. Para. A. ...

2. Para. B. ...

3. Para. C. ...

I've seen the following suggested:

\newcounter{parnum}
\newcommand{\N}{%
   \noindent\refstepcounter{parnum}%
    \makebox[\parindent][l]{\textbf{\arabic{parnum}.}}}
% Use a generous paragraph indent so numbers can be fit inside the
% indentation space.
\setlength{\parindent}{2em}

From here: comp.text.tex: Re: How do I number paragraphs in LaTeX?

Then use \N in front of every paragraph-to-be-numbered, i.e.

\N Para. A. ...

\N Para. B. ...

\N Para. C. ...

I've also seen references to Sarovar and numberpar, but both are referred to as "unstable" or "unpredictable", and things like "randomly breaks", which makes me wary.

I'd like some input on what may be the best course of action, here, and I think it's a topic worth some discussion.

Thank you for your interest and attention to this.

EDIT: I've tried the following

\begin{enumerate}
\item Para No. 1
\item Para No. 2
...
\end{enumerate}

However it results in typesetting problems, notably because I am interspersing section headings ala.

\begin{enumerate}
\item Para No. 1
\item Para No. 2
\section{Part II}
\item Para No. 5
\item Para No. 6
...
\end{enumerate}

and the section heading "Part II" will sometimes end up at the very bottom of the page (i.e. it doesn't keep with the following text).

+1  A: 

I believe another option is the ledmac package. Here is a quote from the documentation:

The normal \label, \ref and \label \pageref macros may be used within numbered text, and operate in the familiar fashion. As an example, here is one way of numbering paragraphs in numbered text, and then being able to refer to the paragraph numbers, in addition to line and page numbers.

\newcounter{para} \setcounter{para}{0}
\newcommand{\newpara}{%
  \refstepcounter{para}%
  \noindent\llap{\thepar. }\quad}
\newcommand{\oldpara}[1]{%
  \noindent\llap{\ref{#1}. }\quad}

The definitions of \newpara and \oldpara put the numbers in the left margin and the first line of the paragraph is indented. You can now write things like:

\linenummargin{right}
\beginnumbering
\pstart
\newpara\label{P1} A paragraph about \ldots
\pend
  In paragraph~\ref{P1} the author \ldots
\pstart
\oldpara{P1} This has the same
             \edtext{number}{\Afootnote{\ref{P1} is the paragraph, not line}}
  as the first paragraph.
\pend
\endnumbering

I've never attempted this myself, however.

Jon Ericson
+1  A: 

I think there are three possible solutions (at least!) which don't involve rolling your own or someone else's macro, depending on exactly what you are trying to do.

1 If the numbering is required throughout the document, use \paragraph, which is a lower-level sectioning command (like \chapter, \section, \subsection, etc.)

See the LaTeX wikibook for more information.

\setcounter{secnumdepth}{5}
...
\paragraph{If we want to} do something ...

(You may find this overkill/ugly, because it needs a properly nested structure of sections and subsections not to be)

Note that if your using the memoir document class (which I recommend unhesitatingly), the \setcounter line becomes \maxsecnumdepth{paragraph}

2 If it's just a small piece, use a list:

\begin{enumerate}
\item Para No. 1
\item Para No. 2
...
\end{enumerate}

3 Or a generalized list (\begin{list}...\end{list{}) if you want to tweak the formatting. I haven't immediately been able to find a good online reference for this, other than the piece in A Guide to LaTeX

Brent.Longborough
\setcounter{secnumdepth}{5} + \paragraph was the functionality I was looking for. Thanks!
Brian M. Hunt