0

I have a document (witch is an update of an old one) with a sectioning numbering system like this:

\chapter       1
\section       1.1
\subsection    1.1.1
\subsubsection 1.1.1.1
\paragraph     1.1.1.1.1

But, in an old version of this document, the numbering was the following one:

\chapter       A
\section       A.1
\subsection    A.1.i
\subsubsection A.1.ii.1
\paragraph     A.1.iii.1.a

The goal then is to use the new numbering but remain the old numbering refference in the margin.

Then I put in the preamble the following commands:

\usepackage{titlesec} % Usefull to change the sectioning style
\usepackage{marginnote} % To put the old numbering in the marging

\setcounter{secnumdepth}{4} % activating \paragraph numbering

\titleformat{\section}[runin]{\normalsize\bfseries}{\thesection}{1em}{{\normalfont\marginnote{\vspace{-10cm}Someting}}}
\titleformat{\subsection}[runin]{\normalsize\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}[runin]{\normalsize\bfseries}{\thesubsubsection}{1em}{}

For the moment, I could put “someting” in the margin next each section. But how to translate the arabic numbers (1, 2, 3… 9…) into letter numbering (A, B, C… I…) in section margin? Same question for \subsection how to translate arabic numbers into lowcase roman (i, ii, iii… ix…) and print the full subsection number like this “A.1.i”.

Same question with \paragraph, etc.

As example, near the paragraph 2.1.5.1.7, should appear the old sectioning number style B.1.v.1.g.

3
  • 3
    As usual: A minimal working example instead of code snippets would be helpful to do testing of your code an our suggestions quickly … Without, I would just say: Use, e.g. \Alph{section}.\arabic{section}.\roman{subsection}.
    – cabohah
    Nov 25, 2023 at 9:41
  • 1
    This is usually done by redefining \thesection etc. \def\thesection{\Alph{section}} \def\thesubsection{\thesection.\arabic{subsection}} \def\thesubsubsection{\thesubsection.\roman{subsection}} No titlesec needed. Nov 25, 2023 at 15:46
  • Please clarify whether the old style numbering matches the new style or doesn't need to.
    – egreg
    Nov 25, 2023 at 18:02

1 Answer 1

0

Define "old-style counters" and add them to the output of the sectioning commands. The parameters for \titlefomat come from §8.2 of the titlesec documentation.

\documentclass{book}

\usepackage{titlesec}
\setcounter{secnumdepth}{4}

\newcommand*{\oldthechapter}{\Alph{chapter}}
\newcommand*{\oldthesection}{\theoldchapter.\arabic{section}}
\newcommand*{\oldthesubsection}{\theoldsection.\roman{subsection}}
\newcommand*{\oldthesubsubsection}{\theoldsubsection.\arabic{subsubsection}}
\newcommand*{\oldtheparagraph}{\theoldsubsubsection.\alph{paragraph}}
% helper macro
\newcommand*{\llapinheading}[1]{\makebox[0pt][r]{\csname oldthe#1\endcsname\kern15pt}\csname the#1\endcsname}

\titleformat{\chapter}[display]{\normalfont\huge\bfseries}
   {\makebox[0pt][r]{\oldthechapter\kern15pt}\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titleformat{\section}{\normalfont\Large\bfseries}
   {\llapinheading{section}}{1em}{}
\titleformat{\subsection}{\normalfont\large\bfseries}
   {\llapinheading{subsection}}{1em}{}
\titleformat{\subsubsection}{\normalfont\normalsize\bfseries}
   {\llapinheading{subsubsection}}{1em}{}
\titleformat{\paragraph}[runin]{\normalfont\normalsize\bfseries}
   {\llapinheading{paragraph}}{1em}{}

\begin{document}
\setcounter{chapter}{1}
\chapter{Foo}
\section{foo}
\setcounter{subsection}{4}
\subsection{foo}
\subsubsection{foo}
\setcounter{paragraph}{6}
\paragraph{foo}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .