I have written a LaTeX Document and it compiles fine on my machine, but now I would like to give the sources to someone else. Is there a quick way to list all the packages that have been used for compilation?
-
difficult. You should use Tex Live anyway which has all you need packaged. – Feb 20 '12 at 21:26
-
I didn't install the TeX distribution but it seems that TeX Live is used in some way as it occurs a lot of times in the generated lag file. – Feb 20 '12 at 21:33
2 Answers
Yes. Add \listfiles somewhere in your document preamble. The output should be posted in your .log file. Here's an example from a test document containing 2 packages in the preamble and compiled using TeX Live 2009:
\documentclass{article}
\listfiles
\usepackage{array}% http://ctan.org/pkg/array
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\begin{document}
test
\end{document}
The .log file now includes
*File List*
article.cls 2007/10/19 v1.4h Standard LaTeX document class
size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
array.sty 2008/09/09 v2.4c Tabular extension package (FMi)
hyperref.sty 2010/05/04 v6.81a Hypertext links for LaTeX
ltxcmds.sty 2010/04/26 v1.7 LaTeX kernel commands for general use (HO)
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
kvsetkeys.sty 2010/03/01 v1.9 Key value parser (HO)
infwarerr.sty 2010/04/08 v1.3 Providing info/warning/message (HO)
etexcmds.sty 2010/01/28 v1.3 Prefix for e-TeX command names (HO)
pdfescape.sty 2010/03/01 v1.9 Provides hex, PDF name and string conversions
(HO)
pdftexcmds.sty 2010/04/01 v0.9 Utility functions of pdfTeX for LuaTeX (HO)
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
ifpdf.sty 2010/01/28 v2.1 Provides the ifpdf switch (HO)
ifvtex.sty 2010/03/01 v1.5 Switches for detecting VTeX and its modes (HO)
ifxetex.sty 2009/01/23 v0.5 Provides ifxetex conditional
hycolor.sty 2009/12/12 v1.6 Color options of hyperref/bookmark (HO)
xcolor-patch.sty 2009/12/12 xcolor patch
letltxmacro.sty 2008/06/24 v1.3 Let assignment for LaTeX macros (HO)
pd1enc.def 2010/05/04 v6.81a Hyperref: PDFDocEncoding definition (HO)
intcalc.sty 2007/09/27 v1.1 Expandable integer calculations (HO)
hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
kvoptions.sty 2010/02/22 v3.7 Keyval support for LaTeX options (HO)
url.sty 2006/04/12 ver 3.3 Verb mode for urls, etc.
bitset.sty 2007/09/28 v1.0 Data type bit set (HO)
bigintcalc.sty 2007/11/11 v1.1 Expandable big integer calculations (HO)
atbegshi.sty 2010/03/25 v1.12 At begin shipout hook (HO)
hpdftex.def 2010/05/04 v6.81a Hyperref driver for pdfTeX
atveryend.sty 2010/03/24 v1.5 Hooks at very end of document (HO)
rerunfilecheck.sty 2010/03/16 v1.6 Rerun checks for auxiliary files (HO)
uniquecounter.sty 2009/12/18 v1.1 Provides unlimited unique counter (HO)
nameref.sty 2010/04/30 v2.40 Cross-referencing by name of section
refcount.sty 2008/08/11 v3.1 Data extraction from references (HO)
gettitlestring.sty 2009/12/18 v1.3 Cleanup title references (HO)
***********
So, you can see that loading only array and hyperref (say), actually loads a large number of other packages as well.
- 603,163
-
-
1I have some recollection of a script that uses
\listfilesto actually bundle up all files that are belonging to a particular document for archival purposes. Anybody having a pointer? – Frank Mittelbach Feb 20 '12 at 22:54 -
3
-
Great answer. Is there a way to only get the 1st level? As in only those that I've explicitly specified in the TeX file, and not those loaded because a package I've used needs them? Over time, changes occur and you can have quite a list of packages at the top of the document, but I'm not longer making use of maybe 10% of them. – Travis Bemrose Feb 13 '15 at 21:13
-
@TravisBemrose: There is no easy way to do this, as all package inclusions use the same mechanism (
\inputor\includeor\usepackageor ...). One way would be to define a macro\usemypackage{<package>}which could accumulate package names, then do a search-and-replace for\usepackagein your main document to\usemypackage. As such, there's no easy, out-of-the-box solution. Of course, you could just start removing any packages that you think you don't use or are obsolete (see How to keep up with packages and know which ones are obsolete?. – Werner Feb 13 '15 at 22:27 -
That's basically my process right now, remove a
\usepackageline, compile, check for error, rinse, repeat. At least this process is of orderO(n). – Travis Bemrose Feb 15 '15 at 00:08
TL;DR: Use the snapshot package.
The CTAN tag archival lists tools made for such or similar use cases. For instance, the package embedall can be used to embed all required files into the generated PDF. See Is there some way to embed LaTeX source code in a PDF file? for a discussion.
In the following, I evaluate mkjobtexmf and snapshot. I assume the main tex file being main.tex.
mkjobtexmf
Preparation: No need for a special modification of main.tex
Execution: mkjobtexmf --jobname main
Result: Directory main.mjt. It contains a sub directory texmf, which in turn contains a directory tex, where one can find the packages.
tree shows following output:
└───texmf
├───fonts
│ └───type1
│ └───public
│ └───amsfonts
│ └───cm
├───miktex
│ └───data
│ └───le
│ └───pdftex
├───pdftex
│ └───config
└───tex
├───generic
│ ├───atbegshi
│ ├───bigintcalc
│ ├───bitset
│ ├───etexcmds
│ ├───gettitlestring
│ ├───iftex
│ ├───infwarerr
│ ├───intcalc
│ ├───kvdefinekeys
│ ├───kvsetkeys
│ ├───ltxcmds
│ ├───pdfescape
│ ├───pdftexcmds
│ └───uniquecounter
└───latex
├───atveryend
├───auxhook
├───base
├───graphics
├───hycolor
├───hyperref
├───kvoptions
├───l3backend
├───letltxmacro
├───refcount
├───rerunfilecheck
├───tools
└───url
snapshot
Preparation: Add \RequirePackage{snapshot} at the first line of main.tex
Execution: pdflatex main
Output: main.dep
\RequireVersions{
*{application}{pdfTeX} {0000/00/00 v1.40.23}
*{format} {LaTeX2e} {2021-11-15 v2.e}
*{package}{snapshot} {2020/06/17 v2.14}
*{class} {article} {2021/10/04 v1.4n}
*{file} {size10.clo} {2021/10/04 v1.4n}
*{package}{array} {2021/10/04 v2.5f}
*{package}{hyperref} {2021-06-07 v7.00m}
*{package}{ltxcmds} {2020-05-10 v1.25}
*{package}{iftex} {2020/03/06 v1.0d}
*{package}{pdftexcmds} {2020-06-27 v0.33}
*{package}{infwarerr} {2019/12/03 v1.5}
*{package}{keyval} {2014/10/28 v1.15}
*{package}{kvsetkeys} {2019/12/15 v1.18}
*{package}{kvdefinekeys}{2019-12-19 v1.6}
*{package}{pdfescape} {2019/12/09 v1.15}
*{package}{hycolor} {2020-01-27 v1.10}
*{package}{letltxmacro} {2019/12/03 v1.6}
*{package}{auxhook} {2019-12-17 v1.6}
*{package}{kvoptions} {2020-10-07 v3.14}
*{file} {pd1enc.def} {2021-06-07 v7.00m}
*{file} {hyperref-langpatches.def}{2021-06-07 v7.00m}
*{package}{intcalc} {2019/12/15 v1.3}
*{package}{etexcmds} {2019/12/15 v1.7}
*{file} {puenc.def} {2021-06-07 v7.00m}
*{package}{url} {2013/09/16 v3.4}
*{package}{bitset} {2019/12/09 v1.3}
*{package}{bigintcalc} {2019/12/15 v1.5}
*{package}{atbegshi-ltx}{2021/01/10 v1.0c}
*{file} {hpdftex.def} {2021-06-07 v7.00m}
*{package}{atveryend-ltx}{2020/08/19 v1.0a}
*{package}{rerunfilecheck}{2019/12/05 v1.9}
*{package}{uniquecounter}{2019/12/15 v1.4}
*{file} {l3backend-pdftex.def}{2021-10-18 v3}
*{-------}{Document-specific files:}{----}
*{package}{nameref} {2021-04-02 v2.47}
*{package}{refcount} {2019/12/15 v3.6}
*{package}{gettitlestring}{2019/12/15 v1.6}
*{file} {main.out} {0000/00/00 v0.0}
*{file} {main.out} {0000/00/00 v0.0}
}
texdeps
This is a tool from 1999 and runs for the MWE. For a real-live document, I aborted it after 5 minutes runtime.
Preparation: No need for a special modification of main.tex. perl needs to be installed
Execution: perl "c:\Users\kopppor\Downloads\texdeps.pl" main.tex
Result:
! kpse couldn't find \Hy@driver.def (in C:/MiKTeX/tex/latex/hyperref/hyperref.sty)
main.tex
C:/MiKTeX/tex/latex/tools/array.sty
C:/MiKTeX/tex/latex/hyperref/hyperref.sty
C:/MiKTeX/tex/latex/hyperref/pd1enc.def
C:/MiKTeX/tex/latex/hyperref/puenc.def
C:/MiKTeX/tex/latex/hyperref/puenc-greekbasic.def
C:/MiKTeX/tex/latex/hyperref/psdextra.def
C:/MiKTeX/tex/latex/hyperref/hyperref-langpatches.def
C:/MiKTeX/tex/latex/hyperref/puvnenc.def
C:/MiKTeX/tex/latex/hyperref/puvnenc.def
C:/MiKTeX/tex/latex/hyperref/puarenc.def
C:/MiKTeX/tex/latex/hyperref/puenc-greekbasic.def
Summary and Recommendation
texdeps does not find all dependencies for the MWE. Thus, I cannot recommend it at all. Which a MWE, the "output" of mkjobtexmf is good to handle. Just open a file explorer and navigate around.
Even though one has to modify its main tex document, I like the output of snapshot best, as it lists all external files and categorizes them.
- 3,252