If package is not loaded, provide command that doesn't interfere

The hyperref bundle comes with the nohyperref package, which provides the command syntax of hyperref without the actual complicated hyperref mechanism. This makes it useful for draft documents, which seems to be what you're looking for.

Example:

\documentclass{article}

\usepackage{nohyperref}

\newcommand{\secref}[1]{%
  \hyperref[#1]{section \ref*{#1}}%
}

\begin{document}

\section{Huhu}
\label{CLA:huhu}

Text \secref{CLA:huhu}

\end{document}

When you're approaching the final version of the document, you just need to replace nohyperref with hyperref.

Another possibility is to load hyperref with the draft option:

\documentclass{article}

\usepackage[draft]{hyperref}

\newcommand{\secref}[1]{%
  \hyperref[#1]{section \ref*{#1}}%
}

\begin{document}

\section{Huhu}
\label{CLA:huhu}

Text \secref{CLA:huhu}

\end{document}

This also speeds up document compilation.


You may simply use \ignorespaces:

\documentclass{article}

\providecommand{\hyperref}[4]{#1\ignorespaces}

\newcommand{\secref}[1]{%
  \hyperref{%
    \ref{#1}
  }{}{}{}
}

\begin{document}

\section{Huhu}
\label{CLA:huhu}

Text \secref{CLA:huhu}


\end{document}

Tags:

Macros

Nesting