3

As an odd recurrence with many previous documents (and by subsequent trials and errors), I noticed that with this default, reduced MWE:

\documentclass[a4paper]{article}
%
\usepackage[OT1]{fontenc}
\usepackage[utf8]{inputenx}
%
%\usepackage{amsmath,amssymb,amsthm}
%
%\usepackage{fixltx2e}
%
%\numberwithin{equation}{section}
%\numberwithin{figure}{section}
%\numberwithin{table}{section}
%
\usepackage[english,italian]{babel}
%
\begin{document}
%
All'interno di una semicirconferenza vi è uniformemente distribuita una carica $Q$, definibile 
%
\end{document}

some lines of text contain evidently too much space between words; as the output clearly shows:

enter image description here

To me it's difficult to think that babel wasn't able to recognize the correct hyphenation for the last line word carica, as the legal breaking ca-ri-ca should have sufficed to decrease the word spacing of the first line.

The rather surprising part came out after deleting the italian option, because at first this error was shown:

! Package babel Error: You haven't loaded the option italian yet.
See the babel package documentation for explanation.
Type  H <return>  for immediate help.
...                                            
l.3 \select@language{italian}                      
? 

I honestly do not know why this error message is supposed to exist. However, by disregarding this, the generated output is:

enter image description here

Now the last word of the line was wrongly hyphenated (as suspected); but still, this leads to this final question: why babel couldn't simply hypenate carica as ca-, gaining the correct word spacing, instead as leaving those ugly voids?. I know that this word is not esoteric, and should be enlisted into the hypen dictionary.

And, for the sake of completeness, why there is such an error when I delete a language option? My thought about this could be that whenever an option is modified, the *.aux file somehow interferes with the new declaration, hence pointing out an error; but I'm not sure.

egreg
  • 1,121,712
TheVal
  • 2,488

1 Answers1

7

The hyphenation is taken into consideration, but not used, because it would give higher demerits. Here's what I get

@firstpass
@secondpass
[]\T1/cmr/m/n/10 All'interno di una se-mi-cir-con-fe-ren-za vi <E8> uni-for-me-men
-te di-stri-bui-ta una 
@ via @@0 b=189 p=0 d=49601
@@1: line 1.0 t=49601 -> @@0
ca-
@\discretionary via @@0 b=0 p=50 d=2600
@@2: line 1.2- t=2600 -> @@0
ri-
@\discretionary via @@0 b=25 p=50 d=3725
@@3: line 1.3- t=3725 -> @@0
ca $\OML/cmm/m/it/10 Q$\T1/cmr/m/n/10 , de-fi-ni-bi-le 
@\par via @@1 b=0 p=-10000 d=10100
@\par via @@2 b=0 p=-10000 d=50000100
@\par via @@3 b=0 p=-10000 d=50000100
@@4: line 2.2- t=59701 -> @@1

(I just loaded T1, but the result is almost the same with OT1).

What's the problem? As you clearly see, the added \finalhyphendemerits, that babel-italian sets to a very high value (50000000), make undesirable a hyphen in the last but one line. With the default value of 5000, the hyphen would be added.


What does that listing mean? It represents TeX's computations for line breaking.

  • \@firstpass means what TeX does without trying hyphenation; nothing shows because there's no way to respect the constraints given by the value of \pretolerance.

  • \@secondpass shows the real computations; the first feasible point is after una; before it, no good place for line breaking can be found; note that @@0 represents the start of the paragraph.

  • @ at the start of a line denotes a candidate for a break point; then the badness, the available penalties and the demerits are shown.

  • @@1 represents this found line break point; the line is classified 1.0, that is, line 1 which is “loose”;

  • @@2 is another good candidate for a line break, with total demerits 2600; line 1.2- means it's a “decent” line, but with a final hyphen.

  • @@3 would produce higher demerits, with a “tight line”, which ends with a hyphen.

After “definibile” there's \par, so TeX tries to find the “shortest path” adding also the “global demerits”, in particular \finalhyphendemerits if the last but one line is hyphenated. So the route is from @@4 (the final break forced by \par) via @@1 to @@0.

egreg
  • 1,121,712
  • Interesting! Although it's rather obscure why \finalhyphendemerits has been set to this value and not the defalut. As it can be seen on the MWE there isn't any package affecting this value. – TheVal May 18 '14 at 20:06
  • @AndreaL. Ask Claudio Beccari, who wrote the module of babel for Italian. I have always thought it's too high a value. A short paragraph will suffer from it, a longer paragraph will have sufficient flexibility that a value like the default (5000) is enough. – egreg May 18 '14 at 20:13
  • I will surely follow your advice (as soon I'll have the time), because the style of many documents I'm used to write consists of very small paragraphs (explanations of mathemathical steps); this issue evidently comes to the eye as a punch. On the last bit, do you know where I could get more specific information of \finalhyphendemerits et similia? – TheVal May 18 '14 at 20:21
  • @AndreaL. The TeXbook or TeX by Topic (texdoc texbytopic if you have TeX Live). – egreg May 18 '14 at 20:38