10

I had a really bad overfull hbox in my bibliography caused by an emdash in the first line of a two line entry. The only solution to get rid of the overfull hbox was to line break the emdash to the beginning of the second line which looks ok.

The problem is that the emdash is affected by the protrusion of microtype causing one third of it going into the left margin which doesn't look good at the beginning of a line. Can I disable the protrusion locally for this point?

  • Does something like {\microtypesetup{protrusion=false}---} help? – Arash Esbati Dec 30 '15 at 15:07
  • @ArashEsbati This gives me a lot of errors starting with Use of \reserved@a doesn't match its definition – user2653422 Dec 30 '15 at 15:14
  • 1
    If you don't like the dash protruding into the left margin, then you should change the protrusion settings. – Robert Dec 31 '15 at 0:26
7

You can define a command that prints an emdash after a small kern (zero is not sufficient, but 1sp is the least nonzero length in TeX and goes unnoticed):

\documentclass{article}

\usepackage{etoolbox,microtype,showframe}

\setlength{\textwidth}{7cm}

\newrobustcmd{\npemdash}{%
  \mbox{\kern1sp ---}%
}

\begin{document}

Let's push the emdash to the next line\linebreak---with some text afterwards

Let's push the emdash to the next line\linebreak\npemdash with some text afterwards

Let's push the emdash to the next line\linebreak---with some text afterwards

\end{document}

You can use this macro wherever you want, also in the bib file.

enter image description here

  • 1
    Your code doesn't compile; you should add \usepackage{etoolbox} as well. – Arash Esbati Dec 30 '15 at 15:57
  • @ArashEsbati Yes, of course! I had biblatex but then removed it. – egreg Dec 30 '15 at 16:00
7

It is possible to temporarily disable microtype, here an example:

\documentclass[12pt,oneside]{report}

\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage[activate,verbose=true]{microtype}

\begin{document}

\begingroup
  \microtypesetup{activate=false}%
  \noindent Disable protrusion from microtype for just one word
  \linebreak --- for example\par
\endgroup

\end{document}

enter image description here

It depends on your use case how to inject the code into right place.

  • Thank your for the answer. But how can I add this into the title field of a bib entry? The bibliography file will be used by biblatex with biber. – user2653422 Dec 30 '15 at 15:37
  • @user2653422 - Maybe with the execute field? Otherwise try the answer provided by egreg. – Arash Esbati Dec 30 '15 at 15:53
  • 4
    biblatex provides begentry and finentry hooks. You con can use them to set toggle to activate disactivate micro type. To restrict to a single entry see tex.stackexchange.com/a/195910/16895 – Guido Dec 30 '15 at 16:03
  • Thank you both. I upvoted your answer, however accepted the solution from egreg as it was the easiest solution in this case. – user2653422 Dec 30 '15 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.