是否可以生成一个 TeX 文件,其中包含有关 TeXLive 发行版已安装软件包的所有必要信息?
如果您只想要表格中的某些元素,您可以使用此代码片段。:-)
\begin{filecontents*}{\jobname.lua}
dofile( assert( kpse.find_file( "tlpdb.tlu", "texmfscripts" ) ) )
tlpdb = read_tlpdb( kpse.var_value("SELFAUTOPARENT") )
for name, pkg in pairs( tlpdb ) do
texio.write_nl( name )
tex.print( "\\section*{" )
tex.print( name )
tex.print( "}" )
tex.print( "" )
if pkg.longdesc ~= nil then
tex.write( tostring(pkg.longdesc) )
tex.print( "" )
end
if pkg. revision ~= nil then
tex.write( tostring(pkg.longdesc) )
tex.print( "" )
tex.print( "\\clearpage" )
end
\end{filecontents*}
答案1
有关已安装软件包的信息存储在纯文本数据库中<installation root>/tlpkg/texlive.tlpdb
。要获取数据库中软件包的简单列表,可以使用以下一行代码:
awk '/^name/ {print $2}' texlive.tlpdb
对于任何更复杂的事情,您需要自己解析数据库文件(如果您了解 perl 或 lua,您可以使用 TeX Live 的一些代码来实现此目的)。
编辑:这里有一个使用 luatex 的示例,它在单独的页面上打印有关每个包的信息(编辑2:包名称按字母顺序排序)。
\begin{filecontents*}{\jobname.lua}
dofile( assert( kpse.find_file( "tlpdb.tlu", "texmfscripts" ) ) )
tlpdb = read_tlpdb( kpse.var_value( "SELFAUTOPARENT" ) )
pkglist = {}
for name in pairs( tlpdb ) do
table.insert( pkglist, name )
end
table.sort( pkglist )
for i, name in ipairs( pkglist ) do
texio.write_nl( name )
tex.print( "PACKAGE: " .. name )
tex.print( "" )
for field, value in pairs( tlpdb[name] ) do
if type( value ) ~= "table" then
tex.write( field .. ": " .. tostring( value ) )
tex.print( "" )
end
end
tex.print( "\\clearpage" )
end
\end{filecontents*}
\documentclass{article}
\begin{document}
\directlua{ dofile "\jobname.lua" }
\end{document}
答案2
我接受了 pdf(La)TeX 的挑战(代码很容易修改为仅使用 eTeX)。它并不漂亮。它应该生成一个包含所有信息的约 5000 页长的 pdf 文件(而且编译需要很长时间……大约 4 小时)。我不得不硬编码 texlive 安装的路径(代码的第一行)。
\def\tlpath{/usr/local/texlive/2011}
\documentclass{book}
\usepackage[T1]{fontenc}
\makeatletter
\newread\tl@read
\openin\tl@read \tlpath/tlpkg/texlive.tlpdb\relax
\newif\if@tl@itemize
\def\tl@analyse#1 {%
\ifcsname #1\endcsname
\csname #1\expandafter\endcsname
\else
\tl@open@if@new{#1}{#1\begin{itemize}}\@tl@itemizetrue{}%
\def\tl@current{#1}%
\expandafter\tl@unknown
\fi}
\def\tl@open@if@new#1#2#3#4%
{%
\ifnum\pdfstrcmp{#1}{\tl@current}=0\relax
\g@addto@macro\tl@text{#4}%
\else
\ifx\tl@text\empty\else
\if@tl@itemize
\g@addto@macro\tl@text{\end{itemize}}%
\fi
\fi
\@tl@itemizefalse
#3%
\g@addto@macro\tl@text{\item#2}%
\fi
\def\tl@current{#1}%
}
\def\tl@unknown#1\relax{%
\if@tl@itemize
\g@addto@macro\tl@text{\item#1}%
\else
\g@addto@macro\tl@text{#1}%
\fi}
\let\tl@current\empty
\let\tl@name\empty
\def\tl@i{}
\def\tl@i@relax#1#2\relax{#1}
\def\tl@flush{%
\tl@open@if@new{*}{}{\@gobblefour{}}{}%
\ifx\tl@name\empty\else
\ifnum\pdfstrcmp{\expandafter\tl@i@relax\tl@name\relax}{\tl@i}=0\relax
\else
\edef\tl@i{\expandafter\tl@i@relax\tl@name\relax}%
\chapter{Packages starting with \tl@i}%
\fi
\section{\rmfamily\tl@name
\ifx\tl@category\empty\else\space(\tl@category)\fi
\ifx\tl@revision\empty\else \space r. \tl@revision\fi}%
\begin{itemize}\tl@text\end{itemize}%
\fi
\let\tl@text\empty\let\tl@category\empty
\let\tl@name\empty\let\tl@revision\empty}
\def\name#1\relax{\tl@flush\def\tl@name{#1}}
\def\category#1\relax{\def\tl@category{#1}}
\def\revision#1\relax{\def\tl@revision{#1}}
\def\tl@oneliner#1#2#3\relax{\tl@open@if@new{#1}{#2: #3}{}{}}
\def\tl@def@oneliner#1#2{\expandafter\def\csname#1\endcsname
{\tl@oneliner{#1}{#2}}}
\tl@def@oneliner{catalogue}{Catalogue}
\tl@def@oneliner{shortdesc}{Short description}
\tl@def@oneliner{relocated}{Relocated}
\tl@def@oneliner{containersize}{Container size}
\tl@def@oneliner{containermd5}{Container md5}
\tl@def@oneliner{doccontainersize}{Doc container size}
\tl@def@oneliner{doccontainermd5}{Doc container md5}
\tl@def@oneliner{srccontainersize}{Source container size}
\tl@def@oneliner{srccontainermd5}{Source container md5}
\tl@def@oneliner{catalogue-ctan}{On CTAN}
\tl@def@oneliner{catalogue-date}{Dated}
\tl@def@oneliner{catalogue-license}{License}
\tl@def@oneliner{catalogue-version}{Version}
\def\longdesc#1\relax{\tl@open@if@new{longdesc}{Long description: #1}{}{#1}}
\def\docfiles#1\relax{\tl@open@if@new{docfiles}%
{Doc files: #1\@gobble}{\def\tl@current{}}{}}
\def\runfiles#1\relax{\tl@open@if@new{runfiles}%
{Run files: #1\@gobble}{\def\tl@current{}}{}}
\def\srcfiles#1\relax{\tl@open@if@new{srcfiles}%
{Source files: #1\@gobble}{\def\tl@current{}}{}}
\begin{document}
\title{All of the packages in \TeX{}live}
\author{}
\maketitle
\tableofcontents
\endlinechar=-1\relax
\loop
\readline\tl@read to\tl@line
\ifx\empty\tl@line
\clearpage
\else
\expandafter\tl@analyse\tl@line\relax
\fi
\unless\ifeof\tl@read
\repeat
\end{document}