Related to Autoref with optional argument, I would like to define an (optional) argument to \autoref that appears after the regular autoref printout, but within the actual link that is generated by \autoref.

I.e., the command

\autoref[(left inset)]{fig:somefigure} 

should produce a hyperref link with the complete text being active

... Figure 1 (left inset) ...

Is that possible in a generic way?


The trick is to always use a non-link reference and then separately adding the hyperlink: (example copied from Christian Hupfers answer to the original question)





See \autoref[ is very nice]{section:foo} or \autoref*[ is nice too]{section:foobar}

\section{Foo section}\label{section:foo}

\section{Foo bar section}\label{section:foobar}


enter image description here

  • Great – thank you Marcel! For completeness, I've added an \xspace to automatically get the space between regular and optional argument –> \autoreforig*{#3}\xspace\IfValueT{#2}{#2} – yogik Apr 24 '18 at 18:39

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.