1

我正在以打字机字体设置例如目录名称。这些名称可能会变长。使用连字符包,我启用了连字符。现在,缺少的是连字符被替换为例如向后的箭头。因此,我想做的是

\usepackage[htt]{hyphenat}
\newcommand{\origttfamily}{}%
\let\origttfamily=\ttfamily%
\renewcommand{\ttfamily}{\origttfamily \hyphenchar\font=\ensuremath{\hookleftarrow}}
\begin{document}
\texttt{/etc/really/long{\fshyp}directory{\fshyp}name/}
\end{document}

但是,\ensuremath{\hookleftarrow} 在这种情况下不起作用 - 它不是单个字符。

有人可以指出我的解决方案吗?非常感谢!

4

1 回答 1

0

您不能将 设置\hyphenchar为不同字体的字符,但可以重新定义\BreakableSlash

\documentclass{minimal}
\usepackage[htt]{hyphenat}
\newsavebox\leftarrowbox
\sbox\leftarrowbox{$\leftarrow$}
\makeatletter
\renewcommand*{\BreakableSlash}{%
  \leavevmode
  \prw@zbreak
  /%
  \discretionary{\usebox\leftarrowbox}{}{}%
  \prw@zbreak
}
\makeatother
\begin{document}
\parbox{20mm}{%
  \texttt{/etc\fshyp really\fshyp long\fshyp directory\fshyp name/}%
}
\end{document}
于 2011-01-20T17:17:11.530 回答