[Tex/LaTex] How to fit large sideways table with Equations/References on A4

equationstables

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.

enter image description here
enter image description here
enter image description here

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\\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
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}

Best Answer

Fig. 1 Output without long equations, Fig. 2 Output with long equations

enter image description here enter image description here

Codes

Code 1 without long equations

\documentclass[english]{article}
\usepackage{amsmath, amsfonts,rotating}
\begin{document}
\begin{sidewaystable}
\centering
\caption{Ideals computed with basis and lexicographic}
\label{GroebnerRHR}
\hspace*{-2cm}
% https://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 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}

Code 2 with long equations and with Andrew's fix here about the environment

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

% https://tex.stackexchange.com/a/139450/13173
% https://tex.stackexchange.com/a/324197/13173
\newcommand{\eqbreak}[1][2]{\\&\hskip#1em}
\begin{document}
\begin{sidewaystable}
\centering
\caption{Ideals computed with basis and lexicographic}
\label{GroebnerRHR}
\hspace*{-2cm}
% https://tex.stackexchange.com/a/31681/13173
\bgroup
\def\arraystretch{1.5}%  1 is the default, change whatever you need
\renewcommand{\eqbreak}[1][1]{\\&\hskip#1em} % to save horizontal space as requested by OP so from 2 to 1; arraystretch just affects vertical spacing so it has nothing to do here
\begin{tabular}{| l | p{3cm} | p{5cm} | p{2cm} | p{2cm} |}
    \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.                  &
                                                $\begin{aligned}
                                                   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
Related Question