4

For the purpose of a paper I am writing I have some very big tables. I couldn't fit the numbers inside the boxes so I used pbox. The problem is that now the numbers within the box aren't distributed evenly and there is too much free space in between lines. Is there a solution to it that still uses pbox?

\usepackage{multirow}
\usepackage{pbox}
\usepackage{caption}

\begin{table}[h]
\begin{tabular}{|l|l|l|l|l|}
\hline
\multicolumn{2}{|l|}{SOME TEXT HERE}           & \multicolumn{3}{l|}{Big title that takes the whole page} \\ \hline
\multicolumn{2}{|l|}{MORE TEXT}                           & number    & number    & number \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number    & number    & number         \\ \hline
some title here          & value       &\pbox{25cm}{12341 538768 \\ 23423 22}& \pbox{25cm}{12341 538768 \\ 23423 22}   &    \pbox{25cm}{12341 538768 \\ 23423 22}      \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number    & number    & number    \\ \hline
some title here         & value                     &  \pbox{25cm}{12341 538768 \\ 23423 228}& \pbox{25cm}{12341 538768 \\ 23423 22}   &  \pbox{25cm}{12341 538768 \\ 23423 22}       \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number    & number    & number     \\ \hline
some title here         & value l                     &   \pbox{25cm}{12341 538768 \\ 23423 22}& \pbox{25cm}{12341 538768 \\ 23423 22}  & \pbox{25cm}{12341 538768 \\ 23423 22}      \\ \hline
\end{tabular}
\captionof{table}{There should be proper caption.}
\end{table}

Below I attached an image showing the current result:

enter image description here

7
  • Where do you get \pbox from?
    – Werner
    Jan 27, 2015 at 19:59
  • From this package: \usepackage{pbox}
    – Max
    Jan 27, 2015 at 20:01
  • It's helpful if you make your examples complete so people can test see the result and test answers. Jan 27, 2015 at 20:21
  • Further to @DavidCarlisle's comment, I don't get such a bad result when I paste your code into a basic document. Something else must be affecting the interline spacing. Jan 27, 2015 at 20:27
  • the edit still does not make your posted code runnable, compare with the fragment in my answer which you can test without having to edit. Jan 27, 2015 at 20:32

2 Answers 2

6

You can use the makecell package for that: it allows for linebreaks and common formatting in certain cells, with the \makecell and \thead commands:

\documentclass[a4paper]{article}
\usepackage{array}
\usepackage{makecell}
\renewcommand\cellalign{lc}
\setcellgapes{3pt}
\makegapedcells

\begin{document}

\begin{table}[htp]
\begin{tabular}{|*{5}{l|}}
\hline
\multicolumn{2}{|l|}{SOME TEXT HERE} & \multicolumn{3}{l|}{Big title that takes the whole page} \\ \hline
\multicolumn{2}{|l|}{MORE TEXT} & number & number & number \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value &\makecell{12341 538768 \\ 23423 22}& \makecell{12341 538768 \\ 23423 22} & \makecell{12341 538768 \\ 23423 22} \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value & \makecell{12341 538768 \\ 23423 228}& \makecell{12341 538768 \\ 23423 22} & \makecell{12341 538768 \\ 23423 22} \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value l & \makecell{12341 538768 \\ 23423 22}& \makecell{12341 538768 \\ 23423 22} & \makecell{12341 538768 \\ 23423 22} \\ \hline
\end{tabular}
\caption{There should be proper caption.}
\end{table}

\end{document} 

enter image description here

5

pbox doesn't seem to help you much here, I'd just use tabular

enter image description here

\documentclass[a4paper]{article}
\usepackage{array}
\setlength\extrarowheight{2pt}
\begin{document}
\newcommand\pb[1]{%
\begin{tabular}{@{}l@{}}#1\end{tabular}}
\begin{table}[htp]
\begin{tabular}{|l|l|l|l|l|}
\hline
\multicolumn{2}{|l|}{SOME TEXT HERE}           & \multicolumn{3}{l|}{Big title that takes the whole page} \\ \hline
\multicolumn{2}{|l|}{MORE TEXT}                           & number    & number    & number \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number    & number    & number         \\ \hline
some title here          & value       &\pb{12341 538768 \\ 23423 22}& \pb{12341 538768 \\ 23423 22}   &    \pb{12341 538768 \\ 23423 22}      \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number    & number    & number    \\ \hline
some title here         & value                     &  \pb{12341 538768 \\ 23423 228}& \pb{12341 538768 \\ 23423 22}   &  \pb{12341 538768 \\ 23423 22}       \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number    & number    & number     \\ \hline
some title here         & value l                     &   \pb{12341 538768 \\ 23423 22}& \pb{12341 538768 \\ 23423 22}  & \pb{12341 538768 \\ 23423 22}      \\ \hline
\end{tabular}
\caption{There should be proper caption.}
\end{table}

\end{document}
1
  • If these \pbox/\pb` entries are just a large single numer you want to wrap on space that could be automatic without needing to have a command and explicit \\ but I left it this way as it wasn't clear in your question the input context Jan 27, 2015 at 20:41

You must log in to answer this question.

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