In a (complicated) definition of a command, I'm using \hyperref{.... But the package hyperref slows down compilation. So I'd like to make \hyperrefsimply do nothing, as long as the package hyperref is not loaded.
In a later stage I'd like to add \usepackage{hyperref}to my text, when I have to compile less often.
So I thought of \providecommand. What I don't know, is how to define \hyperref in a way that it simply does nothing, but without preventing the rest of my complicated command from being executed.
I wrote a MWE. In case the hyperref package is not loaded, \secrefshould be executed as if there were no \hyperref, which means in the case of my stupid example, just \refshould be executed.
\documentclass{article}
\providecommand{\hyperref}{»DO NOTHING«}
\newcommand{\secref}[1]{%
\hyperref{%
\ref{#1}
}
}
\begin{document}
\section{Huhu}
\label{CLA:huhu}
Text \secref{CLA:huhu}
\end{document}
I know that my example won't work, if I load the hyperref package, but this isn't the question. I lacked of a better idea for the MWE.
\hyperrefto fall back to\ref? – Aug 30 '16 at 12:45\hyperrefto do nothing, as long as the package hyperref is not loaded. But 'nothing' means, the rest of the command\secrefshould be executed. – Keks Dose Aug 30 '16 at 12:48\providecommand{\hyperref}{}? – Ulrike Fischer Aug 30 '16 at 13:04\hyperrefeither has an optional argument and a mandatory one or another version with 4 mand. arguments, none of them is gobbled away with\providecommand{hyperref}{}in my point of view! – Aug 30 '16 at 13:38\secref. If you remove this space, then\providecommand{\hyperref}[2][]{#2}should do what you ask. – Werner Aug 30 '16 at 15:16\providecommand{\hyperref}{}? – Keks Dose Aug 30 '16 at 16:25