Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I search things about some functions in LaTeX on Linux in the command-line?

Tried texdoc, but texdoc cite, for example, don't works.

I would like a tool to search about LaTeX functions in terminal like pydoc if to search about if statement of python.

share|improve this question
What's packages I need to install to enable $TEMF enviroment variable? My ubuntu didnt have it. –  GarouDan Oct 16 '11 at 20:28
add comment

3 Answers

(La)TeX isn't build like Python which can store and build documentation in and from the code itself. You need to figure out which package is defining the macro (aka "commands") and then load the package manual e.g. using texdoc <package name>. There is no cross-reference from the macros to their packages, besides the one done by Google & Co. TeX also doesn't know namespaces etc. While it is Turing complete it should not be compared with software programming languages, especially not with such which are over 30 years younger.

The closest thing you are looking for is the Perl script texdef (which can also be installed as latexdef) which normally shows the definition of macros, but which has also a --find / -f option to display where the given macros are first defined. The catch is that you need to load the packages it should search by yourself. It uses LaTeX internally and loading all installed packages in one document automatically isn't possible. So, e.g. latexdef -f -p hyperref href tells you the definition of \href and that it is first defined by url.sty (which is loaded by hyperref). This can be used to find you which packages in a list is defining the macro. Unfortunately this is cumbersome, and a web search might be easier and more fruitful.

share|improve this answer
I've always wondered why TeX Live doesn't provide latexdef as a symbolic link to texdef. –  egreg Oct 10 '11 at 13:52
@egreg: I contacted them after the first release and the told me they don't like to add to many symlinks/aliases for new packages, don't like to prefer LaTeX before ConTeXt (there is a contextdef as well) and that there is also the issue under Windows which doesn't know symlinks. –  Martin Scharrer Oct 10 '11 at 13:57
Where I can find this latexdef package to install? There isnt in Ubuntu repository. –  GarouDan Oct 10 '11 at 21:32
@GarouDan: It is on CTAN and can be installed using TeX Live for example. Note that the script is actually called texdef and you need to add a symlink named latexdef to it, or use texdef -t latex instead. –  Martin Scharrer Oct 10 '11 at 21:58
I had installed latexdef and I got some interesting things...but your example latexdef -f -p hyperref href didn't work. Why? Do you recommend a link to get docs or a linux packages to install? @LeoLio below said cite is in natbib, and texdoc natbib works, but why latexdef -f -p natbib cite as you explained don't work? Thx...aprecciate the time to answer. –  GarouDan Oct 11 '11 at 10:32
add comment

Genrally speaking, you can't. There is not such a document that contains all macros in TeX.

You can, however, search the macro in some books and documents. And there are many books and documents for different levels.

  • For user level LaTeX commands and environments, you need a good book, e.g. A Guide to LaTeX. You can find a command in the index. For quick reference, you may have a look at latex2e-help-texinfo, tex-refs and some other electronic documents. Try

    texdoc latex2e-help-texinfo

    These are not comprehensive documents, but indeed useful.

    You can find \cite command in these books/documents, of course.

  • For any macros in a LaTeX package, most of the time you must read the package document --- it is the only source to get the information. If you want to know in which package it is, Google is the best way as I know.

    For example, you search keywords "LaTeX \citep" in Google and you'll know that \citep is a command provided by natbib package. Then you can read the document of natbib for datails.

  • For some special purpose, there may be special documents. Almost all LaTeX symbols can be found in The Comprehensive LaTeX Symbol List (texdoc symbols), for example. Other documents includes: epslatex (only French version in TeX Live), mathmode, tamethebeast (for bibliography), etc.

  • You can find all macros in LaTeX2e kernel and standard classes in the documented source of LaTeX2e: source2e and classes documents. But you can't find any macro defined in a package in these documents. Note that documented source code is more suitable for package writers. Before reading them, try other user level documents.

  • For Plain TeX and TeX primitives, you may read Knuth's TeXbook. Also TeX for the Impatient (texdoc impatient) and TeX by Topic (texdoc texbytopic) are very convenience.

share|improve this answer
I think the commmunity (us) should start a open-source project trying to document all TeX commands in one place, in a searchable document... –  GarouDan Oct 10 '11 at 21:34
add comment

I guess there’s no way to search all package documentations for a single command. With texdoc you can access only the full package documentation, e.g. texdoc biblatex.

If I need information about a special command and I don’t know in which package it is I try to google it ;-)

If you like more about the latex implematation have a look at source2e (or texdoc source2e)

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.