Text FormattingDysfunctionnal justification

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
PierreJ
Posts: 9
Joined: Mon Feb 07, 2022 5:54 pm

Dysfunctionnal justification

Post by PierreJ »

Hello All,

In my last text, justification is dysfunctional: I've had to use about 200 \linebreak commands, sometimes 2-3 in one paragraph, whereas I didn't need any in my previous texts (I didn't even know about \linebreak before). Why is this the case? Thanks in advance for your help.

Here is a MWE with actual text in attached file to show the problem.

Code: Select all

% Typesetter: XeLaTeX

\documentclass[a4paper,twoside,openright,french]{memoir}
\usepackage[fontsize=13pt]{scrextend}
\usepackage[french]{babel}
\usepackage{fontspec}
\usepackage{ebgaramond}

\begin{document}

\righthyphenmin=4   
\lefthyphenmin=3

Certains pubs anglais ont donné l'impression d'obtempérer en affichant une pancarte sur leur porte avec les mots \textit{Black Troops Only} (réservé aux militaires noirs) — sauf qu'à l'intérieur il y avait les clients habituels, si bien que les soldats noirs qui entraient se retrouvaient dans un pub normal et fraternisaient avec les locaux blancs, y compris des jeunes femmes ravies de découvrir les danses des États-Unis, particulièrement le jitterbug. Cette façon ironique d'implanter la ségrégation enrageait les racistes américains, ce qui réjouissait d'autant plus les patrons des pubs concernés.

\end{document}
justification_errors.png
justification_errors.png (293.59 KiB) Viewed 4411 times
Last edited by PierreJ on Mon Feb 07, 2022 7:45 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
MjK
Posts: 89
Joined: Fri Jan 28, 2022 6:09 pm

Dysfunctionnal justification

Post by MjK »

I cannot test it, because you have not marked the code as code (simply select the code with the mouse and click the »Code« button in the toolbar) and it is not a Infominimal working example, because it does not show the problem but only a not working snippet. However I would expect that these are overfull \hboxes. In this case there should be several warnings in the log file. To get less such overfull \hboxes you can remove your changes of \righthyphenmin and \lefthyphenmin to allow some more hyphenation. You can also try package microtype.
My main topics are KOMA-Script and other questions related to my packages. If I reply to any other topic or if you've not yet added a minimal working example, please do not expect any further response. And please don't forget to tag examples as code.
PierreJ
Posts: 9
Joined: Mon Feb 07, 2022 5:54 pm

Dysfunctionnal justification

Post by PierreJ »

Thank you very much for your explanation! I've corrected my post.

The problem with changing \righthyphenmin and \lefthyphenmin is that I then get faulty hyphenation cases (for instance, in French, it's forbidden to have "chan-gent").
PierreJ
Posts: 9
Joined: Mon Feb 07, 2022 5:54 pm

Dysfunctionnal justification

Post by PierreJ »

I've just found a solution: replacing \usepackage{ebgaramond} with \usepackage{libertinus} solves almost all cases of lengthened lines.
The last remaining ones were solved with the line \usepackage[protrusion=true,expansion=true,final,babel]{microtype}. Thanks a lot MJK !
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Dysfunctionnal justification

Post by Ijon Tichy »

PierreJ wrote:Thank you very much for your explanation! I've corrected my post.

The problem with changing \righthyphenmin and \lefthyphenmin is that I then get faulty hyphenation cases (for instance, in French, it's forbidden to have "chan-gent").
babel sets \lefthyphenmin to 2 and \righthyphenmin to 3 for french which AFAIK is correct for French (if it isn't, you should make a bug report). But if only some words are faulty hyphenated, you should correct these words, e.g., using \hyphenation{changent} in your document preamble. Global settings of \lefthyphenmin and \righthyphenmin to large values make hyphenation and therefore paragraph breaking difficult to TeX. So it is not recommended to do so to solve hyphenations problems of some words only.

BTW: AFAIK

Code: Select all

% Typesetter: XeLaTeX

\documentclass[a4paper,twoside,openright,french]{memoir}
\usepackage[fontsize=13pt]{scrextend}
\usepackage[french]{babel}
\usepackage{fontspec}
\usepackage{ebgaramond}

\begin{document}

Certains pubs anglais ont donné l'impression d'obtempérer en affichant une pancarte sur leur porte avec les mots \textit{Black Troops Only} (réservé aux militaires noirs) — sauf qu'à l'intérieur il y avait les clients habituels, si bien que les soldats noirs qui entraient se retrouvaient dans un pub normal et fraternisaient avec les locaux blancs, y compris des jeunes femmes ravies de découvrir les danses des États-Unis, particulièrement le jitterbug. Cette façon ironique d'implanter la ségrégation enrageait les racistes américains, ce qui réjouissait d'autant plus les patrons des pubs concernés.

\end{document}
used only allowed hyphenations. So there is also no need to change the font. However, of you like Linux Libertine more than Garamond, just use it. (But don't expect, that this solves all hyphenation problems for every text and for all time).

Moreover, if you are using the current French hyphenation pattern, changent will not be hyphenated with the default settings:

Code: Select all

%!TeX log
\documentclass[a4paper,twoside,openright,french]{memoir}
\usepackage[fontsize=13pt]{scrextend}
\usepackage[french]{babel}
\usepackage{fontspec}
\usepackage{ebgaramond}

\begin{document}
\showhyphens{changent}
\end{document}
shows

Code: Select all

Underfull \hbox (badness 10000) in paragraph at lines 8--8
\TU/lmr/m/n/13 changent
in the log-file. So there are not any hyphenation points in «changent». If you get another result, you should check, if the hyphenation patterns for french are installed and activated and if your TeX installation is up-to-date.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
PierreJ
Posts: 9
Joined: Mon Feb 07, 2022 5:54 pm

Dysfunctionnal justification

Post by PierreJ »

Ijon Tichy, thank you very much for your input. I'll follow your advice and use \hyphenation to solve special cases. I'm not sure it's a bug problem, maybe it's just too complicated to manage. For instance, "pa-rent" is legal if it means "relative" but it's illegal if it means "(they) avert".

Funnily, changing fonts did solve most of my hyphenation problems (please see the attached picture, to be compared with the picture attached to my first post). The last issues (line 6 and 18) were solved by the microtype package.
justification1.png
justification1.png (310.26 KiB) Viewed 4361 times
Post Reply