25

给定一堆段落:

Para. A ...

Para. B ...

Para. C ...

如何让 LaTeX 自动为它们编号,即

1. Para. A. ...

2. Para. B. ...

3. Para. C. ...

我看过以下建议:

\newcounter{parnum}
\newcommand{\N}{%
   \noindent\refstepcounter{parnum}%
    \makebox[\parindent][l]{\textbf{\arabic{parnum}.}}}
% Use a generous paragraph indent so numbers can be fit inside the
% indentation space.
\setlength{\parindent}{2em}

从这里:comp.text.tex:Re:如何在 LaTeX 中为段落编号?

然后在每个要编号的段落前使用\N,即

\N Para. A. ...

\N Para. B. ...

\N Para. C. ...

我还看到了对Sarovarnumberpar的引用,但两者都被称为“不稳定”或“不可预测”,以及诸如“随机中断”之类的东西,这让我很警惕。

我想就什么可能是最好的行动方案提出一些意见,在这里,我认为这是一个值得讨论的话题。

感谢您对此的关注和关注。

编辑:我试过以下

\begin{enumerate}
\item Para No. 1
\item Para No. 2
...
\end{enumerate}

然而,它会导致排版问题,特别是因为我正在穿插部分标题ala。

\begin{enumerate}
\item Para No. 1
\item Para No. 2
\section{Part II}
\item Para No. 5
\item Para No. 6
...
\end{enumerate}

并且标题“第二部分”的部分有时会出现在页面的最底部(即它与以下文本不一致)。

4

4 回答 4

17

我认为有三种可能的解决方案(至少!)不涉及滚动您自己或其他人的宏,具体取决于您要执行的操作。

1 如果整个文档都需要编号,请使用\paragraph,这是一个较低级别的切片命令(如 \chapter、\section、\subsection 等)

有关更多信息,请参阅LaTeX wikibook

\setcounter{secnumdepth}{5}
...
\paragraph{If we want to} do something ... 

(您可能会发现这种过度杀伤/丑陋,因为它需要节和小节的正确嵌套结构而不是)

请注意,如果您使用 memoir 文档类(我毫不犹豫地推荐),则该\setcounter行变为\maxsecnumdepth{paragraph}

2 如果只是一小部分,请使用列表:

\begin{enumerate}
\item Para No. 1
\item Para No. 2
...
\end{enumerate} 

\begin{list}...\end{list{}3如果您想调整格式,可以使用通用列表 ( )。除了A Guide to LaTeX中的那篇文章之外,我还没有立即找到一个好的在线参考资料

于 2009-02-12T21:27:03.487 回答
4

就我而言,我最终通过重新定义一个\P像段落一样工作的新宏来解决这个问题。

\newcounter{paranum}
\newcommand{\P}{\vspace{10pt}\noindent\textbf{\refstepcounter{paranum}\theparanum}\textbf}

写一个新的“段落”我做

\P{Paragraph title No. 1} ...text...
...
\P{Paragraph title No. 2} ...text...

使枚举链接到我使用的部分

\newcounter{paranum}[section]
\newcommand{\P}{\vspace{10pt}\noindent\textbf{\thesection.\refstepcounter{paranum}\theparanum}\textbf}

我知道这实际上是拙劣的,但最终为我工作。

于 2012-06-24T14:01:47.463 回答
2

我相信另一种选择是ledmac包装。这是文档中的引用:

普通的 \label、\ref 和 \label \pageref 宏可以在编号文本中使用,并以熟悉的方式操作。例如,这是一种在编号文本中对段落进行编号的方法,然后除了行号和页码之外,还可以引用段落编号。

\newcounter{para} \setcounter{para}{0}
\newcommand{\newpara}{%
  \refstepcounter{para}%
  \noindent\llap{\thepar. }\quad}
\newcommand{\oldpara}[1]{%
  \noindent\llap{\ref{#1}. }\quad}

\newpara 和 \oldpara 的定义将数字放在左边距并且段落的第一行缩进。您现在可以编写如下内容:

\linenummargin{right}
\beginnumbering
\pstart
\newpara\label{P1} A paragraph about \ldots
\pend
  In paragraph~\ref{P1} the author \ldots
\pstart
\oldpara{P1} This has the same
             \edtext{number}{\Afootnote{\ref{P1} is the paragraph, not line}}
  as the first paragraph.
\pend
\endnumbering

但是,我自己从未尝试过。

于 2009-02-12T21:21:51.143 回答
2

这个问题的一个解决方案是使用由印度特里凡得琅河谷技术公司的 CV Radhakrishnan 编写的parano包。

我从以下网页知道这个解决方案 http://www.ub-filosofie.ro/~solcan/wt/gnu/n/np.html

于 2013-07-28T05:49:01.813 回答