1

I have a table that I am trying to display in the PDF output.

\begin{center}
\begin{tabular}{ |c|c|c|c|c|c|c|c|c| } 
 \hline
 Day & $\mu(R)$ & $\sigma(R)$ & $\lvert R\textsuperscript{-} \rvert$ & $\mu(R\textsuperscript{-})$ & $\sigma(R\textsuperscript{-})$ & $\lvert R\textsuperscript{+} \rvert$ & $\mu(R\textsuperscript{+})$ & $\sigma(R\textsuperscript{+})$ \\
 \hline
 Monday & 0.002353 & 0.010166 & 21 & -0.005882 & 0.003802 & 25 & 0.009270 & 0.008518 \\  
 \hline
\end{tabular}
\end{center}

In the output, the last column is not 100% visible. enter image description here

How can I adjust the table so that all 9 columns fit?

  • 3
    between center and tabular use \small or \footnotesize or whatever works, you have not said anything about the size of the area or the fonts you are using so we can't know exactly what size is OK – David Carlisle Nov 04 '21 at 10:22
  • @DavidCarlisle I wasn't sure what size to indicate but basically it should be visible and legible and fit into the PDF output – Vadim Katsemba Nov 04 '21 at 10:45
  • 2
    yes but you are asking how to make some text fit in some space, but you have not said what size the text is nor said what size the space is so you can only get very general advice. It is always better to include a small test file, although really this is a duplicate of https://tex.stackexchange.com/questions/332902/my-table-doesnt-fit-what-are-my-options – David Carlisle Nov 04 '21 at 11:00
  • @DavidCarlisle Okay, I decided to go with the \scriptsize font. It seems like it's the best option. Thanks for the advice – Vadim Katsemba Nov 04 '21 at 11:31

1 Answers1

2

As @DavidCarlisle has noted in the comments below your posting, your question cannot be answered fully as you did not provide several important pieces of information, such as the width of the text block, the font that's in use in your document, and the fontsize that's in use.

Assuming that you employ the article document class and haven't changed the default settings, employing a \small relative font size (with a 10% linear reduction relative to \normalsize), getting rid of the unneeded vertical lines, and switching from a tabular to a tabular* environment (with the overall width set to \textwidth) is actually all that it takes to make the table fit; see the first table in the screenshot below. (If you've changed some of the defaults, please do let us know what the new relevant parameter values are.)

However, you may [should?!] want to seize this opportunity to rethink your entire approach to displaying the quantitative information contained in the table. I hope I don't hurt your feelings too badly by opining that your table does a less than perfect job of presenting the information. The second and especially the third table below provide several specific improvement suggestions. My main suggestions are to provide a more explicit structure to the header row(s) and to use math mode rather that text mode for the 8 data columns. Scaling the means and standard deviations by 1e4 would also add a nice touch, especially as doing so would mean that you don't have to resort to switching font sizes.

enter image description here

\documentclass[a4paper]{article}
\usepackage{array,amsmath,booktabs}
\newcolumntype{C}{>{$}c<{$}}
\newcommand\scaleme{\scriptstyle[\times10^4]}
\begin{document}

\begin{center} % OP's code, minimally adjusted \small % 10% linear reduction in font size \setlength\tabcolsep{0pt} % let LaTeX figure out intercol. whitespace \begin{tabular}{\textwidth}{@{\extracolsep{\fill}} ccccccccc } \hline Day & $\mu(R)$ & $\sigma(R)$ & $\lvert R\textsuperscript{-} \rvert$ & $\mu(R\textsuperscript{-})$ & $\sigma(R\textsuperscript{-})$ & $\lvert R\textsuperscript{+} \rvert$ & $\mu(R\textsuperscript{+})$ & $\sigma(R\textsuperscript{+})$ \ \hline Monday & 0.002353 & 0.010166 & 21 & -0.005882 & 0.003802 & 25 & 0.009270 & 0.008518 \ \hline \end{tabular} \end{center}

\bigskip \begin{center} % provide more structure to table's header \small % 10% linear reduction in font size \setlength\tabcolsep{0pt} % let LaTeX figure out intercol. whitespace \begin{tabular}{\textwidth}{@{\extracolsep{\fill}} l {8}{C} } \toprule Day & \multicolumn{2}{C}{R} & \multicolumn{3}{C}{\lvert R^- \rvert} & \multicolumn{3}{C}{\lvert R^+ \rvert} \ \cmidrule{2-3} \cmidrule{4-6} \cmidrule{7-9} & \mu & \sigma & n & \mu & \sigma & n & \mu & \sigma \ \midrule Monday & 0.002353 & 0.010166 & 21 & -0.005882 & 0.003802 & 25 & 0.009270 & 0.008518 \ \bottomrule \end{tabular*} \end{center}

\bigskip \begin{center} % additionally, scale means and std. dev.s by 10^4 \setlength\tabcolsep{0pt} % let LaTeX figure out intercol. whitespace \begin{tabular}{\textwidth}{@{\extracolsep{\fill}} l {8}{C} } \toprule Day & \multicolumn{2}{C}{R} & \multicolumn{3}{C}{\lvert R^- \rvert} & \multicolumn{3}{C}{\lvert R^+ \rvert} \ \cmidrule{2-3} \cmidrule{4-6} \cmidrule{7-9} & \mu & \sigma & n & \mu & \sigma & n & \mu & \sigma \ & \scaleme & \scaleme & & \scaleme & \scaleme & & \scaleme & \scaleme \ \midrule Monday & 2353 & 10166 & 21 & -5882 & 3802 & 25 & 9270 & 8518 \ \bottomrule \end{tabular*} \end{center} \end{document}

Mico
  • 506,678