LaTeX 中如何表示类名?
您认为在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
\texttt
是一个不错的选择。如果你的类名最终“超出了边距”,那是因为 LaTeX 默认情况下不会对
\texttt
文本进行连字符。 (因此,您可能会收到有关“overfull hboxes”的警告。)对此有两种可能的解决方案:要么重写文本,使类名不会出现在行尾,要么告诉 LaTeX 对您的类使用连字符名称(如果您可以接受)。对于后者,请查看
hyphenat
包。尝试像这样使用它:您可能还需要告诉 LaTeX 在哪里连接您的类名,如下所示:(
对于类
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:You will also probably need to tell LaTeX where to hyphenate your class names, like this:
(for class
ThisIsMyLongClassName
).也许更好的方法是定义您自己的宏:
然后像这样使用它:
这样做意味着您的类名被标记为此类,而不是打字机样式的文本。
Perhaps better would be to define your own macro:
which you then use like this:
Doing this means that your class names are tagged as such, not as typewriter-style text.
您可以使用 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.