Em dash in LaTeX

My friend Daniel Reeves was recently discussing different ways to typeset em dashes. Here is the way I like to do it in LaTeX.

GeSHi Error: GeSHi could not find the language tex (using path /home/robfelty/robfelty.com/wp-content/plugins/codecolorer/lib/geshi/) (code 2)

Here is the resulting output:

Different ways to make em dashes in LaTeX

Different ways to make em dashes in LaTeX

Notice how using spaces around the --- can result in a dash at the end of a line, which is not desirable. And using no spaces around the --- doesn’t look nice, and can also result in problems when copying and pasting. The \dash command solves both of these issues. I did not come up with it myself, but I cannot remember where I found it.

This entry was posted in latex. Bookmark the permalink.

One Response to Em dash in LaTeX

  1. Nice little macro. I like how you use \unskip to remove any interword glue that appears beforehand. The use of \thinspace before the dash prevents a line break at that point – could that be a problem? Also, why \ignorespaces at the end? Wouldn’t that prevent explicit spaces such as “\ “?