0

I want a link to a chapter or subsection name...

...
\begin{document}
\chapter{Laravel installation}
\label{laravelinstallation}

Install Laravel by...

\section{PhpStorm}
\label{phpstorm}

After installation, see \autoref{laravelinstallation}...

\end{document}
  1. I want to output "After installation, see Laravel installation..."

  2. I must use \autoref{} because I'm compiling Scrivener to Latex via MMD mark-up and that's how it's output.

I'm using Hyperref and Cleveref, and spent hours on search engines to the point where my two braincells have ceased to cooperate. Is there an easy/recommended/flamingly-obvious way to do this?

  • 1
    You're looking for \nameref{laravelinstallation} here... – Werner Nov 19 '19 at 22:39
  • Okay. I was specific about "I must use \autoref{} because...". Linking a reference to title text is a very common scenario, as is specifically compiled output from excellent software written by experts over thousands of man hours. That's what I want to do, resolve a very common scenario. Is there a healthy way to redefine \autoref to do what \nameref produces? – Mike A Nov 20 '19 at 7:48
0

I built upon a helpful answer by karlkoeller at Combining \autoref and \eqref, although my effort is not as smooth as answers there.

I removed cleveref package and modified \autoref...

\renewcommand{\autoref}[1]{%
    \begingroup%
    \def\chapterautorefname~##1\null{Chapter~(##1)\null}%
    \def\sectionautorefname~##1\null{Section~(##1)\null}%
    \def\subsectionautorefname~##1\null{Sub--Section~(##1)\null}%
    \def\figureautorefname~##1\null{Figure~(##1)\null}%
    \def\tableautorefname~##1\null{Table~(##1)\null}%
    \def\equationautorefname~##1\null{Equation~(##1)\null}%
    \emph{see \nameref{#1}}%
    \endgroup%
}

It produced this (image from document, not originally posted example)...

enter image description here

That line \emph{see \nameref{#1}}% solves my specific problem.

I accept this is a kludge but I looked far and wide for an answer and needed something as quickly as possible. Of course, it redefines \autoref to look like \nameref, thus destroying \autoref's nice section 1.2.3 formatting. Time permitting, I shall look at how to modify -- unless someone here does it first! ;)

| improve this answer | |

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.