3

I am using the hyperref package in my document for links and ntheorem for theorems. I want to use the "break" theoremstyle that gives a line break after the theorem label. But then using references in the first line of my theorem will cause hyperref to overdraw the red box.

MWE:

\documentclass[]{report}

\usepackage[pdftex]{hyperref}
\usepackage[hyperref]{ntheorem}
\newtheorem{theorem}{Theorem}
\theoremstyle{break}
\newtheorem{lemma}{Lemma}

\begin{document}

\begin{lemma}\label{lem}
    An interesting lemma!
\end{lemma}
\begin{lemma}[Some description]
    Here we refer to lemma \ref{lem}. This causes the red box to overdraw.
\end{lemma}
\begin{theorem}
    Here, we need some more space to get into the second line, but then the link to our lemma \ref{lem} does not pose a problem.
\end{theorem}

\end{document}          

Screenshot: Screenshot of the MWE

Does anyone know how to fix this? Thank you!

2 Answers2

1

You could surround your \ref with a \mbox. In the following example there's an own command for that.

boxes

\documentclass[]{report}

\usepackage[hyperref]{ntheorem}
\usepackage{hyperref}

\newtheorem{theorem}{Theorem}
\theoremstyle{break}
\newtheorem{lemma}{Lemma}

\newcommand{\lref}[1]{\mbox{\ref{#1}}}

\begin{document}

\begin{lemma}\label{lem}
    An interesting lemma!
\end{lemma}
\begin{lemma}[Some description]
    Here we refer to lemma \lref{lem}. This causes the red box to overdraw.
\end{lemma}
\begin{theorem}
    Here, we need some more space to get into the second line, but then the link to our lemma \lref{lem} does not pose a problem.
\end{theorem}

\end{document}          
TeXnician
  • 33,589
1

The height and depth of the surrounding box is used to get height and depth of the annotation rectangle in case of driver pdftex. The surrounding box for the link in Lemma 2 includes the Lemma title line and the descender of f in refer. The theorem is implemented differently, thus the current height is much smaller.

The rectangles can be more tight by surrounding the links with smaller boxes, \mbox. The third link in the row increases the box by \vphantom to get a more uniform height and depth. Then the rectangles for link texts 1, m, g would share the same height and depth.

\documentclass[]{report}

\usepackage[pdftex]{hyperref}
\usepackage[hyperref]{ntheorem}
\newtheorem{theorem}{Theorem}
\theoremstyle{break}
\newtheorem{lemma}{Lemma}

\begin{document}

\begin{lemma}\label{lem}
    An interesting lemma!
\end{lemma}
\begin{lemma}[Some description]
    Here we refer to lemma
    \ref{lem}/\mbox{\ref{lem}}/\mbox{\vphantom{g\"A}\ref{lem}}.
    This causes the red box to overdraw.
\end{lemma}
\begin{theorem}
    Here, we need some more space to get into the second line,
    but then the link to our lemma
    \ref{lem}/\mbox{\ref{lem}}/\mbox{\vphantom{g\"A}\ref{lem}}
    does not pose a problem.
\end{theorem}

\end{document}

Result

Heiko Oberdiek
  • 271,626