1 % This is chkconfig.ltx, a script which tries to autodetect and
2 % document your LaTeX configuration.
3 % Author: Jean-Marc Lasgouttes (Jean-Marc.Lasgouttes@inria.fr)
4 % with minimal changes by Asger Alstrup (alstrup@diku.dk).
6 % This script should only be run from the configure script to update
7 % the files textclass.lst and doc/LaTeXConfig.lyx
9 % This script is in fact a complete rewrite of the original chkconfig
10 % script. Expect bugs.
12 %%% If you want to add new packages/documentclasses to be recognized,
13 %%% read the explanation that follow and jump to the section 'Actual
14 %%% inspection code' below. You do not need to understand the ugly
15 %%% LaTeX code below to help improving chkconfig.ltx :-)
17 %%% If you want to add the new package <name>, all you need most of
18 %%% the times is a two-steps work:
19 %%% 1- Add the command \TestPackage{<name>}. The syntax is:
20 %%% \TestPackage[<file>]{<name>}, which tests whether <name>.sty
21 %%% (or <file>, if this optional parameter is provided) exists.
22 %%% 2- Add a description for <name> in doc/LaTeXConfig.lyx,
23 %%% containing in particular a line like
24 %%% Found: [InsetInfo]
25 %%% where [InsetInfo] is obtained by entering in the minibuffer (Alt+X)
26 %%% info-insert package <name>
27 %%% This inset will automatically display a boxed "yes" or "no"
28 %%% depending on the availability of the package.
30 %%% For document classes, things are even simpler, since you do not
31 %%% need to edit this file. Just put your layout file in some place
32 %%% where LyX can find it and add if you wish a description in
33 %%% LaTeXConfig.lyx, as described above but using
34 %%% "info-insert textclass <name>" instead of "info-insert package <name>".
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 %%%%%%%%%%%%%%%%%%%%%%% Initialization part (skip) %%%%%%%%%%%%%%%%%%%%%
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 % we do not want to stop on errors
41 \nonstopmode\makeatletter
43 %%% Some useful macros.
44 % Several commands are defined to test for packages:
45 % \AddLayout{<layout>} adds an entry for <layout> in textclass.lst
46 % \AddVariable{<name>}{<value>} creates a new variable chk_<name>,
47 % and gives it the value <value>.
48 % \TestDocClass{<name>}{<command>} if layout <name> has not already
49 % been tested for, execute <command>. Note that you will
50 % probably not need to use this directly, since the configure
51 % script generates the needed macro calls automatically.
52 % \TestPackage[<file>]{<name>} tests whether <name>.sty (or <file>,
53 % if it is provided) exists.
54 % Both commands call \AddVariable to give value 'yes' or 'no' to
55 % the variable chk_<name>.
58 \newcommand{\prefix}{+} % the character used by grep to filter 'good' output
60 \newcommand{\AddLayout}[4][\default]{
62 \immediate\write\layouts{"#2" "#1" "#3" "#4"}}
64 \newcommand{\AddVariable}[2]{
65 \immediate\write\vars{chk_#1='#2'}}
67 \newcommand{\AddPackage}[1]{
68 \immediate\write\packages{#1}}
70 % Tests whether an item is present
71 % Syntax: \TestItem[<file>]{<name>}{<type>}{<ext>}{<iftrue>}{<iffalse>}
74 \newcommand{\TestItem}[6][\default]{
77 \message{^^J\prefix checking for #3 #2 [#1]...}
78 \let\firstelement\relax
80 \@for\file:=\files\do{
81 \ifx\firstelement\relax
82 \edef\firstelement{\file}
86 {\IfFileExists{\file.#4}{}{\existsfalse}}
98 \newcommand{\TestPackage}[2][\default]{
99 \TestItem[#1]{#2}{package}{sty}{\AddPackage{#2}}{}}
101 \newcommand{\TestDocClass}[2]{
102 \def\layoutname{#1} % remember the name of the layout file
103 \@ifundefined{layout@#1}
104 {#2 % execute the command
105 \global\@namedef{layout@#1}{}}
106 {} % we have already tried this one.
109 \newcommand{\DeclareLaTeXClass}[2][\default]{
110 \TestItem[#1]{\layoutname}{document class}{cls}
111 {\AddLayout[\firstelement]{\layoutname}{#2}{true}}
112 {\AddLayout[\firstelement]{\layoutname}{#2}{false}}
115 % Only for compatibility. Will be removed later.
116 \let\DeclareSGMLClass=\DeclareDocBookClass
118 \newcommand{\DeclareDocBookClass}[2][\default]{
119 \message{^^J\prefix checking for docbook\space\space class \layoutname... }
120 \@ifundefined{hasdocbook}
122 \AddLayout[#1]{\layoutname}{#2}{false}}
124 \AddLayout[#1]{\layoutname}{#2}{true}}
127 % Stolen from article.cls
128 \newcommand{\today}{\ifcase\month\or
129 January\or February\or March\or April\or May\or June\or
130 July\or August\or September\or October\or November\or December\fi
131 \space\number\day, \number\year}
133 % Initializes the files
134 \typeout{\prefix Inspecting your LaTeX configuration.}
135 \newwrite{\layouts} \immediate\openout \layouts = textclass.lst.tmp
136 \newwrite{\vars} \immediate\openout \vars = chkconfig.vars
137 \newwrite{\packages} \immediate\openout \packages = packages.lst.tmp
139 \immediate\write\layouts{%
140 # This file declares layouts and their associated definition files.^^J%
141 # It has been automatically generated by configure^^J%
142 # Use "Options/Reconfigure" if you need to update it after a^^J%
143 # configuration change. Run ./configure manually to update the^^J%
144 # system wide version of this file.}
146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147 %%%%% ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150 %%% Add any new package or document class here.
152 %%% First, we want the day on which the test has been run.
153 \AddVariable{date}{\today}
155 %%% Then, the version of LaTeX we are using
156 \message{^^J\prefix checking for LaTeX version... \fmtversion}
157 \AddVariable{fmtversion}{\fmtversion}
159 %%% And now, the list of available languages
160 % The trick is to know that \the\everyjob contains something like
161 % \typeout{LaTeX2e <2001/06/01>}
162 % \typeout{Babel <v3.7h> and hyphenation patterns for american, french, german, ngerman, nohyphenation, loaded.}
163 % All we have to do is to extract the list from there:
164 % (1) concatenate all the messages that are displayed everytime the
165 % format is loaded. The is done by redefining locally \typeout to
166 % append its argument to the macro \mesg.
168 {\def\typeout#1{\xdef\mesg{\mesg #1}}
171 % (2) strip the useless parts from \mesg. This uses the fact that TeX
172 % allows to define macros with parameters delimited by arbitrary text.
173 \def\platexname{pLaTeX2e}
174 \ifx\pfmtname\platexname
177 \def\strip#1patterns for #2, loaded.#3\endmark{\def\langs{#2}}
178 \expandafter\strip\mesg\endmark
181 % (3) handle the result
182 \message{^^J\prefix checking for available hyphenation patterns... \langs}
183 \AddVariable{languages}{\langs}
185 %%% Check for ec fonts. Most of this code has been shamelessely stolen
186 %%% from the file ltxcheck.tex in the LaTeX distribution. In particular,
187 %%% don't ask me how the macro \ecrm works...
193 {\expandafter\string\csname ecrm\endcsname}%
194 {\expandafter\expandafter\expandafter
195 \string\csname T1/cmr/m/n\endcsname}}%
199 \message{^^J\prefix checking for default encoding (this may take a long time)^^J}
200 \font\test=ecrm1000\relax
203 \message{^^J\prefix\prefix checking for ec fonts... no^^J}
205 \AddVariable{fontenc}{default}
207 \message{^^J\prefix\space\space checking for ec fonts... yes^^J}
208 \message{^^J\prefix\space\space checking for ec support in LaTeX format...}
213 \AddVariable{fontenc}{T1}
214 \message{^^J\prefix\space\space default encoding will be set to T1^^J}
217 \AddVariable{fontenc}{default}
223 % The list of layout files has been put in this file here by the
229 \TestPackage{accents}
230 \TestPackage{algorithm}
231 \TestPackage{amstext}
234 \TestPackage{bibtopic}
236 \TestPackage{booktabs}
237 \TestPackage{braille}
238 \TestPackage{CJKutf8}
239 \TestPackage{color} % this one should be there if graphics.sty is there.
240 \TestPackage{covington}
241 \TestPackage{csquotes}
242 \TestPackage{dvipost}
243 \TestPackage{endnotes}
244 \TestPackage{enumitem}
248 \TestPackage{fancybox}
249 \TestPackage{fancyhdr}
251 \TestPackage{geometry}
252 \TestPackage{graphicx}
253 \TestPackage{hyperref}
254 \TestPackage[japanese.ldf]{japanese}
255 \TestPackage{jurabib}
257 \TestPackage{lettrine}
258 \TestPackage{listings}
259 \TestPackage{longtable}
260 \TestPackage{mathdots}
263 \TestPackage{nicefrac}
264 \TestPackage{nomencl}
265 \TestPackage{pdfcolmk}
266 \TestPackage{pdfpages}
267 \TestPackage{prettyref}
268 \TestPackage{preview}
269 \TestPackage{rotating}
270 \TestPackage{rotfloat}
271 \TestPackage{setspace}
272 \TestPackage{slashed}
274 \TestPackage{splitidx}
277 \TestPackage{textcomp}
281 \TestPackage{varioref}
282 \TestPackage{wrapfig}
286 % psnfss is in fact the name of a set of style files, among which
287 % times.sty. If times.sty is here, we will assume that everything is fine.
288 \TestPackage[times.sty]{psnfss}
289 % test the following fonts in case they are not in all versions of psnfss
291 \TestPackage{bookman}
292 \TestPackage{chancery}
293 \TestPackage{charter}
294 \TestPackage{courier}
296 \TestPackage{mathpazo}
297 \TestPackage{mathpple}
298 \TestPackage{mathptm}
299 \TestPackage{mathptmx}
300 \TestPackage{newcent}
303 % Other font packages
306 \TestPackage{ccfonts}
307 \TestPackage{cmbright}
309 \TestPackage{fourier}
310 \TestPackage{lmodern}
311 \TestPackage{luximono}
315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316 %%%%% END ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
317 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
319 % End of the LaTeX job
320 \immediate\closeout\layouts
321 \immediate\closeout\vars
322 \immediate\closeout\packages
323 \typeout{\prefix Inspection done.}
324 \typeout{\prefix Read the file doc/LaTeXConfig.lyx for more information.}
326 % Get the real \end command, that has been hidden by LaTeX