3

This answer shows a nicely spaced emdash. I'm wondering if with lualatex and all its power if it's possible to automatically convert --- to the \dash command in the above link? (say with the toggles \autodashON and \autodashOFF)

1 Answers1

7

enter image description here

You can replace --- in the input by \dash

\documentclass{article}

\DeclareRobustCommand\dash{% \unskip\nobreak\thinspace\textemdash\allowbreak\thinspace\ignorespaces}

\directlua{ function dashes(s) return string.gsub(s,'[-][-][-]','\string\dash ') end}

\def\autodashON{\directlua{% luatexbase.add_to_callback("process_input_buffer",dashes,"spaced em dash")% }} \def\autodashOFF{\directlua{% luatexbase.remove_from_callback("process_input_buffer","spaced em dash")% }}

\setlength\parskip{20pt} \setlength\parindent{0pt} \begin{document}

One---two three --- four five. One---two three --- four five. One---two three --- four five. One---two three --- four five.

\autodashON

One---two three --- four five. One---two three --- four five. One---two three --- four five. One---two three --- four five.

\autodashOFF

One---two three --- four five. One---two three --- four five. One---two three --- four five. One---two three --- four five.

\end{document}

David Carlisle
  • 757,742
  • Very cool—thank you! Any thoughts towards using a technique like this to make TeX'ing a bit easier? Any immediate downsides come to mind? – likethevegetable Jan 18 '23 at 14:23
  • @likethevegetable you need to be careful of verbatim, --- possibly unlikely but x-- common in C-like languages, also any --- coming from package code – David Carlisle Jan 18 '23 at 19:12