Text FormattingFormatting problem with long words

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
cybermiaou
Posts: 2
Joined: Wed Jul 25, 2012 3:20 am

Formatting problem with long words

Post by cybermiaou »

Hi,
I am not a Latex expert.
In some case long and indivisible parts of URL at the end of a text go over the right margin.
I can "see" that obviously this would not occur if the previous text would be correctly shrinked or expanded in such a way the url reaches the marging at characters like / : or - (it does this well mostly), but it seems that the formatting does not anticipate enough to do this in some cases.
So the question is: is there a parameter to tell Latex to be more "intelligent" and anticipate more ?

I tested by replacing the url with a long word at the end of the text, the same problem occurs, strangely it does not even try to hyphenate (while it hyphenates well on the previous text, anyway hyphenizing an URL would not be a solution), so the problem is not specific to the url format.

Notice that the indivisible parts of URL or long words for debuging are shorter than the textwidth :D

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Formatting problem with long words

Post by Stefan Kottwitz »

Hi,

some suggestions:
  • Improve hyphenation, i.e. load babel with your language, perhaps use the \hyphenation command to specify hyphenation for specific words.
  • Use T1 font encoding, which improves hyphenation when you use special characters such as accented characters: \usepackage[T1]{fontenc}.
  • Load microtype for better justification.
  • Insert hyphenation points in the URLs or allow hyphenation at further special characters.
  • If nothing helps, use a sloppypar-environment, or \sloppy and \fuzzy (in emergency or for simplicity, better avoid it).
  • More sophisticated parameters, from l2tabuen:

    Code: Select all

    \tolerance 1414
    \hbadness 1414
    \emergencystretch 1.5em
    \hfuzz 0.3pt
    \widowpenalty=10000
    \vfuzz \hfuzz
    \raggedbottom
  • Or simply change the wording in the affected line a bit.
Stefan
LaTeX.org admin
cybermiaou
Posts: 2
Joined: Wed Jul 25, 2012 3:20 am

Re: Formatting problem with long words

Post by cybermiaou »

Thank you, \sloppy or package microtype fixed the problem !
Post Reply