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 like the style of the following table (booktabs effects, nice caption, equal width of data columns, right alignment of data, width set equal to the \linewidth, able to look at two estimator evaluation criteria side-by-side (MPE and MAPE), etc.). What I do NOT like is the imperfect right-alignment of the data (e.g., see data row 3) because there's a little too much "stuff" in the table and tabularx is trying to get all of it to fit within \linewidth.

Q: What are some good/standard options for dealing with this problem of a table with content that is too wide for the document?

I figure a few are:

  1. Use longtable and display the table in landscape (Would rather not do this. But it's not the worst approach)
  2. Stack the table so that the "Est." column is repeated once and "MPE" section is above the "MAPE" section (Would rather not do this. Like the idea of being able to look straight across the table)
  3. Decrease the font size of the document or the table (Not really an option. I just don't like this approach)
  4. Don't insist on equal column-widths so that columns without "-" signs are a little smaller. Then everything can fit (Really don't like this approach. Prefer equal column widths)
  5. Decrease \tabcolsep. (Not bad)
  6. Remove a digit. (This is probably my leading candidate)

tab1

\documentclass{article}
\usepackage{booktabs}
\usepackage{diagbox}
\usepackage{tabularx}
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=colon,tableposition=top,figureposition=top]{caption}
\begin{document}
\newcolumntype{R}{>{\raggedleft\arraybackslash$}X<{$}}
\begin{table}[ht]
  \centering
  \caption{My caption. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.}
  \begin{tabularx}{\linewidth}{@{}lRRRRRRRR@{}}
    \toprule
    & \multicolumn{4}{l}{MPE} & \multicolumn{4}{l}{MAPE}\\
    \cmidrule(r){1-1}  \cmidrule(lr){2-5} \cmidrule(l){6-9}
    \diagbox[trim=lr]{Est.}{Jumps} & 0 & 3 & 10 & 30 & 0 & 3 & 10 & 30 \\
    \midrule
    $\widetilde{JV}$                & 2.14 & 2.42    & 1.35     & -1.69  & 2.14 & 4.57 & 4.92  & 4.74 \\
    $\widehat{JV}$                  & 1.99 & 2.16    & 1.12     & -1.83  & 1.99 & 4.47 & 4.91  & 4.81 \\
    $\widehat{JV}_{\mathrm{BNS04}}$ & 0.35 & -4.35   & -12.91   & -26.35 & 3.11 & 5.48 & 12.95 & 26.35 \\
     \midrule
    $\widetilde{IV}$                & -2.03 & -2.52 & -1.33 & 1.73  & 6.54 & 6.37 & 5.24  & 3.71 \\
    $\widehat{IV}$                  & -1.87 & -2.26 & -1.10 & 1.87  & 6.48 & 6.31 & 5.23  & 3.80 \\
    $\widehat{IV}_{\mathrm{BNS04}}$ & -0.24 & 4.25  & 12.93 & 26.39 & 6.61 & 7.06 & 13.11 & 26.39 \\
    \bottomrule
  \end{tabularx}
\end{table}
\end{document}

NOTE: This is an extension of this previous question of mine where I was just trying to figure out how to do equal column widths and right-alignment in a table.

share|improve this question
1  
You could simply transpose the table, but keeping MPE and MAPE at the top, although that does not always make sense, data wise. Else I would try to do without the \diagbox, or if you really like it, remove space in that box so that it typesets smaller. –  zeroth Jan 23 '12 at 22:49
1  
@zeroth: +1 for the transpose and +1 for removing the \diagbox, I find such things disguisting –  tohecz Jan 23 '12 at 23:00
    
@tohecz: I'm curious why you find the \diagbox disgusting? What would you propose instead? Eliminating "Est." or "Jumps"? Adding an extra row to label "Est." and "Jumps" separately? –  lowndrul Jan 23 '12 at 23:30
    
@brianjd I will have to agree, it seems unstructered to the eye. However, some do like them as they can be very descriptive, in your case Est. is likely not descriptive, whence it could be left out. In that case you could right align Jumps or do Jumps: to show its relation to the row. Or further you could add Jumps after MPE and MAPE as those do seem to be related. –  zeroth Jan 23 '12 at 23:45
1  
@brianjd: I can't say I have a specific reason, just a feeling in my eye. The diagonal line simply visually breaks the structure of the table. First suggestion: I would probably remove the word Est. completely and think out a good caption of the table. Everybody who reads your article know what those JV and IV mean, and who did not, Est. abbreviation wouldn't help him anyways. Second suggestion: If you make Jumps and 0,3,10,30 in bold, you visually connect them and therefore it is clear, "who is who". –  tohecz Jan 24 '12 at 0:07

2 Answers 2

I'd take less space for the first column and use dcolumn rather than tabularx which ensures the numbers align and makes latex work a lot less hard, note this uses 2.2 as the size specifier which means no space is allocated for the minus signs and they stick into the intercolumn space, but I think that's OK here (and you haven't room for a specification of 3.2)

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage{diagbox}
\usepackage{tabularx}
\usepackage{dcolumn}
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=colon,tableposition=top,figureposition=top]{caption}
\begin{document}
%\newcolumntype{R}{>{\raggedleft\arraybackslash$}X<{$}}
\newcolumntype{R}{D{.}{.}{2.2}}
\begin{table}[ht]
  \centering
  \caption{My caption. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.}
  \begin{tabular}{@{}lRRRRRRRR@{}}
    \toprule
    & \multicolumn{4}{l}{MPE} & \multicolumn{4}{l}{MAPE}\\
    \cmidrule(r){1-1}  \cmidrule(lr){2-5} \cmidrule(l){6-9}
    \small\diagbox[trim=lr,width=4.5em]{Est.}{\kern3ptJumps\kern-3pt}& 0 & 3 & 10 & 30 & 0 & 3 & 10 & 30 \\
    \midrule
    $\widetilde{JV}$                & 2.14 & 2.42    & 1.35     & -1.69  & 2.14 & 4.57 & 4.92  & 4.74 \\
    $\widehat{JV}$                  & 1.99 & 2.16    & 1.12     & -1.83  & 1.99 & 4.47 & 4.91  & 4.81 \\
    $\widehat{JV}_{\mathrm{BNS04}}$ & 0.35 & -4.35   & -12.91   & -26.35 & 3.11 & 5.48 & 12.95 & 26.35 \\
     \midrule
    $\widetilde{IV}$                & -2.03 & -2.52 & -1.33 & 1.73  & 6.54 & 6.37 & 5.24  & 3.71 \\
    $\widehat{IV}$                  & -1.87 & -2.26 & -1.10 & 1.87  & 6.48 & 6.31 & 5.23  & 3.80 \\
    $\widehat{IV}_{\mathrm{BNS04}}$ & -0.24 & 4.25  & 12.93 & 26.39 & 6.61 & 7.06 & 13.11 & 26.39 \\
    \bottomrule
  \end{tabular}
\end{table}
\end{document}
share|improve this answer

One way (I do not know whether it is a good way or not, but should do since you have given me only limited options) is to use fullpage

\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage{fullpage} %<======================== here.
\usepackage{diagbox}
\usepackage{tabularx}
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=colon,tableposition=top,figureposition=top]{caption}
\begin{document}
\newcolumntype{R}{>{\raggedleft\arraybackslash$}X<{$}}
\begin{table}[ht]
  \centering
  \caption{My caption. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.}
  \begin{tabularx}{1\linewidth}{@{}lRRRRRRRR@{}}
    \toprule
    & \multicolumn{4}{c}{MPE} & \multicolumn{4}{c}{MAPE}\\
    \cmidrule(r){1-1}  \cmidrule(lr){2-5} \cmidrule(l){6-9}
    \diagbox[trim=lr]{Est.}{Jumps} & 0 & 3 & 10 & 30 & 0 & 3 & 10 & 30 \\
    \midrule
    $\widetilde{JV}$                & 2.14 & 2.42    & 1.35     & -1.69  & 2.14 & 4.57 & 4.92  & 4.74 \\
    $\widehat{JV}$                  & 1.99 & 2.16    & 1.12     & -1.83  & 1.99 & 4.47 & 4.91  & 4.81 \\
    $\widehat{JV}_{\mathrm{BNS04}}$ & 0.35 & -4.35   & -12.91   & -26.35 & 3.11 & 5.48 & 12.95 & 26.35 \\
     \midrule
    $\widetilde{IV}$                & -2.03 & -2.52 & -1.33 & 1.73  & 6.54 & 6.37 & 5.24  & 3.71 \\
    $\widehat{IV}$                  & -1.87 & -2.26 & -1.10 & 1.87  & 6.48 & 6.31 & 5.23  & 3.80 \\
    $\widehat{IV}_{\mathrm{BNS04}}$ & -0.24 & 4.25  & 12.93 & 26.39 & 6.61 & 7.06 & 13.11 & 26.39 \\
    \bottomrule
  \end{tabularx}
\end{table}
%==================================
\end{document}

enter image description here

share|improve this answer

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.