5

I've recently read through my \jobname.log files to spot errors in typography.

I came across this:

Overfull \hbox (6.8925pt too wide) in paragraph at lines 650--651
[][]\T1/cmtt/m/n/10 plot([][][]<functie>[], []col=<kleur>[], []lwd=<breedte van
 de geplotte lijn>[], []type=<type plot,
 []


Underfull \hbox (badness 10000) in paragraph at lines 650--651
\T1/cmtt/m/n/10 zie hierboven>[], []xlab="<eenheid op de x-as>"[], []ylab="<een
heid op de y-as>"[], []main=[]
 []

In the document this part of the document looks like

this (link).

In this case there are three options for me:

  1. Use \linebreak before the part of \textcolor{orange}{main=....
  2. Use \linebreak in the middle of main=... (current solution).
  3. Don't use any linebreaks.

All three solutions produce a message of both underfull as well as overfull hbox.

Is there a way to encourage LaTeX to linebreak within the environment to fix at least one of these errors? Or scale text, adjust boxes of characters, etc.

I've read through the existing questions and they all suggest linebreaking. In this environment that may be too much asked for, but I'd at least like to explore to possibilities to fix this in a special case (if a such special solution even exists - fingers crossed).

1
  • lease help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – cfr
    May 11, 2014 at 2:03

2 Answers 2

4

This stems from the fact that the typewriter font (\ttfamily) does not have any inter-word stretch or shrink. As such, it typically doesn't work well in getting a justified look. Stefan wrote a nice blog entry on this the TeXblog: Full justification with typewriter font. For completeness, I'll duplicate the discussion here:

enter image description here

\documentclass[a4paper,10pt]{article}
\renewcommand*\familydefault{\ttdefault}
\begin{document}
\begin{description}
  \item[slant] \the\fontdimen1\font
  \item[inter-word space] \the\fontdimen2\font
  \item[inter-word stretch] \the\fontdimen3\font
  \item[inter-word shrink] \the\fontdimen4\font
  \item[extra space] \the\fontdimen7\font
  \item[xspaceskip] \the\xspaceskip
  \item[hyphenchar] \the\hyphenchar\font
\end{description}
\end{document}

Note the 0.0pt inter-word stretch and shrink.

The suggestion is to add some inter-word stretch/shrink, and you may want to do this in general for the lines environment in your code screenshot. However, without a visual of how lines is written, I can only suggest that you add the following to the beginning of the environment:

\fontdimen3\font=0.2em% inter-word stretch
\fontdimen4\font=0.1em% inter-word shrink

and perhaps play around with the values.

2
\documentclass{article}
\usepackage[english]{babel}
\usepackage{geometry,blindtext}
\usepackage{everysel}
\renewcommand*\familydefault{\ttdefault}
\begin{document}
\section{Default typesetting}
\blindtext

\section{With hyphenation}
\hyphenchar\font=`\-% to allow hyphenation
\blindtext

\section{With hyphenation and justification}
%\EverySelectfont{%
\fontdimen2\font=0.4em% interword space
\fontdimen3\font=0.2em% interword stretch
\fontdimen4\font=0.1em% interword shrink
\fontdimen7\font=0.1em% extra space
%\hyphenchar\font=`\-% to allow hyphenation
%}
\blindtext
\end{document}

enter image description here

You must log in to answer this question.

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