GeneralPrinting Chapter, Section, and Item names using \autoref

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
kihashi
Posts: 3
Joined: Mon Mar 08, 2010 10:55 pm

Printing Chapter, Section, and Item names using \autoref

Post by kihashi »

I am using the hyperref package and \autoref to make some in document labels and cross-references.

I am using alternate chapter and section numbering shown here:

Code: Select all

\def\thechapter{\Roman{chapter}}
\def\thesection{\Alph{section}} %These 2 lines make Chapters be labled by Roman Numerals and Sections labled by letters.
My document is normally formatted:

Code: Select all

\documentclass{book}
...
\chapter{chap-name}
\section{section-name}
\label{my-label1}
\begin{enumerate}
\item text \label{my-label2}
...
\end{enumerate}
Currently, the \autoref prints only the level immediately above the label. (EX section C) The behavior I want is Chapter II, Section C or Chapter II, Section C, Item 1 (in the case of \begin{enumerate}) or something similar so that I can reference across chapters.

How would I go about doing this? The hyperref manual and a search for \autoref on here were not very helpful in this regard.

EDIT: I realize after thinking about this a little further that there are actually 2 questions here: How do I get this behavior for renamed sections/chapters and How do I get labels in lists to also print the section and chapter they are in?
Last edited by kihashi on Mon Mar 15, 2010 8:38 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

kihashi
Posts: 3
Joined: Mon Mar 08, 2010 10:55 pm

Printing Chapter, Section, and Item names using \autoref

Post by kihashi »

After some poking around in the hyperref.sty file, I have figured it out.

Include

Code: Select all

\def\sectionautorefname{Chapter \thechapter, Section}
\def\itemautorefname{Chapter \thechapter, Section \thesection, Item}
in your preamble.

The default code is thus:

Code: Select all

\def\sectionautorefname{section}
\def\itemautorefname{item}
EDIT: I was wrong. This prints the current section and chapter title rather than the one that the label is in. Any help?
kihashi
Posts: 3
Joined: Mon Mar 08, 2010 10:55 pm

Re: Printing Chapter, Section, and Item names using \autoref

Post by kihashi »

Bump?
Post Reply