LaTeX forum ⇒ Text FormattingOvefull hbox created by em-dash

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Aaliyah
Posts: 3
Joined: Mon May 06, 2013 3:30 pm

Ovefull hbox created by em-dash

Postby Aaliyah » Mon May 06, 2013 4:28 pm

Hello everyone!
There is one problem that currently seems insolvable to me. I am typesetting a book in Russian language and I noticed that, in some cases, an overfull box appears which cannot be solved via manual hyphenation or linebreak or even emergencystretch, because an em-dash is causing it. Due to the typesetting rules, the em-dash MUST stay at the end of the line if the line is about to break at this point, which is why moving it to the beginning of the next line cannot be considered.
I tried applying microtype, but it seems not being able to condense the em-dash ONLY in case it is positioned at the end of the line AND is causing an overfull. Or to condense it at all, to be honest. If I re-define the width of the em-dash-symbol, the same problem will occur at other positions in the book.
Changing the width of the text body didn't bring the desired effect either, because same situation came up as described above.
Here comes the MWE:

  1. \documentclass[fontsize=11pt,russian,open=any]{scrbook}
  2. \usepackage[T2A]{fontenc}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage[russian]{babel}
  5. \usepackage{fancyhdr}
  6. \usepackage[paperwidth=14.2cm, paperheight=20.4cm, top=1cm, bottom=1.3cm, twoside, inner=1.0cm, outer=1.2cm, bindingoffset=0.5cm, footskip=0.65cm, headsep=0cm, headheight=0cm, voffset=0pt, hoffset=0pt]{geometry}
  7. \usepackage[kerning=true,tracking=true,spacing=true,selected=true,babel=true,stretch=10,shrink=10]{microtype}
  8.  
  9. \deffootnote[1.5em]{0.5em}{0em}{
  10. \textsuperscript{\thefootnotemark}}
  11.  
  12. \setlength{\parindent}{1.25em}
  13. \setlength{\emergencystretch}{1pt}
  14.  
  15. \frenchspacing
  16. \righthyphenmin=2
  17.  
  18. \renewcommand{\baselinestretch}{0.9}
  19.  
  20. \clubpenalty=10000
  21. \widowpenalty=10000
  22. \flushbottom
  23.  
  24. \pagestyle{fancy}
  25. \fancyhf{}
  26. \fancyfoot[EC,OC]{\thepage}
  27. \renewcommand{\headrulewidth}{0pt}
  28.  
  29. \begin{document}
  30.  
  31. Когда его вопль, отражаясь испуганной белкой от пустых котлов и голых стен, замер, завязнув в тягучей темноте, снова воцарилась тишина, нарушить которую было не в силах даже потрескивание дров в одиноком камине. Конечно, надо было бы пойти бросить в него ещё несколько поленьев, но за это время эти подонки смогут улизнуть или спрятаться получше!..
  32.  
  33. --- Да. Его так зовут. Забавно, правда? Царство Костей. Костей~--- правитель Царства Костей.
  34.  
  35. Агафон насупился, поколебался несколько секунд между <<Именно секрет>> и <<А тебе зачем?>>, но вздохнул подавленно, махнул рукой и признался.
  36.  
  37. --- В Царство Костей,~--- с надеждой вскинул на него глаза Иван~--- уж не вспомнит ли дед ещё что-нибудь полезное?
  38.  
  39. --- Ну хорошо. А как насчёт неразговаривания с набитым ртом?~--- не сдавался Костей.
  40.  
  41. \end{document}


Oh, and I'm using TeXstudio 2.5.2.

If you take a closer look at the screenshot you'll see that sometimes even the hyphenation symbol is protruding into the margin, which also causes an overfull vbox:

http://imageshack.us/photo/my-images/12/96357038.jpg/

I'd like to know how to handle these overfull boxes. Is there a way to narrow those symbols depending on their position in text or something like this?
Thanks in advance!
Last edited by Aaliyah on Tue May 07, 2013 11:42 am, edited 1 time in total.

Tags:

User avatar
cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Mon May 06, 2013 5:45 pm

Hi Aaliyah,

Welcome to the LaTeX community!

I'd like to mention the fact that you've also asked this question on TeX.sx as a reference to users who like to try to answer your question so that they are aware of possibly existing solutions.

Regards
site moderator & package author

Aaliyah
Posts: 3
Joined: Mon May 06, 2013 3:30 pm

Postby Aaliyah » Mon May 06, 2013 6:49 pm

Oh, hi, I just didn't expect to get an answer so soon, but it seems that the problem was already solved, not as I'd want it, but still :)
I'd like to close the discussion both there and here, but have to go to work. If it can wait until several hours later?

User avatar
cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Mon May 06, 2013 7:02 pm

It can wait as long as you want.

It would be nice if you could post the solution you're using here (when you have the time again) so future visitors of this thread can see what the answer was/is.

Regards
site moderator & package author

Aaliyah
Posts: 3
Joined: Mon May 06, 2013 3:30 pm

Postby Aaliyah » Tue May 07, 2013 10:36 am

To summarize what I have learned at tex.sx so far, I have to:

1. Remove all the microtype-options from my preamble. It has to look like \usepackage{microtype}. This action alone has reduced the number of overfull hboxes to a tenth of the previous amount.

2. Handle the remaining cases manually, after the whole document is put together and the page layout has been set and won't be changed.

2a. Place a manual hyphenation in the word preceding the em-dash - sometimes Latex will break it there. If the paragraph with the sentence in question stretches over more than one line - try to add some manual hyphenation above, thus, added up, the hyphenations may provide the desired effect.

2b. Use thin unbreakable space \, instead of ~ where possible, it additionally reduces the overfull hbox, and if it's below 1pt, then it's acceptable.

2c. If thin space doesn't bring the desired effect and neither does manual hyphenation, but the protrusion is still too big, then apply hyphenation, enclose the last syllable together with the em-dash and following word into \mbox and check whether the result looks better than before.


If anyone can come up with another suggestion how to solve this (preferably automatically) - I'd love to hear and test it.
Last edited by Aaliyah on Tue May 07, 2013 10:51 am, edited 2 times in total.

User avatar
cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Tue May 07, 2013 10:42 am

Thanks!
site moderator & package author


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 4 guests