I am trying to substitute an em-dash for double-hyphens (--) whenever they occur in user-generated text. The fonts that I am using (Chivo and Gentium Basic) result in double-hyphens added to the document, rather than \emdash{} (—).


The substitution code resembles:

  \ctxlua{context(string.gsub("#1", "[-][-]", "\\emdash{}"))}

  \SubEmdash{Escaping ampersands -- \& -- is troublesome.}

This fails for strings that contain ampersands.


An answer to either of these questions would be tremendously helpful:

  • How do you force -- to produce em-dashes throughout the text, regardless of font?
  • How would you escape user-generated text so that the \SubEmdash macro never fails?


The following answers also cannot handle ampersands in parameterized text:

1 Answer 1


The issue is due to font features being disabled by default. Enable font features as follows:

\starttypescript [serif] [ContentBody]
  \definefontsynonym [Serif] [name:librebaskervilleregular] [features=default]

\definetypeface[ContentFont] [rm] [serif] [ContentBody] [default]
\usetypescript[ContentFont] [ec]

This should automatically output curly quotes, elongated dashes, and ligatures.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .