Latex:用向后箭头替换连字符

发布于 2024-10-12 21:40:12 字数 459 浏览 2 评论 0原文

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

\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} 在这种情况下不起作用 - 它不是单个字符。

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

I am setting e.g. directory names in a typewriter font. These names can become long. With the hyphenat package, I enabled hyphenation.
Now, what is missing, is that the hyphenation character is replaced e.g. by a backwards oriented arrow.
Thus, what I want to do is something like

\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}

however, \ensuremath{\hookleftarrow} does not work in this case - it is not a single character.

Can somebody point me towards a solution? Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清泪尽 2024-10-19 21:40:12

您无法将 \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}

You cannot set the \hyphenchar to a character from a different font, but you can redefine \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}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文