LaTeX, package documentation look-up
A. I discovered there is a "url" command through a Google search, how can I get a "list of commands/packages"?
The list of packages is on CTAN. But by itself it’s not very helpful – there are too many packages. Similarly, there’s no list of commands, that’s not meaningful since there are simply too many. The easiest way of finding out about a package/command is to google for general typesetting help in its domain (e.g. googling for latex plot
) and taking it from there.
B. I update my "packages" using TeX Live Utility.app, is this the "right" way to do it?
Yes. This is by far the easiest and less painful way. If you need to install specific versions of packages which aren’t yet available via this interface (e.g. beta versions) you need to use the tlmgr
command line interface instead.
Could I have not got to this information in a simpler way?
I wish there was something like "JavaDoc" or a "built-in help system" akin to what I get using Eclipse and installing JavaDoc jars and attaching source documentations
On the command line,
texdoc url
Generally, every package’s documentation can be accessed via texdoc <packagename>
. Most packages come with a typeset documentation as a PDF. – Incidentally, I don’t know why most LaTeX beginners’ guides don’t mention this, or only mention it obliquely. This is by far the most useful thing I’ve ever learned about LaTeX. For instance, all core commands of LaTeX are documented in texdoc source2e
(which is highly technical, but complete).
In fact, LaTeX’ documentation system is far more complete than JavaDoc or similar systems. Package writers are strongly encouraged to practice literal programming, i.e. they don’t comment/document their code. Rather, they write a documentation which contains the code (not the other way round, as in the case of JavaDoc). This usually means that package documentation is very comprehensive. For an extreme example, try texdoc tikz
(an awesome package, by the way) – this is a beautifully typeset 700-page documentation with several tutorials and examples throughout.
Besides texdoc, which gives you quick access to packages documentation, there's also a great tool called texdef. Quoting the description on CTAN:
The (Perl) script displays the definition of (La)TeX command sequences/macros. Various options allow the selection of the used class and package files and other things which can have influence on the definition (before/after the preamble, inside an environment, …).
The usage is simple: issuing
texdef --tex latex --package url --source url
gives the source of the definition of the command
% url.sty, line 194:
\DeclareUrlCommand\url{}
which points to the definition of \DeclareUrlCommand
, so
texdef --tex latex --package url --source DeclareUrlCommand
% url.sty, line 190:
\def\DeclareUrlCommand#1#2{\def#1{\leavevmode\begingroup #2\Url}}
Check the author's (Martin Scharrer) announcement of the tool in his answer to Where do I find out how a command/environment is defined?. See also N.N.'s answer to Display source for a command.
At www.ctan.org you can search for packages by keyword, by a hierarchical characterization and by a text search of the descriptions. (However, this seems to be little used; that I can tell, everyone just googles.)