I've created some tabular output through Python (pandas database). However, it leaves a too wide space between columns 2,3 (for which I cannot detect the reason), and actually overflowing the page width.
Sample code is below
% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = pdflatexmk
\documentclass[11pt]{article}
\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper} % ... or a4paper or a5paper or ...
\usepackage{booktabs}
\usepackage{longtable}
\begin{document}
\begin{longtable}{lrrrrrrrrrrrrrr}
\toprule
{} & $\underline Y$ & $\bar Y $ & $\epsilon$ & $\bar p$ & $\underline s$ & $\bar s$ & $\theta$ & $\underline\theta$ & $\bar\theta$ & u & $\underline v$ & $\bar v$ & $\underline w$ & $\bar w$ \\
\midrule
\endhead
\midrule
\multicolumn{3}{r}{{Continued on next page}} \\
\midrule
\endfoot
\bottomrule
\endlastfoot
0 & 0.532 & 0.394 & 1.0 & 1.349 & 0.20 & 0.40 & 32.223 & 12.978 & 19.245 & 0.074 & 0.960 & 1.424 & 0.423 & 0.458 \\
1 & 0.603 & 0.317 & 1.0 & 1.901 & 0.15 & 0.65 & 38.459 & 11.728 & 26.731 & 0.079 & 0.928 & 2.115 & 0.485 & 0.576 \\
2 & 0.566 & 0.361 & 0.5 & 1.253 & 0.20 & 0.40 & 30.642 & 13.475 & 17.167 & 0.073 & 0.986 & 1.256 & 0.407 & 0.433 \\
3 & 0.504 & 0.422 & 2.0 & 1.428 & 0.20 & 0.40 & 33.573 & 12.558 & 21.015 & 0.075 & 0.937 & 1.568 & 0.437 & 0.479 \\
\end{longtable}
\end{document}
Best Answer
Since your table has fifteen [15!] columns, reducing the value of
\tabcolsep
-- the parameter that governs the amount of intercolumn whitespace -- is helpful.In the following example, the thin line above the table is inserted just to illustrate the width of the text block.