Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
share|improve this question
    
Welcome to TeX.sx! –  hpesoj626 Oct 28 '12 at 22:53
add comment

1 Answer

up vote 6 down vote accepted

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

share|improve this answer
    
Hey, thanks for the example. It works as a minimum working example, but when I try to integrate it into my style file it doesn't work correctly. I've edited my original post with the full style file, as well as where I tried adding it. The issue is that it seems to be changing both the toc and body styles to just (a) or (i), even though I tried placing your suggested code just after all my other \renewcommands. If I put a new \renewcommand down the bottom to restore the format (in the body) to 1(a) etc, it changes the toc as well :/ Any ideas? –  sapi Oct 28 '12 at 23:27
    
@sapi I updated my answer with the modifications to the .sty file. Please let me know if things work as expected now. –  Gonzalo Medina Oct 29 '12 at 0:09
    
almost. The modifications fix the table of contents and the paragraph styles, but because they removed my \renewcommand\paragraph, the actual text starts on the same line as the heading (instead of having a line break). If I add that back in, it breaks as before. What should I change in your definition to preserve the space after /paragraph and /subparagraph? Thanks again :) –  sapi Oct 29 '12 at 0:19
    
@sapi answer updated. I hope everything is OK now. –  Gonzalo Medina Oct 29 '12 at 0:27
    
Thanks, that looks to work perfectly! :) –  sapi Oct 29 '12 at 0:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.