Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have some issue with LaTeX and I haven’t found a solution yet. So hopefully some of you can help me.

I'm writing a big article with four levels of sectioning (so I'm using paragraph for the lowest level). Furthermore in my faculty it is common to have the sections in Alph, subsections in Roman, subsubsections in arabic and paragraphs in alph. This didn't seem to be a problem by redefining \thesection, etc.

But now I'm struggling with a problem, when referencing. In the subsequent example I have a reference and if I don't redefine \the..., then the last sentence in the PDF will be You find some information about it in 1.1.1.. So I expected to have the same structure after redefining: You find some information about it in A.I.1., but instead I get You find some information about it in 1. How can I achieve my desired output?

I faced the same problem with fancy, but I could fix it by redefining \sectionmark, \subsectionmark and \subsubsectionmark. Maybe there is some similar solution for my \ref problem? I'm using the hyperref package, if this is of any importance.

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngermanb]{babel}

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

\begin{document}
\section{My first Section}\label{sec:s1}
\subsection{My first Subsection}\label{sec:s1-ss1}
\subsubsection{My first Subsubsection}\label{sec:s1-ss1-sss1}
This is some text, pretty similar to \emph{lorem ipsum}.

\section{My first Section}\label{sec:s2}
Have you ever heard about \emph{lorem ipsum}? You find some information about it
in \ref{sec:s1-ss1-sss1}.
\end{document}
share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

The following redefinition will work. It is also the way the standard \the... defined.

\renewcommand \thesection {\Alph{section}}
\renewcommand \thesubsection {\thesection.\Roman{subsection}}
\renewcommand \thesubsubsection {\thesubsection.\arabic{subsubsection}}
share|improve this answer
    
Thanks! This is so easy, that I feel kind of dumb now :-) –  Alex Jun 19 '11 at 10:15
add comment

In addition to Yan Zhous answer: According to your question (though not shown in your example), you also want to use alph-numbered \paragraph sections. To do so, redefining \theparagraph is not sufficient -- you also have to set the secnumdepth counter to the appropriate value.

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngermanb]{babel}

\setcounter{secnumdepth}{4}

\renewcommand*{\thesection}{\Alph{section}}
\renewcommand*{\thesubsection}{\thesection.\Roman{subsection}}
\renewcommand*{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}
\renewcommand*{\theparagraph}{\thesubsubsection.\alph{paragraph}}

\begin{document}
\section{My first Section}\label{sec:s1}
\subsection{My first Subsection}\label{sec:s1-ss1}
\subsubsection{My first Subsubsection}\label{sec:s1-ss1-sss1}
\paragraph{My first paragraph section}\label{sec:s1-ss1-sss1-p1}
This is some text, pretty similar to \emph{lorem ipsum}.

\section{My second Section}\label{sec:s2}
Have you ever heard about \emph{lorem ipsum}? You find some information about it
in \ref{sec:s1-ss1-sss1-p1}.
\end{document}
share|improve this answer
    
@Yan Zhou: My copy of Kopka/Daly, A Guide to LaTeX, states on p. 434--435 that it is exactly the other way round: \newcommand resembles \long\def, while the starred version \newcommand* (introduced on December 1, 1994) resembles \def. –  lockstep Jun 20 '11 at 16:13
    
You are right. I was confused since I seldom use \newcommand etc (still used to \def...). I deleted my comment -:) –  Yan Zhou Jun 20 '11 at 17:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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