# Adjust vertical spacing in tabular containing \href

I seem to be stumped by what seems like a basic tabular spacing issue (when an \href is used). The obvious solution of tweaking arraystretch does not seem to work.

What I want is that the output of the tabular to look like the output of itemize, in terms of vertical spacing between the lines. The first column below is the spacing that itemize produces and looks great. The next two columns are what tabular and tabu produce with default settings:

As you can see, the lines in tabular and tabu are too close vertically.

So I thought that increasing the \arraystretch in tabular, or setting \tabulinesep in tabu should work just fine. I wanted to avoid a manual solution of adding specifying the vertical space following a \\. But even that does not work!

The columns above are:

1. the desired vertical spacing produced by itemize,
2. tabular with \renewcommand*{\arraystretch}{2.4},
3. tabu with \tabulinesep=0.5ex, and
4. manually added \\[1.25ex] at the end of the line:

Basically, I do not want the \href box to stretch, but do want the lines further apart.

## Notes:

• In only put these in minipages to make it easier to compare. In my really application they are below each other. Plus this makes one nice wide image. So, am not trying to get the baseline's aligned here.
• Now that I put this the two figures above it appears that the overlap does not change. That seems to be a clue, but not sure how I can use that info.

## Code:

\documentclass{article}
\usepackage{enumitem}
\usepackage{tabu}

\usepackage{hyperref}

\begin{document}
\begin{minipage}{2.0cm}
\begin{itemize}
\end{itemize}
\end{minipage}
%
\begin{minipage}{2.0cm}
%\renewcommand*{\arraystretch}{2.4}
\begin{tabular}{ll}
\end{tabular}
\end{minipage}
%
\begin{minipage}{2.0cm}
%\tabulinesep=0.5ex
\begin{tabu}{ll}
\end{tabu}
\end{minipage}
%
\begin{tabular}{ll}
\end{tabular}
\end{minipage}
\end{document}

-
The default vertical space between consecutive items is controlled by \itemsep+\parsep, so the following should work: \begin{tabular}{ll} \AddLinkToFile{e} & f \\[\dimexpr\itemsep+\parsep\relax] \AddLinkToFile{g} & h \\end{tabular} –  Gonzalo Medina Oct 8 '12 at 2:55
Yes, but that stretches out the \href box. Also would like to figure out how to automate it, as I have many tables in my document following an itemize. –  Peter Grill Oct 8 '12 at 2:59
@cmhughes and Gonzalo: I found a manual solution by an accident during copy and past error (forgot to remove the \\  before pasting another one. The following works: \\ \\[-4pt]. The first \\  makes sure the \href box is the correct size, and the second \\[-4pt] controls the spacing. So, how do I automate this? –  Peter Grill Oct 8 '12 at 3:03
The 4pt is from \itemsep, so \\ \[-\itemsep] should also work. Arghhh! How do you write \\ using code tags in comments? –  Gonzalo Medina Oct 8 '12 at 3:06
Ok that explains the 4pt. The only way I found to show a \\  is to leave a trailing space before the closing back tick. So, now just need to figure out how to automate it. –  Peter Grill Oct 8 '12 at 3:13

• For the correct vertical spacing I will use listliketab
• Amsmath's \smash is surprisingly helpful.

## Introducing to \smash

If I'd use

\newcommand*{\AddLinkToFile}[1]{\smash{\href{run:#1.pdf}{\strut#1}}}


The href-box becomes now a very small box (1pt height, 1pt depth?). This is also true for not-tabularized material.

## There are three optional argument to \smash

After playing around with [b] and [t] to see its effect I tried

\newcommand*{\AddLinkToFile}[1]{\smash[]{\href{run:#1.pdf}{\strut#1}}}


which does wonders:

(The height and depth of the resulting box comes from \strut.)
Bug or feature? I don't know …

But every use of \strut ([t], [b], [] or no optional at all) breaks the \AddLinkToFile in a real itemize environment unless you add a \leavevmode in front of it.

So the final \AddLinkToFile command would be:

\newcommand*{\AddLinkToFile}[1]{\leavevmode\smash[]{\href{run:#1.pdf}{\strut#1}}}


## Code

\documentclass{article}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{tabu}
\usepackage{listliketab}
\usepackage{hyperref}

\storestyleof{itemize}

\begin{document}

\begin{itemize}
\end{itemize}

\begin{minipage}{2.0cm}
\begin{listliketab}
\begin{tabular}{Ll}
\end{tabular}
\end{listliketab}
\end{minipage}
%
\begin{minipage}{2.0cm}
\begin{listliketab}
\renewcommand*{\arraystretch}{2.4}
\begin{tabular}{ll}
\end{tabular}
\end{listliketab}
\end{minipage}
%
\begin{minipage}{2.0cm}
\begin{listliketab}
\tabulinesep=0.5ex
\begin{tabu}{ll}
\end{tabu}
\end{listliketab}
\end{minipage}
%
\begin{minipage}{2.0cm}
\begin{listliketab}
\begin{tabular}{ll}

Well that seems to fix the tabular issue, but creates an issue for itemize? –  Peter Grill Oct 8 '12 at 4:06