LaTeX 中如何表示类名?

发布于 2024-08-03 00:59:08 字数 206 浏览 2 评论 0原文

您认为在 LaTeX 文档中呈现类名的最佳方式是什么(编写一个软件)。

我目前正在使用 \texttt (等宽打字字体),否则效果很好,但我的类名最终会“超过”边距。

因此,我要求提供

  • 一种替代(美观)的方式来表示类名,
  • 以确保我的类名不会超出边缘

br, 灯子

what do you see as best way of presenting class names in LaTeX documents (writing about a piece of software).

I'm currently using \texttt (monospaced typewrite font) which otherwise works fine but my class names end up goind "over" the margins.

So, I'm asking for either

  • an alternative (good-looking) way of representing the class names
  • way to make sure my classnames won't go over the margins

br,
Touko

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

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

发布评论

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

评论(3

樱桃奶球 2024-08-10 00:59:08

\texttt 是一个不错的选择。

如果你的类名最终“超出了边距”,那是因为 LaTeX 默认情况下不会对 \texttt 文本进行连字符。 (因此,您可能会收到有关“overfull hboxes”的警告。)对此

有两种可能的解决方案:要么重写文本,使类名不会出现在行尾,要么告诉 LaTeX 对您的类使用连字符名称(如果您可以接受)。对于后者,请查看 hyphenat。尝试像这样使用它:

\usepackage[htt]{hyphenat}

您可能还需要告诉 LaTeX 在哪里连接您的类名,如下所示:(

This\-Is\-My\-Long\-Class\-Name

对于类 ThisIsMyLongClassName)。

\texttt is a good choice.

If your class names end up "going over the margins", that's because LaTeX doesn't hyphenate \texttt text by default. (You're probably getting warnings about "overfull hboxes" because of this.)

There are two possible solutions to this: Either rewrite your text so that class names don't appear at the ends of lines, or tell LaTeX to hyphenate your class names (if that's acceptable to you). For the latter, check out the hyphenat package. Try using it like this:

\usepackage[htt]{hyphenat}

You will also probably need to tell LaTeX where to hyphenate your class names, like this:

This\-Is\-My\-Long\-Class\-Name

(for class ThisIsMyLongClassName).

む无字情书 2024-08-10 00:59:08

也许更好的方法是定义您自己的宏:

\newcommand{\classname}[1]{\texttt{#1}}

然后像这样使用它:

\classname{MyClass}

这样做意味着您的类名被标记为此类,而不是打字机样式的文本。

Perhaps better would be to define your own macro:

\newcommand{\classname}[1]{\texttt{#1}}

which you then use like this:

\classname{MyClass}

Doing this means that your class names are tagged as such, not as typewriter-style text.

云淡风轻 2024-08-10 00:59:08

您可以使用 url 包,尽管它的名称可以可用于以打字机字体排版任何类型的文本,并允许换行。

You could use the url package, which despite its name can be used to typeset any kind of text in a typewriter font, allowing for linebreaks.

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