将每个符号定义为 LaTeX 中的命令
我正在开发一个大型项目,涉及用 LaTeX 排版的多个文档。 我希望在使用符号时保持一致,因此为整个项目中具有特定含义的每个符号定义一个命令可能是一个好主意。 有人对这个有经验么? 有什么需要注意的问题吗?
更具体一点。 比如说,在整个文档中,我将通过脚本 P 来表示称为可渗透性的东西,这是否是一个定义的想法
\providecommand{\permeability}{\mathscr{P}}
,或者这更像是“为 $n$ 定义命令”的情况?
I'm working on a large project involving multiple documents typeset in LaTeX. I want to be consistent in my use of symbols, so it might be a nice idea to define a command for every symbol that has a specific meaning throughout the project. Does anyone have any experience with this? Are there issues I should pay attention to?
A little more specific. Say that, throughout the document I would denote something called permability by a script P, would it be an idea to define
\providecommand{\permeability}{\mathscr{P}}
or would this be more like the case "defining a command for $n$"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一些提示:
\providecommand
才会定义该命令。 因此,如果您没有得到预期的结果,您可能正在尝试定义一个已在其他地方定义的命令。如果您使用
\ensuremath
将数学包含在命令中,则无论您发出命令时是否处于数学模式,它都会执行正确的操作:使用您自己的命令可以让您轻松更改以后某些内容的印刷表示形式。 例如:
会将
\vect{x}
打印为粗体 x。 如果您后来决定更喜欢矢量上方的箭头,您可以将命令更改为:A few tips:
\providecommand
will define that command only if it's not been previously defined. So if you're not getting the results you expected, you may be trying to define a command that's been defined elsewhere.If you wrap the math in your commands with
\ensuremath
, it will do the right thing regardless of whether you're in math mode when you issue the command:Using your own commands allows you to easily change the typographical representation of something later. For instance:
would print
\vect{x}
as a boldfaced x. If you later decide you prefer arrows above your vectors, you could change the command to:我一直在为任何具有特定含义并且比单个符号长的东西这样做,主要是为了节省打字:
但是后来我注意到我不再犯不一致的错误(objId vs ObjId vs ObjID),所以我同意这是一个好主意。
但是,我不确定如果输出中的符号是单个拉丁符号,这是否是一个好主意,如下所示:
即使为其定义了命令,也很容易键入单个符号并忘记它。
编辑:使用您的示例恕我直言,定义
\permeability
是一个好主意,因为它不仅仅是一个您必须在没有命令的情况下输入的 P 。 但这是千钧一发。I have been doing this for anything that has a specific meaning and is longer than a single symbol, mostly to save typing:
However then I noticed that I stopped making inconsistency errors (objId vs ObjId vs ObjID), so I agree that it is a nice idea.
However I am not sure if it is a good idea in case symbols in the output are, well, single Latin symbols, as in:
It is too easy to type a single symbol and forget about it even though a command was defined for it.
EDIT: using your example IMHO it'd be a good idea to define
\permeability
because it is more than a single P that you have to type in without the command. But it's a close call.