Text FormattingTrouble with section numbering

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
dawadoc
Posts: 2
Joined: Mon May 10, 2010 1:55 pm

Trouble with section numbering

Post by dawadoc »

Hi,

I'm writting down my thesis and I'm stuck with a little numbering problem.

I renewed the way chapter and section are numbered:

\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{section}}

Obviously, when I call a section with the \ref command, latex only displays the section number.

How can i force latex to dipslay the chapter number too without having the chapter number in the section numbering ?

Thx for your help :)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Trouble with section numbering

Post by php1ic »

There may be a package that already does this, but if not, you can create a new command to use instead of \ref

Calling it \cref, it takes the label as an argument as with \ref, but displays the current chapter first then the section number.

Code: Select all

\documentclass{report}

\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{section}}

\newcommand\cref[1]{\thechapter.\ref{#1}}

\begin{document}

\chapter{First}

\section{One}\label{sec:1.1}

Blah blah blah \cref{sec:1.1} blah lah blah.

\chapter{Second}

\section{Two}\label{sec:2.1}

Blah blah blah \cref{sec:2.1} blah lah blah.

\end{document}
rf
Posts: 21
Joined: Mon Jul 20, 2009 5:27 pm

Trouble with section numbering

Post by rf »

dawadoc wrote: I'm writing down my thesis and I'm stuck with a little numbering problem.

I renewed the way chapter and section are numbered:

\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{section}}

Obviously, when I call a section with the \ref command, latex only displays the section number.

How can i force latex to dipslay the chapter number too without having the chapter number in the section numbering ?

Code: Select all

\makeatletter
\def\p@section{\thechapter}%
\makeatother
to get C4 for section 4 of chapter C.

or

Code: Select all

\makeatletter
\def\p@section{\thechapter.}%
\makeatother
to get C.4

i think i would go for having the "." in there.
dawadoc
Posts: 2
Joined: Mon May 10, 2010 1:55 pm

Re: Trouble with section numbering

Post by dawadoc »

thx guys.
This problem is solved :ugeek:
Post Reply