6

I have defined a new command to increase the length between rows in a table:

\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}

For example

\documentclass[a4paper, 11pt]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}

\begin{document}

\ra{3}
\begin{tabular}{ll}
\hline
col 1 & col 2 \\
\hline
1 & 2 \\
3 & 4 \\
5 & 6 \\
7 & 8 \\
\hline
\end{tabular}

\end{document}

Here is what it gives (left) and what I would like (right). That is, I would like the new command not to have any effect in the header.

enter image description here

Can you help me?

0

2 Answers 2

4

enter image description here

\documentclass[a4paper, 11pt]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{array}

\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}

\begin{document}

\ra{3}
\begin{tabular}{ll}
\hline
\noalign{\vskip-12pt}
col 1 & col 2 \\
\noalign{\vskip-5pt}
\hline
1 & 2 \\
3 & 4 \\
5 & 6 \\
7 & 8 \\
\hline
\end{tabular}

\end{document}
2
  • Thanks! How have you chosen '12pt'?
    – Marco
    Apr 22, 2013 at 9:06
  • @Marco I looked at it on screen and picked a number out of my head:-) (It would be possible to do some arithmetic based on the various lengths but really table headers are a visual design and in the end what looks right is right.) Apr 22, 2013 at 9:18
2

I know is not the most elegant solution, but you could try:

\documentclass[a4paper, 11pt]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\begin{document}


\begin{tabular}{ll}
\hline
col 1 & col 2 \\
\hline
1 & 2 \\[2mm]
3 & 4 \\[2mm]
5 & 6 \\[2mm]
7 & 8 \\[2mm]
\hline
\end{tabular}


\end{document}

I know is like trying to insert a screw with a hammer, but perhaps it could be useful too, since takes away the need for your \ra command.

UPDATE:

Found a solution! is here: How to add extra spaces between rows in tabular environment?

1
  • Thanks (+1) This is the solution I am currently using, and I am looking for something more elegant.
    – Marco
    Apr 22, 2013 at 7:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .