I have used the StylishArticle class several times, but I recently thought it would be a good idea to reference sections based on their names instead of using sections numbers or pageref.

So I defined \newcommand{\appref}[1]{Appendix:\nameref{#1}} for use with \subsection* (not numbered), and tested it with a normal article class. Seems to be working fine.

However when I use it with StylishArticle, it doesn't seem to work so well, and I get a warning:

Package hyperref Warning: Suppressing empty link on input line 86.

This link will get you to an Overleaf document (read-only) so you can see for yourself. I tried to keep the example small, but I don't think it's minimal; I need help identifying what's causing this issue. Any help greatly appreciated!

Following @egreg suggestion, here is a much shorter MWE:



    \section{A normal section}
    Reference to \appref{app}.


  • @Sh3ljohn The life time of the link target can be different of the life time of the question. Therefore, it is better to include the short document in the question text. – Heiko Oberdiek Oct 2 '16 at 14:48
  • @HeikoOberdiek Please see the latest edit, sorry about the length, but that's as short as it gets if I should include the class-file. – Jonathan H Oct 2 '16 at 14:51
  • I can easily make up a non working example with the article class, by just loading titlesec. – egreg Oct 2 '16 at 14:52
  • @egreg Very sorry, but I don't know how to do that. :/ – Jonathan H Oct 2 '16 at 14:53
  • 1
    @Sh3ljohn \documentclass{article}\usepackage{titlesec}\usepackage{hyperref}, then the definition of \appref and the same body as your test document. – egreg Oct 2 '16 at 15:04

From hyperref's README:


nameref supports titlesec, but hyperref does not (unsolved is the anchor setting, missing with unnumbered section, perhaps problems with page breaks with numbered ones).

| improve this answer | |
  • Right, so there is no way I can link the names of my unnumbered sections then? – Jonathan H Oct 2 '16 at 15:16
  • @Sh3ljohn Does the answer of the duplicate, found by you, works for you? – Heiko Oberdiek Oct 2 '16 at 16:46
  • Sorry for being so demanding, but although I understand that titlesec is causing the issue, and I understand that @egreg defined new commands for subsubsections, I am not sure how to implement this in the class-file linked in the OP.. I can see a titleformat definition in there for (sub(sub))sections, but there is also a special definition for \titleformat{name=\section,numberless} and I don't know how to adapt the answer from the duplicate to that case. – Jonathan H Oct 2 '16 at 17:40

As in @egreg's answer, the following definitions did it for me, although this implied using \appsubsec{name}{app:label} instead of the usual \subsection*{name}\label{app:label}.

  \def\@currentlabelname{App: #1}%
  \def\@currentlabelname{App: #1}%
  \def\@currentlabelname{App: #1}%

These commands make sure that only appsec (the equivalent of section*) is entered into the table of contents, so that you only see one entry Appendices (which should be defined in your document to mark the beginning of appendices), and not each appendix listed as a normal subsection.

Note that these commands require a label (the second input is not optional), and that calling \nameref{app:label} in your document will yield a link with text App: name.

| improve this answer | |
  • Thank you! And I just want to throw this out there for anyone else; make sure you use \makeatletter and \makeatother or you won't get any effect. – user59034 Nov 5 '16 at 19:04

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.