]> git.lyx.org Git - features.git/blob - lib/chkconfig.ltx
Use \babelfonts only if babel >= 3.15 is available.
[features.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/document classes 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 %%% Since \TestPackage does not find font metric (tfm) files, there's an
31 %%% additional test \TestFont[<file>]{<name>} for this purpose.
32 %%%
33 %%% For document classes, things are even simpler, since you do not
34 %%% need to edit this file. Just put your layout file in some place
35 %%% where LyX can find it and add if you wish a description in
36 %%% LaTeXConfig.lyx, as described above but using
37 %%% "info-insert textclass <name>" instead of "info-insert package <name>".
38
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 %%%%%%%%%%%%%%%%%%%%%%% Initialization part (skip) %%%%%%%%%%%%%%%%%%%%%
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42
43 % we do not want to stop on errors
44 \nonstopmode\makeatletter
45
46 %%% Some useful macros.
47 %   Several commands are defined to test for packages:
48 %    \AddLayout{<layout>} adds an entry for <layout> in textclass.lst
49 %    \AddVariable{<name>}{<value>} creates a new variable chk_<name>,
50 %      and gives it the value <value>.
51 %    \TestDocClass{<name>}{<command>} if layout <name> has not already
52 %      been tested for, execute <command>. Note that you will
53 %      probably not need to use this directly, since the configure
54 %      script generates the needed macro calls automatically.
55 %    \TestPackage[<file>]{<name>} tests whether <name>.sty (or <file>,
56 %      if it is provided) exists.
57 %    \TestFont[<file>]{<name>} test whether <name>.tfm (or <file>.tfm,
58 %      if provided) exists.
59 %   These three commands call \AddVariable to give value 'yes' or 'no' to
60 %   the variable chk_<name>.
61 %%%
62
63 \newcommand{\prefix}{+} % the character used by grep to filter 'good' output
64
65 \newcommand{\AddLayout}[5][\default]{
66   \def\default{#2}
67   \@ifundefined{category@#2}{%
68        \immediate\write\layouts{"#2"   "#1"   "#3"   "#4"   "#5"   ""}%
69    }{%
70        \immediate\write\layouts{"#2"   "#1"   "#3"   "#4"   "#5"   "\@nameuse{category@#2}"}%
71    }
72 }
73        
74
75 \newcommand{\AddVariable}[2]{
76   \immediate\write\vars{chk_#1='#2'}}
77
78 \newcommand{\AddPackage}[1]{
79   \immediate\write\packages{#1}}
80
81 % Tests whether an item is present
82 % Syntax: \TestItem[<file>]{<name>}{<type>}{<ext>}{<iftrue>}{<iffalse>}
83 \newif\ifexists
84
85 \newcommand{\TestItem}[6][\default]{
86   \def\default{#2}
87   \def\files{#1}
88   \message{^^J\prefix checking for #3 #2 [#1]...}
89   \let\firstelement\relax
90   \let\missingelements\empty
91   \existstrue
92   \@for\file:=\files\do{
93     \ifx\firstelement\relax
94        \edef\firstelement{\file}
95     \fi
96     \@expandtwoargs\in@{.}{\file}
97     \ifin@
98       \def\myfile{\file}
99     \else
100       \def\myfile{\file.#4}
101     \fi
102     \IfFileExists{\myfile}
103       {}
104       {
105         \existsfalse
106         \ifx\missingelements\empty
107           \edef\missingelements{\myfile}
108         \else
109           \edef\missingelements{\missingelements,\myfile}
110         \fi
111       }
112   }
113   \ifexists
114     \message{yes^^J}
115     \AddVariable{#2}{yes}
116     #5
117   \else
118     \message{no^^J}
119     \AddVariable{#2}{no}
120     #6
121   \fi}
122
123 % Tests whether an package is present in a specific version (or newer)
124 % Syntax: \TestPackageVersion{<name>}{<yyyy/mm/dd>}
125 % Note: This requires the package to be loaded first
126
127 \newcommand{\TestPackageVersion}[2]{
128   \message{^^J\prefix checking for package #1 at least as of #2...}
129   \IfFileExists{#1.sty}
130   {
131     \@ifpackagelater{#1}{#2}{\existstrue}{\existsfalse}
132   }
133   {
134     \existsfalse
135   }
136   \ifexists
137     \message{yes^^J}
138     \AddVariable{#1}{yes}
139     \AddPackage{#1-#2}
140   \else
141     \message{no^^J}
142     \AddVariable{#1}{no}
143   \fi}
144
145
146 % Adapted from ltxcheck.tex
147 \newcommand{\TestFont}[2][\default]{
148   \def\default{#2}
149   \batchmode
150   \font\test=#1\relax
151   \nonstopmode
152   \message{^^J\prefix checking for font #2 [#1]...}
153   \ifx\test\nullfont
154     \message{no^^J}
155     \AddVariable{#2}{no}
156     \@tempswatrue
157   \else
158     \message{yes^^J}
159     \AddVariable{#2}{yes}
160     \AddPackage{#2}
161   \fi}
162
163 \newcommand{\TestPackage}[2][\default]{
164   \TestItem[#1]{#2}{package}{sty}{\AddPackage{#2}}{}}
165
166 \newcommand{\TestDocClass}[2]{
167    \def\layoutname{#1}  % remember the name of the layout file
168    \@ifundefined{layout@#1}
169      {#2  % execute the command
170       \global\@namedef{layout@#1}{}}
171      {} % we have already tried this one.
172 }
173
174 \newcommand{\DeclareLaTeXClass}[2][\default]{
175   \TestItem[#1]{\layoutname}{document class}{cls}
176            {\AddLayout[\firstelement]{\layoutname}{#2}{true}{\missingelements}}
177            {\AddLayout[\firstelement]{\layoutname}{#2}{false}{\missingelements}}
178 }
179
180 \newcommand{\DeclareCategory}[2]{
181    \@ifundefined{category@#1}
182      {\global\@namedef{category@#1}{#2}}%
183      {}% we have already defined this one.
184 }
185
186 % Only for compatibility. Will be removed later.
187 \let\DeclareSGMLClass=\DeclareDocBookClass
188
189 \newcommand{\DeclareDocBookClass}[2][\default]{
190   \message{^^J\prefix checking for docbook\space\space class \layoutname... }
191   \@ifundefined{hasdocbook}
192     {\message{no^^J}
193      \AddLayout[#1]{\layoutname}{#2}{false}{docbook}}
194     {\message{yes^^J}
195      \AddLayout[#1]{\layoutname}{#2}{true}{}}
196 }
197
198 % Stolen from article.cls
199 \newcommand{\today}{\ifcase\month\or
200   January\or February\or March\or April\or May\or June\or
201   July\or August\or September\or October\or November\or December\fi
202   \space\number\day, \number\year}
203
204 % Initializes the files
205 \typeout{\prefix Inspecting your LaTeX configuration.}
206 \newwrite{\layouts} \immediate\openout \layouts = textclass.lst.tmp
207 \newwrite{\vars} \immediate\openout \vars = chkconfig.vars
208 \newwrite{\packages} \immediate\openout \packages = packages.lst.tmp
209
210 \immediate\write\layouts{%
211 # This file declares layouts and their associated definition files.^^J%
212 # It has been automatically generated by configure^^J%
213 # Use "Tools/Reconfigure" if you need to update it after a^^J%
214 # configuration change. Run ./configure manually to update the^^J%
215 # system wide version of this file.}
216
217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
218 %%%%% ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220
221 %%% Add any new package or document class here.
222
223 %%% First, we want the day on which the test has been run.
224 \AddVariable{date}{\today}
225
226 %%% Then, the version of LaTeX we are using
227 \message{^^J\prefix checking for LaTeX version... \fmtversion}
228 \AddVariable{fmtversion}{\fmtversion}
229
230 %%% And now, the list of available languages
231 % The trick is to know that \the\everyjob contains something like
232 %  \typeout{LaTeX2e <2001/06/01>}
233 %  \typeout{Babel <v3.7h> and hyphenation patterns for american, french, german, ngerman, nohyphenation, loaded.}
234 % All we have to do is to extract the list from there:
235 % (1) concatenate all the messages that are displayed everytime the
236 % format is loaded. The is done by redefining locally \typeout to
237 % append its argument to the macro \mesg.
238 \def\mesg{}
239 {\def\typeout#1{\xdef\mesg{\mesg #1}}
240  \the\everyjob}
241
242 % (2) strip the useless parts from \mesg. This uses the fact that TeX
243 % allows to define macros with parameters delimited by arbitrary text.
244 \def\platexname{pLaTeX2e}
245 \ifx\pfmtname\platexname
246   \def\langs{japanese}
247 \else
248   \def\strip#1patterns for #2, loaded.#3\endmark{\def\langs{#2}}
249   \expandafter\strip\mesg\endmark
250 \fi
251
252 % (3) handle the result
253 \message{^^J\prefix checking for available hyphenation patterns... \langs}
254 \AddVariable{languages}{\langs}
255
256 %%% Check for ec fonts. Most of this code has been shamelessely stolen
257 %%% from the file ltxcheck.tex in the LaTeX distribution. In particular,
258 %%% don't ask me how the macro \ecrm works...
259 \def\ecrm{%
260   \begingroup
261     \escapechar-1
262     \xdef\reserved@a{%
263       \noexpand\in@
264         {\expandafter\string\csname ecrm\endcsname}%
265         {\expandafter\expandafter\expandafter
266            \string\csname T1/cmr/m/n\endcsname}}%
267   \endgroup
268   \reserved@a}
269
270 \message{^^J\prefix checking for default encoding (this may take a long time)^^J}
271 \font\test=ecrm1000\relax
272
273 \ifx\test\nullfont
274   \message{^^J\prefix\prefix checking for ec fonts... no^^J}
275   \AddVariable{ec}{no}
276   \AddVariable{fontenc}{default}
277 \else
278   \message{^^J\prefix\space\space checking for ec fonts... yes^^J}
279   \message{^^J\prefix\space\space checking for ec support in LaTeX format...}
280   \ecrm
281   \ifin@
282     \message{yes^^J}
283     \AddPackage{ec}
284     \AddVariable{fontenc}{T1}
285     \message{^^J\prefix\space\space default encoding will be set to T1^^J}
286   \else
287     \message{no^^J}
288     \AddVariable{fontenc}{default}
289   \fi
290 \fi
291
292
293 %%% Packages
294 \TestPackage{a0poster}
295 \TestPackage{accents}
296 \TestPackage{achicago}
297 \TestPackage{afterpage}
298 \TestPackage{algorithm}
299 \TestPackage{algorithm2e}
300 \TestPackage{amsmath}
301 \TestPackage{amstext}
302 \TestPackage{apacite}
303 \TestPackage{apalike}
304 \TestPackage[arabic.ldf]{arabi}
305 \TestPackage{array}
306 \TestPackage{astron}
307 \TestPackage{authordate1-4}
308 \TestPackage{babel}
309 \TestPackage{beamerposter}
310 \TestPackage{biblatex}
311 \TestPackage{biblatex-chicago}
312 \TestPackage{bibtopic}
313 \TestPackage{bicaption}
314 \TestPackage{bidi}
315 \TestPackage{bm}
316 \TestPackage{booktabs}
317 \TestPackage{braille}
318 \TestPackage{breakurl}
319 \TestPackage{CJK}
320 \TestPackage{calc}
321 \TestPackage{cancel}
322 \TestPackage{chapterbib}
323 \TestPackage{chemgreek}
324 \TestPackage{chessboard}
325 \TestPackage{chessfss}
326 \TestPackage{chicago}
327 \TestPackage{color} % this one should be there if graphics.sty is there.
328 \TestPackage{covington}
329 \TestPackage{cprotect}
330 \TestPackage{csquotes}
331 \TestPackage{drs}
332 \TestPackage[koi8-r.def]{cyrillic}
333 \TestPackage{dvipost}
334 \TestPackage{endnotes}
335 \TestPackage{enumitem}
336 \TestPackage{environ} % required by tcolorbox
337 \TestPackage{esint}
338 \TestPackage{eso-pic}
339 \TestPackage{fancybox}
340 \TestPackage{fancyhdr}
341 \TestPackage{filehook}
342 \TestPackage{fixltx2e}
343 \TestPackage{fix-cm}
344 \TestPackage{float}
345 \TestPackage{fontspec}
346 \TestPackage{footmisc}
347 \TestPackage{footnote}
348 \TestPackage{footnotehyper}
349 \TestPackage{forest}
350 \TestPackage{framed}
351 \TestPackage{geometry}
352 \TestPackage{graphicx}
353 \TestPackage[iso-8859-7.def]{greek-inputenc}
354 \TestPackage{harvard}
355 \TestPackage{hhline}
356 \TestPackage{hyperref}
357 \TestPackage{hyphenat}
358 \TestPackage{iftex}
359 \TestPackage{ifthen}
360 \TestPackage[japanese.ldf]{japanese}
361 \TestPackage{jurabib}
362 \TestPackage{l3experimental} % required by various packages
363 \TestPackage{l3kernel} % required by various packages
364 \TestPackage{l3packages} % required by various packages
365 \TestPackage{latex8}
366 \TestPackage{lettrine}
367 \TestPackage{listings}
368 \TestPackage[lithuanian.ldf]{lithuanian}
369 \TestPackage{longtable}
370 \TestPackage{lscape}
371 \TestPackage{luainputenc}
372 \TestPackage{mathdots}
373 \TestPackage{mathrsfs}
374 \TestPackage{mathtools}
375 \TestPackage{mhchem}
376 \TestPackage[mongolian.ldf]{mongolian}
377 \TestPackage{mslapa}
378 \TestPackage{multirow}
379 \TestPackage{named}
380 \TestPackage{natbib}
381 \TestPackage{nicefrac}
382 \TestPackage{nomencl}
383 \TestPackage{paralist}
384 \TestPackage{pdfcolmk}
385 \TestPackage{pdflscape}
386 \TestPackage{polyglossia}
387 \TestPackage{pdfcomment}
388 \TestPackage{pdfpages}
389 \TestPackage{pgf} % required by tcolorbox
390 \TestPackage{pict2e}
391 \TestPackage{prettyref}
392 \TestPackage{preview}
393 \TestPackage{refstyle}
394 \TestPackage{rotating}
395 \TestPackage{rotfloat}
396 \TestPackage{sciposter}
397 \TestPackage{sectionbox}
398 \TestPackage[serbianc.ldf]{serbianc}
399 \TestPackage{setspace}
400 \TestPackage{slashed}
401 \TestPackage{soul}
402 \TestPackage{splitidx}
403 \TestPackage{stackrel}
404 \TestPackage{stmaryrd}
405 \TestPackage{subfig}
406 \TestPackage{subscript}
407 \TestPackage{Sweave}
408 \TestPackage{tablefootnote}
409 \TestPackage{tabularx}
410 \TestPackage{tcolorbox}
411 \TestPackage{textcomp}
412 \TestPackage{thswitch}
413 \TestPackage[turkmen.ldf]{turkmen}
414 \TestPackage{ulem}
415 \TestPackage{undertilde}
416 \TestPackage{unicode-math}
417 \TestPackage{units}
418 \TestPackage{url}
419 \TestPackage{varioref}
420 \TestPackage{varwidth}
421 \TestPackage{wallpaper}
422 \TestPackage{wrapfig}
423 \TestPackage{xargs}
424 \TestPackage{xcolor}
425 \TestPackage[xetex.def]{xetex-def}
426 \TestPackage{xkeyval}
427 \TestPackage{xltabular}
428 \TestPackage{xskak} % required by chessboard
429
430 % Packages used by LyX's documentation files
431 \TestPackage{arydshln}
432 \TestPackage{braket}
433 \TestPackage{cancel}
434 \TestPackage{caption}
435 \TestPackage{colortbl}
436 \TestPackage{diagbox}
437 \TestPackage{etoolbox} % required by polyglossia and tcolorbox
438 \TestPackage{eurosym}
439 \TestPackage{fp}
440 \TestPackage{makecmds} % required by polyglossia
441 \TestPackage{marginnote}
442 \TestPackage{picinpar}
443 \TestPackage{pict2e}
444 \TestPackage{sidecap}
445 \TestPackage{upgreek}
446
447 % psnfss is in fact the name of a set of style files, among which
448 % times.sty. If times.sty is here, we will assume that everything is fine.
449 \TestPackage[times.sty]{psnfss}
450 % test the following fonts in case they are not in all versions of psnfss
451 \TestPackage{avant}
452 \TestPackage{bookman}
453 \TestPackage{chancery}
454 \TestPackage{charter}
455 \TestPackage{cochineal}
456 \TestPackage{courier}
457 \TestPackage{crimson}
458 \TestPackage{helvet}
459 \TestPackage{mathpazo}
460 \TestPackage{mathpple}
461 \TestPackage{mathptm}
462 \TestPackage{mathptmx}
463 \TestPackage{newcent}
464 \TestPackage{pifont}
465 \TestPackage{utopia}
466 % Other font packages
467 \TestPackage{ae}
468 \TestPackage{bera}
469 \TestPackage{biolinum}
470 \TestPackage{biolinum-type1}
471 %\TestFont[glic1000]{cbgreek}% for Greek % suported by LyX but too large to force downloading
472 \TestPackage{ccfonts}
473 \TestFont[ccr10]{concrete} % required by ccfonts
474 \TestFont[eorm10]{ecc} % required by ccfonts
475 \TestPackage[ot1ccr.fd]{concmath} % required by ccfonts
476 \TestPackage{cmbright}
477 \TestPackage{DejaVuSans}
478 \TestPackage{DejaVuSansCondensed}
479 \TestPackage{DejaVuSansMono}
480 \TestPackage{DejaVuSerif}
481 \TestPackage{DejaVuSerifCondensed}
482 \TestPackage{eco}
483 \TestPackage{eulervm}
484 \TestPackage{feyn}
485 \TestPackage{fourier}
486 \TestPackage{garamondx}
487 \TestPackage{plex-serif}
488 \TestPackage{plex-sans}
489 \TestPackage{plex-mono}
490 \TestPackage{sourceserifpro}
491 \TestPackage{sourcesanspro}
492 \TestPackage{sourcecodepro}
493 \TestFont[zgmr8r]{garamondx-fonts}
494 \TestPackage{iwona}
495 \TestPackage{kurier}
496 \TestPackage{lh-lcy}
497 \TestPackage{fontaxes} % required by libertine
498 \TestPackage{libertine}
499 \TestPackage{libertine-type1}
500 \TestPackage{libertineMono-type1}
501 \TestPackage{libertineMono}
502 \TestPackage{libertineRoman}
503 \TestPackage{lmodern}
504 \TestPackage{luximono}
505 \TestPackage{mathdesign}% for Roman fonts
506 \TestPackage{mdbch}
507 \TestPackage{mdput}
508 \TestPackage{mdugm}
509 \TestPackage{menukeys}
510 \TestPackage{MinionPro}
511 \TestFont[rzmnr]{minion2newtx}
512 \TestPackage{newtxmath}
513 \TestPackage[binhex.tex]{binhex} % required by newtxmath
514 \TestPackage{noto}
515 \TestPackage{noto-serif}
516 \TestPackage{noto-sans}
517 \TestPackage{noto-mono}
518 \TestPackage{paratype}
519 \TestFont[psyr]{symbol}
520 \TestPackage{tgadventor}
521 \TestPackage{tgbonum}
522 \TestPackage{tgchorus}
523 \TestPackage{tgcursor}
524 \TestPackage{tgheros}
525 \TestPackage{tgpagella}
526 \TestPackage{tgschola}
527 \TestPackage{tgtermes}
528 \TestFont[ugmr8r]{ugm}
529 \TestFont[uopr8r]{urwclassico}
530 \TestPackage{tipa}
531 \TestPackage{tipx}
532 \TestPackage{tone}
533 \TestPackage{txfonts}% For the txtt monospaced font
534 \TestPackage{XCharter}
535 % symbol packages supported by LyX for items and the special character dialog
536 % see the unicodesymbols file
537 \TestPackage{ascii}
538 \TestPackage{bbding}
539 \TestPackage{ifsym}
540 \TestPackage{marvosym}
541 \TestPackage{pmboxdraw}
542 \TestPackage{textgreek}
543 \TestPackage{tfrupee}
544 \TestFont[wasy10]{wasy}
545 \TestPackage{wasysym}
546 % These packages are disabled in the unicodesymbols file
547 % see comment there
548 %\TestPackage{txfonts}% But see above!
549 %\TestPackage{pxfonts}
550 %\TestPackage{mathabx}
551 %\TestPackage{mathdesign}% But see above!
552
553 %%% Specific package versions
554 % This only works if the package has been loaded before
555 \IfFileExists{babel.sty}{\RequirePackage{babel}}{}
556 \TestPackageVersion{babel}{2017/11/03}
557
558 %%% Document classes
559 % The list of layout files has been put in this file here by the
560 % configure script.
561 \input{chklayouts}
562 \input{chkmodules}
563 \input{chkciteengines}
564
565 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
566 %%%%% END ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
568
569 % End of the LaTeX job
570 \immediate\closeout\layouts
571 \immediate\closeout\vars
572 \immediate\closeout\packages
573 \typeout{\prefix Inspection done.}
574 \typeout{\prefix Read the file doc/LaTeXConfig.lyx for more information.}
575
576 % Get the real \end command, that has been hidden by LaTeX
577 \@@end