[Tex/LaTex] Different section numbering styles for toc and body

numberingsectioningtable of contents

I'm looking for a way to display section numbering differently in the text body and in the toc.

I've set up the numbering in the body as

\renewcommand*\theparagraph{\arabic{subsubsection}(\alph{paragraph})}

so I get something like 2(a) for this level (and 2(a)(i) for the next).

In the toc, I'd like this to just show as (a) or (i).

I know you can set different section headers in the toc by using, eg

\subsection[toc]{body}

but I can't find something similar for numbering.

Any help would be appreciated 🙂

EDIT: I've included the full context of what I'm trying to do

\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

Best Answer

The titlesec package can be used here. The modifications to the .sty file:

\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

Since titlesec was used to change the formatting for \paragraph and \subparagraph, it could also be used for the other sectional units.

Here's a simple test document using the aglc.sty file to show the desired changes in action:

\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}

And the resulting document:

enter image description here