Changes

Jump to navigation Jump to search
2,301 bytes added ,  07:35, 17 July 2023
m
remove dead mailing list link
This code was proposed by Taco to the list:== Standard Paragraph Numbering ==
<texcode>\newcounter\Paracount\setcounter\Paracount1ConTeXt has a built-in mechanism for paragraph numbering, which places numbers in the margin. This is accessed with {{cmd|setupparagraphnumbering}}.
\def\Paragraphnumber% 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 {\increment\Paracount \Paracount.~}\def\startParagraphs% {\par \begingroup \appendtoks \Paragraphnumber \to \everyparmodule|pararef}\def\stopParagraphs% {\par \endgroup}module described at [[Paragraph Referencing]].
<context source="yes">
\setuppapersize[A5]
\starttext
Unnumbered Some text in an unnumbered paragraph beforethe paragraph numbering starts.
\startParagraphssetupparagraphnumbering[state=start,style=italic,distance=0pt]This is the first numbered paragraph; it's shortThis 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. \startitemize[packed] \item an \item itemization\stopitemize
This is another paragraph. This is anotherparagraph. This is another A third numbered paragraph.\stopParagraphssetupparagraphnumbering[state=stop]
Unnambered text And, finally, an unnumbered paragraph afterthe paragraph numbering.
\stoptext
</texcodecontext>  == Paragraph Numbering in the Text ==
This produces 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}} macro. The following result:code was proposed by Taco on the mailing list.
<contextsource="yes" text="This produces the following result:">\setuppapersize[A6]
\newcounter\Paracount
\setcounter\Paracount1
 
\def\Paragraphnumber%
{\increment\Paracount
\Paracount.~}
\def\startParagraphsstartParagraphNumbers%
{\par \begingroup \appendtoks \Paragraphnumber \to \everypar}
\def\stopParagraphsstopParagraphNumbers%
{\par \endgroup}
\starttext
Unnumbered Some text in an unnumbered paragraph beforethe paragraph numbering starts. \startParagraphNumbersThis is the first numbered paragraph; it's short.
\startParagraphsThis is the first 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.
This is another paragraph. This is anotherparagraph. This is another A third numbered paragraph.\stopParagraphsstopParagraphNumbers
Unnambered text And, finally, an unnumbered paragraph afterthe paragraph numbering.
\stoptext
</context>
If you're happy == Combining Section Numbering with numbers in the margin, this is in-built ConTeXt way, with <cmd>setupparagraphnumbering</cmd>:Paragraph Numbering and Titles ==
Idris provided 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: <texcodecontext source="yes" text="The output from the previous code is:">\starttextdefineseparatorset [ParagraphNumber][.,] % no second decimal for susubparagraphs% \showframedefineseparatorset [ParagraphNumber][.,.] % second decimal for susubparagraphs \setupcolorsdefinecounter[state=startParagraphNumber]\setupparagraphnumbering[state=start,stylenumberseparatorset=italicParagraphNumber,distancecriterium=0ptall] \define\sectionParagraphNumber {{bloo\bf \incrementcounter[ParagraphNumber]% \convertedcounter[ParagraphNumber][numbersegments=1]}\quad} \define\subParagraphNumber {{\bf \input knuth incrementcounter[ParagraphNumber][2]% \convertedcounter[ParagraphNumber][numbersegments=1:2]}\section{blahquad} \input knuth define\par subsubParagraphNumber {{\bf \setupparagraphnumberingincrementcounter[ParagraphNumber][state=stop3]% \input tufte convertedcounter[ParagraphNumber][numbersegments=1:3]}\parquad} \setupparagraphnumberingsetuphead[section] [statestyle=\bf, alternative=text, criterium=all, number=startno,color textcommand=red\ParagraphNumber, insidesection=\hskip-0.49em]% adjust space after title \dorecurse{4}{setuphead[subsection] [style=\input tufte bf, alternative=text, criterium=all, number=no, textcommand=\par}subParagraphNumber, insidesection=\stoptext</texcode>hskip-0.49em] % adjust space after title
<context>\setuphead[subsubsection] [style=\setupcolorsbf, alternative=text, criterium=all, number=no, textcommand=\subsubParagraphNumber, insidesection=\hskip-0.49em] % adjust space after title \setupwhitespace[state=startline]
\starttext
Unnumbered text before\startsection[title={Text.}]\input ward\startsubsection\input ward\setupparagraphnumberingstartsubsubsection[statetitle=start,style=italic,distance=0pt{Text.}]This is the first numbered paragraph.\input ward\stopsubsubsectionThis is another paragraph. This is anotherparagraph. This is another paragraph.\stopsubsection\setupparagraphnumbering[state=stop]stopsection
Unnambered text after.\startsection\input ward\startsubsubsection\input ward\stopsubsubsection\stopsection
\stoptext
</context>
 
[[Category:Basics]]

Navigation menu