2

I'm writing an article in LaTeX, and, as always the content numbering style is like this:

1 section title

1.1 subsection title

1.2 subsection title

2 section title

...

I want to know if it's possible to obtain something like this:

1 section title

A subsection title

B subsection title

2 section title

...
  • Welcome to TeX.SE. Please tell us which document class you use. – Mico Jul 19 '16 at 20:46
  • this way you will get subsection A and subsection B in section 2 too and this is not really good. – touhami Jul 19 '16 at 20:52
  • I don't recommend the A,B,C numbering style -- this should be used with care and most likely in an appendix only. A label will use A then instead of 1.1, but it is not clear which subsection is meant -- is it 1.1 or is it 2.1 etc??? – user31729 Jul 19 '16 at 20:54
  • "See subsection 'A'... ok, but what subsection 'A'? ... A bad idea if you want to make cross-references to these subsections with \ref{}. – Fran Jul 19 '16 at 21:10
3

Assuming you're using one of the default LaTeX document classes -- article, report, and book -- you could try

\renewcommand\thesubsection{\Alph{subsection}}

A full MWE (minimum working example):

\documentclass{article}
\renewcommand\thesubsection{\Alph{subsection}}
\begin{document}
\section{First section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}
\subsection{Another subsection}
\end{document}
  • 1
    Perhaps you should mention that this restricts the number of subsections to 26 ;-) Just in case there is a huge bunch of subsections ;-) – user31729 Jul 19 '16 at 20:55
  • 1
    @ChristianHupfer - I suspect that any document that has more than 26 subsections per section -- irrespective of the enumeration style (Arabic numerals, Roman letters, ...) -- is going to face severe resistance from its intended readers... :-) – Mico Jul 19 '16 at 21:20
  • I'll see whether I can find a document produced by pupils that has this scheme -- unfortunately, I can't reject that :-( – user31729 Jul 19 '16 at 21:23
  • @ChristianHupfer - I forgot that sometimes documents/writers have captive readers. I'm in the fortunate position (professionally speaking) to be able to simply refuse to even begin reading any document that features more than 26 subsections per section. But not everybody is this lucky, I suppose... – Mico Jul 19 '16 at 21:31
2

You can do as follows, so references to subsections in the same section only have the letter, whereas references to subsections in another section also have the section number.

\documentclass{article}
\usepackage{etoolbox}

\makeatletter
\renewcommand{\thesubsection}{\Alph{subsection}}
\renewcommand{\p@subsection}{\test@section{\thesection}}
\newrobustcmd{\test@section}[1]{%
  \ifnum#1=\value{section}\else#1.\fi
}
\makeatother


\begin{document}
\section{First section}

\subsection{First subsection}\label{subsec:test}

\subsection{Second subsection}

A reference to a subsection in the same section: \ref{subsec:test}

\section{Second section}

\subsection{Another subsection}

A reference to a subsection in another section: \ref{subsec:test}
\end{document}

enter image description here

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.