I have an appendix in my document which I want to reference by its name in the text. I use the starred \section*
command here, because I do not want the appendix to appear in the TOC. However, \nameref
simply puts an empty space where the word "Appendix" should be.
Thanks to the comments, I now can see that the problem is actually the titlesec
package. I want my section Appendix
to appear as a non-numbered item in the TOC, but at the same time, I want to do there referencing with \nameref
as explained above. So I edited my example to now look like this:
\documentclass[11pt, oneside, a4paper]{article}\usepackage{titlesec} \titleformat{\section}{\normalfont\LARGE\bfseries}{\thesection}{1em}{} \titleformat{\subsection}{\normalfont\Large\bfseries}{\thesubsection}{1em}{} \titleformat{\subsubsection}{\normalfont\large\bfseries}{\thesubsubsection}{1em}{} \titleformat{\paragraph}[runin]{\normalfont\large\bfseries}{\theparagraph}{1em}{}\usepackage[hidelinks]{hyperref}\usepackage{nameref}\newcommand{\sectionbreak}{\clearpage}\begin{document}\tableofcontents % added this line\section{Section 1}\label{sec:section_1}All that can be seen in the \nameref{sec:appendix}.\section*{Appendix}\label{sec:appendix}\addcontentsline{toc}{section}{Appendix} % added this lineHere comes the appendix.\end{document}