]> git.lyx.org Git - lyx.git/blob - lib/chkconfig.ltx
Tutorial.lyx, Spanish UserGuide.lyx: updates and bugfixes by Ignacio
[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}[4][\default]{
61   \def\default{#2}
62   \immediate\write\layouts{"#2"   "#1"   "#3"   "#4"}}
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   \existstrue
80   \@for\file:=\files\do{
81     \ifx\firstelement\relax
82        \edef\firstelement{\file}
83     \fi
84     \IfFileExists{\file}
85       {}
86       {\IfFileExists{\file.#4}{}{\existsfalse}}
87   }
88   \ifexists
89     \message{yes^^J}
90     \AddVariable{#2}{yes}
91     #5
92   \else
93     \message{no^^J}
94     \AddVariable{#2}{no}
95     #6
96   \fi}
97
98 \newcommand{\TestPackage}[2][\default]{
99   \TestItem[#1]{#2}{package}{sty}{\AddPackage{#2}}{}}
100
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.
107 }
108
109 \newcommand{\DeclareLaTeXClass}[2][\default]{
110   \TestItem[#1]{\layoutname}{document class}{cls}
111            {\AddLayout[\firstelement]{\layoutname}{#2}{true}}
112            {\AddLayout[\firstelement]{\layoutname}{#2}{false}}
113 }
114
115 % Only for compatibility. Will be removed later.
116 \let\DeclareSGMLClass=\DeclareDocBookClass
117
118 \newcommand{\DeclareDocBookClass}[2][\default]{
119   \message{^^J\prefix checking for docbook\space\space class \layoutname... }
120   \@ifundefined{hasdocbook}
121     {\message{no^^J}
122      \AddLayout[#1]{\layoutname}{#2}{false}}
123     {\message{yes^^J}
124      \AddLayout[#1]{\layoutname}{#2}{true}}
125 }
126
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}
132
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
138
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.}
145
146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147 %%%%% ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
149
150 %%% Add any new package or document class here.
151
152 %%% First, we want the day on which the test has been run.
153 \AddVariable{date}{\today}
154
155 %%% Then, the version of LaTeX we are using
156 \message{^^J\prefix checking for LaTeX version... \fmtversion}
157 \AddVariable{fmtversion}{\fmtversion}
158
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.
167 \def\mesg{}
168 {\def\typeout#1{\xdef\mesg{\mesg #1}}
169  \the\everyjob}
170
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
175   \def\langs{japanese}
176 \else
177   \def\strip#1patterns for #2, loaded.#3\endmark{\def\langs{#2}}
178   \expandafter\strip\mesg\endmark
179 \fi
180
181 % (3) handle the result
182 \message{^^J\prefix checking for available hyphenation patterns... \langs}
183 \AddVariable{languages}{\langs}
184
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...
188 \def\ecrm{%
189   \begingroup
190     \escapechar-1
191     \xdef\reserved@a{%
192       \noexpand\in@
193         {\expandafter\string\csname ecrm\endcsname}%
194         {\expandafter\expandafter\expandafter
195            \string\csname T1/cmr/m/n\endcsname}}%
196   \endgroup
197   \reserved@a}
198
199 \message{^^J\prefix checking for default encoding (this may take a long time)^^J}
200 \font\test=ecrm1000\relax
201
202 \ifx\test\nullfont
203   \message{^^J\prefix\prefix checking for ec fonts... no^^J}
204   \AddVariable{ec}{no}
205   \AddVariable{fontenc}{default}
206 \else
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...}
209   \ecrm
210   \ifin@
211     \message{yes^^J}
212     \AddPackage{ec}
213     \AddVariable{fontenc}{T1}
214     \message{^^J\prefix\space\space default encoding will be set to T1^^J}
215   \else
216     \message{no^^J}
217     \AddVariable{fontenc}{default}
218   \fi
219 \fi
220
221
222 %%% Document classes
223 % The list of layout files has been put in this file here by the
224 % configure script.
225 \input{chklayouts}
226
227
228 %%% Packages
229 \TestPackage{accents}
230 \TestPackage{algorithm}
231 \TestPackage{array}
232 \TestPackage{babel}
233 \TestPackage{bibtopic}
234 \TestPackage{bm}
235 \TestPackage{booktabs}
236 \TestPackage{braille}
237 \TestPackage{CJKutf8}
238 \TestPackage{color} % this one should be there if graphics.sty is there.
239 \TestPackage{covington}
240 \TestPackage{csquotes}
241 \TestPackage{dvipost}
242 \TestPackage{endnotes}
243 \TestPackage{enumitem}
244 \TestPackage{esint}
245 \TestPackage{ifsym}
246 \TestPackage{ifthen}
247 \TestPackage{fancybox}
248 \TestPackage{fancyhdr}
249 \TestPackage{framed}
250 \TestPackage{geometry}
251 \TestPackage{graphicx}
252 \TestPackage{hyperref}
253 \TestPackage[japanese.ldf]{japanese}
254 \TestPackage{jurabib}
255 \TestPackage{latex8}
256 \TestPackage{listings}
257 \TestPackage{longtable}
258 \TestPackage{natbib}
259 \TestPackage{nicefrac}
260 \TestPackage{nomencl}
261 \TestPackage{pdfcolmk}
262 \TestPackage{pdfpages}
263 \TestPackage{prettyref}
264 \TestPackage{preview}
265 \TestPackage{relsize}
266 \TestPackage{rotating}
267 \TestPackage{rotfloat}
268 \TestPackage{setspace}
269 \TestPackage{slashed}
270 \TestPackage{soul}
271 \TestPackage{subfig}
272 \TestPackage{textcomp}
273 \TestPackage{ulem}
274 \TestPackage{units}
275 \TestPackage{url}
276 \TestPackage{varioref}
277 \TestPackage{wrapfig}
278 \TestPackage{xargs}
279 \TestPackage{xcolor}
280
281 % psnfss is in fact the name of a set of style files, among which
282 % times.sty. If times.sty is here, we will assume that everything is fine.
283 \TestPackage[times.sty]{psnfss}
284 % test the following fonts in case they are not in all versions of psnfss
285 \TestPackage{avant}
286 \TestPackage{bookman}
287 \TestPackage{chancery}
288 \TestPackage{charter}
289 \TestPackage{courier}
290 \TestPackage{helvet}
291 \TestPackage{mathpazo}
292 \TestPackage{mathpple}
293 \TestPackage{mathptm}
294 \TestPackage{mathptmx}
295 \TestPackage{newcent}
296 \TestPackage{pifont}
297 \TestPackage{utopia}
298 % Other font packages
299 \TestPackage{ae}
300 \TestPackage{bera}
301 \TestPackage{ccfonts}
302 \TestPackage{cmbright}
303 \TestPackage{eco}
304 \TestPackage{fourier}
305 \TestPackage{lmodern}
306 \TestPackage{luximono}
307 \TestPackage{tipa}
308
309
310 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
311 %%%%% END ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
313
314 % End of the LaTeX job
315 \immediate\closeout\layouts
316 \immediate\closeout\vars
317 \immediate\closeout\packages
318 \typeout{\prefix Inspection done.}
319 \typeout{\prefix Read the file doc/LaTeXConfig.lyx for more information.}
320
321 % Get the real \end command, that has been hidden by LaTeX
322 \@@end