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 am constructing my thesis, and am using a variant of the report class. I have chapters, sections, subsections, and subsubsections in places. When reading the text, having a long string of numbers, letters, and roman numerals in the title for subsections and subsubsections is unpleasant-looking. I would prefer these titles to just have the relevant subsection or subsubsection title, and do so using:

\renewcommand\thesubsection{\Roman{subsection}}

(Depending on how things end up looking, I may include the section counter, but I'll definitely strip off the chapter counter.) However, when I make a reference to the subsection or subsubsection, I would much prefer the entire string of numbers to be used, otherwise the reference is poorly defined. Can anyone comment on how to do this?

Here is a minimal example.

\documentclass{report}

\begin{document}

\renewcommand\thesection{\arabic{chapter}.\arabic{section}}
\renewcommand\thesubsection{\Roman{subsection}}

\chapter{Chapter}

\section{Section}

\subsection{Subsection}\label{subsection}

\noindent I have the subsections labelled in Roman in the title, because 1.1.I would just be long.
\\

\noindent Here is a reference to the subsection: (\ref{subsection})
\\

\noindent I would like references to the subsection to be (1.1.I), however.

\end{document}
share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Redefine \p@subsection (the prefix using for the references to subsections):

\documentclass{report}

\renewcommand\thesection{\arabic{chapter}.\arabic{section}}
\renewcommand\thesubsection{\Roman{subsection}}
\makeatletter
\renewcommand\p@subsection{\thesection.}
\makeatother

\begin{document}

\chapter{Chapter}

\section{Section}

\subsection{Subsection}\label{subsection}

\noindent I have the subsections labelled in Roman in the title, because 1.1.I would just be long.

\noindent Here is a reference to the subsection: (\ref{subsection})

\end{document}

enter image description here

By the way, never use the combination \\ + blank line; this will generate underfull boxes warnings.

share|improve this answer
    
Wow, that was incredibly fast. Many thanks :-) –  Jolyon Aug 18 '12 at 22:14
add comment

References can automatically be prefixed by \p@<counter>, see example:

\documentclass{report}
\usepackage{parskip}

\renewcommand\thesection{\arabic{chapter}.\arabic{section}}
\renewcommand\thesubsection{\Roman{subsection}}

\makeatletter
\renewcommand*{\p@subsection}{\thesection.}
\makeatother

\begin{document}
\chapter{Chapter}

Here is a reference to the subsection: \ref{subsection}

\section{Section}

\subsection{Subsection}\label{subsection}

\end{document}

Result:

Result

share|improve this answer
    
Thank you. Basically the same answer as above, and works a charm :-) Does the * in renewcommand* do anything significant? –  Jolyon Aug 18 '12 at 22:20
    
Yes, written at the same time. \(re)newcommand with star is the same as \def, without star it is \long\def. Here the difference is not important (without arguments). –  Heiko Oberdiek Aug 19 '12 at 3:58
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.