1

I am puzzled why I cannot put "\end{scriptsize}" on a new line without getting the following Overfull \hbox error:

enter image description here

The LaTeX code (with the Overfull message) is here:

\documentclass[10pt, twoside, a4paper]{report}
\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}
\usepackage{fontenc}
\usepackage[ top=21mm, bottom=21mm, left=16mm, right=10mm]{geometry}
\showboxbreadth=50  % use for logging
\showboxdepth=50    % use for logging
\begin{document}
\sffamily
\begin{scriptsize}
\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
3 & 221°30.0 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}48.4\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
9 & 311°27.4 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}47.5\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
15 & 41°26.9 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}44.0\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
21 & 131°28.3 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}38.1\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
27 & 221°30.4 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}51.1\\ 
\end{tabular*}
\end{scriptsize}
\end{document}

There is no Overfull message if I put both of these commands at the end of my script on one line (and the resulting PDF appears to be identical):

\end{tabular*}\end{scriptsize}

I see in the log file that the Overfull problem is related to the $\cdot$ content; but this character is perfect for my requirements.

EDIT: I removed all the other table rows without the math font. These do not cause the Overfull message. The Overfull message is somehow related to the specific row that includes the math font.

A more general question would be - what freedom does a programmer have in formatting TeX/LaTeX code lines? I mention this because all LaTeX code is generated automatically by Python code and I would like the resulting TeX file to be somewhat readable. In some cases indentation (of the TeX/LaTeX) code has no effect on the PDF output file, however I thought that I can place commands such as the offending two above on separate lines to improve readability (of the TeX/LaTeX file).

2
  • For what it's worth, putting content on a new line in most cases will inject a space at the end of the preceding line. I can't test your code now, but do you get the same error if you put a comment char (ie %) at the end of your line(s) wherever you are using a newline and producing the error? eg using \end{tabular*}% prior to the newline and \end{scriptsize}?
    – Jason
    Commented Feb 7, 2020 at 11:34
  • Hi. There is no error if it is terminated with '%' (as mentioned in the comments following the answer below). But no one has explained why only rows with the math font cause a penalty of 10000. Strangely, there is no error (in the above script) if math font is excluded.
    – Aendie
    Commented Feb 7, 2020 at 16:40

2 Answers 2

1

(Edited to incorporate useful comments from @DavidCarlisle)

A single line break is typically treated as a space in LaTeX. So, for example, consider the following:

\documentclass{article}
\begin{document}
Hello
world
\end{document}

(which has no space after "Hello") will output "Hello world" (with a space).

At the end of a paragraph (indicated by a \par or two line breaks, or (in your MWE) the end of the document), the extra space automatically gets taken out again by LaTeX, via an \unskip so everything renders nicely.

In your case, you've got two spaces: one from the linebreak after the last \end{tabular*}, and another from the linebreak after \end{scriptsize}. LaTeX will get rid of one of these for you, but not both. That is, one space remains, and this makes the line including your tables too wide.

If you want both linebreaks (e.g. for readability) the usual method whilst avoiding extraneous spaces is to put a % at the end of the line (which, in effect, comments it out). Thus:

\documentclass[10pt, twoside, a4paper]{report}
\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}
\usepackage{fontenc}
\usepackage[ top=21mm, bottom=21mm, left=16mm, right=10mm]{geometry}
\showboxbreadth=50  % use for logging
\showboxdepth=50    % use for logging
\begin{document}
\sffamily
\begin{scriptsize}
\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
3 & 221°30.0 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}48.4\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
9 & 311°27.4 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}47.5\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
15 & 41°26.9 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}44.0\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
21 & 131°28.3 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}38.1\\ 
\end{tabular*}\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
27 & 221°30.4 & \raisebox{0.24ex}{\boldmath$\cdot$~\boldmath$\cdot$~~}51.1\\ 
\end{tabular*}%
\end{scriptsize}
\end{document}

This now has just one space-created-by-a-linebreak at the end (after \end{scriptsize}), which LaTeX will handle for you.

5
  • what you say is true but the bit that you are missing is that tex only removes one space at the end of a paragraph, and the above has two (one after tabular*} and one after {scriptsize} Commented Feb 7, 2020 at 14:58
  • Yes, of course, there are other spaces too - am I right in thinking they're all nonbreakable? Eliminating the first seemed to be enough to stop the overfull hbox. In terms of having the tables spread evenly to take up the full page width, would removing that other space have an effect?
    – rbrignall
    Commented Feb 7, 2020 at 15:13
  • 1
    yes but you could comment out either of those two. A space at the end of a paragraph is almost always there and gets removed, the issue here is that there are two spaces at the end of the line and the \unskip only removes one of them. They are normal breakable inter-word spaces, not non breakable spaces. Commented Feb 7, 2020 at 15:44
  • Ahh of course. I will edit my answer, because this is a very good point.
    – rbrignall
    Commented Feb 7, 2020 at 15:54
  • So far so good - I appreciate your responses. However, if the math font is removed, there is no penalty of 10000 causing the Overfull \hbox. A table with plain text can end with two spaces - and no Overfull message. What clashes between the math font and the two trailing "spaces" (or new line characters) after the table? And is this normal behaviour or a possible bug in the system?
    – Aendie
    Commented Feb 7, 2020 at 16:45
0

Wow! Based on David Carlisle's response to my other question (Overfull \vbox caused by change of font), this script ending also eliminates the Overfull \hbox message:

\end{tabular*}

\end{scriptsize}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .