0

I want to have the following sections numbering style:

I. Section

A. Subsection

  1. SubSubsection

The following lines of code present different style:

\renewcommand{\thesection}{\Roman{section}} 

\renewcommand{\thesubsection}{\thesection.\Alph{subsection}}

\renewcommand\thesubsubsection{\thesubsection.\arabic{subsubsection}}

I. Section

I.A. Subsection

I.A.1. SubSubsection

Your help is highly appreciated!

Best regards,

  • what about a \phantom to include \thesection in second command and \thesubsection in third? (Not tested) – koleygr Mar 31 '18 at 10:16
  • In order to get rid of the section number in the subsection title, you could use \renewcommand{\thesubsection}{\Alph{subsection}}. Analogously, you can remove thesubsection from the definition of thesubsubsection. – leandriis Mar 31 '18 at 10:16
  • 1
    The indented subsubsection number is weird and only useful, if the subsubsection content has an appropriate indent as well – user31729 Mar 31 '18 at 11:44
  • I find it a bad idea to kill the top - level numbering of subsection etc. As soon as there two or more sections having sub- and subsubsection the numbering repeats and cross-referencing is weird – user31729 Mar 31 '18 at 12:06
  • I agree it's a strange system, but then again, we've seen other weird requests lately (mostly from thesis commitees...) – remco Mar 31 '18 at 12:12
1

The following does almost what you want, except for the font sizes:

\documentclass[]{article}
    \makeatletter %needed
    % reduce space between number and section title a bit
    \renewcommand{\@seccntformat}[1]%
        {{\csname the#1\endcsname\hspace{.25em}}}
    % allow more space in ToC for section number (4.5em here)
    \renewcommand{\l@section}{\@dottedtocline{1}{1.5em}{4.5em}}
    % adjust indentation for the lower levels
    \renewcommand{\l@subsection}{\@dottedtocline{1}{3.0em}{1.5em}}
    \renewcommand{\l@subsubsection}{\@dottedtocline{1}{3.5em}{2.5em}}
\makeatother

\renewcommand{\thesection}{\Roman{section}.}    
\renewcommand{\thesubsection}{\Alph{subsection}.}    
\renewcommand\thesubsubsection{\protect\phantom{\thesubsection}%
    \arabic{subsubsection}.}    

\begin{document}
\tableofcontents

\section{A section}

\subsection{A subsection}

\subsubsection{A subsubsection}

\end{document}

Note the \protect in the redefinition of \thesubsubsection: the argument of the macro is a moving argument (used in several places, here in the headers and in the ToC), so certain macros (like \phantom) need a \protect to avoid compilation errors.

EDIT: Added some extra redefinitions to give space for the longer Roman numerals.

  • 1
    This was the idea of my comment, but check a \setcounter{section}{35} before the first section and see the toc... Doesn't work as expected in toc... So it was a bad idea – koleygr Mar 31 '18 at 10:34
  • That can be corrected through some other redefinitions, see my edited answer. – remco Mar 31 '18 at 12:13
  • Using your "edited way" I suppose you could just be used for the fixed space without the \phantom. It is now a mix of unrelated ideas. Explaining: The first idea was to use a "dynamic" phantom space that would be adjusted by the compiler... The second is manual fixes and thus doesn't respect the second and will need adjustments anyway. I don't really see a reason to mix these ideas... – koleygr Mar 31 '18 at 12:18
  • The phantom takes up the space for the section number, the fixed spaces are for the reserved space in the Toc, and space between number and title. A better solution would be to remove the added space in `\thesubsubsection' completely., as Christian Hupfer suggested. A definite answer will have to combine the different bits... – remco Mar 31 '18 at 12:33
  • @koleygr: Your \phantom approach would insert the space in a potential reference as well – user31729 Mar 31 '18 at 14:23
2

Incorporating the space inside of the \thesubsubsection is a bad idea since this space will enter the cross-referencing as well, so \ref{foo} would give ______1, where ______ indicates the additional space.

I suggest to change the \@seccntformat macro for subsubsection, using \ifnum0=\pdfstrcmp in order to check whether the counter is subsubsection etc.

\documentclass{article}

\usepackage{tocloft}


\renewcommand*{\thesection}{\Roman{section}.}
\renewcommand*{\thesubsection}{\Alph{subsection}.}
\renewcommand*{\thesubsubsection}{\arabic{subsubsection}.}
\newlength{\subsubsectionnumberindent}
\setlength{\subsubsectionnumberindent}{3ex}

\addtolength{\cftsubsubsecnumwidth}{-3.5ex}


\newcommand{\subsubsectionheadingformat}{%
  \hskip\subsubsectionnumberindent\arabic{subsubsection}.\quad%
}

\makeatletter
\let\latex@@seccntformat\@seccntformat
\renewcommand{\@seccntformat}[1]{%
  \ifnum0=\pdfstrcmp{#1}{subsubsection}%
  \subsubsectionheadingformat%
  \else
  \latex@@seccntformat{#1}%
  \fi
}
\makeatother
\begin{document}

\tableofcontents


Please see \fbox{\ref{foosubsubsec}}

\section{Section}
\subsection{Subsection}
\subsubsection{SubSubsection} \label{foosubsubsec}

\end{document}

enter image description here

  • Latex, XeLatex, and LuaLatex didn't like this code (the \pdfstrcmp, perhaps?). and it has the same problem @koleygr noticed in my initial proposal – remco Mar 31 '18 at 12:27
  • @remco: Which problem? The spacing in ToC? That's the natural spacing which is there in the ToC anyway. And I did not claim that it would work with LaTeX, XeLaTeX or LuaLaTeX -- those are lacking some features and therefore I don't use them – user31729 Mar 31 '18 at 14:16
  • A large section number overwrites the title in the ToC. – remco Mar 31 '18 at 14:29
  • @remco: That's the case already even without redefinition of \the.... stuff. What you achieved by redefinition of \l@.... can be done with tocloft as well, quicker, in my point of view. The O.P. left no information about the real spacing, that's why I did not change the number width – user31729 Mar 31 '18 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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