# How to fit large sideways table with Equations/References on A4?

I have a big Table with long equations and references in some of the entries which overflow the margin. I want to decrease the column width in the table and fit the table better on the page. I decrease font size to decrease complications but it is not sustainable. Pseudocode

1. Normal size font.
2. Have more vertical space in the table.
3. Decrease the column width.
4. More rows per cell entry.
5. Extra spacing.

Fig. 1 .tex file, Fig. 2 The big table with long equations looks where I would like the table to take more vertical space and fit the page better, Fig. 3 Output of Masi's first code and my edit for long equations, Fig. 4 Output of Zarko's first code and my edit for long equations.

MWE1 with easier-to-manage cases

\documentclass[english]{article}
\usepackage{amsmath, amsfonts,rotating}
\begin{document}
\begin{sidewaystable}
\centering
\caption{Ideals computed with basis and lexicographic}
\label{GroebnerRHR}
\hspace*{-2cm}
\begin{tabular}{| l | l | l | l | l |}
\hline
CountVars & Description                 &   Basis           &   Count of elements   &   Count of Monomials      \\
\hline
1       &   system 1                    &   0           &   0               &   0           \\
2       &   system 2                    &   0       &   0               &   0           \\
2       &   system 3                    &   1       &   1               &   2           \\
3       &   series system with 3 vertices   &   1+3     &   1               &   6           \\
5       &   See Figure 15.              &   medium size equation            &   0               &   0           \\
7       &   See Figure 28.              &   $long equation+ long long- long long long long- long* long long= long equation$         &   9               &   20          \\
36      &   PP                      &   $very long =equation 1+2 stereo aloe nag rouen haosteu +saohu natoehs untaose thaoetu saothe staehosun haotnh saonthe + snatohu snthaosun thaosnth oanteuh+ snoathu sntoahe - snthoasen thoastn hosatnh soah sntohaent hoasnu hsonatheu * toha snahous$     &   899             &   2222    \\
\hline
\end{tabular}
\end{sidewaystable}
\end{document}


MWE2 by Masi

\documentclass[english]{article}
\usepackage{amsmath, amsfonts,rotating}
\begin{document}
\begin{sidewaystable}
\centering
\caption{Ideals computed with basis and lexicographic}
\label{GroebnerRHR}
\hspace*{-2cm}
% http://tex.stackexchange.com/a/31681/13173
\bgroup
\def\arraystretch{1.5}%  1 is the default, change whatever you need
\begin{tabular}{| l | p{3cm} | p{3cm} | p{3cm} | p{3cm} |}
\hline
CountVars & Description                       &   Basis   &   Count of elements   &   Count of Monomials      \\ \hline
1         &   system 1                        &   0       &   0                   &   0           \\ \hline
2         &   system 2                        &   0       &   0                   &   0           \\ \hline
2         &   system 3                        &   1       &   1                   &   2           \\ \hline
3         &   series system with 3 vertices   &   1+3     &   1                   &   6           \\ \hline
5         &   See Figure 15.                  &   medium size equation            &   0               &   0           \\ \hline
7         &   See Figure 28.                  &   $long equation = long long +long long- long long *long long *long+long$         &   9               &   20          \\ \hline
36        &   PP                              &   $very long equation = stereo- aloe+nag - rouen *haosteu saohu natoehs -untaose thaoetu +saothe staehosun haotnh saonthe snatohu +snthaosun thaosnth oanteuh snoathu sntoahe +snthoasen thoastn hosatnh soah sntohaent hoasnu hsonatheu -toha snahous$      &   899             &   2222    \\ \hline
\end{tabular}
\egroup
\end{sidewaystable}
\end{document}


where the equations entries do not get nicely presented in the columns but go over other columns, how to fix this by making the equations to continue on the next line?

MWE3 with Zarko

\documentclass[english]{article}
\usepackage{amsmath, amsfonts,rotating}
\usepackage{makecell,tabularx}

\usepackage[showframe]{geometry}

\begin{document}
\begin{sidewaystable}
\centering
\renewcommand\arraystretch{1.2}
\setlength\tabcolsep{3pt}%  1 is the default, change whatever you need
\caption{Ideals computed with basis and lexicographic}
\label{GroebnerRHR}
\begin{tabularx}{\textwidth}{| r |p{8em} | X | l | l |}
\hline
&   \thead[b]{Count of\\ Monomials}    \\ \hline
1       &   system 1
& 0 & 0 & 0                                 \\ \hline
2       &   system 2
& 0 & 0 & 0                                 \\ \hline
2       &   system 3
& 1 & 1 & 2                                 \\ \hline
3       &   series system with 3 vertices
& 1+3   & 1 & 6                             \\ \hline
5       &   See Figure 15.
&   medium size equation
& 0 & 0                                 \\ \hline
7       &   See Figure 28.
&   $long equation = if *it is longer +than is column width - then it hed to be set * as multi line equation + with help of asmmath or mathtool math environments$
& 9  & 20                               \\ \hline
36      &   PP
&   $very long equation = stereo +aloe nag rouen haosteu - saohu natoehs untaose thaoetu +saothe staehosun haotnh saonthe snatohu - snthaosun thaosnth -oanteuh snoathu sntoahe snthoasen thoastn hosatnh soah sntohaent +hoasnu hsonatheu toha snahous$
& 899   & 2222                          \\ \hline
\end{tabularx}
\end{sidewaystable}
\end{document}

• So, do you want to increase the text area (geometry, \newgeometry), shrink the table (graphicx \resizebox), or increase the paper size (pgfpages, \pgfpagesuselayout{resize to}[a4paper})? – John Kormylo Aug 9 '16 at 13:31
• @Masi I added MWE2 where linebreaks not in equations. – hhh Aug 10 '16 at 11:09
long equation long long
\eqbreak[-5] \times long long long \\
=long long long long long
\end{aligned}$& 9 & 20 \\ \hline 36 & PP &$\begin{aligned}
very stereo aloe nag rouen
\eqbreak[-11] \times haosteu saohu natoehs \eqbreak[-11] \times untaose thaoetu staehosun \eqbreak[-11] \times saonthe snthaosun thaosnth \eqbreak[-11] \times oanteuh snoathu sntoahe \eqbreak[-11] \times thoastn hosatnh soah sntohaent \eqbreak[-11] \times hoasnu hsonatheu toha snahous \end{aligned}& 81111 & 2222 \\ \hline \end{tabular} \egroup \end{sidewaystable} \end{document}  Optional remarks • Better example with more challenging Math symbols etc integrals here about Math in a table • You can likely remove \hspace*{-2cm} because negative spacing may not be needed anymore, at least, I think the third column looks funny in Fig. 1. See here about general \hspace spacing • See here where the column entries are equations not text: the equations go over other columns, how to fix this? (updated to the Q with slightly modified version of your MWE) – hhh Aug 10 '16 at 11:07 In your code 2 example you are missing alignment points in the aligned expressions. If you don't put a & on the first line of an aligned it is implicitly at the right-hand end. So you should be writing something like \begin{aligned}
&long equation long long
\eqbreak
\times long long long \\
&=long long long long long
&long equation long long
\eqbreak
\times long long long \\
&=long long long long long
\end{aligned}$& 9 \\ \midrule PP &$\begin{aligned}
&very stereo aloe nag rouen \eqbreak
\times haosteu saohu natoehs \eqbreak
\times untaose thaoetu staehosun \eqbreak
\times saonthe snthaosun thaosnth \eqbreak
\times oanteuh snoathu sntoahe \eqbreak
\times thoastn hosatnh soah sntohaent \eqbreak
\times hoasnu hsonatheu toha snahous
\end{aligned}$& 81111 \\ \bottomrule \end{tabular} \end{sidewaystable} \end{document}  I have renewed the \eqbreak command for this table, so its default indent is 1em instead of 2em. • You define two times eqbreak with just one small difference ([1][2] vs [1][1]) . Is there reason for that? It seems it has to be done because there is the command \def\arraystretch{1.5}. Right? - - I cannot see any changes in the output by the re-definition. – Léo Léopold Hertz 준영 Aug 10 '16 at 13:52 • @Masi I only did because the poster wants to save horizontal space, so I redefined the default argument from 2 to 1. It has nothing to do with the \arraystretch which affects vertical spacing. – Andrew Swann Aug 10 '16 at 13:55 See, if the following reformatting gives what you like to achieve: In creating this table looks-out I use two packages: makecell from which I use (default set) macro thead for setting column heads in two lines, and tabularx package to spread table over whole text width in sidewaystable (which equal to text height in normal pages) and use cell for multi row equation if itis necessary. Also I assume, that you wish to have maximal possible width in third column where is long equation, and that multi line text is expected in the second (more narrow) column. As is noted in MWE below, if long equation can not be fit in avilable column width, I suggest to use one of among amsmath or mathtool math environments, preferable multilined from mathtools (to bi more indicative, I need more information about your equation). Package geometry with option showframe I used to show page layout and also define more usual its size. \documentclass[english]{article} \usepackage{amsmath, amsfonts,rotating} \usepackage{makecell,tabularx} \usepackage[showframe]{geometry} \begin{document} \begin{sidewaystable} \centering \renewcommand\arraystretch{1.2} \setlength\tabcolsep{3pt}% 1 is the default, change whatever you need \caption{Ideals computed with basis and lexicographic} \label{GroebnerRHR} \begin{tabularx}{\textwidth}{| r |p{8em} | >{\raggedright\arraybackslash}X | l | l |} \hline \thead[b]{Count\\Vars} & \thead[b]{Description} & \thead[b]{Basis} & \thead[b]{Count of\\ elements} & \thead[b]{Count of\\ Monomials} \\ \hline 1 & system 1 & 0 & 0 & 0 \\ \hline 2 & system 2 & 0 & 0 & 0 \\ \hline 2 & system 3 & 1 & 1 & 2 \\ \hline 3 & series system with 3 vertices & 1+3 & 1 & 6 \\ \hline 5 & See Figure 15. & medium size equation & 0 & 0 \\ \hline 7 & See Figure 28. & long equation, if it is longer than is column width then it hed to be set as multi line equation with help of asmmath or mathtool math environments & 9 & 20 \\ \hline % alternatively for above row (added as described in addendum) 7 & See Figure 28. &$
a_0 + a_1x + a_2x^2 + a_3^3 + a_4x^4 + a_5x^5 + a_6x^6 + a_7x^7 + a_8x^8 + a_9x^9 + a_{10} + a_{11}x^{11} + a_{12}x^{12} + a^{13}x{13} + a^{14}x^{14} + a_{15}x^{15} + a_{16}x^{16} + a_{17}x^{17} + a_{18}x^{18} + a_{19}x^{19} + a_{20}x^{20} + a_{21}x^{21}
$& 9 & 20 \\ \hline % 36 & PP & very stereo aloe nag rouen haosteu saohu natoehs untaose thaoetu saothe staehosun haotnh saonthe snatohu snthaosun thaosnth oanteuh snoathu sntoahe snthoasen thoastn hosatnh soah sntohaent hoasnu hsonatheu toha snahous & 899 & 2222 \\ \hline \end{tabularx} \end{sidewaystable} \end{document}  Addendum: Till to now I newer seen variable set $long equation, if it is longer than is column width then it had to be set as multi line equation with help ofasmmathormathtoolsmath environments$! This "text" math consider as one long sequence of variables. See your result, all characters are tied together and between them is no space for braking equation. In normal circumstances row with long equation probably is something like this: 7 & See Figure 28. &$
a_0 + a_1x + a_2x^2 + a_3^3 + a_4x^4 + a_5x^5 + a_6x^6 + a_7x^7 + a_8x^8 + a_9x^9 + a_{10} + a_{11}x^{11} + a_{12}x^{12} + a^{13}x{13} + a^{14}x^{14} + a_{15}x^{15} + a_{16}x^{16} + a_{17}x^{17} + a_{18}x^{18} + a_{19}x^{19} + a_{20}x^{20} + a_{21}x^{21}
\$
& 9  & 20                               \\ \hline


I consider above row in my MWE and also include to answer the new image of table. Since you still didn't give any indication what is your really equation, I didn't use any other math environment which enable to structure equation on some other way (with manual tweaking of breaking points).

Edit: For better align contents in cells of the third column -- as suggest David Carlisle in his comment below -- seems to be sensible change column type X to

>{\raggedright\arraybackslash}X


or maybe to

>{\RraggedRight\arraybackslash}X


which require to load package ragged2e in document preamble. I improve my first suggestion with above expalined and accordingly replace image of the obtained table.

• I added MWE3 with long equation enviroment here slightly changing your alternative with long equation environment and I get the same problem as with Masi's alternative -- the column entries of long equations go over other columns. How to fix that? – hhh Aug 10 '16 at 11:15
• I pointed this in text where I suspect you like to have long equation :-). You write equation on wrog way. See addendum to my answer. – Zarko Aug 10 '16 at 11:24
• @Zarko if you change X to >{\raggedright}X I suspect this answer would be accepted (see comments under the question:-) – David Carlisle Aug 10 '16 at 13:53
• @DavidCarlisle, thank you suggestion. I will consider it. – Zarko Aug 10 '16 at 14:34