如何在 ConteXt 中继续 \startParagraphNumbers

如何在 ConteXt 中继续 \startParagraphNumbers

我刚开始使用 ConteXt 排版一些法律文件。这些文档中的段落需要按顺序编号。不过我在这里找到了一个代码上下文引用 \startParagraphNumbers,问题是每次中断时编号都会重置(见下文)

在此处输入图片描述

我没有找到解决方案(除了手动输入数字或学习 lua?这超出了我的能力范围)。希望你们能帮助我。谢谢。

(PS:我曾经使用过 parano.sty/LateX,但最近改用了 ConteXt,因为它看起来更整洁)

最小样本。

\definepapersize[pb][width=8.5in,height=13in]
\setuppapersize[pb]

\setuppagenumbering[alternative=singesided,location={footer,right}]

\newcounter\Paracount
\setcounter\Paracount
\def\Paragraphnumber%
   {\increment\Paracount
    \Paracount.~ }
\def\startParagraphNumbers%
   {\par \begingroup \appendtoks \Paragraphnumber \to \everypar}
\def\stopParagraphNumbers%
   {\par \endgroup}



\definefontfamily [myfamily][rm][XCharter][features={default,quality}]
\definefontfamily [myfamily] [ss][Calibre][features={default,quality}]
\definefontfamily [myfamily] [mm][pagella][features={default,quality}]
\setupbodyfont [myfamily,10pt]

\setupalign[hz,hanging]
\setupindenting[yes,medium,first]
\setupwhitespace[medium]

\starttext

\noindent
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc feugiat in sapien nec efficitur. 

\startParagraphNumbers
Donec at mauris ut orci consequat vulputate. Proin vestibulum magna commodo, tincidunt nulla non, fermentum risus. 

Nulla vitae ornare tortor. Suspendisse potenti. Sed sit amet feugiat orci, quis elementum orci.  
\stopParagraphNumbers

\startitemize[2,packed]
\item Nam ut ligula justo.
\item Integer a lacus fermentum, tincidunt libero id,
\item blandit sem. Sed gravida mauris ac sem finibus, 
\stopitemize

\startParagraphNumbers
ac suscipit diam dignissim. Vivamus tristique tempor nisi, eget vehicula velit maximus eu. 

Phasellus vel ornare est, sit amet volutpat nunc. Donec est nulla, porttitor a convallis vitae, pulvinar ut ligula. 
\stopParagraphNumbers

\stoptext

答案1

我可能不应该回答这个问题,因为我从来没有使用过 ConTeXt,但是:

\def\pauseParagraphNumbers{\xdef\savedParacount{\Paracount} \par\endgroup}
\def\resumeParagraphNumbers{\par \begingroup \let\Paracount=\savedParacount \appendtoks \Paragraphnumber \to \everypar}

你可以像这样使用:

\definepapersize[pb][width=8.5in,height=13in]
\setuppapersize[pb]

\setuppagenumbering[alternative=singesided,location={footer,right}]

\newcounter\Paracount
\setcounter\Paracount
\def\Paragraphnumber%
   {\increment\Paracount
    \Paracount.~ }
\def\startParagraphNumbers%
   {\par \begingroup \appendtoks \Paragraphnumber \to \everypar}
\def\stopParagraphNumbers%
   {\par \endgroup}    

\def\pauseParagraphNumbers{\xdef\savedParacount{\Paracount} \par\endgroup}
\def\resumeParagraphNumbers{\par \begingroup \let\Paracount=\savedParacount  \appendtoks  \Paragraphnumber \to \everypar}


\definefontfamily [myfamily][rm][XCharter][features={default,quality}]
\definefontfamily [myfamily] [ss][Calibre][features={default,quality}]
\definefontfamily [myfamily] [mm][pagella][features={default,quality}]
\setupbodyfont [myfamily,10pt]

\setupalign[hz,hanging]
\setupindenting[yes,medium,first]
\setupwhitespace[medium]

\starttext

\noindent
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc feugiat in sapien nec efficitur.

\startParagraphNumbers
Donec at mauris ut orci consequat vulputate. Proin vestibulum magna commodo, tincidunt nulla non, fermentum risus.

Nulla vitae ornare tortor. Suspendisse potenti. Sed sit amet feugiat orci, quis elementum orci.
\pauseParagraphNumbers

Just to see:
\savedParacount

\startitemize[2,packed]
\item Nam ut ligula justo.
\item Integer a lacus fermentum, tincidunt libero id,
\item blandit sem. Sed gravida mauris ac sem finibus,
\stopitemize

\resumeParagraphNumbers
ac suscipit diam dignissim. Vivamus tristique tempor nisi, eget vehicula velit maximus eu.

Phasellus vel ornare est, sit amet volutpat nunc. Donec est nulla, porttitor a convallis vitae, pulvinar ut ligula.    
\pauseParagraphNumbers

\startitemize[2,packed]
\item Nam ut ligula justo.
\item Integer a lacus fermentum, tincidunt libero id,
\item blandit sem. Sed gravida mauris ac sem finibus,
\stopitemize

\resumeParagraphNumbers
ac suscipit diam dignissim. Vivamus tristique tempor nisi, eget vehicula velit maximus eu.

Phasellus vel ornare est, sit amet volutpat nunc. Donec est nulla, porttitor a convallis vitae, pulvinar ut ligula.    
\stopParagraphNumbers

\stoptext

答案2

您可以使用\setupparagraphintro在每个段落开头插入数字。使用reset关键字可以禁用数字插入。

\definelabel[parnumber][text=,headstyle=]

\definestartstop
  [ParagraphNumbers]
  [before={\setupparagraphintro[each][\parnumber~]},
   after={\setupparagraphintro[reset]}]

\setupindenting[yes,medium,first]
\setupwhitespace[medium]

\starttext

\noindentation
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc feugiat in sapien nec efficitur. 

\startParagraphNumbers
Donec at mauris ut orci consequat vulputate. Proin vestibulum magna commodo, tincidunt nulla non, fermentum risus. 

Nulla vitae ornare tortor. Suspendisse potenti. Sed sit amet feugiat orci, quis elementum orci.  
\stopParagraphNumbers

\startitemize[2,packed]
\item Nam ut ligula justo.
\item Integer a lacus fermentum, tincidunt libero id,
\item blandit sem. Sed gravida mauris ac sem finibus, 
\stopitemize

\startParagraphNumbers
ac suscipit diam dignissim. Vivamus tristique tempor nisi, eget vehicula velit maximus eu. 

Phasellus vel ornare est, sit amet volutpat nunc. Donec est nulla, porttitor a convallis vitae, pulvinar ut ligula. 
\stopParagraphNumbers

\stoptext

相关内容