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 make use of autoref thoughout my now rather long document. I have an appendix with sections, though currently a small number, so changes could be made here.

I want references in my document to sections within the appendix to say something like appendix A.1 instead of section A.1 but still refer to sections not in the appendix by section. I had an idea along the lines of creating some alias to section which had their own autorefname and using these instead of section. I tried and failed to use aliascnt for this. I don't know if it was because I was doing it wrongly or because it can't do what I wanted.

Any help would be appreciated!

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

I assume you're using a class that includes the \chapter command (e.g. book or report). In that case, within the appendix \autoref will refer to chapters as "Appendix", but to sections still as "section" (contrary to the article class, where sections would constitute an "Appendix"). Solution: (EDIT: My first "solution" was very ill-advised) Load cleveref after hyperref and use \cref instead of \autoref. (Yes, the links won't be as pretty as before.)

\documentclass{report}

\usepackage{hyperref}
\usepackage{cleveref}% Load AFTER hyperref!

% \crefname{subappendix}{fairy tale}{fairy tales}

\begin{document}

\chapter{bla}\label{bla}

\section{blubb}\label{blubb}

As shown in \cref{foo} and especially in \cref{bar} \dots

\appendix

\chapter{foo}\label{foo}

\section{bar}\label{bar}

As shown in \cref{bla} and especially in \cref{blubb} \dots

\end{document}
share|improve this answer
    
Dear lockstep, thanks very much for this. In fact I had tried this solution with no success. There is possibly a misunderstanding about what I want it to do... I would like a reference to the appendix, written before the start of the appendix to refer to it as "appendix A.1" not just references (autorefs) written after the start of the appendix. –  aghsmith Nov 22 '10 at 19:00
    
ok, i'm excited by the new solution, just investigating it now –  aghsmith Nov 22 '10 at 20:07
    
Ok. I can see that cref is going to take a while to master. but in the mean time it has sorted out the underlying problem. I'm a bit worried that my labels might not all be 100% propper but... we will see. Cheers –  aghsmith Nov 22 '10 at 20:28
    
You can get nicer looking links with something along the lines of \crefformat{chapter}{#2chapter~#1#3} and \Crefformat{chapter}{#2Chapter~#1#3}. –  mpr Oct 29 '11 at 4:33
    
@lockstep: Is there really no way to do this without cleveref? –  einpoklum Jan 26 '12 at 19:39
add comment

The simplest workaround is to define a new command:

\newcommand{\aref}[1]{\hyperref[#1]{Appendix~\ref{#1}}}

and use it for appendix sections:

\aref{sec:appendix_section}
share|improve this answer
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.