我怎样才能让我的 dash 与 microtype 一起工作?

我怎样才能让我的 dash 与 microtype 一起工作?

考虑以下定义:

\documentclass[a6paper]{article}
\usepackage[showframe]{geometry}
\usepackage{microtype}

\def\Dash{\unskip\thinspace\textemdash\thinspace\ignorespaces\allowbreak}

\begin{document}
Lorem ipsum doler sit amet. Here is some text that I don't know what
I'm typing but it's okay \Dash all I need is enough text for the line
break and then I can put in my custom dash at it \Dash because
\emph{I'm so clever}.  (This worked out surprisingly well.)
\end{document}

我怎样才能定义\Dash正确地突出到边缘,就像连字符一样?

输出

答案1

的定义\thinspace

% latex.ltx, line 1315:
\def\thinspace{\kern .16667em }

因此它是一个字距;由于它后面没有粘连,所以它不是一个可行的换行点。

您可能想要用\hspace{.16667em}代替它;那么\allowbreak就不需要了。另一方面,\ignorespaces在您放置它的地方什么也不做,因为它唯一的操作是触发 的扩展\allowbreak。 无论如何,后面的空格都会被忽略\Dash

\documentclass[a6paper]{article}
\usepackage[showframe]{geometry}
\usepackage{microtype}

\newcommand\Dash{\unskip\thinspace\textemdash\hspace{.16667em}}

\begin{document}
Lorem ipsum doler sit amet. Here is some text that I don't know what
I'm typing but it's okay \Dash all I need is enough text for the line
break and then I can put in my custom dash at it \Dash because
\emph{I'm so clever}.  (This worked out surprisingly well.)
\end{document}

在此处输入图片描述

相关内容