TeX - LaTeX Asked by tjollans on June 21, 2021
Em-dashes — when used to separate parenthetical clauses — are often used without any spacing, but I rather prefer them with a hair (or perhaps thin) space on either side.
The ‘obvious’ way to do this is probably to write A,---,B
rather than A---B
(no spaces) or A --- B
(unfortunately large spaces). However, this does not allow line breaks around the dash, should they be needed.
The best solution I’ve been able to come up with is this:
newcommand{mdash}
{discretionary{}{}{kern 0.1em}---discretionary{}{}{kern 0.1em}}
It looks like that works, but:
----
rather than mdash{}
?tugboat has been setting em-dashes with thin spaces for years. (the editors are not fond of the dash nearly crashing into whatever is on either side.)
here is a somewhat simplified version of the tugboat definitions. Observe that it wipes out preceding and following spaces so results are uniform.
DeclareRobustCommand{thinskip}{hskip 0.16667emrelax}
defemdash{---}
defd@sh#1#2{unskip#1thinskip#2thinskipignorespaces}
defDash{d@shnobreakemdash}
defLdash{d@shempty{hbox{emdash}nobreak}}
defRdash{d@shnobreakemdash}
a line break is permissible on either side of the basic Dash
. (the use of
thinskip
with hskip
rather than thinspace
is what allows this.)
if a line break should be permitted on only the right or left of the dash,
Rdash
and Ldash
are provided to accommodate that.
Correct answer by barbara beeton on June 21, 2021
First off I need to note this method works only with pdfTeX (≥1.40).
I used the microtype package as such:
usepackage[activate=false,kerning]{microtype}
SetExtraKerning[unit=character]{encoding=*}{textemdash={100,100}}
As far as I can tell, this is pretty much the sort of thing microtype kerning is designed for, and if nothing else has the advantage that you can still just type ---
.
This adds space (but not a space), equal to a tenth of the dash itself, to the left and right (this is half a 'thin space'). The unit is actually a thousandth of what is assigned to unit
; unit=1em
would make the unit 0.001em.
This package adds some very nice automatic features if you omit the activate=false
as well.
A documented (extremely minor in my view) limitation of microtype kerning is that the word following the dash will not be automatically hyphenated—but you can still insert a manual breakpoint. I haven't tested this.
I don't believe this changes the breaking behaviour immediately before or after the dash; I've certainly confirmed that it will still break immediately after, and it still does this in preference to hyphenating a word.
Answered by lukeuser on June 21, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP