如何在 LaTeX 中为段落编号? [英] How can one number paragraphs in LaTeX?

查看:335
本文介绍了如何在 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. ...

我看到了以下建议:


ewcounter{parnum}

ewcommand{N}{%
   
oindent
efstepcounter{parnum}%
    makebox[parindent][l]{	extbf{arabic{parnum}.}}}
% Use a generous paragraph indent so numbers can be fit inside the
% indentation space.
setlength{parindent}{2em}

从这里:comp.text.tex: Re: How我要在 LaTeX 中给段落编号吗?

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

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

N Para. A. ...

N Para. B. ...

N Para. C. ...

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

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.

编辑:我尝试了以下方法

egin{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.

egin{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)

请注意,如果您使用 memoir 文档类(我毫不犹豫地推荐),则 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:

egin{enumerate}
item Para No. 1
item Para No. 2
...
end{enumerate} 

3 如果您想调整格式,可以使用通用列表 (egin{list}...end{list{}).除了 LaTeX 指南

3 Or a generalized list (egin{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 中为段落编号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆