如何防止 LaTeX 对包含破折号的单词进行连字符?

发布于 2024-10-10 10:24:39 字数 230 浏览 0 评论 0原文

我想在全球范围内阻止 LaTeX 连接“Objective-C”。我知道 \hyphenation 命令,但我不知道如何使用它。如果我将“Objective-C”传递给此命令,破折号将被视为连字符连字符的提示。

我发现的一种解决方案是每次使用 Objective-C 时将其包装到 mbox 中。然而,我正在编写的文档包含很多这个名称,并且每次将其包装到 mbox 中都很丑陋(就像定义一个命令并在源代码中一遍又一遍地使用它一样)。

I would like to globally prevent LaTeX from hyphenating 'Objective-C'. I am aware of the \hyphenation command, but I don't see how I can make use of it. If I pass 'Objective-C' to this command, the dash will be treated as a hint to hyphenate the word there.

One solution I found is wrapping Objective-C into an mbox each time I use it. However, the document I am writing contains this name a lot, and wrapping it into an mbox each time is ugly (as is defining a command and using this over and over again in the source code).

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

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

发布评论

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

评论(3

浊酒尽余欢 2024-10-17 10:24:39

为什么定义一个新命令很难看?这就是 \LaTeX\ 的定义方式。

\def\ObjectiveC{\mbox{Objective-C}}

Why is defining a new command ugly? It's how \LaTeX\ defines itself.

\def\ObjectiveC{\mbox{Objective-C}}
她如夕阳 2024-10-17 10:24:39

使用\nobreakdash。这就是当我插入一个不间断的破折号并将其转换为 tex 时 LyX 产生的结果。

Use \nobreakdash. That's what LyX produces when I insert a nonbreakingdash and convert it to tex.

与往事干杯 2024-10-17 10:24:39

正如此处所建议的,您可以定义这样的命令:

 \newcommand\dash{\nobreakdash-\hspace{0pt}}

并像这样使用

Consider the $n$\dash dimensional manifold ... 

它,您可以使用 babel 包并使用 "~ 作为受保护的连字符。我不确定在写入时是否建议使用 babel不过,英语。

As suggested here, you could define a command like this:

 \newcommand\dash{\nobreakdash-\hspace{0pt}}

and use it like this

Consider the $n$\dash dimensional manifold ... 

Also, you could use the babel package and use "~ as a protected hyphen. I'm not sure if using babel is advisable when writing in english, though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文