6

Hi I have a problem with sectioning:

I would like to call each section with Roman numbers I, II, III and each subsection with letters A, B, C and subsubsections with Arabic numbers 1, 2, 3. However when using \ref{} to cite subsubsection 2 in subsection B of section III, I would like to have III.B.2 but I only get B.2. The same for the section I would like III.B..

This is what I have so far.

\documentclass[12pt,letterpaper,leqno,doublespacing]{article}
\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\Alph{subsection}}
\renewcommand{\thesubsubsection}{\arabic{subsubsection}}
\begin{document}
\section{sec 1}
\subsection{subsec 1}
\subsection{subsec 2}
\subsection{subsec 3}
\section{sec 2}
\subsection{subsec 1}
\subsection{subsec 2}
\section{sec 3}
\subsection{subsec 1}
\subsection{subsec 2}
\subsubsection{subsub 1}
\subsubsection{subsub 2}\label{reference}
This is section \ref{reference}
\end{document}

marked as duplicate by Mico, egreg cross-referencing Mar 20 '15 at 17:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Try \makeatletter \renewcommand{\thesection}{\Roman{section}} \renewcommand{\thesubsection}{\thesection.\Alph{subsection}} \renewcommand{\thesubsubsection}{\thesubsection.\arabic{subsubsection}} \makeatother – Steven B. Segletes Mar 20 '15 at 15:59
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – karlkoeller Mar 20 '15 at 16:57
  • @StevenB.Segletes - I think the OP does not want to prefix the section "number" to the subsection "number" inside a subsection-level header. Rather, I think that he/she wants the prefix only when creating cross-references. – Mico Mar 20 '15 at 16:57
3

there's no need to load any special packages. Just redefine the label-prefix macros that LaTeX sets up automatically for every counter variable.

\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\Alph{subsection}}
\renewcommand{\thesubsubsection}{\arabic{subsubsection}}
\makeatletter
\renewcommand{\p@subsection}{\thesection.}
\renewcommand{\p@subsubsection}{\thesection.\thesubsection.}
\makeatother
2

A solution with titlesec.

Define your counters as

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

and then format your sectioning titles in this way:

\titleformat{\section}
    {\normalfont\Large\bfseries}{\Roman{section}}{1em}{}
\titleformat{\subsection}
    {\normalfont\large\bfseries}{\Alph{subsection}}{1em}{}
\titleformat{\subsubsection}
    {\normalfont\normalsize\bfseries}{\arabic{subsubsection}}{1em}{}

MWE:

\documentclass[12pt,letterpaper,leqno,doublespacing]{article}

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

\usepackage{titlesec}

\titleformat{\section}
    {\normalfont\Large\bfseries}{\Roman{section}}{1em}{}
\titleformat{\subsection}
    {\normalfont\large\bfseries}{\Alph{subsection}}{1em}{}
\titleformat{\subsubsection}
    {\normalfont\normalsize\bfseries}{\arabic{subsubsection}}{1em}{}

\begin{document}
\section{sec 1}
\subsection{subsec 1}
\subsection{subsec 2}
\subsection{subsec 3}
\section{sec 2}
\subsection{subsec 1}
\subsection{subsec 2}
\section{sec 3}
\subsection{subsec 1}
\subsection{subsec 2}
\subsubsection{subsub 1}
\subsubsection{subsub 2}\label{reference}
This is section \ref{reference}
\end{document} 

Output:

enter image description here

0

Here is a solution

\documentclass[12pt,letterpaper,leqno,doublespacing]{article}
\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\thesection.\Alph{subsection}}
\renewcommand{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}
\makeatletter
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
{\csname the#1\endcsname\quad}%
{\csname #1@cntformat\endcsname}}
\def\section@cntformat{\thesection\quad}
\def\subsection@cntformat{\Alph{subsection}\quad}
\def\subsubsection@cntformat{\arabic{subsubsection}\quad}
\makeatother

\begin{document}
\section{sec 1}
\subsection{subsec 1}
\subsection{subsec 2}
\subsection{subsec 3}
\section{sec 2}
\subsection{subsec 1}
\subsection{subsec 2}
\section{sec 3}
\subsection{subsec 1}
\subsection{subsec 2}
\label{refer}
\subsubsection{subsub 1}
\subsubsection{subsub 2}\label{reference}
This is subsubsection \ref{reference} part of \ref{refer}
\end{document}

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