3

See the MWE below. I want to achieve that, the \nameref{c} is printed as Appendix not as Some Stuff.

\documentclass{book}
\usepackage{lipsum}
\usepackage{appendix}
\usepackage{hyperref}
\begin{document}
\chapter{First Chapter}
\lipsum[1]

We refer to the \nameref{c}.

\lipsum

\begin{appendices}

\renewcommand\thechapter{}
\chapter{Some stuff}\label{c}
\lipsum
\end{appendices}
\end{document}

Note that for some reasons I want to use \renewcommand\thechapter{} rather than \chapter*{...} plus \addcontentsline....

This seems like a bit of a special situation. However, the following MWE shows an application which might be quite frequent:

\documentclass{book}
\usepackage{lipsum}
\usepackage{appendix}
\usepackage{hyperref}
\begin{document}
\chapter{First Chapter}
\lipsum[1]

This is explained in the next chapter. 
%I want to set a link on "next chapter" which points to the second chapter

\lipsum[2]

\chapter{Second Chapter}
\lipsum[3]
\end{document}

NB: I have rewritten my original question. It is now much more to the point and may also be more interesting for others.

2 Answers 2

6

\nameref solves your problem, the example below also works without redefining \thechapter and adds an entry to the table of contents and the bookmarks.

\documentclass{book}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{bookmark}
\bookmarksetup{numbered}

\begin{document}
\tableofcontents

\chapter{First Chapter}
\lipsum[1]

We refer to the \nameref{chap:second}.

\lipsum

\cleardoublepage
\addcontentsline{toc}{chapter}{Second Chapter}
\chapter*{Second Chapter}
\label{chap:second}
\lipsum
\end{document}

PS: This also works with \renewcommand*{\thechapter}{}, because in the solution the title of the chapter is referenced. I assume that you also want the string "Chapter" without number at the start of the chapter above the chapter title and that the numbering continues nevertheless.

\documentclass{book}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{bookmark}
\bookmarksetup{numbered}

\begin{document}
\tableofcontents

\chapter{First Chapter}
\lipsum[1]

We refer to the \nameref{chap:second}.

\lipsum

\renewcommand*{\thechapter}{}
\chapter{Second Chapter}
\label{chap:second}
\lipsum
\end{document}

PPS: Third variant because of changed question.

The name title for \nameref is internally stored in \@currentlabelname. That can be redefined to a new string that will be read by the next \label.

\documentclass{book}
\usepackage{lipsum}
\usepackage{appendix}
\usepackage{hyperref}

\makeatletter
\newcommand*{\SetNameTitle}[1]{%
  \def\@currentlabelname{#1}%
}
\makeatother

\begin{document}
\chapter{First Chapter}
\lipsum[1]

We refer to the \nameref{c}.

\lipsum

\begin{appendices}

\renewcommand\thechapter{}
\chapter{Some stuff}
\SetNameTitle{\appendixname}
\label{c}
\lipsum
\end{appendices}
\end{document}

And a variant, where the reference text is replaced instead.

\documentclass{book}
\usepackage{lipsum}
\usepackage{appendix}
\usepackage{hyperref}

\begin{document}
\chapter{First Chapter}
\lipsum[1]

We refer to the \hyperref[c]{\appendixname}.

\lipsum

\begin{appendices}

\renewcommand\thechapter{}
\chapter{Some stuff}\label{c}
\lipsum
\end{appendices}
\end{document}
2
  • Please note that I have reformulated by original question. Consequently, Heiko's answer, which perfectly solved the original problem, no longer does so. Therefore, I have unaccepted it.
    – lpdbw
    Aug 22, 2012 at 8:36
  • Thanks for updating your answer! The last variant is exayctly what I was looking for!
    – lpdbw
    Aug 22, 2012 at 9:27
1

Here is a possible solution:

\documentclass{book}
\usepackage{lipsum}
\usepackage{appendix}
\usepackage{hyperref}
\begin{document}
\chapter{First Chapter}
\lipsum[1]

We refer to the \hyperlink{c}{Appendix}.

\lipsum

\begin{appendices}

\renewcommand\thechapter{}

\cleardoublepage
\phantomsection\hypertarget{c}{}
\chapter{Some stuff}\label{c}
\lipsum

\end{appendices}

\end{document}

... and for the second MWE:

\documentclass{book}
\usepackage{lipsum}
\usepackage{appendix}
\usepackage{hyperref}
\begin{document}
\chapter{First Chapter}
\lipsum[1]

This is explained in the \hyperlink{c}{next chapter}. 
%Now the link points to the second chapter and is printed as "next chapter"

\lipsum[2]

\cleardoublepage
\phantomsection\hypertarget{c}{}
\chapter{Second Chapter}
\lipsum[3]
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .