12

I have a big table where I need to use multiple lines on each cell. The table is too big though so I need the space between lines on each cell to be smaller.

I found on another post that I could use this to make several lines on a cell

\newcommand{\specialcell}[2][c]{\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}

And this is part of my table

\begin {table}[H]
\begin{center}
  \begin{tabular}
      {| >{\footnotesize}C{2cm} | >{\footnotesize}C{2cm} | >{\footnotesize}C{2cm} | >{\footnotesize}C{2cm} | >{\footnotesize}C{2cm} |} \hline Imagen a comparar & $1^{er}$ resultado de clasificación & $2^{do}$ resultado de clasificación & $3^{er}$ resultado de clasificación & $4^{to}$ resultado de clasificación \\
      \hline \specialcell{\includegraphics[scale=0.05]{barley/b2.jpeg} \\ barley2 \\(\textbf{Clase 1})} &
      \specialcell{\includegraphics[scale=0.05]{barley/b2.jpeg} \\barley2 \\(0.0)} &
      \specialcell{\includegraphics[scale=0.05]{barley/b4.jpeg} \\barley4 \\(0.236041)} &
      \specialcell{\includegraphics[scale=0.05]{barley/b5.jpeg} \\barley5 \\(0.248987)} &
      \specialcell{\includegraphics[scale=0.05]{barley/b1.png} \\barley1 \\(0.333787)} \\ 
      \hline \specialcell{\includegraphics[scale=0.05]{canvas/c21.jpeg} \\canvas21 \\\textbf{Clase 2}} &
      \specialcell{\includegraphics[scale=0.05]{canvas/c21.jpeg} \\canvas21 \\(0.0)} & 
      \specialcell{\includegraphics[scale=0.05]{canvas/c28.jpeg} \\canvas28 \\(0.309975)} & 
      \specialcell{\includegraphics[scale=0.05]{seeds/s9.jpeg} \\seeds9 \\(0.321354)} &
      \specialcell{\includegraphics[scale=0.05]{canvas/c14.jpeg} \\canvas14 \\(0.338891)} \\ 
      \hline
  \end{tabular}
  \caption{Resultados de la clasificación ascendente de texturas Outex.} \label{cuadroOutex}
 \end{center}
\end{table}

So any idea how can I make the linebreaks smaller I tried adding [0.5ex] after each linebreak within a cell but the space didn't seem to change.

3
  • 2
    \setlength\extrarowheight{-1pt} might do it, changing -1pt to desired value. Jul 16, 2013 at 18:28
  • You haven't given any information about your definitions so hard to say but it looks like your C columns are par columns already so would allow mult-line content so the \specialcell command is not needed. Also you probably want to use \centering rather than \begin{center} \end{center} as the latter adds vertical space. Jul 16, 2013 at 20:39
  • @StevenB.Segletes Would you like to write an answer? Aug 3, 2013 at 22:40

2 Answers 2

11

As David Carlisle pointed out at extrarowheight vs arraystretch, \extrarowheight is a length added by the array package to change the default inter-line gap setting between array or tabular lines. It can be positive or negative (though it appears the negative values are limited in how close they can scrunch the lines).

Here is a demonstration showing both negative and positive \extrarowheight:

\documentclass{article}
\usepackage{array}
\begin{document}

\begin {table}[ht]
\begin{center}
  \setlength\extrarowheight{-3pt}
  \begin{tabular}{ccc}
  1 & 2 & 3\\
  4 & 5 & 6\\
  7 & 8 & 9\\
  \end{tabular}
  \caption{My caption}
 \end{center}
\end{table}

\begin {table}[ht]
\begin{center}
  \setlength\extrarowheight{6pt}
  \begin{tabular}{ccc}
  1 & 2 & 3\\
  4 & 5 & 6\\
  7 & 8 & 9\\
  \end{tabular}
  \caption{My caption}
 \end{center}
\end{table}

\end{document}

enter image description here

4

Simply \renewcommand{\arraystretch}{0.8} (Default value is 1).

It can be placed before \begin{tabular}{ c c c } or at beggining of document for all tables.

Source: overleaf

Follow a working example:

\documentclass{article}
\usepackage{array}
\begin{document}

\begin {table}[ht]
\begin{center}
  \renewcommand{\arraystretch}{0} %%% Default value: 1, place  before \begin{tabular}{ c c c }.
  \begin{tabular}{ccc}
  1 & 2 & 3\\
  4 & 5 & 6\\
  7 & 8 & 9\\
  \end{tabular}
  \caption{My caption}
 \end{center}
\end{table}

\begin {table}[ht]
\begin{center}
  \renewcommand{\arraystretch}{0.8} %%% Default value: 1, place  before \begin{tabular}{ c c c }.
  \begin{tabular}{ccc}
  1 & 2 & 3\\
  4 & 5 & 6\\
  7 & 8 & 9\\
  \end{tabular}
  \caption{My caption}
 \end{center}
\end{table}

\begin {table}[ht]
\begin{center}
  \renewcommand{\arraystretch}{2} %%% Default value: 1, place  before \begin{tabular}{ c c c }.
  \begin{tabular}{ccc}
  1 & 2 & 3\\
  4 & 5 & 6\\
  7 & 8 & 9\\
  \end{tabular}
  \caption{My caption}
 \end{center}
\end{table}

\end{document}

enter image description here

You must log in to answer this question.

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