I am using a thesis.sty file written by previous students to write my thesis, and it contains the following:
\def\thesection {\Alph{section}}
\def\labelsection {\thesection.}
The section headings are automatically numbered A, B, C.
When I make reference to a section using \ref{sec:Ex}, I want to see 3.B for the 2nd section in Chapter 3. However, only the section number shows up, i.e., B without the chapter number. I tried to amend the above 2 lines with
\def\thesection {\thechapter.\Alph{section}}
\def\labelsection {\thechapter.\thesection.}
The reference with \ref{sec:Ex} works now, but the section headings also include the chapter number. How do I remove the chapter number?
Document Classes ⇒ Section Numbering
Section Numbering
Last edited by pengyau on Fri Sep 10, 2010 11:55 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

-
- Posts: 14
- Joined: Wed Sep 01, 2010 4:47 pm
Section Numbering
I haven't been using latex for long so I am not an expert but have you tried:
Good luck!
Code: Select all
\def\thesection {\Alph{section}}\def\labelsection {\thechapter.\thesection.}
Section Numbering
You may use varioref package and redefine the look of references. E.g.:
This code will typeset references exactly as you requested: chapter_number.section_number.
And here's a full example:
Code: Select all
Code, edit and compile here:
\usepackage{varioref}\labelformat{section}{\thechapter.#1}
And here's a full example:
Code: Select all
Code, edit and compile here:
\documentclass{report}\renewcommand{\thesection}{\Alph{section}}%\def\labelsection{\thechapter.\thesection}\usepackage{varioref}\labelformat{section}{\thechapter.#1}\begin{document}\tableofcontents\chapter{A chapter}\label{ch:one}Some text\ldots{}\section{A section}\label{sec:one}A reference:~\ref{sec:one}.\section{Another section}Some text\ldots{}\section{And another one}\label{sec:two}More references:~\ref{sec:two} and \ref{sec:one}.\chapter{Another chapter}\label{ch:two}Some text\ldots{} and references:~\ref{ch:one}, \ref{ch:two}, \ref{sec:one}, \ref{sec:two}.\section{One more section}\label{sec:three}\ldots{}and one more reference:~\ref{sec:three}.\end{document}
Re: Section Numbering
What meho_r suggested works like magic. Thanks.
I tried what ChemistKatie suggested as well, the problem with that is my section headings also include the chapter number, which I do not want.
Thanks all for your hints.
I tried what ChemistKatie suggested as well, the problem with that is my section headings also include the chapter number, which I do not want.
Thanks all for your hints.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Section Numbering
Now that the problem is solved, please be so kind and mark the topic accordingly as clearly described in Section 3 of the Board Rules (to be read before posting).
Best regards and welcome to the board
Thorsten
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10