在乳胶中定义宏 \etc \ie 的正确方法
在 这篇文章作者讨论了使用\@来放置正确的句号后的空格不在句子末尾,例如 Mr. ie 等。
建议的宏
\newcommand\etc{etc\@ifnextchar.{}{.\@}}
并不十分完美,因为在 (\etc more text)
的情况下它会生成 (etc .更多文字)
。
我见过很多作者制作了自己的 \etc
宏版本,大部分是 etc.\
的变体。
\etc
、\ie
、\etal
、\eg
的哪些宏在大多数情况下会产生最好的结果?
这是不是太个人化了,无法普遍解决?
In
this article the author discusses the use of \@ to put correct spacings after full stops that are not at the end of a sentence e.g. Mr. i.e. etc.
The macro suggested
\newcommand\etc{etc\@ifnextchar.{}{.\@}}
is not quite perfect since in the case (\etc more text)
it produces (etc.more text)
.
I have seen a lot of authors who have made their own versions of the \etc
macro, mostly variations on etc.\
.
What macros for \etc
, \ie
, \etal
, \eg
produce the nicest results in the most situations?
Is this something too personal in taste to be solved in general?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
早些时候,我使用宏来表示“et al.”等,但现在我会阻止人们定义此类宏。
一个问题是您已经观察到的:要获得正确的定义以便它们正确处理所有特殊情况(包括与其他包的交互 - 例如,那些重新定义“\cite”命令并调整引用之前的间距的包,这是非常棘手的) )。
但更重要的是,即使您有一堆适合您需求的宏,并且您知道如何使用它们,您的共同作者也可能对具体如何使用它们感到困惑在各种特殊情况下正确使用宏。
因此,我建议您避免使用宏来处理诸如“et al”之类的琐碎事情。并使用标准 Latex 标记简单地拼出所有内容。毕竟,大多数情况不需要任何特殊处理(“eg”后面经常跟逗号;“et al.”后面经常跟“~\cite”等),而每当需要特殊处理时,所有Latex 用户应该知道如何使用“\”和“\@”等命令。
Earlier I used macros for "et al.", etc., but nowadays I would discourage people from defining that kind of macros.
One problem is what you already observed: it's surprisingly tricky to get the definitions right so that they handle all special cases correctly (including the interactions with other packages – e.g., those that re-define the "\cite" command and tweak spacing before references).
But more importantly, even if you have a bunch of macros that suit your needs and you know how to use them, your co-authors are likely to be confused with exactly how to use your macros correctly in various special cases.
Hence I'd recommend that you avoid macros for trivial things such as "et al." and simply spell out everything by using standard Latex markup. After all, most cases don't need any special handling ("e.g." is often followed by a comma; "et al." is often followed by "~\cite", etc.), and whenever special handling is needed, all Latex users should know how to use commands such as "\ " and "\@".
在CVPR的样式包中,定义为:
In CVPR's style package, it is defined as:
您是否尝试过使用
xspace
包?示例宏:
一些测试:
产品:
来自 文档:
Have you tried using the
xspace
package?Example macro:
Some tests:
Produces:
From the documentation:
技术挑战!我们可以通过查看下一个字符的catcode并查看它是否是字母来避免空格后字母的问题;这可以使用 Latex3 的 expl3 宏
\peek_charcode:NTF
来完成(我的第一个 expl3 代码!):不过,我认为 Jukka 的建议是合理的:我想说这个问题将与他的 \etc 一起解决我们应该将这个宏视为 Tex 的双倍行距实现中的一个错误(Will Robertson 应该索要他的支票):如果您知道存在该错误,您可以通过在诸如“.)”之类的情况下输入 \@ 来直接解决它,或者你可能有棘手的代码,这意味着你不必在这种情况下思考,但你增加了排版方式的复杂性,这对于你来说不会在下一个意外故障(你可能已经介绍过)中起作用。
Postscript 先前版本已修复,感谢约瑟夫·赖特 (Joseph Wright) 在 tex.stackexchange.com 上注意到一个愚蠢的错误。
A technical challenge! We can avoid the problem of letters after spaces by looking at the catcode of the next character and seeing whether or not it is a letter; this can be done with the Latex3's expl3 macro
\peek_charcode:NTF
(my first expl3 code!):Jukka's advice I think is sound, though: I'd say the problem Will works around with his \etc macro we should see as a bug in Tex's implementation of double spacing (Will Robertson should ask for his cheque): if you know the bug is there, you can workaround it directly by putting in \@ in cases such as ".)", or you can have tricky code that means you don't have to think in this case, but you have added complexity to the way you typeset which is not going to work for you with the next unexpected glitch, one you probably have introduced yourself.
Postscript Previous version fixed, thanks to Joseph Wright noticing a stupid error at tex.stackexchange.com.
所有 LaTeX 命令都消除了后面的空格。如果你想要一个空格,你需要转义它:
这是必要的,因为你需要清楚命令名在哪里结束。
\etcno space
无法正确解释。All LaTeX commands eliminate space after them. If you want a space, you need to escape it:
This is necessary, because you need to be clear where the command name ends.
\etcno space
cannot be correctly interpreted.