5

I have been using upref to remove italics in \refs. Does there exist a package that does the same for \hyperrefs?

As per request, a minimal example:

\begin{theorem}
Each \hyperref[def:bounded_sequence]{bounded sequence} in $\mathbb{R}^n$
has a convergent subsequence.
\end{theorem}

Here, "bounded sequence" with the usual theorem style, but I would like to appear without it.

1
  • Can you make an example of what you mean?
    – egreg
    Oct 2, 2015 at 15:39

2 Answers 2

1

Set the corresponding \hyperref entry with the font declaration \upshape:

enter image description here

\documentclass{article}

\usepackage{hyperref,amsfonts}

\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}\label{def:bounded_sequence}
Some bounded sequence theorem.
\end{theorem}

\begin{theorem}
Each \hyperref[def:bounded_sequence]{\upshape bounded sequence} in $\mathbb{R}^n$
has a convergent subsequence.
\end{theorem}

\end{document}

For a global setup you could add

\usepackage{letltxmacro}
\LetLtxMacro\oldhyperref\hyperref
\renewcommand{\hyperref}[2][]{\oldhyperref[#1]{\upshape #2}}

to your preamble.

Instead of \upshape, you could use other declarations like \normalfont.

1
  • Redefining \hyperref that way is not a good idea.
    – egreg
    Oct 2, 2015 at 21:27
3

The mandatory argument to \hyperref is actually managed by the auxiliary macro \label@@hyperref and it would be wrong to redefine \hyperref, because this disrupts all the setup the command must do for neutralizing special characters in link references.

\documentclass{article}

\usepackage{amsfonts}
\usepackage{etoolbox}
\usepackage{hyperref} % last one

\makeatletter
\patchcmd{\label@@hyperref}{\begingroup#3}{\begingroup\upshape#3}{}{}
\patchcmd{\label@@hyperref}{{#3}}{{\textup{#3}}}{}{}
\makeatother

\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}\label{def:bounded_sequence}
Some bounded sequence theorem.
\end{theorem}

\begin{theorem}                
Each \hyperref[def:bounded_sequence]{bounded sequence} in $\mathbb{R}^n$
has a convergent subsequence.
\end{theorem}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy