2

Hi I have the following code

    \documentclass[12pt,a4paper,twoside]{report}
    \setlength{\textwidth}{16cm}
    \setlength{\oddsidemargin}{0pt}
    \setlength{\evensidemargin}{0pt}
    \setlength{\parskip}{3mm}
    \setlength{\parindent}{0mm}
    \usepackage{amsmath,amsthm,tabu}
    \usepackage{tabularx,ragged2e,booktabs,caption}
    \usepackage{mathtools}
\begin{document}
            \begin{tabularx}{\textwidth}{|c|>{\raggedright\arraybackslash}X |>{\raggedright\arraybackslash}X|c|c|}
        \hline
    $n$ & $B_n$ & $w_n$ & $w_n\pmod{5}$ \\ 
    \hline
     1 & $-2^2\cdot3^6$ & $1$ & 1\\ 
     \hline
     2 & $2^2\cdot3^4$  & $1$ & 1\\ 
     \hline
     3 & $-2^2\cdot3^6$ & $1$ & 1 \\ 
     \hline
     4 & $2^2\cdot3^4\cdot19^2$  & $19$ & -1 \\ 
     \hline
     5 & $2^2\cdot3^6\cdot13^2$  & $13$ & -2 \\ 
     \hline
     6 & $3^4\cdot127^2$  & $127$ & 2 \\ 
     \hline
      7 & $-2^2\cdot3^6\cdot1291^2$  & $1291$ & 1\\ 
     \hline
     8 & $2^2\cdot14741^2$  & $14741$ & 1\\ 
     \hline
     9 & $-2^2\cdot3^6\cdot7901^2$ & $7901$ & 1 \\ 
     \hline
     10 & $2^2\cdot3^4\cdot3156697^2$ & $3156697$ & 2 \\ 
     \hline
     11 & $-2^2\cdot3^6\cdot 47^2\cdot799817^2$ & $ 47\cdot799817$ & -1 \\ 
     \hline
     12 & $3^4\cdot19^2\cdot6490213^2$ & $19\cdot6490213$ & 2 \\ 
     \hline
     13 & $-2^2\cdot3^6\cdot149^2\cdot239^2\cdot753611^2$ & $149\cdot239\cdot753611$ & 1 \\ 
     \hline
     14 & $2^2\cdot3^4\cdot53^2\cdot58963203163^2$ & $53\cdot58963203163$ & -1 \\ 
     \hline
     15 & $-2^2\cdot3^6\cdot13^2\cdot1361^2\cdot1277496791^2$ & $13\cdot1361\cdot1277496791$ & -2 \\ 
     \hline
     16 & $2^2\cdot1326053^2\cdot2774248223^2$ & $1326053\cdot2774248223$ & -1 \\ 
     \hline
     17 & $-2^2\cdot3^6\cdot557^2\cdot3331^2\cdot5147^2\cdot108649481^2$ & $557\cdot3331\cdot5147\cdot108649481$ & -1 \\ 
     \hline
     18 & $3^4\cdot127^2\cdot271^2\cdot359^2\cdot11283039459271^2$ & $127\cdot271\cdot359\cdot11283039459271$ & -2 \\ 
     \hline
     19 & $-2^2\cdot3^6\cdot157^2\cdot190367^2\cdot417192073484831^2$ & $157\cdot190367\cdot417192073484831$ & -1 \\ 
     \hline
     20 & $19^2\cdot67^2\cdot251^2\cdot17327^2\cdot870931^2\cdot2201234507^2$ & $19\cdot67\cdot251\cdot17327\cdot870931\cdot 2201234507$ & 2 \\ 
     \hline
     21 & $-2^2\cdot3^6\cdot1279^2\cdot1291^2\cdot173549^2\cdot1505227^ 2\cdot 1826825317^2$ & $1279\cdot1291\cdot173549\cdot1505227\cdot 1826825317$ & -1 \\ 
     \hline
     22 & $2^2\cdot3^4\cdot77239^2\cdot1477946658973^2\cdot18191777262077^2$ & $77239\cdot1477946658973\cdot18191777262077$ & -1 \\ 
     \hline
     23 & $-2^2\cdot3^6\cdot2053^2\cdot240257^2\cdot664708181^2\cdot 531369737672759^2$ & $2053\cdot240257\cdot664708181\cdot 531369737672759$ & -1 \\ 
     \hline
     24 & $8389^2\cdot14741^2\cdot51683576785065855501\allowbreak80202343^2$ & $8389\cdot14741\cdot51683576785065855501\allowbreak80202343$ &  2\\ 
     \hline
     25 & $-2^2 \cdot 3^6 \cdot13^2\cdot103^2\cdot643355871684956977670141294665607837^2$ & $13\cdot103\cdot643355871684956977670141294665607837$ & -2 \\ 
     \hline
     26 & $2^2\cdot3^4\cdot30347^2\cdot49857737^2\cdot357534917849299^2 \cdot1706574816319801^2$ & $30347\cdot49857737\cdot357534917849299\cdot1706574816319801$ & 1 \\ 
     \hline
    27 & $-2^2\cdot3^6\cdot659^2\cdot1543^2\cdot7901^2\cdot5808403^2\cdot158844137^2\cdot 1158342511^2 \cdot50827475227^2$ & $659\cdot1543\cdot7901\cdot 5808403\cdot 158844137\cdot 1158342511\cdot50827475227$ & -1 \\ 
    \hline
    28 & $2^2 \cdot3^4\cdot19^2 \cdot987143^2\cdot635616634615737191007756403110436513428793^2$ & $19\cdot 987143\cdot635616634615737191007756403110436513428793$ & 1 \\ 
    \hline
     29 & $-2^2 \cdot3^6\cdot1073602478183^2 \cdot18489706532449215619546038681792311392837^2$ & $1073602478183\cdot 18489706532449215619546038681792311392837$ & 1 \\ 
     \hline
     30 & $3^4\cdot127^2\cdot6173^2\cdot80831^2\cdot224969^2\cdot3156697^2\cdot 5489411^2\cdot 60570921936790713413493767^2$ & $127\cdot 6173\cdot 80831\cdot 224969\cdot 3156697\cdot 5489411\cdot 60570921936790713413493767$ & 1 \\ 
     \hline
    \end{tabularx}
\end{document}

The problem occurred at n=25,28,29 where the numbers in the second and third column are too long to fit in one column. Is there a way to make it nicely remain in the same column without overlapping with other columns.

enter image description here

Sharina
  • 21

1 Answers1

2

I suggest you (a) switch to landscape mode using sideways environments (provided by the rotating package) and (b) break the table into two parts: the first part could show rows 1 thru 10, and the second could show rows 21 thru 30. I would also get rid of the vertical lines and increase the spacing between rows to provide a more "open" look to the table.

The following screenshot shows the second page generated by this approach, i.e., rows 21 thru 30. (Rows 28 and 29 contain the longest numbers.)

enter image description here

\documentclass[12pt,a4paper,twoside]{report}
\setlength{\textwidth}{16cm}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\parskip}{3mm}
\setlength{\parindent}{0mm}
\usepackage{amsmath,amsthm}
\usepackage{tabularx,ragged2e,booktabs,caption}
\usepackage{mathtools}

% automatic math mode for columns of type L, C, and R
\newcolumntype{L}{>{\raggedright\arraybackslash$}X<{$}}
\newcolumntype{C}{>{$}c<{$}}
\newcolumntype{R}{>{$}r<{$}}   
\setlength\extrarowheight{2pt}  % generate a slightly more "open" look  
\usepackage{rotating}           % for 'sideways' environment


\begin{document}
\begin{sideways}  
\begin{tabularx}{\textheight}{@{}CLLR@{}} % Part 1: Rows 1 to 20
\hline
n & B_n & w_n & w_n\,\mbox{mod 5} \\ 
\hline
 1 & -2^2\cdot3^6 & 1 & 1\\ 
 \hline
 2 & 2^2\cdot3^4  & 1 & 1\\ 
 \hline
 3 & -2^2\cdot3^6 & 1 & 1 \\ 
 \hline
 4 & 2^2\cdot3^4\cdot19^2  & 19 & -1 \\ 
 \hline
 5 & 2^2\cdot3^6\cdot13^2  & 13 & -2 \\ 
 \hline
 6 & 3^4\cdot127^2  & 127 & 2 \\ 
 \hline
  7 & -2^2\cdot3^6\cdot1291^2  & 1291 & 1\\ 
 \hline
 8 & 2^2\cdot14741^2  & 14741 & 1\\ 
 \hline
 9 & -2^2\cdot3^6\cdot7901^2 & 7901 & 1 \\ 
 \hline
 10 & 2^2\cdot3^4\cdot3156697^2 & 3156697 & 2 \\ 
 \hline
 11 & -2^2\cdot3^6\cdot 47^2\cdot799817^2 &  47\cdot799817 & -1 \\ 
 \hline
 12 & 3^4\cdot19^2\cdot6490213^2 & 19\cdot6490213 & 2 \\ 
 \hline
 13 & -2^2\cdot3^6\cdot149^2\cdot239^2\cdot753611^2 & 149\cdot239\cdot753611 & 1 \\ 
 \hline
 14 & 2^2\cdot3^4\cdot53^2\cdot58963203163^2 & 53\cdot58963203163 & -1 \\ 
 \hline
 15 & -2^2\cdot3^6\cdot13^2\cdot1361^2\cdot1277496791^2 & 13\cdot1361\cdot1277496791 & -2 \\ 
 \hline
 16 & 2^2\cdot1326053^2\cdot2774248223^2 & 1326053\cdot2774248223 & -1 \\ 
 \hline
 17 & -2^2\cdot3^6\cdot557^2\cdot3331^2\cdot5147^2\cdot108649481^2 & 557\cdot3331\cdot5147\cdot108649481 & -1 \\ 
 \hline
 18 & 3^4\cdot127^2\cdot271^2\cdot359^2\cdot11283039459271^2 & 127\cdot271\cdot359\cdot11283039459271 & -2 \\ 
 \hline
 19 & -2^2\cdot3^6\cdot157^2\cdot190367^2\cdot417192073484831^2 & 157\cdot190367\cdot417192073484831 & -1 \\ 
 \hline
 20 & 19^2\cdot67^2\cdot251^2\cdot17327^2\cdot870931^2\cdot2201234507^2 & 19\cdot67\cdot251\cdot17327\cdot870931\cdot 2201234507 & 2 \\ 
 \hline
\end{tabularx}
\end{sideways}

\begin{sideways} 
\begin{tabularx}{\textheight}{@{}CLLR@{}} % Part 2: Rows 21 to 30
\hline
n & B_n & w_n & w_n\,\mbox{mod 5} \\ 
\hline
 21 & -2^2\cdot3^6\cdot1279^2\cdot1291^2\cdot173549^2\cdot1505227^ 2\cdot 1826825317^2 & 1279\cdot1291\cdot173549\cdot1505227\cdot 1826825317 & -1 \\ 
 \hline
 22 & 2^2\cdot3^4\cdot77239^2\cdot1477946658973^2\cdot18191777262077^2 & 77239\cdot1477946658973\cdot18191777262077 & -1 \\ 
 \hline
 23 & -2^2\cdot3^6\cdot2053^2\cdot240257^2\cdot664708181^2\cdot 531369737672759^2 & 2053\cdot240257\cdot664708181\cdot 531369737672759 & -1 \\ 
 \hline
 24 & 8389^2\cdot14741^2\cdot51683576785065855501\allowbreak80202343^2 & 8389\cdot14741\cdot51683576785065855501\allowbreak80202343 &  2\\ 
 \hline
 25 & -2^2 \cdot 3^6 \cdot13^2\cdot103^2\cdot643355871684956977670141294665607837^2 & 13\cdot103\cdot643355871684956977670141294665607837 & -2 \\ 
 \hline
 26 & 2^2\cdot3^4\cdot30347^2\cdot49857737^2\cdot357534917849299^2 \cdot1706574816319801^2 & 30347\cdot49857737\cdot357534917849299\cdot1706574816319801 & 1 \\ 
 \hline
27 & -2^2\cdot3^6\cdot659^2\cdot1543^2\cdot7901^2\cdot5808403^2\cdot158844137^2\cdot 1158342511^2 \cdot50827475227^2 & 659\cdot1543\cdot7901\cdot 5808403\cdot 158844137\cdot 1158342511\cdot50827475227 & -1 \\ 
\hline
28 & 2^2 \cdot3^4\cdot19^2 \cdot987143^2\cdot635616634615737191007756403110436513428793^2 & 19\cdot 987143\cdot635616634615737191007756403110436513428793 & 1 \\ 
\hline
 29 & -2^2 \cdot3^6\cdot1073602478183^2 \cdot18489706532449215619546038681792311392837^2 & 1073602478183\cdot 18489706532449215619546038681792311392837 & 1 \\ 
 \hline
 30 & 3^4\cdot127^2\cdot6173^2\cdot80831^2\cdot224969^2\cdot3156697^2\cdot 5489411^2\cdot 60570921936790713413493767^2 & 127\cdot 6173\cdot 80831\cdot 224969\cdot 3156697\cdot 5489411\cdot 60570921936790713413493767 & 1 \\ 
 \hline
\end{tabularx}
\end{sideways}
\end{document}
Mico
  • 506,678