#6
\fi}
-% Tests whether an package is present in a specific version (or newer)
-% Syntax: \TestPackageVersion{<name>}{<yyyy/mm/dd>}
-
-\newcommand{\TestPackageVersion}[2]{
- % The actual test only works if the package has been loaded before
- \IfFileExists{#1.sty}{\RequirePackage{#1}}{}
- \@TestPackageVersion{#1}{#2}
+% Tests whether an package is present and also adds the version to the package list
+\newcommand{\TestPackageAddVersion}[2][\default]{
+ \def\default{#2}
+ \def\package@version{}
+ % The actual test only works after the package has been loaded
+ \IfFileExists{#1.sty}{%
+ \RequirePackage{#1}%
+ \protected@edef\package@@version{\csname ver@#1.sty\endcsname}%
+ \protected@edef\package@version{\expandafter\@parse@version\package@@version//00\@nil}%
+ }{}
+ \TestItem[#1]{#2}{package}{sty}{\AddPackage[\package@version]{#2}}{}
}
-\newcommand{\@TestPackageVersion}[2]{
- \message{^^J\prefix checking for package #1 at least as of #2...}
- \IfFileExists{#1.sty}
- {
- \@ifpackagelater{#1}{#2}{\existstrue}{\existsfalse}
- }
- {
- \existsfalse
- }
- \ifexists
- \message{yes^^J}
- \AddVariable{#1}{yes}
- \AddPackage{#1-#2}
- \else
- \message{no^^J}
- \AddVariable{#1}{no}
- \fi}
-
-
% Adapted from ltxcheck.tex
\newcommand{\TestFont}[2][\default]{
\def\default{#2}
\AddVariable{fmtversion}{\fmtversion}
%%% Store the current LaTeX version
-\AddPackage[\fmtversion]{LaTeX}
+\AddPackage[\expandafter\@parse@version\fmtversion//00\@nil]{LaTeX}
%%% And now, the list of available languages
% The trick is to know that \the\everyjob contains something like
\TestPackage{array}
\TestPackage{astron}
\TestPackage{authordate1-4}
-\TestPackage{babel}
+\TestPackageAddVersion{babel}
\TestPackage{beamerposter}
\TestPackage{biblatex}
\TestPackage{biblatex-chicago}
\TestPackage[iso-8859-7.def]{greek-inputenc}
\TestPackage{harvard}
\TestPackage{hhline}
-\TestPackage{hyperref}
+\TestPackageAddVersion{hyperref}
\TestPackage{hyphenat}
\TestPackage{iftex}
\TestPackage{ifthen}
\TestPackage{mhchem}
\TestPackage[mongolian.ldf]{mongolian}
\TestPackage{mslapa}
-\TestPackage{multirow}
+\TestPackageAddVersion{multirow}
\TestPackage{named}
\TestPackage{natbib}
\TestPackage{nicefrac}
\TestPackage{thswitch}
\TestPackage{tikz}
\TestPackage[turkmen.ldf]{turkmen}
+\TestPackageAddVersion{ucs}
\TestPackage{ulem}
\TestPackage{undertilde}
\TestPackage{unicode-math}
%\TestPackage{mathabx}
%\TestPackage{mathdesign}% But see above!
-%%% Specific package versions
-% This introduces \babelfonts
-\TestPackageVersion{babel}{2017/11/03}
-% This introduces multiple paragraphs in multirows
-\TestPackageVersion{multirow}{2021/01/29}
-% With this version, hyperref option unicode is true
-% by default
-\TestPackageVersion{hyperref}{2021/02/04}
-% As of this version, the ucs package must be explicitly
-% loaded to get utf8x (rather than utf8) encoding tables
-\TestPackageVersion{ucs}{2022/08/07}
-
%%% Document classes
% The list of layout files has been put in this file here by the
% configure script.
if (useNonTeXFonts) {
// Babel (as of 2017/11/03) loads fontspec itself
if (!features.isProvided("fontspec")
- && !(features.useBabel() && features.isAvailable("babel-2017/11/03")))
+ && !(features.useBabel() && features.isAvailableAtLeastFrom("babel", 2017, 11, 3)))
os << "\\usepackage{fontspec}\n";
if (features.mustProvide("unicode-math")
&& features.isAvailable("unicode-math"))
// Thus we load ucs.sty in order to keep functionality
// that would otherwise be silently dropped.
if (doc_encoding == "utf8x"
- && features.isAvailable("ucs-2022/08/07")
+ && features.isAvailableAtLeastFrom("ucs", 2022, 8, 7)
&& !features.isProvided("ucs"))
os << "\\usepackage{ucs}\n";
os << "\\usepackage[" << doc_encoding << "]{"
// As of 2017/11/03, Babel has its own higher-level
// interface on top of fontspec that is to be used.
bool const babelfonts = features.useBabel()
- && features.isAvailable("babel-2017/11/03");
+ && features.isAvailableAtLeastFrom("babel", 2017, 11, 3);
string const texmapping =
(features.runparams().flavor == Flavor::XeTeX) ?
"Mapping=tex-text" : "Ligatures=TeX";
string const p = lex.getString();
// Parse optional version info
lex.eatLine();
- string const v = lex.getString();
+ string const v = trim(lex.getString());
packages_.insert(make_pair(p, v));
}
}
getAvailable();
bool result = false;
- // Check for yyyy-mm-dd
- static regex const reg("([\\d]{4})-([\\d]{2})-([\\d]{2})");
+ // Check for yyyy[-/]mm[-/]dd
+ static regex const reg("([\\d]{4})[-/]?([\\d]{2})[-/]?([\\d]{2})");
for (auto const & package : packages_) {
if (package.first == name && !package.second.empty()) {
smatch sub;
// Since LyX uses unicode, also set the PDF strings to unicode strings
// with the hyperref option "unicode". This is only needed with pdflatex.
// As of 2021/02/04, unicode=true is default.
- if (!LaTeXFeatures::isAvailable("hyperref-2021/02/04")
+ if (!LaTeXFeatures::isAvailableAtLeastFrom("hyperref", 2021, 2, 4)
&& !runparams.isFullUnicode() && !runparams.use_japanese)
opt += "unicode=true,";
} else if (!isPartOfMultiRow(row, c)) {
if (!runparams.nice)
os.texrow().start(par.id(), 0);
- if (isMultiRow(cell) && !LaTeXFeatures::isAvailable("multirow-2021/01/29"))
+ if (isMultiRow(cell) && !LaTeXFeatures::isAvailableAtLeastFrom("multirow", 2021, 1, 29))
newrp.isNonLong = true;
inset->latex(os, newrp);
}