2

How do I change a section and a subsection to have something like this:

A) A.i) A.ii) B) B.i) B.ii)

I tried with \renewcommand:

\renewcommand{\thesection}{\Alph{section})}

\renewcommand{\thesubsection}{\thesection\roman{subsection})}

But I have: A) A).i) A).ii) B) B).i) B).ii)

I have no idea how to get rid of parentheses after a section in a subsection.

2
  • 4
    Welcome to TeX.se. Please don't post code fragments. Instead edit your question to give a small compilable example document that shows what you're doing.
    – Alan Munn
    Commented Jun 18 at 18:23
  • 1
    \renewcommand{\thesubsection}{\Alph{section}\roman{subsection})}?
    – cfr
    Commented Jun 18 at 18:24

2 Answers 2

4

Since you include the parenthesis as part of the \thesection, you can't use it in the definition of \thesubsection so instead you just need to use \Alph{section}:

\documentclass{article}
\renewcommand{\thesection}{\Alph{section})}
\renewcommand{\thesubsection}{\Alph{section}.\roman{subsection})}

\begin{document}
\section{A section}
\subsection{A subsection}
\subsection{A susection}
\section{A section}
\subsection{A subsection}

\end{document}

As egreg mentions in his answer, it's better not to put too much formatting into the counter definitions. Another way to adjust the title headings without needing to know much about the internals is to use the titlesec package. It provides a \titlelabel command that allows you to style the label easily:

\documentclass{article}
\usepackage{titlesec}
\titlelabel{\thetitle)\space}
\renewcommand{\thesection}{\Alph{section}}
\renewcommand{\thesubsection}{\thesection.\roman{subsection}}

\begin{document}
\section{A section}
\subsection{A subsection}
\subsection{A susection}
\section{A section}
\subsection{A subsection}

\end{document}
5

I wouldn't add the parentheses to \thesection and \thesubsection, but rather to the section header making command. The less you hardwire in the counter's representation, the better.

\documentclass{article}

\makeatletter
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname)\quad}
\makeatother

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

\begin{document}

\section{A section} \label{test1}
\subsection{A subsection} \label{test2}
\subsection{A susection}
\section{A section}
\subsection{A subsection}

\ref{test1} and \ref{test2}

\end{document}

enter image description here

With this approach, the cross references won't have the parenthesis. If you want them, then it's easy as well.

\documentclass{article}

\makeatletter
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname)\quad}
\makeatother

\renewcommand{\thesection}{\Alph{section}}
\renewcommand{\thesubsection}{\thesection.\roman{subsection}}
\labelformat{section}{#1)}
\labelformat{subsection}{#1)}

\begin{document}

\section{A section} \label{test1}
\subsection{A subsection} \label{test2}
\subsection{A susection}
\section{A section}
\subsection{A subsection}

\ref{test1} and \ref{test2}

\end{document}

enter image description here

You must log in to answer this question.

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