如何对(左边距)段落而不是行进行编号?

如何对(左边距)段落而不是行进行编号?

我知道 lineno 包用于行号,但是由于英语语言编辑,我的行号可能会改变,但我的段落可能不会改变:是否可以对段落而不是行进行编号(在左边距),这样我就可以将某些文本引用为“第 2.2 节,第 3 段”?

我看见如何在页边空白处对段落(和章节)进行编号?但是章节编号和段落编号在那里放在一起,而我正在寻找更像 lineno 的东西,在边缘上我只有段落编号而不是行数。

答案1

您可以使用parano其他帖子中提到的包,以及以下几个修复和自定义。现在已更新以使用hyperref

示例输出

\documentclass{article}

\usepackage{parano}% http://www.sci.usq.edu.au/staff/braithwa/parano.sty
%\usepackage{hyperref}

%Fixes to parano.sty
\makeatletter

\newcommand{\paranospace}{\hfill}% Introduced for more flexible customisation

\renewcommand{\@parano}{%
  \everypar{\setbox0\lastbox% Fixes first paragraph indent problem
    \refstepcounter{parano}%
    \hbox to \paranoboxwidth{\prepara\theparano\paranospace}\postpara}}

\def\@@parano[#1]{\setcounter{parano}{#1}\addtocounter{parano}{-1}%
   \@parano}% To avoid code duplication

\makeatother

%Customizations for this example

\renewcommand{\prepara}{\hss}
\renewcommand{\postpara}{\hspace{\parindent}\ignorespaces}
\renewcommand{\paranospace}{\quad\hfill}
\setlength{\paranoboxwidth}{0pt}

\usepackage{lipsum}

\begin{document}

\parano

\section{Test}

\lipsum[1-2]

Here is a paragraph to be labelled.\label{mypara}

\lipsum[3]

The labelled paragraph was \ref{mypara}.

\end{document}

如果你希望每个部分内的段落都编号,那么添加

\renewcommand\theparano{\arabic{parano}}
\makeatletter\@addtoreset{parano}{section}\makeatother

回到序言。

相关内容