Укажите название ссылки

Укажите название ссылки

См. MWE ниже. Я хочу добиться того, чтобы \nameref{c}печаталось как Appendixне как 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}

Обратите внимание, что по некоторым причинам я хочу использовать \renewcommand\thechapter{}вместо \chapter*{...}плюса \addcontentsline....

Это кажется немного особой ситуацией. Однако следующий MWE показывает приложение, которое может быть довольно частым:

\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: Я переписал свой изначальный вопрос. Теперь он гораздо более по существу и может быть интереснее для других.

решение1

\namerefрешает вашу проблему, пример ниже также работает без переопределения \thechapterи добавляет запись в оглавление и закладки.

\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: Это также работает с \renewcommand*{\thechapter}{}, поскольку в решении есть ссылка на название главы. Я предполагаю, что вы также хотите строку "Глава" без номера в начале главы над названием главы и что нумерация тем не менее продолжается.

\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: Третий вариант из-за изменившегося вопроса.

Имя title для \namerefхранится внутри \@currentlabelname. Его можно переопределить в новую строку, которая будет прочитана следующим \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}

И вариант, где вместо этого заменяется текст ссылки.

\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

Вот возможное решение:

\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}

... и для второго МВЭ:

\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}

Связанный контент