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:
- the desired vertical spacing produced by
itemize
, tabular
with\renewcommand*{\arraystretch}{2.4}
,tabu
with\tabulinesep=0.5ex
, and- 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}
\newcommand*{\AddLinkToFile}[1]{\href{run:#1.pdf}{\strut#1}}
\begin{document}
\begin{minipage}{2.0cm}
\begin{itemize}
\item \AddLinkToFile{a} b
\item \AddLinkToFile{c} d
\end{itemize}
\end{minipage}
%
\begin{minipage}{2.0cm}
%\renewcommand*{\arraystretch}{2.4}
\begin{tabular}{ll}
\AddLinkToFile{e} & f \\
\AddLinkToFile{g} & h \\
\end{tabular}
\end{minipage}
%
\begin{minipage}{2.0cm}
%\tabulinesep=0.5ex
\begin{tabu}{ll}
\AddLinkToFile{i} & j \\
\AddLinkToFile{k} & l \\
\end{tabu}
\end{minipage}
%
\begin{minipage}{2.0cm}% Manually adding space
\begin{tabular}{ll}
\AddLinkToFile{l} & m \\[1.25ex]
\AddLinkToFile{n} & o \\
\end{tabular}
\end{minipage}
\end{document}
\itemsep+\parsep
, so the following should work:\begin{tabular}{ll} \AddLinkToFile{e} & f \\[\dimexpr\itemsep+\parsep\relax] \AddLinkToFile{g} & h \\end{tabular}
\href
box. Also would like to figure out how to automate it, as I have many tables in my document following anitemize
.\\
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?\itemsep
, so \\ \[-\itemsep] should also work. Arghhh! How do you write \\ using code tags in comments?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.