4

I was drawing a table with extra spacing between the rows. Here is my code

\begin{tabular}{| c | c | c | c |}
\hline
$\alpha$ & $< -1 $ & $=-1$ & $>-1$ \\
\hline
\\[-1em]
$\int_0^1 x^\alpha \dd{x}$ & D & D & C \\[0.5ex]
\hline
\\[-1em]
$\int_1^{+\infty} x^\alpha \dd{x}$ & C & D & D \\[0.5ex]
\hline 
\end{tabular} 

table

As you can see there are discontinuous vertical lines. Why is that happening ?

4

You're not specifying all columns in the “empty” rows.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\dd}[1]{\mathop{}\!\mathrm{d}#1}

\begin{document}

\begin{tabular}{| c | c | c | c |}
\hline
$\alpha$ & $< -1 $ & $=-1$ & $>-1$ \\
\hline
&&&\\[-1em]
$\int_0^1 x^\alpha \dd{x}$ & D & D & C \\[0.5ex]
\hline
&&&\\[-1em]
$\int_1^{+\infty} x^\alpha \dd{x}$ & C & D & D \\[0.5ex]
\hline
\end{tabular}
\end{document}

enter image description here

A possible improvement, without the useless vertical rules:

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}

\newcommand{\dd}[1]{\mathop{}\!\mathrm{d}#1}

\begin{document}

\begin{tabular}{cccc}
\toprule
 & $\alpha< -1 $ & $\alpha=-1$ & $\alpha>-1$ \\
\midrule
$\displaystyle\int_0^1 x^\alpha \dd{x}$ & D & D & C \\
\addlinespace
$\displaystyle\int_1^{+\infty} x^\alpha \dd{x}$ & C & D & D \\
\bottomrule
\end{tabular} 

\end{document}

enter image description here

4

\\[-1em] adds a blank line, breaking all the rules with \baselineskip of space and the backs up by 1em so will more or less randomly overprint the previous line or leave a gap, depending on the relative sizes of 1em and \baselineskip.

\\ should only ever be use before \hline not after.

To increase the spacing below the \hline you could increase \arraystretch or use

\setlength\extrarowheight{2pt}

which requires the array package.

Also tables usually look better without vertical lines, which would make the problem of the gaps go away as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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