# Hyperlinks Vertical Alignment Inside tabulary

When trying to create a table using tabulary as:

 \documentclass{article}

\usepackage{booktabs}
\usepackage{tabulary}
\usepackage{hyperref}

\begin{document}

\begin{tabulary}{6in}{rCJ}
\toprule
\textbf{Thing} & \textbf{Another} & \textbf{Thing} \\
\midrule
DEF & \hyperlink{def:ABC_DEF}{\texttt{ABC\_DEF}} & Some letters going on over here. \\
GHIJKL & \hyperlink{def:ABC_GHI}{\texttt{ABC\_GHI}} \hyperlink{def:ABC_JKL}{\texttt{ABC\_JKL}} & This box has enough text inside of it to do some word wrapping I should hope, as that's what happens in my table. \\
\bottomrule
\end{tabulary}

\end{document}


the table entries that are hyperlinks show up as being aligned with the bottom of the cell such that they're offset from the other text in the same row (i.e. DEF is above ABC_DEF in the table). When I remove the hyperlinks, however, the text in the rows are all aligned.

Is there any way I can use hyperlinks in a 'C' column of tabulary and maintain vertical alignment?

But the text is aligned; the boxes from the hyperlinks extend downwards, but the vertical position of the text remains unaltered, as can be seen with some auxiliary lines:

\documentclass{article}
\usepackage{tabulary}
\usepackage{booktabs}
\usepackage{hyperref}

\usepackage{tikz}

\begin{document}

\begin{tabulary}{6in}{rCJ}
\toprule
\textbf{Thing} & \textbf{Another} & \textbf{Thing} \\
\midrule
DEF & \hyperlink{def:ABC_DEF}{\texttt{ABC\_DEF}} & Some letters going on over here. \\
GHIJKL & \hyperlink{def:ABC_GHI}{\texttt{ABC\_GHI}} \hyperlink{def:ABC_JKL}{\texttt{ABC\_JKL}} & This box has enough text inside of it to do some word wrapping I should hope, as that's what happens in my table. \\
\bottomrule
\end{tabulary}

\begin{tikzpicture}[remember picture,overlay]
\draw[blue] (0,31.5pt)  -- +(\textwidth,0);
\draw[blue] (0,19.3pt)  -- +(\textwidth,0);
\draw[blue] (0,8pt)  -- +(\textwidth,0);
\end{tikzpicture}
\end{document}


Perhaps you could suppress the hyperlink boxes using some of the hyperref options, as in, for example, \usepackage[colorlinks]{hyperref}:

\documentclass{article}
\usepackage{tabulary}
\usepackage{booktabs}

\begin{document}

\begin{tabulary}{6in}{rCJ}
\toprule
\textbf{Thing} & \textbf{Another} & \textbf{Thing} \\
\midrule
DEF & \hyperlink{def:ABC_DEF}{\texttt{ABC\_DEF}} & Some letters going on over here. \\
GHIJKL & \hyperlink{def:ABC_GHI}{\texttt{ABC\_GHI}} \hyperlink{def:ABC_JKL}{\texttt{ABC\_JKL}} & This box has enough text inside of it to do some word wrapping I should hope, as that's what happens in my table. \\
\bottomrule
\end{tabulary}

\end{document}


If you want to keep the boxes, but making them tighter, you can use Heiko Oberdiek's suggestions in his answer to \ref with tight box surrounding the reference:

\documentclass{article}
\usepackage{tabulary}
\usepackage{booktabs}
\usepackage{hyperref}

\begin{document}

\begin{tabulary}{6in}{rCJ}
\toprule
\textbf{Thing} & \textbf{Another} & \textbf{Thing} \\
\midrule
DEF & \mbox{\hyperlink{def:ABC_DEF}{\texttt{ABC\_DEF}}} & Some letters going on over here. \\
GHIJKL & \hyperlink{def:ABC_GHI}{\texttt{ABC\_GHI}} \mbox{\hyperlink{def:ABC_JKL}{\texttt{ABC\_JKL}}} & This box has enough text inside of it to do some word wrapping I should hope, as that's what happens in my table. \\
\bottomrule
\end{tabulary}

\end{document}


• Nice! Ugly red frames I would say. Is it possible to do it closer? Oct 16, 2012 at 1:36
• @Sigur what do you mean? Do you mean to have the boxes tighter? Oct 16, 2012 at 1:40
• Yes, like \fbox. Oct 16, 2012 at 1:41
• @Sigur one can use \hypersetup{pdflinkmargin=0pt} (see tex.stackexchange.com/a/77595/3954) but if the surrounding boxes have descenders the hyperlink boxes will still have depth. Oct 16, 2012 at 1:45
• @Sigur please see the last example in my updated answer. Oct 16, 2012 at 1:51