5

Context

My document has one title phrase and one table containing texts. I would like to have them both on one page.

  • The table's content may change (sometimes more or less 2-or-3-lines-texts cells), but there are always 2 columns and 20 rows. I have put a minimal row height of 0.5 cm for readability.

  • I do not want to split the table over the next page

  • But I want the text to be as big as possible.

Attempts

If I use a smaller size, (like \normalsize instead of \large) then it fits, but the font is much smaller and actually a bit too small, whereas a large blank space is left at the bottom of the page.

So, as I want to resize (or scale?) it automatically, I thought the answer would be here and wanted to use the adjustbox package, but I can't seem to make it work the way I want. I'm a bit lost about all the keys and values meanings. Anyway, neither \adjustbox{max width=\columnwidth} nor \adjustbox{max width=\textwidth} provide a solution. I couldn't find any solution using max height or max totalheight.

Also, I wonder if my problem has to do with the more general problem of the position of a float environment. Not sure because if the table is too large, I understand LaTeX will "push" it to the next page. But if yes, how to deal with it in this situation?

Finally I wonder if it's at all possible to achieve what I want to (moreover, using tabular).

Code producing the problem

\documentclass[a4paper,fleqn,12pt]{article}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[british]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{geometry}
\usepackage{array}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{adjustbox}

% Page layout 
\geometry{hmargin=1.5cm, vmargin=1.5cm}
\setlength{\parindent}{0cm}
\pagestyle{empty}


\begin{document}
\LARGE
\textbf{Mental calculation: mini-problems}
\newline \newline \large
\adjustbox{max width=\textwidth}{
\begin{tabular}{|>{\centering}m{14 cm}|>{\centering}m{4 cm}@{}m{0pt}@{}|}
\hline 
My golden goose laid 4 eggs each day during 9 days. How many eggs has she laid?&
 & \tabularnewline
 [0.5cm] \hline 
Mya has 40 marbles. She gives them out to 5 friends. How many marbles will get each friend?&
 & \tabularnewline
 [0.5cm] \hline 
We have 4 sheep. Our neighbours have 7 times more sheep than us. How many sheep do they have?&
 & \tabularnewline
 [0.5cm] \hline 
I will give out 72 candies to the 8 friends that I invited at my birthday's party. How many candies will receive each of my friends?&
 & \tabularnewline
 [0.5cm] \hline 
I had to fill this can with 18$~\text{L}$ of water. There was 7$~\text{L}$ left in it. How much does it contain?&
...............$~\text{L}$ & \tabularnewline
 [0.5cm] \hline 
We have loaded 64$~\text{kg}$ of flour, shared in 8 packets. How heavy is one packet?&
...............$~\text{kg}$ & \tabularnewline
 [0.5cm] \hline 
A market gardener had 72 cabbages in his vegetable garden, and harvested 54 of them last week. How many cabbages are still in the garden?&
 & \tabularnewline
 [0.5cm] \hline 
9$~\text{m}^{2}$ of this wall are already painted. 7$~\text{m}^{2}$ are still missing to have the wall completely painted. What is its area?&
...............$~\text{m}^{2}$ & \tabularnewline
 [0.5cm] \hline 
I already rode 84$~\text{km}$ out of 98$~\text{km}$. How long do I still have to go cycling?&
...............$~\text{km}$ & \tabularnewline
 [0.5cm] \hline 
Lily gets 6 £ pocket money every month. If she doesn't spend it during 7 months, how much will she spare?&
...............~£ & \tabularnewline
 [0.5cm] \hline 
Yesterday, my golden goose laid 8 eggs. That's 11 less than today. How many eggs has she laid today?&
 & \tabularnewline
 [0.5cm] \hline 
Janet bought 8 boxes of 7 pencils. How many pens did she buy?&
 & \tabularnewline
 [0.5cm] \hline 
A market gardener had 78 cabbages in his vegetable garden, and harvested 56 of them last week. How many cabbages are still in the garden?&
 & \tabularnewline
 [0.5cm] \hline 
I will give out 49 candies to the 7 friends that I invited at my birthday's party. How many candies will receive each of my friends?&
 & \tabularnewline
 [0.5cm] \hline 
Jerry has 17 marbles. Elijah has 17 marbles more than Jerry. How many marbles has Elijah?&
 & \tabularnewline
 [0.5cm] \hline 
Isabel has prepared 30 truffles splitted in 5 packets. How many truffles is there in one packet?&
 & \tabularnewline
 [0.5cm] \hline 
The gardener has planted 16 cabbages last week, and 5 cabbages more this week. How many cabbages did he plant altogether?&
 & \tabularnewline
 [0.5cm] \hline 
Our neighbours have 98 sheep. That's 70 more than us. How many sheep do we have?&
 & \tabularnewline
 [0.5cm] \hline 
Layla bought 9 pens at 7 £. How much did she pay?&
...............~£ & \tabularnewline
 [0.5cm] \hline 
My bike ride is 73$~\text{km}$ long and I already rode 36$~\text{km}$. How long do I still have to go cycling?&
...............$~\text{km}$ & \tabularnewline
 [0.5cm] \hline 
\end{tabular}
}

\end{document} 
11
  • 3
    Shrinking the font size in order to make the table fit (vertically) risks making your document look like a ransom note. Have you considered using a longtable environment?
    – Mico
    May 1 '16 at 8:36
  • No, I haven't considered using a longtable yet, since I've read about it in questions about splitting the table over several pages. I am reluctant to change to something else than tabular because I need to keep some things like vertical alignment for pictures (in some cases I need to insert pictures) and between rows and I am unsure I can keep all these "settings" if I change for something else. But I'd like to know in what way could longtable solve this case.
    – zezollo
    May 1 '16 at 9:12
  • The key feature that distinguishes a longtable environment from a tabular environment is that the former can handle page breaks (if needed, of course). I realize that you've stated that you do not want to split tables across pages. However, if the choice is being allowing a page split and making the table's font size absurdly small in order to fit it on a page, it may well be preferable to choose the approach that permits page breaks.
    – Mico
    May 1 '16 at 9:19
  • You wrote, "I wonder if my problem has to do with the more general problem of the position of a float environment." Actually, since your code doesn't figure a "float", i.e., a table or figure environment, no float-positioning issues are in play.
    – Mico
    May 1 '16 at 9:37
  • 1
    Actually, the biggest problem seems to be that what you consider to be a table is not a table; it's a list of items. Please do not misuse tables for lists, the result is disasterous.
    – yo'
    May 1 '16 at 10:39
2

I can understand your reluctance to split tabular material across pages. However, if the choice is between (a) allowing a page break in the middle of the tabular material and (b) shrinking the tabular material to make it fit in the available space on a page (and risking the material becoming tiny and virtually unreadable!), the former choice may well be far preferable.

Below is a solution that uses a longtable environment instead of the tabular environment. If \normalsize is in effect, the entire table can fit in a single page; in contrast, if \large or \Large are in effect, a page break is required. Observe the division of relative row widths, viz., 5:1, in the example code; you're free, of course, to set the relative row widths to suit your needs.

Observe further that I also advocate giving the tabular material a much more open look, mainly by getting rid of all vertical lines. Instead of text, the cells could also hold images inserted via \includegraphics statements. And, do consider using the \SI and \si macros of the siunitx package to enforce a consistent appearance of units and of number/unit pairs.

enter image description here

enter image description here

\documentclass[a4paper,fleqn,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{geometry}
\usepackage{array}
\usepackage{amssymb}
\usepackage{amsmath}

\usepackage{longtable,ragged2e,siunitx}
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\RaggedLeft\arraybackslash}p{#1}}
\setlength\extrarowheight{3pt} % provide some visual "breathing space"

% Page layout 
\geometry{margin=1.5cm}
\setlength{\parindent}{0cm}
\pagestyle{empty}

\begin{document}
\large % or: \Large, \huge, or whatever

\begingroup % localize the effect of the following \setlength instruction
\setlength\tabcolsep{0pt} 
\begin{longtable}{L{0.833\textwidth}R{0.167\textwidth}}

\caption{Mental calculation: Mini-problems} \label{tab:mini}\\
\multicolumn{2}{r}{Answer}\\
\hline
\endfirsthead

\caption*{Table \ref{tab:mini}, continued} \\
\multicolumn{2}{r}{Answer}\\
\hline
\endhead

\hline
\multicolumn{2}{r}{\small (Continued on the following page)}\\
\endfoot

\hline
\endlastfoot

My golden goose laid 4 eggs each day during 9 days. How many eggs has she laid?&\\
\hline
Mya has 40 marbles. She gives them out to 5 friends. How many marbles will each friend get?&\\
\hline
We have 4 sheep. Our neighbours have 7 times more sheep than us. How many sheep do they have?&\\
\hline
I will give out 72 candies to the 8 friends that I invited at my birthday party. How many candies will each of my friends receive?&\\
\hline
I had to fill this can with \SI{18}{\liter} of water. There was \SI{7}{\liter} left in it. How much does it contain?&
\si{\liter}\\
\hline
We have loaded \SI{64}{\kilogram} of flour, shared in 8 packets. How heavy is one packet?&
~\si{\kilogram}\\
\hline
A market gardener had 72 cabbages in his vegetable garden, and harvested 54 of them last week. How many cabbages are still in the garden?&\\
\hline
\SI{9}{\meter\squared} of this wall are already painted. \SI{7}{\meter\squared} are still missing to have the wall completely painted. What is its area?&
~\si{\meter\squared}\\
\hline
I already rode \SI{84}{\kilo\meter} out of \SI{98}{\kilo\meter}. How long do I still have to go cycling?&
~\si{\kilo\meter}\\
\hline
Lily gets 6\,£ pocket money every month. If she doesn't spend it during 7 months, how much will she spare?&
~£\\
\hline
Yesterday, my golden goose laid 8 eggs. That's 11 less than today. How many eggs has she laid today?&\\
\hline
Janet bought 8 boxes of 7 pencils. How many pens did she buy?&\\
\hline
A market gardener had 78 cabbages in his vegetable garden, and harvested 56 of them last week. How many cabbages are still in the garden?&\\
\hline
I will give out 49 candies to the 7 friends that I invited at my birthday's party. How many candies will receive each of my friends?&\\
\hline
Jerry has 17 marbles. Elijah has 17 marbles more than Jerry. How many marbles has Elijah?&\\
\hline
Isabel has prepared 30 truffles splitted in 5 packets. How many truffles are there in one packet?&\\
\hline
The gardener planted 16 cabbages last week and 5 cabbages more this week. How many cabbages did he plant altogether?&\\
\hline
Our neighbours have 98 sheep. That's 70 more than us. How many sheep do we have?&\\
\hline
Layla bought 9 pens at 7\,£. How much did she pay?&
~£\\
\hline
My bike ride is \SI{73}{\kilo\meter} long and I already rode \SI{36}{\kilo\meter}. How long do I still have to go cycling?&
~\si{\kilo\meter}\\
\end{longtable}
\endgroup
\end{document} 
4
  • Well, I really can't afford to split the table, it has to be on one page altogether. Yet it must be readable. Using \large gives a satisfying result in regards to the readability. Using \normalsize is a bit small. Now, I was hoping to use \large and rescale the whole tabular, what would require to display texts just a little bit smaller than \large and thought this would keep a sufficient readability.
    – zezollo
    May 1 '16 at 10:14
  • @zezollo - Choosing \large brings about a 10% linear increase in font size. If you then must scale the table back down (by roughly 10%, in all likelihood) in order to make it fit on a page, you might as well use \normalsize immediately. Incidentally, if the table simply must fit on a table, I suggest you decrease the vertical margins a bit.
    – Mico
    May 1 '16 at 10:27
  • Maybe I do not estimate it very well, but if I use \normalsize, then the table fits into the page but there's quite a big gap between its bottom and the page's bottom. So there's no way to tell LaTeX to rescale the table just a little bit, in order for it to finish to fill the page?
    – zezollo
    May 1 '16 at 10:42
  • @zezollo - Rescaling an object affects both its width and its height, unless you do purely vertical scaling -- in which case the output will likely look seriously distorted. I really wouldn't pursue the rescaling idea.
    – Mico
    May 1 '16 at 10:46
2

If you want your text readable (which you do 111% in a test), you really don't want to shrink it. Therefore you have to split it into two pages. Together with de-tabularizing your list, the code could look like this:

\documentclass[a4paper,12pt]{article}
\usepackage[british]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{geometry}
\usepackage{calc}
\usepackage{siunitx}


% Page layout 
\geometry{hmargin=1.5cm, vmargin=1.5cm}

\newenvironment{problems}{
    \newcommand\problem[2][]{
        \par
        \noindent\rule{\linewidth}{0.4pt}
        \\\nobreak\ignorespaces
        ##2
        % Borrowed from amsthm.sty
        \leavevmode\unskip\penalty9999\hbox{}\nobreak\hfill\quad
        % Lower the box so that the lines of the paragraph are not disturbed
        \raisebox{-\fboxsep-\fboxrule}{\fbox{\hbox to 2cm{\strut\hfil\si{##1}}}}
        \par
    }
}{}

\begin{document}

\subsection*{Mental calculation: mini-problems}

\begin{problems}
\problem{My golden goose laid 4~eggs each day during 9~days. How many eggs has she laid?}
\problem{Mya has 40~marbles. She gives them out to 5~friends. How many marbles will get each friend?}
\problem{We have 4~sheep. Our neighbours have 7~times more sheep than us. How many sheep do they have?}
\problem{I will give out 72~candies to the 8~friends that I invited at my birthday's party. How many candies will receive each of my friends?}
\problem[L]{I had to fill this can with \SI{18}{L} of water. There was \SI{7}{L} left in it. How much does it contain?}
\problem[kg]{We have loaded \SI{64}{kg} of flour, shared in 8~packets. How heavy is one packet?}
\problem{A market gardener had 72~cabbages in his vegetable garden, and harvested 54~of them last week. How many cabbages are still in the garden?}
\problem[m^2]{\SI{9}{m^2} of this wall are already painted. \SI{7}{m^2} are still missing to have the wall completely painted. What is its area?}
\problem[km]{I already rode \SI{84}{km} out of \SI{98}{km}. How long do I still have to go cycling?}
\problem[\textsterling]{Lily gets \SI{6}{\textsterling} pocket money every month. If she doesn't spend it during 7~months, how much will she spare?}
\problem{Yesterday, my golden goose laid 8~eggs. That's 11~less than today. How many eggs has she laid today?}
\problem{Janet bought 8~boxes of 7~pencils. How many pens did she buy?}
\problem{A market gardener had 78~cabbages in his vegetable garden, and harvested 56~of them last week. How many cabbages are still in the garden?}
\problem{I will give out 49~candies to the 7~friends that I invited at my birthday's party. How many candies will receive each of my friends?}
\problem{Jerry has 17~marbles. Elijah has 17~marbles more than Jerry. How many marbles has Elijah?}
\problem{Isabel has prepared 30~truffles splitted in 5~packets. How many truffles is there in one packet?}
\problem{The gardener has planted 16~cabbages last week, and 5~cabbages more this week. How many cabbages did he plant altogether?}
\problem{Our neighbours have 98~sheep. That's 70~more than us. How many sheep do we have?}
\problem[\textsterling]{Layla bought 9~pens at \SI{7}{\textsterling}. How much did she pay?}
\problem[km]{My bike ride is \SI{73}{km} long and I already rode \SI{36}{km}. How long do I still have to go cycling?}
\end{problems}

\end{document} 

Note that I did couple more changes:

  • used siunitx
  • used \subsection* rather than \textbf{\LARGE stuff
  • removed unnecessary packages
  • changed £ to \textsterling so that utf8x nor ucs is necessary (I'm strongly against using unicode for non-letters in pdflatex)
  • added ~ after all the amounts
2
  • All questions must fit in one page, it can't be another way. So I certainly must play with the margins and maybe remove some questions. Now, I recognize that the presentation you suggest is indeed a very nice one. Still need to understand how it works, though.
    – zezollo
    May 1 '16 at 16:49
  • @zezollo I'm not sure commenting the code would be very useful. You can try to understand the bits by trial and error, and if you had any question, I shall be reachable in the chat
    – yo'
    May 1 '16 at 16:54
1

Here's an alternative answer, which differs from my earlier answer mainly by the use of a tabular environment. To ensure that the tabular material and the header material fit on a single page while using a \large relative font size, it will in general be necessary to decrease the widths of the vertical margins relative to what you've specified in the posting (1.5cm).

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{geometry}
\usepackage{array}
\usepackage{amssymb}
\usepackage[fleqn]{amsmath}

\usepackage{ragged2e,siunitx}
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\RaggedLeft\arraybackslash}p{#1}}
\setlength\extrarowheight{3pt}

% Page layout 
\geometry{hmargin=1.5cm,vmargin=0.75cm}
\setlength{\parindent}{0cm}
\setlength\tabcolsep{0pt}
\pagestyle{empty}

\begin{document}
\large % or: \Large, \huge, or whatever

\textbf{Mental calculation: Mini-problems} 

\smallskip
\begin{tabular}{L{0.88\textwidth}R{0.12\textwidth}}
\multicolumn{2}{r}{Answer}\\
\hline
My golden goose laid 4 eggs each day during 9 days. How many eggs has she laid?&\\
\hline
Mya has 40 marbles. She gives them out to 5 friends. How many marbles will each friend get?&\\
\hline
We have 4 sheep. Our neighbours have 7 times more sheep than us. How many sheep do they have?&\\
\hline
I will give out 72 candies to the 8 friends that I invited at my birthday party. How many candies will each of my friends receive?&\\
\hline
I had to fill this can with \SI{18}{\liter} of water. There was \SI{7}{\liter} left in it. How much does it contain?&
\si{\liter}\\
\hline
We have loaded \SI{64}{\kilogram} of flour, shared in 8 packets. How heavy is one packet?&
~\si{\kilogram}\\
\hline
A market gardener had 72 cabbages in his vegetable garden, and harvested 54 of them last week. How many cabbages are still in the garden?&\\
\hline
\SI{9}{\meter\squared} of this wall are already painted. \SI{7}{\meter\squared} are still missing to have the wall completely painted. What is its area?&
~\si{\meter\squared}\\
\hline
I already rode \SI{84}{\kilo\meter} out of \SI{98}{\kilo\meter}. How long do I still have to go cycling?&
~\si{\kilo\meter}\\
\hline
Lily gets 6\,£ pocket money every month. If she doesn't spend it during 7 months, how much will she spare?&
~£\\
\hline
Yesterday, my golden goose laid 8 eggs. That's 11 less than today. How many eggs has she laid today?&\\
\hline
Janet bought 8 boxes of 7 pencils. How many pens did she buy?&\\
\hline
A market gardener had 78 cabbages in his vegetable garden, and harvested 56 of them last week. How many cabbages are still in the garden?&\\
\hline
I will give out 49 candies to the 7 friends that I invited to my birthday party. How many candies will receive each of my friends?&\\
\hline
Jerry has 17 marbles. Elijah has 17 marbles more than Jerry. How many marbles has Elijah?&\\
\hline
Isabel has prepared 30 truffles splitted in 5 packets. How many truffles are there in one packet?&\\
\hline
The gardener planted 16 cabbages last week and 5 cabbages more this week. How many cabbages did he plant altogether?&\\
\hline
Our neighbours have 98 sheep. That's 70 more than us. How many sheep do we have?&\\
\hline
Layla bought 9 pens at 7\,£. How much did she pay?&
~£\\
\hline
My bike ride is \SI{73}{\kilo\meter} long and I already rode \SI{36}{\kilo\meter}. How long do I still have to go cycling?&
~\si{\kilo\meter}\\
\hline
\end{tabular}
\end{document} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.