]> git.lyx.org Git - lyx.git/blob - lib/chkconfig.ltx
chkconfig.ltx: add the packages used in our documentation files (the docs should...
[lyx.git] / lib / chkconfig.ltx
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).
5 %
6 % This script should only be run from the configure script to update
7 % the files textclass.lst and doc/LaTeXConfig.lyx
8 %
9 % This script is in fact a complete rewrite of the original chkconfig
10 % script. Expect bugs.
11
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 :-)
16 %%%
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.
29 %%%
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>".
35
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 %%%%%%%%%%%%%%%%%%%%%%% Initialization part (skip) %%%%%%%%%%%%%%%%%%%%%
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39
40 % we do not want to stop on errors
41 \nonstopmode\makeatletter
42
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>.
56 %%%
57
58 \newcommand{\prefix}{+} % the character used by grep to filter 'good' output
59
60 \newcommand{\AddLayout}[5][\default]{
61   \def\default{#2}
62   \immediate\write\layouts{"#2"   "#1"   "#3"   "#4"   "#5"}}
63
64 \newcommand{\AddVariable}[2]{
65   \immediate\write\vars{chk_#1='#2'}}
66
67 \newcommand{\AddPackage}[1]{
68   \immediate\write\packages{#1}}
69
70 % Tests whether an item is present
71 % Syntax: \TestItem[<file>]{<name>}{<type>}{<ext>}{<iftrue>}{<iffalse>}
72 \newif\ifexists
73
74 \newcommand{\TestItem}[6][\default]{
75   \def\default{#2}
76   \def\files{#1}
77   \message{^^J\prefix checking for #3 #2 [#1]...}
78   \let\firstelement\relax
79   \let\missingelements\empty
80   \existstrue
81   \@for\file:=\files\do{
82     \ifx\firstelement\relax
83        \edef\firstelement{\file}
84     \fi
85     \@expandtwoargs\in@{.}{\file}
86     \ifin@
87       \def\myfile{\file}
88     \else
89       \def\myfile{\file.#4}
90     \fi
91     \IfFileExists{\myfile}
92       {}
93       {
94         \existsfalse
95         \ifx\missingelements\empty
96           \edef\missingelements{\myfile}
97         \else
98           \edef\missingelements{\missingelements,\myfile}
99         \fi
100       }
101   }
102   \ifexists
103     \message{yes^^J}
104     \AddVariable{#2}{yes}
105     #5
106   \else
107     \message{no^^J}
108     \AddVariable{#2}{no}
109     #6
110   \fi}
111
112 \newcommand{\TestPackage}[2][\default]{
113   \TestItem[#1]{#2}{package}{sty}{\AddPackage{#2}}{}}
114
115 \newcommand{\TestDocClass}[2]{
116    \def\layoutname{#1}  % remember the name of the layout file
117    \@ifundefined{layout@#1}
118      {#2  % execute the command
119       \global\@namedef{layout@#1}{}}
120      {} % we have already tried this one.
121 }
122
123 \newcommand{\DeclareLaTeXClass}[2][\default]{
124   \TestItem[#1]{\layoutname}{document class}{cls}
125            {\AddLayout[\firstelement]{\layoutname}{#2}{true}{\missingelements}}
126            {\AddLayout[\firstelement]{\layoutname}{#2}{false}{\missingelements}}
127 }
128
129 % Only for compatibility. Will be removed later.
130 \let\DeclareSGMLClass=\DeclareDocBookClass
131
132 \newcommand{\DeclareDocBookClass}[2][\default]{
133   \message{^^J\prefix checking for docbook\space\space class \layoutname... }
134   \@ifundefined{hasdocbook}
135     {\message{no^^J}
136      \AddLayout[#1]{\layoutname}{#2}{false}{docbook}}
137     {\message{yes^^J}
138      \AddLayout[#1]{\layoutname}{#2}{true}{}}
139 }
140
141 % Stolen from article.cls
142 \newcommand{\today}{\ifcase\month\or
143   January\or February\or March\or April\or May\or June\or
144   July\or August\or September\or October\or November\or December\fi
145   \space\number\day, \number\year}
146
147 % Initializes the files
148 \typeout{\prefix Inspecting your LaTeX configuration.}
149 \newwrite{\layouts} \immediate\openout \layouts = textclass.lst.tmp
150 \newwrite{\vars} \immediate\openout \vars = chkconfig.vars
151 \newwrite{\packages} \immediate\openout \packages = packages.lst.tmp
152
153 \immediate\write\layouts{%
154 # This file declares layouts and their associated definition files.^^J%
155 # It has been automatically generated by configure^^J%
156 # Use "Tools/Reconfigure" if you need to update it after a^^J%
157 # configuration change. Run ./configure manually to update the^^J%
158 # system wide version of this file.}
159
160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161 %%%%% ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163
164 %%% Add any new package or document class here.
165
166 %%% First, we want the day on which the test has been run.
167 \AddVariable{date}{\today}
168
169 %%% Then, the version of LaTeX we are using
170 \message{^^J\prefix checking for LaTeX version... \fmtversion}
171 \AddVariable{fmtversion}{\fmtversion}
172
173 %%% And now, the list of available languages
174 % The trick is to know that \the\everyjob contains something like
175 %  \typeout{LaTeX2e <2001/06/01>}
176 %  \typeout{Babel <v3.7h> and hyphenation patterns for american, french, german, ngerman, nohyphenation, loaded.}
177 % All we have to do is to extract the list from there:
178 % (1) concatenate all the messages that are displayed everytime the
179 % format is loaded. The is done by redefining locally \typeout to
180 % append its argument to the macro \mesg.
181 \def\mesg{}
182 {\def\typeout#1{\xdef\mesg{\mesg #1}}
183  \the\everyjob}
184
185 % (2) strip the useless parts from \mesg. This uses the fact that TeX
186 % allows to define macros with parameters delimited by arbitrary text.
187 \def\platexname{pLaTeX2e}
188 \ifx\pfmtname\platexname
189   \def\langs{japanese}
190 \else
191   \def\strip#1patterns for #2, loaded.#3\endmark{\def\langs{#2}}
192   \expandafter\strip\mesg\endmark
193 \fi
194
195 % (3) handle the result
196 \message{^^J\prefix checking for available hyphenation patterns... \langs}
197 \AddVariable{languages}{\langs}
198
199 %%% Check for ec fonts. Most of this code has been shamelessely stolen
200 %%% from the file ltxcheck.tex in the LaTeX distribution. In particular,
201 %%% don't ask me how the macro \ecrm works...
202 \def\ecrm{%
203   \begingroup
204     \escapechar-1
205     \xdef\reserved@a{%
206       \noexpand\in@
207         {\expandafter\string\csname ecrm\endcsname}%
208         {\expandafter\expandafter\expandafter
209            \string\csname T1/cmr/m/n\endcsname}}%
210   \endgroup
211   \reserved@a}
212
213 \message{^^J\prefix checking for default encoding (this may take a long time)^^J}
214 \font\test=ecrm1000\relax
215
216 \ifx\test\nullfont
217   \message{^^J\prefix\prefix checking for ec fonts... no^^J}
218   \AddVariable{ec}{no}
219   \AddVariable{fontenc}{default}
220 \else
221   \message{^^J\prefix\space\space checking for ec fonts... yes^^J}
222   \message{^^J\prefix\space\space checking for ec support in LaTeX format...}
223   \ecrm
224   \ifin@
225     \message{yes^^J}
226     \AddPackage{ec}
227     \AddVariable{fontenc}{T1}
228     \message{^^J\prefix\space\space default encoding will be set to T1^^J}
229   \else
230     \message{no^^J}
231     \AddVariable{fontenc}{default}
232   \fi
233 \fi
234
235
236 %%% Document classes
237 % The list of layout files has been put in this file here by the
238 % configure script.
239 \input{chklayouts}
240 \input{chkmodules}
241
242
243 %%% Packages
244 \TestPackage{accents}
245 \TestPackage{algorithm}
246 \TestPackage{amstext}
247 \TestPackage[arabic.ldf]{arabi}
248 \TestPackage{array}
249 \TestPackage{babel}
250 \TestPackage{bibtopic}
251 \TestPackage{bm}
252 \TestPackage{booktabs}
253 \TestPackage{braille}
254 \TestPackage{breakurl}
255 \TestPackage{CJKutf8}
256 \TestPackage{calc}
257 \TestPackage{color} % this one should be there if graphics.sty is there.
258 \TestPackage{covington}
259 \TestPackage{csquotes}
260 \TestPackage{dvipost}
261 \TestPackage{endnotes}
262 \TestPackage{enumitem}
263 \TestPackage{esint}
264 \TestPackage{fontspec}
265 \TestPackage{hhline}
266 \TestPackage{ifsym}
267 \TestPackage{ifthen}
268 \TestPackage{fancybox}
269 \TestPackage{fancyhdr}
270 \TestPackage{fixltx2e}
271 \TestPackage{fix-cm}
272 \TestPackage{float}
273 \TestPackage{framed}
274 \TestPackage{geometry}
275 \TestPackage{graphicx}
276 \TestPackage{hyperref}
277 \TestPackage{hyphenat}
278 \TestPackage[japanese.ldf]{japanese}
279 \TestPackage{jurabib}
280 \TestPackage{latex8}
281 \TestPackage{lettrine}
282 \TestPackage{listings}
283 \TestPackage[lithuanian.ldf]{lithuanian}
284 \TestPackage{longtable}
285 \TestPackage{luainputenc}
286 \TestPackage{mathdots}
287 \TestPackage{mathrsfs}
288 \TestPackage{mhchem}
289 \TestPackage[mongolian.ldf]{mongolian}
290 \TestPackage{multirow}
291 \TestPackage{natbib}
292 \TestPackage{nicefrac}
293 \TestPackage{nomencl}
294 \TestPackage{pdfcolmk}
295 \TestPackage{polyglossia}
296 \TestPackage{pdfpages}
297 \TestPackage{prettyref}
298 \TestPackage{preview}
299 \TestPackage{refstyle}
300 \TestPackage{rotating}
301 \TestPackage{rotfloat}
302 \TestPackage{setspace}
303 \TestPackage{slashed}
304 \TestPackage{soul}
305 \TestPackage{splitidx}
306 \TestPackage{subfig}
307 \TestPackage{Sweave}
308 \TestPackage{textcomp}
309 \TestPackage{subscript}
310 \TestPackage[turkmen.ldf]{turkmen}
311 \TestPackage{ulem}
312 \TestPackage{undertilde}
313 \TestPackage{units}
314 \TestPackage{url}
315 \TestPackage{varioref}
316 \TestPackage{wasysym}
317 \TestPackage{wrapfig}
318 \TestPackage{xargs}
319 \TestPackage{xcolor}
320 \TestPackage{xkeyval}
321
322 % Packages used by LyX's documentation files
323 \TestPackage{arydshln}
324 \TestPackage{braket}
325 \TestPackage{cancel}
326 \TestPackage{colortbl}
327 \TestPackage{eurosym}
328 \TestPackage{marginnote}
329 \TestPackage{picinpar}
330 \TestPackage{sidecap}
331 \TestPackage{was}
332
333 % psnfss is in fact the name of a set of style files, among which
334 % times.sty. If times.sty is here, we will assume that everything is fine.
335 \TestPackage[times.sty]{psnfss}
336 % test the following fonts in case they are not in all versions of psnfss
337 \TestPackage{avant}
338 \TestPackage{bookman}
339 \TestPackage{chancery}
340 \TestPackage{charter}
341 \TestPackage{courier}
342 \TestPackage{helvet}
343 \TestPackage{mathpazo}
344 \TestPackage{mathpple}
345 \TestPackage{mathptm}
346 \TestPackage{mathptmx}
347 \TestPackage{newcent}
348 \TestPackage{pifont}
349 \TestPackage{utopia}
350 % Other font packages
351 \TestPackage{ae}
352 \TestPackage{bera}
353 \TestPackage{ccfonts}
354 \TestPackage{cmbright}
355 \TestPackage{eco}
356 \TestPackage{feyn}
357 \TestPackage{fourier}
358 \TestPackage{lmodern}
359 \TestPackage{luximono}
360 \TestPackage{tipa}
361 % necessary to get correct size for InstantPreview images created by dvipng
362 \TestPackage[c70fs.fd]{zhmetrics}
363
364
365 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
366 %%%%% END ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
367 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368
369 % End of the LaTeX job
370 \immediate\closeout\layouts
371 \immediate\closeout\vars
372 \immediate\closeout\packages
373 \typeout{\prefix Inspection done.}
374 \typeout{\prefix Read the file doc/LaTeXConfig.lyx for more information.}
375
376 % Get the real \end command, that has been hidden by LaTeX
377 \@@end