Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can one number paragraphs in LaTeX?

Tags:

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).

like image 676
Brian M. Hunt Avatar asked Feb 12 '09 20:02

Brian M. Hunt


People also ask

How do I number my paragraphs?

Select your paragraphs by dragging your cursor through them and head to the Home tab. To apply the default number style, click “Numbering” in the Paragraph section of the ribbon. To use a different number format, click the arrow next to the Numbering button and select an option.

How do you make different paragraphs in LaTeX?

3.1 Lines and Paragraphs A paragraph in LaTeX is defined by leaving a blank line. If you just want to leave a line blank to make the text more readable in the source, then you just need to add a comment character, "%", at the start.


2 Answers

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

like image 179
Brent.Longborough Avatar answered Sep 19 '22 16:09

Brent.Longborough


In my case I ended up solving this by redefining a new macro \P that works like a paragraph.

\newcounter{paranum} \newcommand{\P}{\vspace{10pt}\noindent\textbf{\refstepcounter{paranum}\theparanum}\textbf} 

To write a new "paragraph" I do

\P{Paragraph title No. 1} ...text... ... \P{Paragraph title No. 2} ...text... 

To make the enumeration be linked to the section I use

\newcounter{paranum}[section] \newcommand{\P}{\vspace{10pt}\noindent\textbf{\thesection.\refstepcounter{paranum}\theparanum}\textbf} 

I know that this is actually botched-up but ended up working for me.

like image 44
FKaria Avatar answered Sep 18 '22 16:09

FKaria