Paragraph Enumeration

From Wiki
Revision as of 07:18, 4 September 2005 by Brooks (talk | contribs) (Added some examples of the typeset output.)
Jump to navigation Jump to search

This code was proposed by Taco to the list:

\newcounter\Paracount
\setcounter\Paracount1

\def\Paragraphnumber%
   {\increment\Paracount 
    \Paracount.~}
\def\startParagraphs%
   {\par \begingroup \appendtoks \Paragraphnumber \to \everypar}
\def\stopParagraphs%
   {\par \endgroup}

\starttext
Unnumbered text before.

\startParagraphs
This is the first numbered paragraph.

This is another paragraph. This is another
paragraph. This is another paragraph.
\stopParagraphs

Unnambered text after.
\stoptext

This produces the following result:

If you're happy with numbers in the margin, this is in-built ConTeXt way, with \setupparagraphnumbering:

\starttext
\showframe
\setupcolors[state=start]
\setupparagraphnumbering[state=start,style=italic,distance=0pt]
\section{bloo}
\input knuth 
\section{blah}
\input knuth \par 
\setupparagraphnumbering[state=stop]
\input tufte \par
\setupparagraphnumbering[state=start,color=red]
\dorecurse{4}{\input tufte \par}
\stoptext