目录显示(linguex)段落编号

目录显示(linguex)段落编号

我正在撰写一份带有编号段落的法律文件,我希望目录列出段落编号,而不是页码。我使用 来linguex.sty计数段落(在下面的 MWE 中,该命令\ex.使用内部计数器生成按顺序编号的段落ExNo)。

例如,如果第 1 节从第 1 段到第 13 段,第 2 节从第 14 段到第 19 段,第 3 节从第 20 段到第 24 段,那么我希望目录如下所示:

第1节 ............ 1

第2部分 ............ 14

第3节 ...... 20

在每个部分的开头,段落计数器比我希望在目录中显示的数字少 1。如果我可以将页码替换为:

\stepcounter{ExNo}\theExNo\addtocounter{ExNo}{-1}

那么我应该得到正确的结果。我已经tocloft.sty在下面的 MWE 中进行了各种其他调整,但找不到允许我进行这种特定更改的包参数。(我认为答案是可行的,但根本没有效果。)

\documentclass[12pt]{report}
\usepackage{mathptmx}
\usepackage{linguex}
\usepackage{tocloft}
    \renewcommand{\cftsecfont}{\scshape}
    \addtocontents{toc}{\cftpagenumbersoff{chapter}}
    \renewcommand*\thesection{\sc\roman{section}}
    \renewcommand*\thechapter{\sc PART \Roman{chapter}}

\usepackage{titlesec}
    \titleformat{\chapter}[hang]{\normalfont\scshape\filcenter}{PART \thechapter    }{0em}{}
    \titlespacing{\chapter}{0pt}{0pt}{1.5ex}
    \titleformat{\section}[hang]{\normalfont\scshape\filcenter}{\roman{section}.}{0.35em}{}
 
\usepackage{chngcntr}
    \counterwithout{ExNo}{chapter}

\begin{document}

\setlength{\Exlabelsep}{0pt}
\setlength{\Exindent}{-2em}
\setlength{\Exlabelwidth}{2em}
\renewcommand{\ExLBr}{}
\renewcommand{\ExRBr}{.}
\renewcommand{\SubExLBr}{(}
\renewcommand{\SubExRBr}{)}
\setlength{\SubExleftmargin}{1.75em}%
\renewcommand{\theExRBr}{}
\renewcommand{\theExLBr}{}
\renewcommand{\firstrefdash}{}

\tableofcontents

\chapter{}

\section{hier geht's los}
 
\ex. Sauerkraut

\ex. Senfgurken

\section{hier geht's weiter}

\ex. Kaffee \dots

\ex. \dots\ und Kuchen!

\chapter{}

\section{was folgt}

\ex. Bauch-

\ex. -krampf

\end{document}

答案1

这是一个可能的解决方案。每个\section命令都会在.toc文件上写入计数器的状态ExNo,并\l@section重新定义为使用该值而不是页码。

\documentclass[12pt]{report}

\usepackage{linguex}
\usepackage{tocloft}
\usepackage{etoolbox}
\usepackage{titlesec}

\makeatletter
\preto\section{\addtocontents{toc}{\protect\l@parnum{\number\numexpr\value{ExNo}+1\relax}}}
\def\l@parnum#1{\def\current@parnum{#1}}
\def\current@parnum{}
\let\tocloft@l@section\l@section
\def\l@section#1#2{\tocloft@l@section{#1}{\current@parnum}}
\makeatother


\renewcommand{\cftsecfont}{\scshape}
\renewcommand{\cftchapfont}{\scshape}
\addtolength\cftchapnumwidth{3pc}
\renewcommand{\cftchappresnum}{Part~}
\addtocontents{toc}{\cftpagenumbersoff{chapter}}


\titleformat{\chapter}[hang]
  {\normalfont\scshape\filcenter}
  {PART \thechapter}
  {0em}
  {}
\titlespacing{\chapter}
  {0pt}
  {0pt}
  {1.5ex}
\titleformat{\section}[hang]
  {\normalfont\scshape\filcenter}
  {\roman{section}.}
  {0.35em}
  {}

\usepackage{chngcntr}
\counterwithout{ExNo}{chapter}

\begin{document}

\setlength{\Exlabelsep}{0pt}
\setlength{\Exindent}{-2em}
\setlength{\Exlabelwidth}{2em}
\renewcommand{\ExLBr}{}
\renewcommand{\ExRBr}{.}
\renewcommand{\SubExLBr}{(}
\renewcommand{\SubExRBr}{)}
\setlength{\SubExleftmargin}{1.75em}%
\renewcommand{\theExRBr}{}
\renewcommand{\theExLBr}{}
\renewcommand{\firstrefdash}{}

\tableofcontents

\chapter{}

\section{hier geht's los}

\ex. Sauerkraut

\ex. Senfgurken

\section{hier geht's weiter}

\ex. Kaffee \dots

\ex. \dots\ und Kuchen!

\chapter{}

\section{was folgt}

\ex. Bauch-

\ex. -krampf

\end{document}

在此处输入图片描述

最好不要在诸如\thechapter或 之类的命令中添加格式指令\thesection。 无论如何,不​​要使用\scbut \scshape

答案2

这是一个 MWE,它可以执行本机编号(逻辑)段落,就像一种法律论文模板,并且(如果需要)可以使用它们生成基本的目录。(“基本的”,因为表格和法规的列表,如 bl-OSCOLA 已经描述了该方法,比传统的非法律目录(无论如何对于法律论文和类似论文)更实用。)

基本上,它只是一个计数器,rerfstepcounter每次使用时都会增加。非常简单。

它用于fontspec系统字体,所以用 xelatex 进行编译。

个人偏好:有趣的是,使用两个不同比例和方法的数字导航参考系统(编号标题与编号文本)太令人困惑了,我不得不主动忽略其中一个才能使用另一个,所以我关闭了标题标签。如果您使用编号标题,请随意注释掉代码的这些部分并重新打开它们。

\documentclass[12pt,a4paper]{article}

\title{Numbered Paragraphs}
\author{MWE}
\date{23-Nov-2019}

\usepackage{graphicx}
\usepackage[svgnames]{xcolor}
\usepackage{fontspec}
\usepackage{mdframed}
\usepackage{capt-of}

%change fonts as desired
\setmainfont{Noto Serif}%TeXGyreTermes}
\setmonofont{Noto Sans Mono}[Colour=blue]

%sample text
\newcommand\sampletext{This is some sample text. }

%numbered paragraphs
\newcounter{parno}% numbered paragraph (logical paragraph)

%default format = nothing
\newcommand\parnumformat[1][]{#1}
\renewcommand{\theparno}{\arabic{parno}}%

\newcommand\p[1][\par]{%
    #1%
    \refstepcounter{parno}%
    {\parnumformat\noindent [\theparno ]}%
    \ % 
    \paradef{\definnamea\definnameb\definnamec\theparno}%auto cross-ref label
    }% 


%numbered paragraphs cross-referencing method, automatic and manual
\newcommand\definnametext{para}
\newcommand\definnamea{para}
\newcommand\definnameb{:}
\newcommand\definnamec{ref}
%auto label is done inside the \p command
%manual label:
\newcommand{\paradef}[1]{\label{#1}}
%manual reference:
\newcommand\pararef[1]{\definnametext\ [\ref{#1}]}
%auto reference:
\newcommand\pararefauto[1]{\definnametext\ [\ref{\definnamea\definnameb\definnamec#1}]}



%for legibility
\setlength{\parskip}{1.5ex plus 0.8ex minus 0.8ex}

%colophon]
\newcommand\colophon{%
\vspace{5pt}
\bigskip
\hrule
\par \ 
\begin{center}
{\small * End of Document *}
\par 
\end{center}
}

%blank out the number (and spacing)
%paragraph numbers will carry the ref load
\usepackage{titlesec}
\titlelabel{}

\titleformat{name=\section}
 {\normalfont\Large\bfseries}
 {}%prefix to text: empty means no numbers appear
 {1ex}%sep
 {\color{red}}%formatting to apply to text



\usepackage{titletoc}
%stop heading numbers appearing in ordinary TOC
\renewcommand{\thesection}{}
\renewcommand{\thesubsection}{}
\renewcommand{\thesubsubsection}{}


\newcommand\doshortrule{\vspace{1ex}\noindent\hfil\rule{0.4\textwidth}{0.4pt}\hfil}


%===================================
%Custom table of contents
%Create tc2 entries: alternative TOC, using (current) parno

%open the file and prepare it
\newcommand\openxtoc{
\newwrite\fb
\immediate\openout\fb=\jobname.tc2
\immediate\write\fb{\string\section*{Contents}}
\immediate\write\fb{\string\hfill\string\textsc{[Para]}\string\par}
}


% put tc2 TOC (if any) into the text stream
\newcommand\doprinttoc{%
    \IfFileExists{\jobname.tc2}{%
        \input{\jobname.tc2}% read in info from previous run
    }%true
{\typeout{Nothing there: \jobname.tc2}%
}% false
        \openxtoc %prepare for output on this run
}%doprintindex

%update tc2 TOC when a heading is activated
\newcommand\ssection[1]{%
\section{#1}
\addtocounter{parno}{1}
\immediate\write\fb{#1 \string\dotfill\string\hspace{1pc} [\theparno]\string\par}
\addtocounter{parno}{-1}
}

\newcommand\ssubsection[1]{%
\subsection{#1}
\addtocounter{parno}{1}
\immediate\write\fb{\string\small \string\hspace{1pc}#1 \string\dotfill\string\hspace{1pc} [\theparno]\string\par}
\addtocounter{parno}{-1}
}

\newcommand\ssubsubsection[1]{%
\subsubsection{#1}
\addtocounter{parno}{1}
\immediate\write\fb{\string\small \string\hspace{2pc}#1 \string\dotfill\string\hspace{1pc} [\theparno]\string\par}
\addtocounter{parno}{-1}
}

%close off the tc2 TOC
\newcommand\closextoc{
\immediate\closeout\fb
}

\AtEndDocument{\closextoc}



%===================================
\begin{document} 
\maketitle
\doshortrule
%%\tableofcontents
%\addtocontents{toc}{~\hfill\textsc{[Para]}\par} 
\doprinttoc
\listoffigures
\addtocontents{lof}{~\hfill\textsc{Page}\par}

\doshortrule

\ssection{Introduction}
\p Numbered headings and a flow of unadorned text are sufficient for most technical and professional material. 
\p For legal matters, to save time in locating a word or phrase or sentence, more precision in pinpointing text is required, so paragraph numbering has come into play\footnote{And numbered paragraphs also form part of the Medium Neutral Citation (MNC) method.}. And headings are not so important (in fact, unless the tract is extremely long, they are often dispensed with altogether). 

\ssection{Numbered paragraphs}
\p With a new command\footnote{Short, to save typing.}, \verb|\p|, the paragraphs are now numbered, logical style.

Physical paragraphs (like this one) remain as they are\footnote{Note the indentation, as well.} ...

\p ... but logical paragraphs are numbered. (Note that the paragraph numbering is sequential for the whole document.) 
\p The \verb|\par| command is still available for use: occasionally, after a long citation, a concluding observation might be needed, and that can be visibly set off from the quotation by a par, without making a new numbered paragraph out of it.
\p \paradef{sec} To facilitate with building the table of contents (see \pararef{toc}), three sectioning commands have been augmented, to do the usual heading work, plus output TOC data -- they are: 
\begin{itemize}
\item \verb|\ssection|
\item \verb|\ssubsection| 
\item \verb|\ssubsubsection| 
\end{itemize}


\p \paradef{printtoc} To print a plain table of contents which has paragraph numbers instead of page numbers, use \verb|\doprinttoc| at the start of the document\footnote{That is, after \texttt{\textbackslash begin\{document\}}.} instead of \verb|\tableofcontents|.


\ssubsubsection{The \textbackslash p command}
\p\paradef{xys} As a sidenote, this paragraph has a cross-reference label set\footnote{With the \texttt{\textbackslash paradef\{\}} command}. Remember this for when we get to \pararef{train}.
\p The \texttt{\textbackslash p} command complex has the following structure:

%no float
%\begin{figure}
\begin{mdframed}[%
outerlinewidth = 2 ,%
roundcorner = 10 pt ,%
leftmargin = 10 ,%
rightmargin = 10 ,%
backgroundcolor = yellow!40 ,%
outerlinecolor = blue!70!black ,%
innertopmargin = \topskip ,%
splittopskip = \topskip ,%
]
\begin{verbatim}
  % Numbered Paragraphs ============= 
  %define a new counter
\newcounter{parno}
  %typeset with square brackets
\renewcommand{\theparno}{\arabic{parno}}   
  %default format hook = nothing
\newcommand\parnumformat[1][]{#1}
  %\p command for logical paragraphs: 
  % 1. insert a \par (default logical separator)
  % 2. step the counter
  % 3. typeset the formatted version 
  %            (with no indent)
  % 4. with a space
  % 5. add a label
\newcommand\p[1][\par]{%
   #1%
   \refstepcounter{parno}%for cross-referencing
    {\parnumformat\noindent[\theparno ]}%
    \ %space
    %auto cross-ref label
    \paradef{\definnamea\definnameb\definnamec\theparno}
    }% 
 % adjust spacing between paragraphs, 
  %            for legibility
\setlength{\parskip}{1.5ex plus 0.8ex minus 0.8ex}
\end{verbatim}
\end{mdframed}
%\caption{Numbered Paragraphs}
%\end{figure}
\captionof{figure}{Numbered Paragraphs}
\p To make the parnums bold red, we can \texttt{\textbackslash renewcommand} the format hook, \texttt{\textbackslash parnumformat\{\}}, with \texttt{\textbackslash bfseries\textbackslash color\{red\}}.
\renewcommand\parnumformat{\bfseries\color{red}}
\p To specify a separator other than \texttt{\textbackslash par}, -- for example. to make run-in `pars' --, put the code as an option to \verb|\p|, like this: \verb|\p[ $\to$\ ]|: 
\noindent\p[ $\to$ ]\sampletext Run-in text.
\noindent\p[ $\to$ ]\sampletext More run-in text.
\p\sampletext
\noindent\p[ *~]\sampletext
\noindent\p[ *~]\sampletext
\par
\renewcommand\parnumformat{}
\p\sampletext The red bold was done with \\[1ex] \indent\texttt{\textbackslash renewcommand\textbackslash parnumformat\{\textbackslash bfseries\textbackslash color\{red\}\}}\\[1ex] and switching back to default format was done with \\[1ex] \indent\texttt{\textbackslash renewcommand\textbackslash parnumformat\{\}}.
\p\sampletext\p\sampletext 

\ssection{Cross-referencing}
\p After numbered paragraphs, the next requirement is cross referencing. 
\p The \texttt{\textbackslash p} command automatically labels the paragraphs. Auto-labelling gives each paragraph a unique label of the form\\[1ex] \indent\texttt{\definnamea\definnameb\definnamec\textbackslash theparno}\\[1ex]
 and, knowing the paragraph number, these can be referenced manually, if desired, with \verb|\pararefauto{}|. For example, to refer to paragraph 5, the code\\[1ex]
\indent\verb|see \pararefauto{5}|\\[1ex]
 produces \\[1ex]
 \indent see \pararefauto{5} \\[1ex]
 There is no practical purpose in manually referring to auto-labels. 
\p \paradef{train} Manual-labelling and referencing is done as usual: the label is arbitrary text. For example, a label (``xys'') was set in a previous paragraph with \texttt{\textbackslash paradef\{xys\}}, and referencing that label here with \texttt{\textbackslash pararef\{xys\}} produces ``\pararef{xys}''.
\p Cross-referencing requires at least two or three compilation runs for the references to resolve and ``settle''.

\ssection{Table of Contents}
\p \paradef{toc} Headings, if they are used, are mere navigational aids -- they do not form part of a judgment. However, when headings \textit{are} used, it may be useful to collect them into a table of contents.
\p Now, the idea of `page' as the navigational reference point is so fundamental (from the time period when Tex was developed), that it is deep in the internals of the routines and often assumed by other routines, such that it will take time to ferret out in the context of generating a table of contents (and probably will need only one line of code to repoint it to \texttt{parno}). 
\p In the meantime, a workaround solution for the table of contents is provided, where modified sectioning commands (see \pararef{sec}) output some basic formatting code and the \texttt{parno} \textit{with the value it has at that moment in the text processing stream} to an external file (\texttt{.tc2}). The file is then read back in again (with \verb|\doprinttoc|, see \pararef{printtoc}) on a subsequent compilation run.
\p The basic nature of the \texttt{.tc2} file  means that embedding sophisticated commands into section headings (like \texttt{\textbackslash verb} or \texttt{\textbackslash texttt}) will cause compilation errors. Delete the \texttt{.tc2} file and readjust the section heading contents. Careful thinking about whether the command, or the \textit{contents} of the command, should go into the \texttt{.tc2} file may be required.
\p For example, in the case of the heading ``The \textbackslash p command'' back at \pararef{xys}, \\[1ex]
\indent\texttt{The \textbackslash verb|\textbackslash p| command}\\[1ex]
didn't work, but \\[1ex]
\indent\verb|The \textbackslash p command|\\[1ex]
did.

\colophon
\end{document}

例子

也许问题应该被标记为legallaw,而不是语言学问题,以更好地反映更普遍的使用领域,以及专门适应该用法的机制?(无论如何,我通过寻找“编号段落”找到了这个问题)。

相关内容