LaTeX:如何查找命令所属的包?
这是一个简单的问题,我无法找到答案:
给定一个 LaTeX 命令,我如何找出它属于或来自哪个包从?
例如,给定 \qquad
水平间距命令,它来自哪个包?特别麻烦,因为它不需要任何包就可以工作!
It is a simple question to which I am not able to find the answer:
Given a LaTeX command, how do I find out what package(s) it belongs to or comes from?
For example, given the \qquad
horizontal spacing command, what package does it come from? Especially troublesome since it works without including any package!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查阅您的参考资料:
latex.ltx
或标准类文件之一中定义的,而不是在包中。find /usr/share/texmf -name '*.sty'
的结果进行一些奇特的 grep 操作,但要做好痛苦练习的准备。Consult your references:
latex.ltx
or in one of the standard class files, not in a package.find /usr/share/texmf -name '*.sty'
, but be prepared for a painful exercise.您可以搜索 http://www.ctan.org/tex-archive/info /symbols/compressive/ 了解该信息及更多信息。
请记住,LaTeX 是一种基于 TeX 的宏语言,所有宏都是由 TeX 组成的,无需导入。
\qquad
属于该类别。You can search http://www.ctan.org/tex-archive/info/symbols/comprehensive/ for that information and more.
Remember that LaTeX is a macro language on top of TeX, and all the macros are made up of TeX which doesn't need to be imported.
\qquad
is in that category.据我所知,对此没有真正好的通用答案。但是对于任何给定的命令,您都可以尝试多种技术。对于
\qquad
来说,它是基本 TeX 的一部分。请记住,您始终可以在交互模式下使用 TeX:一些宏是由 LaTeX 在 TeX 之上添加的,例如
\begin
:而
其他所有内容都来自包。如果您确实想知道宏来自哪个包(除了通过 google 或 grep texmf 树),您可以在加载每个包后检查它是否已定义。尝试在任何
\usepackage
命令之前定义它:然后,当您在
.tex
文件上运行latex
时,在输出中查找一行:includegraphics 在graphicx 中定义
。这不太可能,但一些狡猾的包可能会用\usepackage
做坏事,所以这可能不起作用。另一种选择是在加载任何包之前简单地定义您感兴趣的命令:然后,当加载定义该命令的包时,您可能会收到一条错误消息。这实际上不如前一种方法可靠,因为许多包使用
\def
和\let
来定义它们的宏而不是\newcommand
,从而绕过了“已定义”检查。您也可以在每次加载之间手动插入一张支票:As far as I know, there is no really good general answer to this. But there are a number of techniques you might try for any given command. In the case of
\qquad
, it's part of basic TeX. Remember that you can always use TeX in interactive mode:Some macros are added by LaTeX on top of TeX, such as
\begin
:whereas
Everything else comes from packages. If you really wanna know which package a macro comes from (other than by google or grepping your texmf tree), you can check after each package you load whether it's defined. Try defining this before any
\usepackage
commands:Then when you run
latex
on your.tex
file, look for a line in the output that saysincludegraphics is defined in graphicx
. It's not likely, but some devious packages might do bad things with\usepackage
so there's a chance this might not work. Another alternative would be to simply define the command you're interested in before loading any packages:Then you might get an error message when the package that defines the command is loading. This is actually less reliable than the former approach, since many packages use
\def
and\let
to define their macros rather than\newcommand
, bypassing the "already-defined" check. You could also just insert a check by hand in between each load:由于缺乏声誉,我无法评论史蒂夫的回答,这对我很有帮助,但我想扩展一下。
首先,在他的第二种方法(摆弄
usepackage
)中,没有处理usepackage
具有可选参数的情况。其次,包通常由其他包通过 RequirePackage 加载,这使得很难找到命令定义的实际位置。所以我对 Steve 的答案的改进是:这里使用 xargs 包来获取 usepackage 的不寻常选项(第一个和第三个参数是可选的)。
将其直接放在
documentclass
之后应该可以告诉includegraphics
的定义位置。Due to lack of reputation I cannot comment on Steve's answer, which was very helpful to me, but I would like to extend it a bit.
First, in his second approach (fiddling with
usepackage
) the case whereusepackage
has optional arguments is not dealt with. Secondly, packages are often loaded by other packages viaRequirePackage
which makes it hard to find the actual place of definition of a command. So my refinement of Steve's answer is:The
xargs
package is used here to get the unusual options ofusepackage
right (first and third parameter are optional).Putting this directly after
documentclass
should tell whereincludegraphics
is defined.