Difference between revisions of "Paragraph Enumeration"

From Wiki
Jump to navigation Jump to search
(add ConTeXt native way)
m (Added some examples of the typeset output.)
Line 1: Line 1:
 
This code was proposed by Taco to the list:
 
This code was proposed by Taco to the list:
 +
 
<texcode>
 
<texcode>
 +
\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
 +
</texcode>
 +
 +
This produces the following result:
  
 +
<context>
 
\newcounter\Paracount
 
\newcounter\Paracount
 
\setcounter\Paracount1
 
\setcounter\Paracount1
Line 8: Line 36:
 
   {\increment\Paracount  
 
   {\increment\Paracount  
 
     \Paracount.~}
 
     \Paracount.~}
 
 
\def\startParagraphs%
 
\def\startParagraphs%
 
   {\par \begingroup \appendtoks \Paragraphnumber \to \everypar}
 
   {\par \begingroup \appendtoks \Paragraphnumber \to \everypar}
 
 
\def\stopParagraphs%
 
\def\stopParagraphs%
 
   {\par \endgroup}
 
   {\par \endgroup}
  
 
\starttext
 
\starttext
 
 
Unnumbered text before.
 
Unnumbered text before.
  
Line 28: Line 53:
 
Unnambered text after.
 
Unnambered text after.
 
\stoptext
 
\stoptext
</texcode>
+
</context>
 +
 
 
If you're happy with numbers in the margin, this is in-built ConTeXt way, with <cmd>setupparagraphnumbering</cmd>:
 
If you're happy with numbers in the margin, this is in-built ConTeXt way, with <cmd>setupparagraphnumbering</cmd>:
 +
 
<texcode>
 
<texcode>
 
\starttext
 
\starttext
Line 45: Line 72:
 
\stoptext
 
\stoptext
 
</texcode>
 
</texcode>
 +
 +
<context>
 +
\setupcolors[state=start]
 +
\starttext
 +
Unnumbered text before.
 +
 +
\setupparagraphnumbering[state=start,style=italic,distance=0pt]
 +
This is the first numbered paragraph.
 +
 +
This is another paragraph. This is another
 +
paragraph. This is another paragraph.
 +
\setupparagraphnumbering[state=stop]
 +
 +
Unnambered text after.
 +
\stoptext
 +
</context>

Revision as of 07:18, 4 September 2005

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