I want my cross reference links to look like:

Chapter X: Chapter Title

To achieve that I have created the following command:

\newcommand{\fancyref}[1]{\autoref{#1}: \nameref{#1}}

The problem is that the : character is not part of the generated hyperlink.

Could someone help?

Thanks in advance.

Warning I get when compiling Leo Liu's example:

LaTeX Warning: Reference `*' on page 1 undefined on input line 10.


LaTeX Warning: There were undefined references.

I think you can use:

\hyperref[label]{\autoref*{label}: \nameref*{label}}

Full example:

  \hyperref[#1]{\autoref*{#1}: \nameref*{#1}}}


  • It didn't quite work for me. It is giving fata errors. I think the problem is the * how can I have the * in a newcommand definition? Jan 17 '11 at 17:51
  • @Tiago: I add a full example works for me. Check your code if there is something wrong. The * avoids a hyper link here.
    – Leo Liu
    Jan 18 '11 at 5:23
  • Perhaps we have different versions, but when i compile your example I get the error in my question above. Jan 18 '11 at 9:02
  • Today I have updated my TeX distribution. I can confirm that this now works for me. Jan 26 '11 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.