Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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}
share|improve this answer
    
Thanks! How have you chosen '12pt'? –  Marco Apr 22 '13 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.) –  David Carlisle Apr 22 '13 at 9:18
add comment

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?

share|improve this answer
    
Thanks (+1) This is the solution I am currently using, and I am looking for something more elegant. –  Marco Apr 22 '13 at 7:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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