本文介绍了LaTeX中如何为一个段落编号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出很多段落:

Para. A ...

Para. B ...

Para. C ...

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

How can one have LaTeX automatically number them, i.e.

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:回复:如何在LaTeX中为段落编号吗?

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

Then use \N in front of every paragraph-to-be-numbered, i.e.

\N Para. A. ...

\N Para. B. ...

\N Para. C. ...

我还看到了 Sarovar numberpar ,但两者均被称为不稳定"或不可预测",还有随机中断"之类的东西,这让我很警惕.

I've also seen references to Sarovar and numberpar, but both are referred to as "unstable" or "unpredictable", and things like "randomly breaks", which makes me wary.

我想在这里提出一些最佳做法的意见,我认为这是一个值得讨论的话题.

I'd like some input on what may be the best course of action, here, and I think it's a topic worth some discussion.

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

Thank you for your interest and attention to this.

编辑:我已经尝试了以下

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

但是它会导致排版问题,主要是因为我在节标题ala中穿插了

However it results in typesetting problems, notably because I am interspersing section headings ala.

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

第二部分"标题有时会出现在页面的最底部(即与下面的文字不符).

and the section heading "Part II" will sometimes end up at the very bottom of the page (i.e. it doesn't keep with the following text).

推荐答案

我认为存在三种可能的解决方案(至少!),这些解决方案不涉及滚动您自己的宏或其他人的宏,具体取决于您要尝试的宏做.

I think there are three possible solutions (at least!) which don't involve rolling your own or someone else's macro, depending on exactly what you are trying to do.

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

1 If the numbering is required throughout the document, use \paragraph, which is a lower-level sectioning command (like \chapter, \section, \subsection, etc.)

有关更多信息,请参见 LaTeX Wikibook .

See the LaTeX wikibook for more information.

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

(您可能会觉得这种做法太过残酷/丑陋,因为它不需要节和小节的正确嵌套结构)

(You may find this overkill/ugly, because it needs a properly nested structure of sections and subsections not to be)

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

Note that if your using the memoir document class (which I recommend unhesitatingly), the \setcounter line becomes \maxsecnumdepth{paragraph}

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

2 If it's just a small piece, use a list:

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

3如果要调整格式,则可以使用广义列表(\begin{list}...\end{list{}).除了 LaTeX指南

3 Or a generalized list (\begin{list}...\end{list{}) if you want to tweak the formatting. I haven't immediately been able to find a good online reference for this, other than the piece in A Guide to LaTeX

这篇关于LaTeX中如何为一个段落编号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 07:09