How can one number paragraphs in LaTeX?

前端 未结 4 680
北恋
北恋 2021-02-05 04:35

Given a bunch of paragraphs:

Para. A ...

Para. B ...

Para. C ...

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

1. Pa         


        
相关标签:
4条回答
  • 2021-02-05 04:46

    I believe another option is the ledmac package. Here is a quote from the documentation:

    The normal \label, \ref and \label \pageref macros may be used within numbered text, and operate in the familiar fashion. As an example, here is one way of numbering paragraphs in numbered text, and then being able to refer to the paragraph numbers, in addition to line and page numbers.

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

    The definitions of \newpara and \oldpara put the numbers in the left margin and the first line of the paragraph is indented. You can now write things like:

    \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
    

    I've never attempted this myself, however.

    0 讨论(0)
  • 2021-02-05 04:49

    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 If the numbering is required throughout the document, use \paragraph, which is a lower-level sectioning command (like \chapter, \section, \subsection, etc.)

    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)

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

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

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

    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

    0 讨论(0)
  • 2021-02-05 05:02

    In my case I ended up solving this by redefining a new macro \P that works like a paragraph.

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

    To write a new "paragraph" I do

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

    To make the enumeration be linked to the section I use

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

    I know that this is actually botched-up but ended up working for me.

    0 讨论(0)
  • 2021-02-05 05:07

    A solution to this problem is the use of the package parano, written by CV Radhakrishnan from River Valley Technologies, Trivandrum, India.

    I know this solution from the following webpage http://www.ub-filosofie.ro/~solcan/wt/gnu/n/np.html

    0 讨论(0)
提交回复
热议问题