如何在没有更高级别计数器的情况下对段落进行编号?

如何在没有更高级别计数器的情况下对段落进行编号?

我如何重新定义段落计数器,使其不显示所有上级计数器,而只显示段落计数器。我认为这可以通过 实现titlesec

我希望每个段落都按§1、§2、§3 等进行编号。

请参阅下面的最小示例:

\documentclass[12pt]{article}
\usepackage{fontspec}

\newcounter{paragraphstep}
\newcommand{\paracount}{%
        \stepcounter{paragraphstep}%
        \theparagraphstep}
        \setcounter{secnumdepth}{6}

\begin{document}

\paragraph{}\label{Personal Statement}
San Francisco is a city in California. See paragraph \ref{Personal Statement}.

\end{document}

该问题与以下内容相关:

答案1

默认情况下,段落在小节内编号,每个小节从 1 开始。如果您只是希望更改段落编号的打印表示,那么您只需

\renewcommand{\theparagraph}{\S\arabic{paragraph}}
\setcounter{secnumdepth}{4}

如果您希望整个文档中的段落也连续编号,那么您可以使用chngcntr软件包的命令\counterwithout撤消重置,如下所示:

示例输出

\documentclass[12pt]{article}

\usepackage{chngcntr}
\counterwithout{paragraph}{subsubsection}
\renewcommand{\theparagraph}{\S\arabic{paragraph}}
\setcounter{secnumdepth}{4}

\begin{document}

\section{First section}

\paragraph{}\label{Personal Statement}
San Francisco is a city in California.

\subsection{A subsection}

\paragraph{}
San Francisco is a city in California.  See paragraph \ref{Personal
Statement}.

\subsubsection{A subsubsection}

\paragraph{}
San Francisco is a city in California.

\section{Second section}

\paragraph{}
San Francisco is a city in California. See paragraph \ref{Personal Statement}.

\paragraph{}
San Francisco is a city in California.


\end{document}

添加以回应评论要调整数字等后的间距,使用titlesec包可能是最简单的方法。这里涉及两个命令:\titleformat\titlespacing。如果您不打算为段落添加标题,则\titlespacing以下命令就足够了。该\titleformat命令确保段落标题中的单词也得到适当处理:

示例输出

\documentclass[12pt]{article}

\usepackage{chngcntr}
\counterwithout{paragraph}{subsubsection}
\renewcommand{\theparagraph}{\S\arabic{paragraph}}
\setcounter{secnumdepth}{4}

\usepackage{titlesec}
\titleformat{\paragraph}[runin]{\normalfont\bfseries}{\theparagraph}{\wordsep}{}
\titlespacing{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{\wordsep}

\begin{document}

\section{First section}

\paragraph{}\label{Personal Statement}
San Francisco is a city in California.

\subsection{A subsection}

\paragraph{}
San Francisco is a city in California.  See paragraph \ref{Personal
Statement}.

\subsubsection{A subsubsection}

\paragraph{}
San Francisco is a city in California.

\section{Second section}

\paragraph{}
San Francisco is a city in California. See paragraph \ref{Personal Statement}.

\paragraph{With title}
San Francisco is a city in California.

\end{document}

给出的论据\titlespacing如下:

  • 部分命令 =\paragraph
  • 左缩进 =0pt
  • 垂直跳过以上 =3.25ex plus 1ex minus .2ex文章类别的标准值
  • 最后的分隔 =\wordsep普通的单词空格

对于\titleformat规范是

  • 部分命令 =\paragraph
  • style =runin标题与文本包含在同一段落中
  • format =\normalfont\bfseries用于设置标题的样式
  • 标签 =\theparagraph章节编号的打印表示
  • sep =\wordsep是标签和标题之间的空格(如果存在)
  • 代码之前 = 空

答案2

您可以使用scrjuraKOMA-Script 包。

一个例子可能是(正如@harish 在他的评论中所要求的;-):

\documentclass[%
  ngerman
 ,paper=a4
 ,fontsize=12pt
 ,parskip=half-
 ,pagesize
 ,numbers=noenddot
]{scrartcl}% scrreprt scrartcl

\usepackage{babel}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[%
  juratotoc%=1              % juratotoc=0 0 chapter, 1 section
 ,paragraphmark=forceboth
 ,juratocnumberwidth=2.5em
]{scrjura}  

\usepackage{enumerate}

\makeatletter
% to get rid of a warning ...
\providecommand*{\toclevel@cpar}{0}
\makeatother


\begin{document}

\subject{Subject}
\title{Title}
\subtitle{Subtitle}
\author{}   % no author: {} empty
%\date{}    % no date

\maketitle  % setzt den Titel der Satzung

\addsec{Preface}
A preface, if you need it.


%\clearpage 
\appendix % Letters instead of numbers

\section{Section One}
\begin{contract}
\Paragraph{title={Title first paragraph}}
The content of first paragraph.

A list of posibilities:
\begin{enumerate}[\qquad a)]
  \item first.
  \item second.
  \item third.
\end{enumerate}

The content of third paragraph.
\end{contract}

\section{Section Two}
\begin{contract}
\Paragraph{title={Title first paragraph}}
The content of first paragraph.
\end{contract}

\end{document} 

结果是:

在此处输入图片描述

相关内容