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.

Is there a way that I can insert a small space in a table? When I use a superscript, the number touches the \hline.

\documentclass[9pt,letterpaper]{article}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}

\begin{document}
\begin{picture}(0,0)

\put(20,-136){\mbox{    
        \footnotesize   
        \begin{tabular}{ p{8em}  r  r  l }  
        \hline      
                        & Total     & Average   & Unit   \\
        \hline      
        Area1           & 419773    &   9.15        &  \emph{m$^2$}      \\      
        Area2           & 0     &   0       &  \emph{m$^3$}      \\
        \hline  
        \end{tabular}
    }}  

\end{picture}

\end{document}

I tried inserting \vspace but this does not move everything, just one cell.

\vspace{0.001 in} Area1 & \vspace{0.001 in} 419773  &   \vspace{0.001 in} 9.15      & \vspace{0.001 in} \emph{m$^2$} \\

My preference would be to adjust this without an external package, as I am using an old version of LaTeX on a server that I cannot replace.

share|improve this question
    
possible duplicate of Column padding in tables –  Werner Apr 1 '12 at 16:29
    
Also a duplicate of tex.stackexchange.com/questions/50332/… -- there are some good answers here also. Amusingly, the two questions were posted three hours apart. –  Simon Shine Jan 19 at 18:11
    
3 hours and 4 minutes! –  celenius Jan 19 at 18:19
add comment

6 Answers 6

up vote 22 down vote accepted

use

\rule{0pt}{4ex}    

in the first column of that line.

share|improve this answer
1  
This does work (thank you). It creates a small offset unless the cell contents are touching the code (no whitespace). –  celenius Apr 1 '12 at 16:41
add comment

For a general reference on how to improve the spacing in tabular and array lines, see the article "Correct spacing for tables and arrays" by Claudio Beccari on p. 10 of TeX and TUG News 1993 (Vol. 2, No. 3).

His method, which involves judiciously inserting "struts", applies to lines in tabular (as well as tabular*, supertabular, xtabular, longtable) and array environments which contain

  • superscript material, on a line that's preceded by an \hline,
  • subscript material, on a line that's followed by an \hline, and
  • any other lines with material (including \hlines) above or below them that might result in a cramped look of the output.

He suggested defining a "top strut" and a "bottom strut" as follows:

\newcommand\T{\rule{0pt}{2.6ex}}       % Top strut
\newcommand\B{\rule[-1.2ex]{0pt}{0pt}} % Bottom strut

Using your MWE as a starting point -- by the way, 9pt is not a recognized option in the article document class, so I'm omitting it -- one could put these macros to use as follows:

\documentclass[letterpaper]{article}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}

\newcommand\T{\rule{0pt}{2.6ex}}       % Top strut
\newcommand\B{\rule[-1.2ex]{0pt}{0pt}} % Bottom strut

\begin{document}  
\begin{tabular}{ p{8em}  r  r  l }  
\hline      
          & Total     & Average   & Unit \T\B  \\
\hline      
Area 1    & 419773    &   9.15    &  m\textsuperscript{2} \T \\      
Volume 1  & 0         &      0    &  m\textsuperscript{3} \B \\
\hline  
\end{tabular}
\end{document}

enter image description here

share|improve this answer
    
This is a very nice approach. Is there a particular reason for putting the struts at the end of the line? That does add a very small padding for me (or maybe I am doing it wrong?) –  Boris Mar 19 at 4:18
    
@Boris - the struts can be inserted anywhere in a given row; I simply find it easiest to read the code if they're inserted at the start of the left-most cell or the end of right-most cell. There should be no extra (horizontal) padding from the struts; what you observe on the MWE is LateX's insertion of whitespace in the amount of \tabcolsep. –  Mico Mar 19 at 8:55
    
+1 for bottom strut. why is the syntax different? –  flies May 6 at 15:06
1  
@flies - Thanks. I'm not sure I understand what you mean by the syntax being different. Are you referring to the way the macros \T and \B are defined? A LaTeX \rule has one optional argument -- its depth, given in square brackets; a non-negative length parameter that indicates how much it protrudes below the baseline; if not provided, the default value of 0pt is used -- and two mandatory arguments: the rule's width (0pt in both cases since we're creating "invisible" rules) and the rule's height above the baseline. The height is nonzero for a top strut and zero for a bottom strut. –  Mico May 6 at 15:23
    
I was asking about the square brackets in ignorance of the difference between depth and height. It looks like my question is also answered in the latex wikibook: part 1 en.wikibooks.org/wiki/LaTeX/Rules_and_Struts part 2 en.wikibooks.org/wiki/LaTeX/Boxes#TeX_character_boxes –  flies May 7 at 16:23
add comment

you can load array package then

\setlength\extrarowheight{3pt}

the array package is a required part of the core latex distribution, so will be available on all installations.

share|improve this answer
add comment

The simplest solution was given by David Carlisle in How to add vertical space struts after hline?

\hline
\noalign{\vskip 2mm}    

For those who can use the bigstrut package, then just inserting \bigstrut[t] will fix the problem.

\documentclass[letterpaper]{article}
\usepackage{helvet}
\usepackage{bigstrut}
\renewcommand{\familydefault}{\sfdefault}

\begin{document}
\begin{picture}(0,0)

\put(20,-136){\mbox{    
        \footnotesize   
        \begin{tabular}{ p{8em}  r  r  l }  
        \hline      
                        & Total     & Average   & Unit   \\
        \hline      
        Area1           & 419773    &   9.15        &  \emph{m$^2$} \bigstrut[t]     \\  
        Area2           & 0     &   0       &  \emph{m$^3$}      \\
        \hline  
        \end{tabular}
    }}  

\end{picture}

\end{document}
share|improve this answer
add comment

fwiw, http://www.tex.ac.uk/cgi-bin/texfaq2html?label=struttab summarises all the above, and mentions a couple of other packages. (apologies for intruding with an obvious pointer.)

share|improve this answer
add comment

It may be worthwhile to take a look at the "booktabs" package, http://www.ctan.org/pkg/booktabs. Then, using e.g. the command \midrule instead of \hline provides additional space between the columns.

share|improve this answer
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.