我正在寻找一种在文本主体和目录中以不同方式显示章节编号的方法。
我在正文中设置了编号
\renewcommand*\theparagraph{\arabic{subsubsection}(\alph{paragraph})}
因此我得到了类似这个级别的 2(a)(和下一个级别的 2(a)(i))。
在目录中,我希望它只显示为 (a) 或 (i)。
我知道你可以在目录中设置不同的节标题,例如
\subsection[toc]{body}
但我找不到类似的编号。
任何帮助,将不胜感激 :)
编辑:我已经包含了我想做的事情的完整内容
\ProvidesPackage{aglc}
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{parskip}
\RequirePackage{chngcntr}
\RequirePackage{titlesec}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\counterwithin*{subsection}{section}
\counterwithin*{paragraph}{subsection}
\counterwithin*{subparagraph}{paragraph}
% AGLC Heading 1
% I Section
\renewcommand\section{\@startsection {section}{1}{\z@ }%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus .2ex}{\normalfont \centering \large \sc }}
\renewcommand*\thesection{\Roman{section}}
% AGLC Heading 2
% A SubSection
\renewcommand\subsection{\@startsection {subsection}{2}{\z@ }%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}{\normalfont \centering \large \emph }}
\renewcommand*\thesubsection{\Alph{subsection}}
% AGLC Heading 3
% 1 SubSubSection
\renewcommand\subsubsection{\@startsection {subsubsection}{3}{\z@ }%
{-3.25ex \@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}{\normalfont \emph }}
\renewcommand*\thesubsubsection{\arabic{subsubsection}}
% AGLC Heading 4
% (a) Paragraph
\renewcommand\paragraph{\@startsection {paragraph}{4}{\z@ }%
{3.25ex \@plus 1ex \@minus .2ex}%
{1.5ex \@plus .2ex}{\normalsize \emph }}
\renewcommand*\theparagraph{\arabic{subsubsection}(\alph{paragraph})}
% AGLC Heading 5
% (i) SubParagraph
\renewcommand\subparagraph{\@startsection {subparagraph}{5}{\z@ }%
{3.25ex \@plus 1ex \@minus .2ex}%
{1.5ex \@plus .2ex}{\normalsize \emph }}
\renewcommand*\thesubparagraph{\arabic{subsubsection}(\alph{paragraph})(\roman{subparagraph})}
% I tried commenting out the above \renewcommands and adding the code here, but it didn't work correctly
\newcommand{\case}[1]{\emph{#1}}
\newcommand{\caseref}[1]{[\emph{#1}]}
\newcommand{\statute}[2][Qld]{\emph{#2} (#1)}
\newcommand{\latin}[1]{\emph{#1}}
\endinput
答案1
这titlesec
包可以在这里使用。对文件的修改.sty
:
\ProvidesPackage{aglc}
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{parskip}
\RequirePackage{chngcntr}
\RequirePackage{titlesec}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\counterwithin*{subsection}{section}
\counterwithin*{paragraph}{subsection}
\counterwithin*{subparagraph}{paragraph}
% AGLC Heading 1
% I Section
\renewcommand*\thesection{\Roman{section}}
\renewcommand\section{\@startsection {section}{1}{\z@ }%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus .2ex}{\normalfont \centering \large \sc }}
% AGLC Heading 2
% A SubSection
\renewcommand*\thesubsection{\Alph{subsection}}
\renewcommand\subsection{\@startsection {subsection}{2}{\z@ }%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}{\normalfont \centering \large \emph }}
% AGLC Heading 3
% 1 SubSubSection
\renewcommand*\thesubsubsection{\arabic{subsubsection}}
\renewcommand\subsubsection{\@startsection {subsubsection}{3}{\z@ }%
{-3.25ex \@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}{\normalfont \emph }}
% AGLC Heading 4
% (a) Paragraph
\renewcommand*\theparagraph{(\alph{paragraph})}
\titleformat{\paragraph}
{\normalfont\normalsize\em}
{\renewcommand*\theparagraph{%
\arabic{subsubsection}(\alph{paragraph})}\theparagraph}
{1em}{}
\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex \@plus .2ex}
% AGLC Heading 5
% (i) SubParagraph
\renewcommand*\thesubparagraph{(\roman{subparagraph})}
\titleformat{\subparagraph}
{\normalfont\normalsize\em}
{\renewcommand*\thesubparagraph{%
\arabic{subsubsection}\theparagraph(\roman{subparagraph})}\thesubparagraph}
{1em}{}
\titlespacing*{\subparagraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex \@plus .2ex}
\newcommand{\case}[1]{\emph{#1}}
\newcommand{\caseref}[1]{[\emph{#1}]}
\newcommand{\statute}[2][Qld]{\emph{#2} (#1)}
\newcommand{\latin}[1]{\emph{#1}}
\endinput
由于titlesec
用于改变\paragraph
和的格式\subparagraph
,它也可以用于其他部分单位。
这是一个简单的测试文档,使用该aglc.sty
文件来显示所需的更改:
\documentclass{article}
\usepackage{aglc}
\usepackage{lipsum}% just to generate text for the example
\begin{document}
\tableofcontents
\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}
\paragraph{Test paragraph}
\lipsum[2]
\subparagraph{Test subparagraph}
\lipsum[2]
\end{document}
生成的文档如下: