]> git.lyx.org Git - lyx.git/blob - lib/chkconfig.ltx
lyx2lyx: fixup gloss reversion
[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/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 % FIXME: As of 2016, babel does not print out the loaded hyphenation patterns to
254 %        the log anymore, so this discontinues to work. For possible workarounds
255 %        (with babel), see https://tex.stackexchange.com/questions/330085/
256 %        Leaving this activated for the time being, since it probably still
257 %        works with older distributions.
258 \message{^^J\prefix checking for available hyphenation patterns... \langs}
259 \AddVariable{languages}{\langs}
260
261 %%% Check for ec fonts. Most of this code has been shamelessely stolen
262 %%% from the file ltxcheck.tex in the LaTeX distribution. In particular,
263 %%% don't ask me how the macro \ecrm works...
264 \def\ecrm{%
265   \begingroup
266     \escapechar-1
267     \xdef\reserved@a{%
268       \noexpand\in@
269         {\expandafter\string\csname ecrm\endcsname}%
270         {\expandafter\expandafter\expandafter
271            \string\csname T1/cmr/m/n\endcsname}}%
272   \endgroup
273   \reserved@a}
274
275 \message{^^J\prefix checking for default encoding (this may take a long time)^^J}
276 \font\test=ecrm1000\relax
277
278 \ifx\test\nullfont
279   \message{^^J\prefix\prefix checking for ec fonts... no^^J}
280   \AddVariable{ec}{no}
281   \AddVariable{fontenc}{default}
282 \else
283   \message{^^J\prefix\space\space checking for ec fonts... yes^^J}
284   \message{^^J\prefix\space\space checking for ec support in LaTeX format...}
285   \ecrm
286   \ifin@
287     \message{yes^^J}
288     \AddPackage{ec}
289     \AddVariable{fontenc}{T1}
290     \message{^^J\prefix\space\space default encoding will be set to T1^^J}
291   \else
292     \message{no^^J}
293     \AddVariable{fontenc}{default}
294   \fi
295 \fi
296
297
298 %%% Packages
299 \TestPackage{a0poster}
300 \TestPackage{accents}
301 \TestPackage{achicago}
302 \TestPackage{afterpage}
303 \TestPackage{algorithm}
304 \TestPackage{algorithm2e}
305 \TestPackage{amsmath}
306 \TestPackage{amstext}
307 \TestPackage{apacite}
308 \TestPackage{apalike}
309 \TestPackage[arabic.ldf]{arabi}
310 \TestPackage{array}
311 \TestPackage{astron}
312 \TestPackage{authordate1-4}
313 \TestPackage{babel}
314 \TestPackage{beamerposter}
315 \TestPackage{biblatex}
316 \TestPackage{biblatex-chicago}
317 \TestPackage{bibtopic}
318 \TestPackage{bicaption}
319 \TestPackage{bidi}
320 \TestPackage{bm}
321 \TestPackage{booktabs}
322 \TestPackage{braille}
323 \TestPackage{breakurl}
324 \TestPackage{CJK}
325 \TestPackage{calc}
326 \TestPackage{cancel}
327 \TestPackage{chapterbib}
328 \TestPackage{chemgreek}
329 \TestPackage{chessboard}
330 \TestPackage{chessfss}
331 \TestPackage{chicago}
332 \TestPackage{color} % this one should be there if graphics.sty is there.
333 \TestPackage{covington}
334 \TestPackage{cprotect}
335 \TestPackage{csquotes}
336 \TestPackage{drs}
337 \TestPackage[koi8-r.def]{cyrillic}
338 \TestPackage{dvipost}
339 \TestPackage{endnotes}
340 \TestPackage{enotez}
341 \TestPackage{enumitem}
342 \TestPackage{environ} % required by tcolorbox
343 \TestPackage{esint}
344 \TestPackage{eso-pic}
345 \TestPackage{fancybox}
346 \TestPackage{fancyhdr}
347 \TestPackage{filehook}
348 \TestPackage{fixltx2e}
349 \TestPackage{fix-cm}
350 \TestPackage{float}
351 \TestPackage{fontspec}
352 \TestPackage{footmisc}
353 \TestPackage{footnote}
354 \TestPackage{footnotehyper}
355 \TestPackage{forest}
356 \TestPackage{framed}
357 \TestPackage{geometry}
358 \TestPackage{graphicx}
359 \TestPackage[iso-8859-7.def]{greek-inputenc}
360 \TestPackage{harvard}
361 \TestPackage{hhline}
362 \TestPackage{hyperref}
363 \TestPackage{hyphenat}
364 \TestPackage{iftex}
365 \TestPackage{ifthen}
366 \TestPackage[japanese.ldf]{japanese}
367 \TestPackage{jurabib}
368 \TestPackage{l3experimental} % required by various packages
369 \TestPackage{l3kernel} % required by various packages
370 \TestPackage{l3packages} % required by various packages
371 \TestPackage{latex8}
372 \TestPackage{lettrine}
373 \TestPackage{listings}
374 \TestPackage[lithuanian.ldf]{lithuanian}
375 \TestPackage{longtable}
376 \TestPackage{lscape}
377 \TestPackage{luainputenc}
378 \TestPackage{mathdots}
379 \TestPackage{mathrsfs}
380 \TestPackage{mathtools}
381 \TestPackage{mhchem}
382 \TestPackage[mongolian.ldf]{mongolian}
383 \TestPackage{mslapa}
384 \TestPackage{multirow}
385 \TestPackage{named}
386 \TestPackage{natbib}
387 \TestPackage{nicefrac}
388 \TestPackage{nomencl}
389 \TestPackage{paralist}
390 \TestPackage{pdfcolmk}
391 \TestPackage{pdflscape}
392 \TestPackage{polyglossia}
393 \TestPackage{pdfcomment}
394 \TestPackage{pdfpages}
395 \TestPackage{pgf} % required by tcolorbox
396 \TestPackage{pict2e}
397 \TestPackage{prettyref}
398 \TestPackage{preview}
399 \TestPackage{refstyle}
400 \TestPackage{rotating}
401 \TestPackage{rotfloat}
402 \TestPackage{sciposter}
403 \TestPackage{sectionbox}
404 \TestPackage[serbianc.ldf]{serbianc}
405 \TestPackage{setspace}
406 \TestPackage{slashed}
407 \TestPackage{soul}
408 \TestPackage{splitidx}
409 \TestPackage{stackrel}
410 \TestPackage{stmaryrd}
411 \TestPackage{subfig}
412 \TestPackage{subscript}
413 \TestPackage{Sweave}
414 \TestPackage{tablefootnote}
415 \TestPackage{tabularx}
416 \TestPackage{tcolorbox}
417 \TestPackage{textcomp}
418 \TestPackage{thswitch}
419 \TestPackage[turkmen.ldf]{turkmen}
420 \TestPackage{ulem}
421 \TestPackage{undertilde}
422 \TestPackage{unicode-math}
423 \TestPackage{units}
424 \TestPackage{url}
425 \TestPackage{varioref}
426 \TestPackage{varwidth}
427 \TestPackage{wallpaper}
428 \TestPackage{wrapfig}
429 \TestPackage{xargs}
430 \TestPackage{xcolor}
431 \TestPackage[xetex.def]{xetex-def}
432 \TestPackage{xkeyval}
433 \TestPackage{xltabular}
434 \TestPackage{xskak} % required by chessboard
435
436 % Packages used by LyX's documentation files
437 \TestPackage{arydshln}
438 \TestPackage{braket}
439 \TestPackage{cancel}
440 \TestPackage{caption}
441 \TestPackage{colortbl}
442 \TestPackage{diagbox}
443 \TestPackage{etoolbox} % required by polyglossia and tcolorbox
444 \TestPackage{eurosym}
445 \TestPackage{fp}
446 \TestPackage{makecmds} % required by polyglossia
447 \TestPackage{marginnote}
448 \TestPackage{picinpar}
449 \TestPackage{pict2e}
450 \TestPackage{sidecap}
451 \TestPackage{upgreek}
452
453 % psnfss is in fact the name of a set of style files, among which
454 % times.sty. If times.sty is here, we will assume that everything is fine.
455 \TestPackage[times.sty]{psnfss}
456 % test the following fonts in case they are not in all versions of psnfss
457 \TestPackage{avant}
458 \TestPackage{bookman}
459 \TestPackage{chancery}
460 \TestPackage{charter}
461 \TestPackage{cochineal}
462 \TestPackage{courier}
463 \TestPackage{crimson}
464 \TestPackage{CrimsonPro}
465 \TestPackage{helvet}
466 \TestPackage{mathpazo}
467 \TestPackage{mathpple}
468 \TestPackage{mathptm}
469 \TestPackage{mathptmx}
470 \TestPackage{newcent}
471 \TestPackage{pifont}
472 \TestPackage{utopia}
473 % Other font packages
474 \TestPackage{ae}
475 \TestPackage{bera}
476 \TestPackage{biolinum}
477 \TestPackage{biolinum-type1}
478 %\TestFont[glic1000]{cbgreek}% for Greek % suported by LyX but too large to force downloading
479 \TestPackage{cantarell}
480 \TestPackage{ccfonts}
481 \TestPackage{Chivo}
482 \TestFont[ccr10]{concrete} % required by ccfonts
483 \TestFont[eorm10]{ecc} % required by ccfonts
484 \TestPackage[ot1ccr.fd]{concmath} % required by ccfonts
485 \TestPackage{cmbright}
486 \TestPackage{DejaVuSans}
487 \TestPackage{DejaVuSansCondensed}
488 \TestPackage{DejaVuSansMono}
489 \TestPackage{DejaVuSerif}
490 \TestPackage{DejaVuSerifCondensed}
491 \TestPackage{eco}
492 \TestPackage{eulervm}
493 \TestPackage{feyn}
494 \TestPackage{fourier}
495 \TestPackage{FiraMono}
496 \TestPackage{FiraSans}
497 \TestPackage{garamondx}
498 \TestPackage{plex-serif}
499 \TestPackage{plex-sans}
500 \TestPackage{plex-mono}
501 \TestPackage{sourceserifpro}
502 \TestPackage{sourcesanspro}
503 \TestPackage{sourcecodepro}
504 \TestFont[zgmr8r]{garamondx-fonts}
505 \TestPackage{iwona}
506 \TestPackage{kurier}
507 \TestPackage{lh-lcy}
508 \TestPackage{fontaxes} % required by libertine
509 \TestPackage{libertine}
510 \TestPackage{libertine-type1}
511 \TestPackage{libertineMono-type1}
512 \TestPackage{libertineMono}
513 \TestPackage{libertineRoman}
514 \TestPackage{lmodern}
515 \TestPackage{luximono}
516 \TestPackage{mathdesign}% for Roman fonts
517 \TestPackage{mdbch}
518 \TestPackage{mdput}
519 \TestPackage{mdugm}
520 \TestPackage{menukeys}
521 \TestPackage{MinionPro}
522 \TestFont[rzmnr]{minion2newtx}
523 \TestPackage{newtxmath}
524 \TestPackage[binhex.tex]{binhex} % required by newtxmath
525 \TestPackage{noto}
526 \TestPackage{noto-serif}
527 \TestPackage{noto-sans}
528 \TestPackage{noto-mono}
529 \TestPackage{paratype}
530 \TestFont[psyr]{symbol}
531 \TestPackage{tgadventor}
532 \TestPackage{tgbonum}
533 \TestPackage{tgchorus}
534 \TestPackage{tgcursor}
535 \TestPackage{tgheros}
536 \TestPackage{tgpagella}
537 \TestPackage{tgschola}
538 \TestPackage{tgtermes}
539 \TestFont[ugmr8r]{ugm}
540 \TestFont[uopr8r]{urwclassico}
541 \TestPackage{tipa}
542 \TestPackage{tipx}
543 \TestPackage{tone}
544 \TestPackage{txfonts}% For the txtt monospaced font
545 \TestPackage{XCharter}
546 % symbol packages supported by LyX for items and the special character dialog
547 % see the unicodesymbols file
548 \TestPackage{ascii}
549 \TestPackage{bbding}
550 \TestPackage{ifsym}
551 \TestPackage{marvosym}
552 \TestPackage{pmboxdraw}
553 \TestPackage{textgreek}
554 \TestPackage{tfrupee}
555 \TestFont[wasy10]{wasy}
556 \TestPackage{wasysym}
557 % These packages are disabled in the unicodesymbols file
558 % see comment there
559 %\TestPackage{txfonts}% But see above!
560 %\TestPackage{pxfonts}
561 %\TestPackage{mathabx}
562 %\TestPackage{mathdesign}% But see above!
563
564 %%% Specific package versions
565 % This only works if the package has been loaded before
566 \IfFileExists{babel.sty}{\RequirePackage{babel}}{}
567 \TestPackageVersion{babel}{2017/11/03}
568
569 %%% Document classes
570 % The list of layout files has been put in this file here by the
571 % configure script.
572 \input{chklayouts}
573 \input{chkmodules}
574 \input{chkciteengines}
575
576 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
577 %%%%% END ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
578 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
579
580 % End of the LaTeX job
581 \immediate\closeout\layouts
582 \immediate\closeout\vars
583 \immediate\closeout\packages
584 \typeout{\prefix Inspection done.}
585 \typeout{\prefix Read the file doc/LaTeXConfig.lyx for more information.}
586
587 % Get the real \end command, that has been hidden by LaTeX
588 \@@end