1

I am trying to underline links using \href from hyperref in a tabular environment, with an increased vertical spacing. As you can see in the MWE and the picture following it, it results in a line quite distant from the text, which is not aesthetically optimal and does not match the same link in the text body.

How can I reduce the vertical spacing between the link and the line? I have tried using \smash as suggested in other questions, but it does not solve the issue.

I could create a command to manually underline a link, like \newcommand{\ul}[2]{\underline{\href{#1}{#2}}}, but I guess there are more elegant solutions.

\documentclass[12pt]{report}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{graphicx}

\usepackage[unicode]{hyperref}
\hypersetup{pdfborderstyle={/S/U/W 1}}

\begin{document}
    
    \renewcommand{\arraystretch}{1.1}
    
    \href{https://www.google.com}{Link}
    
    \begin{tabular}{r}
        \href{https://www.google.com}{Link} \\
        \href{https://www.google.com}{\smash{Link}} \\
    \end{tabular}
    
\end{document}

example

3

The rectangle of a link is calculated by pdftex from the enclosing box, which for tabulars always contains a \strut. You can use \mbox to get a smaller box:

\documentclass[12pt]{report}

\usepackage[T1]{fontenc}

\usepackage{graphicx}

\usepackage[unicode]{hyperref}
\hypersetup{pdfborderstyle={/S/U/W 1}}

\begin{document}

    \renewcommand{\arraystretch}{1.1}

    \href{https://www.google.com}{Link}

    \begin{tabular}{r}
        \mbox{\href{https://www.google.com}{Link}} \\
        \href{https://www.google.com}{\smash{Link}} \\
    \end{tabular}

\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

Not the answer you're looking for? Browse other questions tagged or ask your own question.