Open main menu

Changes

m
no edit summary
== Standard Paragraph Numbering ==
ConTeXt has a built-in mechanism for paragraph numbering, which places numbers in the margin. This is accessed with <{{cmd>|setupparagraphnumbering</cmd>, as in this example, which also sets the number style to italic rather than the default roman}}.
The mechanism numbers ‘TeX paragraphs’, so a formula or an itemization item will get its own number. For ‘block of thought’ paragraphs that can contain multiple TeX paragraphs, see the {{module|pararef}} module described at [[Paragraph Referencing]]. <texcodecontext source="yes">\setuppapersize[A5]
\starttext
Some text in an unnumbered paragraph before the paragraph numbering starts.
line numbers.
A third numbered paragraph.\setupparagraphnumberingstartitemize[state=stoppackedAnd, finally, \item an unnumbered paragraph after the paragraph numbering.\stoptext</texcode> <context>\setuplayout[scale=0.8,width=13cm] \starttextSome text in an unnumbered paragraph before the paragraph numbering starts.item itemization\setupparagraphnumbering[state=start,style=italic,distance=0pt]This is the first numbered paragraph; it's short. This is another numbered paragraph. It's long enough to wrap around ontomore than one line, so as to show that these are paragraph numbers and notline numbers.stopitemize
A third numbered paragraph.
== Paragraph Numbering in the Text ==
An alternate way of numbering paragraphs is to place the numbers in the running text, rather than in the margin. ConTeXt doesn't have a built-in way to do this, but it's not difficult to add a method using the <{{cmd>|everypar</cmd> }} macro. The following code was proposed by Taco on the mailing list.
<texcodecontext source="yes" text="This produces the following result:">\setuppapersize[A6]
\newcounter\Paracount
\setcounter\Paracount1
And, finally, an unnumbered paragraph after the paragraph numbering.
\stoptext
</texcodecontext>
This produces the following result/== Combining Section Numbering with Paragraph Numbering and Titles ==
Idris provided [https://mailman.ntg.nl/pipermail/ntg-context/2017/089454.html a modified version] of an enumerated-paragraphs sample provided by Wolfgang. In the modified version, section numbering is combined with paragraph enumeration, with titles optional: <contextsource="yes" text="The output from the previous code is:">\setuplayoutdefineseparatorset [ParagraphNumber][scale=0.8,width=13cm]% no second decimal for susubparagraphs% \newcounterdefineseparatorset [ParagraphNumber][.,.] % second decimal for susubparagraphs \Paracountdefinecounter[ParagraphNumber][numberseparatorset=ParagraphNumber,criterium=all] \setcounterdefine\Paracount1ParagraphNumber {{\defbf \Paragraphnumberincrementcounter[ParagraphNumber]% \convertedcounter[ParagraphNumber][numbersegments=1]}\quad} \define\subParagraphNumber {{\incrementbf \Paracount incrementcounter[ParagraphNumber][2]% \convertedcounter[ParagraphNumber][numbersegments=1:2]}\Paracount.~quad} \defdefine\startParagraphNumbers%subsubParagraphNumber {{\par bf \begingroup incrementcounter[ParagraphNumber][3]% \appendtoks convertedcounter[ParagraphNumber][numbersegments=1:3]}\Paragraphnumber quad} \to setuphead[section] [style=\everypar}bf, alternative=text, criterium=all, number=no, textcommand=\defParagraphNumber, insidesection=\stopParagraphNumbershskip-0.49em] %adjust space after title \setuphead[subsection] {[style=\bf, alternative=text, criterium=all, number=no, textcommand=\par subParagraphNumber, insidesection=\endgroup}hskip-0.49em] % adjust space after title
\setuphead[subsubsection]
[style=\bf,
alternative=text,
criterium=all,
number=no,
textcommand=\subsubParagraphNumber,
insidesection=\hskip-0.49em] % adjust space after title
\setupwhitespace[line]
\starttext
Some text in an unnumbered paragraph before the paragraph numbering starts\startsection[title={Text.}]\input ward\startsubsection\startParagraphNumbersinput wardThis is the first numbered paragraph; it's short\startsubsubsection[title={Text.}]\input wardThis is another numbered paragraph. It's long enough to wrap around onto\stopsubsubsectionmore than one line, so as to show that these are paragraph numbers and not\stopsubsectionline numbers.\stopsection
A third numbered paragraph.\startsection\input ward\stopParagraphNumbersstartsubsubsection\input wardAnd, finally, an unnumbered paragraph after the paragraph numbering.\stopsubsubsection\stopsection
\stoptext
</context>
 
[[Category:Basics]]