我如何重新定义段落计数器,使其不显示所有上级计数器,而只显示段落计数器。我认为这可以通过 实现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
您可以使用scrjura
KOMA-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}
结果是: