35

Often I'm trying to use a command in my document and it doesn't compile, because I haven't included the package I need for it. Of course, I know, that I can try to google it, but Google often finds some manuals and usage examples without package information (but this is probably because I don't know, how to google better). In all the cases I've succeeded in determining of the package name, but wasted more than 30 minutes in many of them.

Which ways would you advise to search for package name? Which hints would you suggest?

5
  • There are some commands defined by more than one package...
    – Seamus
    Commented Oct 5, 2010 at 11:42
  • 1
    @Seamus, of course, but it would still be nice to have a list of all the packages that provide a particular command. Commented Oct 5, 2010 at 12:12
  • best source so far google: e.g. \scalebox ctan very rarely it fails.
    – yannisl
    Commented Dec 8, 2010 at 15:17
  • 2
    Related question.
    – Raphael
    Commented Jun 11, 2014 at 14:49
  • There's also latexdef --find but it only works if you already know which package you should include, so doesn't apply here.
    – user202729
    Commented Dec 11, 2022 at 8:02

7 Answers 7

15
$ grep -r '\\commandname' $TEXMF/tex/latex
9
  • 2
    Heh, my scalebox comes from graphics. In any case, would it be better if you searched for '\\def\\commandname' instead? Searching for scalebox gives me a whole lotta other packages that use scalebox but not define it. Commented Oct 5, 2010 at 20:08
  • 4
    @Willie Wong: Then you'd miss e.g. \newcommand\commandname or \let\commandname. On the other hand, you'll always miss \expandafter\def\csname command\@empty name\endcsname. @All: you might try grep -IRF, then you don't have to double backslashes and binary files are ignored.
    – Philipp
    Commented Oct 5, 2010 at 22:06
  • 5
    Instead of grep -r I suggest using ack, I find it much faster and the results easier to "understand". There is even a nice TextMate bundle for that...
    – topskip
    Commented Oct 6, 2010 at 14:50
  • 2
    @Lev, how do I do this for MacTeX? Please add to the answer.
    – Kit
    Commented Oct 22, 2010 at 14:26
  • 4
    Nice, although 1) it won't work on non-UNIX-based systems, 2) it requires you to have that package installed already. But still, nice ;-) Commented Dec 8, 2010 at 11:53
8

If the command is for a symbol, I would look it up in the comprehensive symbols list or in Detexify, both let you know which package you need to load in order to get the symbol.

If the command is for a specific topic or feature, I would try to google for “latex feature” or even “ctan feature” instead of searching for the particular command.

7

Since April 2023 there is TeXFindPkg, a tool that does it!

On your terminal type:

texfindpkg query [<name>]

where <name> could be a file name, a command name, or an environment name.

The tool was created to install TeX packages and their dependencies by file names, command names, or environment names.

Its general usage is

texfindpkg <action> [<name>]

where <action> could be install or query, and <name> could be what is listed above.
For example:

texfindpkg install array.sty
texfindpkg install \fakeverb
texfindpkg install {frame}
texfindpkg query array.sty
texfindpkg query \fakeverb
texfindpkg query {frame}

TeXFindPkg supports both TeXLive and MiKTeX distributions.

More info on https://ctan.org/pkg/texfindpkg.

8
  • 1
    I have just updated TL23 (Linux) which installed the binary, but texfindpkg query \includegraphics didn't yield something useful.
    – AlexG
    Commented Apr 12, 2023 at 8:02
  • @AlexG The tool is new, maybe it needs some refinements, I'll tell the author
    – CarLaTeX
    Commented Apr 12, 2023 at 8:05
  • Yes, I tested with commands from other packages which produced correct positives. Something noteworthy: In a Linux shell, the backslash of a command needs to be doubled in order to escape it properly. (Maybe it is mentioned in the docs already, didn't check.)
    – AlexG
    Commented Apr 12, 2023 at 8:09
  • @AlexG I don't see it in the readme, I tell the author for it, too
    – CarLaTeX
    Commented Apr 12, 2023 at 8:13
  • 1
    I reported everything to the author, thank you!
    – CarLaTeX
    Commented Apr 12, 2023 at 8:17
2

in general, ctan doesn't have this information (except in the sources of the packages themselves, of course). the catalogue package descriptions (already mentioned) do occasionally mention command names, but they're not a reliable source of this information.

there's no particular reason why ctan shouldn't hold the information, but collecting it would take absolutely ages. one would have to be careful about duplicates (mentions above of graphics vs graphicx for the same command, for example), and the simple volume of packages is going to make it an unwieldy operation.

(note that commands in latex itself aren't a problem, in that they appear at least twice on the web anyway.)

0

You can try searching here for the command name in the package descriptions on CTAN.

2
  • 1
    Searching for “scalebox”, e.g., gives no results. Remember that you are searching only in the packages’ descriptions, not in the packages’ files. Searching for “scalebox” in the documentation search box, on the other hand, gives 59 results, so you still don’t know where the command might come from.
    – domwass
    Commented Oct 6, 2010 at 6:11
  • 1
    @domwass: I don't claim this will always or even usually be successful; it's just another thing to try. As you point out, documentation searches will usually give too many hits, but sometimes the description will say something like "provides the foo command". Commented Oct 6, 2010 at 14:46
0

Succinctly: Go back to where you learned about the command for the first time (be it a person or a web page) and see if he/she/it can tell you.

More verbosely (since I got a downvote on this answer I'm guessing it's because I came off as glib, sorry): you put that command in the document for a reason. Either somebody suggested it or you found a code snippet on a web page somewhere. That same person/page should also know what package needs to be included to make it work.

Example 1 You are following the advice of your colleague, let's call him...Martin. But because the conversation took place in the hallway you couldn't write down the actual code required.

"Hey, Martin, you remember how you told me I could use \snarfbbf to snarf the bumblefrack?"

"Yeah."

"Well, it doesn't work. It says the control sequence is undefined."

"Did you include the bbfrack package?"

"Oh, I get it. Thanks."

Example 2 Somebody (let's call him...Stefan) writes a blog post about snarfing bumblefracks in TeX documents. You copied-and-pasted a code snippet from part of the post. But because you didn't copy the preamble you have missed the required packages.

Go back to that web page, where either the complete document or a note about which packages are required should be there. If not, ask the blogger.

1
  • IMHO, this answer is as useful as "read the manual" :D
    – CarLaTeX
    Commented Apr 12, 2023 at 8:00
0

Starting 2023, there is texfindpkg:

$ texfindpkg query -e itemize
[tfp] you are using texlive
[tfp] ================================================
[tfp] found package file latex.ltx with environment {itemize}
[tfp] building dependency tree for latex.ltx:
[tfp] ------------------------
[tfp] latex.ltx (from latex)
[tfp] ------------------------
[tfp] texlive package needed: latex
[tfp] this package is already installed
[tfp] ================================================
[tfp] found package file IEEEtran.cls with environment {itemize}
[tfp] building dependency tree for IEEEtran.cls:
[tfp] ------------------------
[tfp] IEEEtran.cls (from ieeetran)
[tfp] |- newtxmath.sty (from newtx)
[tfp]    |- amsmath.sty (from amsmath)
[tfp]       |- amstext.sty (from amsmath)
[tfp]          |- amsgen.sty (from amsmath)
[tfp]       |- amsopn.sty (from amsmath)
[tfp]          |- amsgen.sty (from amsmath)
[tfp]    |- ifthen.sty (from latex)
[tfp]    |- etoolbox.sty (from etoolbox)
[tfp]    |- ifxetex.sty (from iftex)
[tfp]       |- iftex.sty (from iftex)
[tfp]    |- ifluatex.sty (from iftex)
[tfp]    |- xkeyval.sty (from xkeyval)
[tfp]    |- centernot.sty (from oberdiek)
[tfp]    |- amsthm.sty (from amscls)
[tfp] ------------------------
[tfp] texlive packages needed: ieeetran newtx amsmath latex etoolbox iftex xkeyval oberdiek amscls
[tfp] these packages are already installed
[tfp] ================================================
[tfp] found package file IEEEtrantools.sty with environment {itemize}
[tfp] building dependency tree for IEEEtrantools.sty:
[tfp] ------------------------
[tfp] IEEEtrantools.sty (from ieeetran)
[tfp] ------------------------
[tfp] texlive package needed: ieeetran
[tfp] this package is already installed
[tfp] ================================================
[tfp] found package file beamerbaselocalstructure.sty with environment {itemize}
[tfp] building dependency tree for beamerbaselocalstructure.sty:
[tfp] ------------------------
[tfp] beamerbaselocalstructure.sty (from beamer)
[tfp] |- enumerate.sty (from tools)
[tfp] ------------------------
[tfp] texlive packages needed: beamer tools
[tfp] these packages are already installed
[tfp] ================================================
[tfp] found package file enumitem.sty with environment {itemize}
[tfp] building dependency tree for enumitem.sty:
[tfp] ------------------------
[tfp] enumitem.sty (from enumitem)
[tfp] ------------------------
[tfp] texlive package needed: enumitem
[tfp] this package is already installed
[tfp] ================================================
[tfp] found package file paralist.sty with environment {itemize}
[tfp] building dependency tree for paralist.sty:
[tfp] ------------------------
[tfp] paralist.sty (from paralist)
[tfp] ------------------------
[tfp] texlive package needed: paralist
[tfp] this package is already installed
[tfp] ================================================
[tfp] found package file powerdot.cls with environment {itemize}
[tfp] building dependency tree for powerdot.cls:
[tfp] ------------------------
[tfp] powerdot.cls (from powerdot)
[tfp] |- xkeyval.sty (from xkeyval)
[tfp] |- geometry.sty (from geometry)
[tfp] |- ifxetex.sty (from iftex)
[tfp]    |- iftex.sty (from iftex)
[tfp] |- hyperref.sty (from hyperref)
[tfp]    |- kvsetkeys.sty (from kvsetkeys)
[tfp]    |- pdfescape.sty (from pdfescape)
[tfp]       |- ltxcmds.sty (from ltxcmds)
[tfp]       |- pdftexcmds.sty (from pdftexcmds)
[tfp]          |- infwarerr.sty (from infwarerr)
[tfp]    |- letltxmacro.sty (from letltxmacro)
[tfp]    |- kvoptions.sty (from kvoptions)
[tfp]       |- keyval.sty (from graphics)
[tfp]       |- ltxcmds.sty (from ltxcmds)
[tfp]       |- kvoptions-patch.sty (from kvoptions)
[tfp]    |- url.sty (from url)
[tfp]    |- bigintcalc.sty (from bigintcalc)
[tfp]    |- atveryend.sty (from atveryend)
[tfp]    |- nameref.sty (from hyperref)
[tfp]       |- refcount.sty (from refcount)
[tfp]          |- ltxcmds.sty (from ltxcmds)
[tfp]          |- infwarerr.sty (from infwarerr)
[tfp]       |- ltxcmds.sty (from ltxcmds)
[tfp]    |- backref.sty (from hyperref)
[tfp]       |- ltxcmds.sty (from ltxcmds)
[tfp]       |- rerunfilecheck.sty (from rerunfilecheck)
[tfp]          |- infwarerr.sty (from infwarerr)
[tfp]          |- uniquecounter.sty (from uniquecounter)
[tfp]    |- color.sty (from graphics)
[tfp] |- graphicx.sty (from graphics)
[tfp]    |- trig.sty (from graphics)
[tfp] |- pstricks.sty (from pstricks)
[tfp]    |- pgffor.sty (from pgf)
[tfp]       |- pgfrcs.sty (from pgf)
[tfp]          |- everyshi.sty (from everyshi)
[tfp]       |- pgfmath.sty (from pgf)
[tfp]    |- pst-calculate.sty (from pst-calculate)
[tfp]       |- siunitx.sty (from siunitx)
[tfp]          |- translations.sty (from translations)
[tfp]             |- etoolbox.sty (from etoolbox)
[tfp]          |- xspace.sty (from tools)
[tfp]       |- xparse.sty (from l3packages)
[tfp]    |- colortbl.sty (from colortbl)
[tfp]       |- array.sty (from tools)
[tfp]    |- pdfcolmk.sty (from pdfcolmk)
[tfp] |- pst-ovl.sty (from pst-ovl)
[tfp] |- xcolor.sty (from xcolor)
[tfp]    |- pdfcolmk.sty (from pdfcolmk)
[tfp] |- enumitem.sty (from enumitem)
[tfp] |- verbatim.sty (from tools)
[tfp] |- powerdot-default.sty (from powerdot)
[tfp]    |- pifont.sty (from psnfss)
[tfp] |- pdfbase.sty (from media9)
[tfp] |- powerdot-aggie.sty (from powerdot)
[tfp]    |- times.sty (from psnfss)
[tfp]    |- pst-grad.sty (from pst-grad)
[tfp] |- powerdot-BerlinFU.sty (from powerdot-fuberlin)
[tfp]    |- calc.sty (from tools)
[tfp]    |- tabularx.sty (from tools)
[tfp]    |- ragged2e.sty (from ragged2e)
[tfp]       |- footmisc.sty (from footmisc)
[tfp]    |- helvet.sty (from psnfss)
[tfp] |- powerdot-bframe.sty (from powerdot)
[tfp]    |- pst-blur.sty (from pst-blur)
[tfp] |- powerdot-ciment.sty (from powerdot)
[tfp] |- powerdot-elcolors.sty (from powerdot)
[tfp] |- powerdot-fyma.sty (from powerdot)
[tfp]    |- pst-grad.sty (from pst-grad)
[tfp] |- powerdot-horatio.sty (from powerdot)
[tfp] |- powerdot-husky.sty (from powerdot)
[tfp]    |- times.sty (from psnfss)
[tfp]    |- pst-grad.sty (from pst-grad)
[tfp] |- powerdot-ikeda.sty (from powerdot)
[tfp] |- powerdot-jefka.sty (from powerdot)
[tfp] |- powerdot-klope.sty (from powerdot)
[tfp]    |- pst-slpe.sty (from pst-slpe)
[tfp]       |- pst-xkey.sty (from xkeyval)
[tfp] |- powerdot-paintings.sty (from powerdot)
[tfp]    |- times.sty (from psnfss)
[tfp] |- powerdot-pazik.sty (from powerdot)
[tfp]    |- pst-char.sty (from pst-text)
[tfp]    |- pst-grad.sty (from pst-grad)
[tfp]    |- type1cm.sty (from type1cm)
[tfp] |- powerdot-sailor.sty (from powerdot)
[tfp]    |- amssymb.sty (from amsfonts)
[tfp]       |- amsfonts.sty (from amsfonts)
[tfp]    |- pst-grad.sty (from pst-grad)
[tfp] |- powerdot-simple.sty (from powerdot)
[tfp] |- powerdot-tuliplab.sty (from powerdot-tuliplab)
[tfp] |- powerdot-tycja.sty (from powerdot)
[tfp]    |- pst-grad.sty (from pst-grad)
[tfp] |- powerdot-upen.sty (from powerdot)
[tfp]    |- pst-grad.sty (from pst-grad)
[tfp] ------------------------
[tfp] texlive packages needed: powerdot xkeyval geometry iftex hyperref kvsetkeys pdfescape ltxcmds pdftexcmds infwarerr letltxmacro kvoptions graphics url bigintcalc atveryend refcount rerunfilecheck uniquecounter pstricks pgf everyshi pst-calculate siunitx translations etoolbox tools l3packages colortbl pdfcolmk pst-ovl xcolor enumitem psnfss media9 pst-grad powerdot-fuberlin ragged2e footmisc pst-blur pst-slpe pst-text type1cm amsfonts powerdot-tuliplab
[tfp] these packages are already installed
[tfp] ================================================
[tfp] texlive packages not yet installed in total:

(Yes, it stops after the :)

1
  • 2
    In what this differ from my already present answer?
    – CarLaTeX
    Commented Mar 9 at 20:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .