# Why is Latex hyphenating some words automatically, but others dont?

On this example, the word usando is not being hyphenated, but the word Comandos is. If I force a hyphen on the first word usan-do, it is hyphenated correctly:

\documentclass[10pt,openright,twoside,a5paper]{memoir}
\usepackage[brazil]{babel}

\usepackage[showframe]{geometry}
\setlength{\parindent}{1.6cm}

\begin{document}

\frenchspacing
\selectlanguage{brazil}
No entanto, você pode compilar os documentos \LaTeX usando os seguintes
comandos, que devem ser digitados no \emph{Prompt de Comandos} do Windows ou no
\emph{Terminal} do Mac ou do Linux:

\end{document}


test2.tex:11: Overfull \hbox (4.94724pt too wide) in paragraph at lines 11--14[]\OT1/cmr/m/n/10 No en-tanto, voc pode com-pi-lar os do-cu-men-tos L[]T[]Xusando


Is there some way to debug the LaTeX hyphenation? For example, I can debug the overfull boxes, using \usepackage[showframe]{geometry} or \usepackage{showframe} in my preamble. So, is there some package I can include which helps me to find out why LaTeX is not hyphenating some words?

Related questions:

• the word at the end of the first sentence is "\LaTeX usando", not just "usando" and (la)tex will never hyphenate a word that incorporates a control sequence. – barbara beeton Aug 18 '17 at 17:02
• @barbarabeeton as written this isn't true, is it? Of course TeX will hyphenate words with control sequences in it (as long as those resolve simply to characters in the current font). The reason that it doesn't hyphenate \LaTeX adds kerns and boxes etc – Frank Mittelbach Aug 22 '17 at 19:43
• @FrankMittelbach -- er, maybe it isn't strictly true, but i prefer the simpler approach. i just make the rash assumption that there's no break between \LaTeX and what follows, so tex considers it to be a unit. probably it is because of kerns and boxes (and that would be true too of "\TeX book" which won't hyphenate either unless one tells it to with a control sequence definition). also, remember that i'm still working mostly within an ot1 environment. – barbara beeton Aug 22 '17 at 20:15
• @barbarabeeton OT1 is the key, but if you are not typing in English then you often have diacritics. And if you type them as commands, e.g., Gl\"uhw\"urmchen then this hyphenates perfectly (in T1). So at least for languages like German commands have been common inside words in the last 20+ years (only now with utf8 they start to become less). – Frank Mittelbach Aug 22 '17 at 20:32
• @FrankMittelbach -- i do like your example. (reminds me that i miss fireflies here in new england. they used to be everywhere in the summer when i was a kid in baltimore.) – barbara beeton Aug 22 '17 at 20:38

At first the word \LaTeX right before usando is confusing the hyphenation. But most importantly: \righthyphenmin is 3 in this language, that means that LaTeX will never break 2 chars at the end. You can change this:

\documentclass[10pt,openright,twoside,a5paper]{memoir}
\usepackage[brazil]{babel}

\usepackage[showframe]{geometry}
\setlength{\parindent}{1.6cm}

\renewcommand\brazilhyphenmins{22} %left=2, right=2

\begin{document}

\frenchspacing
\selectlanguage{brazil}
No entanto, você pode compilar os documentos \LaTeX{} usando os seguintes
comandos, que devem ser digitados no \emph{Prompt de Comandos} do Windows ou no
\emph{Terminal} do Mac ou do Linux:

\end{document}

• Thanks! But it seems it is another problem other than the \brazilhyphenmins with the word usando. Even after adding it, it still does not hyphenate it. I even tried using \brazilhyphenmins{11}, only forcing it with usan-do hyphenates it. – user Aug 18 '17 at 17:03
• As I wrote: The \LaTeX is problematic too, that's why I added {} and a space after the command. – Ulrike Fischer Aug 18 '17 at 17:07
• Sorry, Now you said so, I understand. When you said \Latex I though you were talking about the Latex language itself, not the word \Latex which comes right before usando. – user Aug 18 '17 at 17:09

Ulrike's answer is right, of course, but such problems can often be prevented by loading the microtype package. Here that gets

\documentclass[10pt,openright,twoside,a5paper]{memoir}
\usepackage[brazil]{babel}

\usepackage[showframe]{geometry}
\usepackage{microtype}
\setlength{\parindent}{1.6cm}

\begin{document}

\frenchspacing
\selectlanguage{brazil}
No entanto, você pode compilar os documentos \LaTeX{}  usando os seguintes
comandos, que devem ser digitados no \emph{Prompt de Comandos} do Windows ou no
\emph{Terminal} do Mac ou do Linux:

\end{document}


EDIT

What microtype does is play with all sorts of typographical features to make words fit better on a line and to make the end of the line look more even. It's clear that it helps here.

• An explanation of why, and what the package does, would be great. – Martin Argerami Aug 19 '17 at 14:54
• Have done...... – JPi Aug 19 '17 at 15:56
• but here, \LaTeX is explicitly terminated with {}, so it's not at all the same as \LaTeX usando, which was the original condition. microtype wouldn't help that, i don't think. – barbara beeton Aug 22 '17 at 20:17
• That is true, though even then it mitigates (but does not completely address) the problem. – JPi Aug 22 '17 at 21:40
• Wish i knew about microtype sooner! – Riki137 Nov 25 '18 at 21:46