4

My current version of parskip is 2021-03-14 so:

\IfPackageAtLeastTF{parskip}{2018-08-24}{\PassOptionsToPackage{indent}{parskip}}{}
\usepackage{parskip}

should pass the indent option to parskip. But it is not the case as pointed out by the following MCE where the paragraphs aren't indented (in the real use case, I need this conditional, not for a document, but for a package). Why?

\documentclass{article}
\IfPackageAtLeastTF{parskip}{2018-08-24}{\PassOptionsToPackage{indent}{parskip}}{}
\usepackage{parskip}
\usepackage{lipsum}
\begin{document}
\lipsum[1-2]
\end{document}
6
  • 5
    Because \IfPackageAtLeastTF returns false if the package isn't loaded. LaTeX cannot know the version of the package unless it has been loaded.
    – cfr
    Commented Jul 8 at 7:02
  • 2
    @cfr that looks like an answer to me Commented Jul 8 at 7:42
  • @cfr Okay. So no way to load a package with a given option if and only if the package is recent enough to provide this option? Commented Jul 8 at 7:48
  • @DenisBitouzé no built in way in LaTeX. You could of course read the file and search for a package version before executing it, though that comes with a whole lot of new problems.
    – Skillmon
    Commented Jul 8 at 9:15
  • 2
    you could append or prepend the option to the class options list: \RequirePackage{etoolbox} \preto\@classoptionslist{indent}\makeatother. But personally I wouldn't care. How probable is it that someone uses your new class from 2024 (which probably uses hooks and so requires a rather new LaTeX) with a parindent from before 2021? Commented Jul 8 at 9:19

1 Answer 1

6

LaTeX only knows the version of a package (or class) once it is loaded. Before that the conditional used by \IfPackageAtLeastTF... returns false. Hence the fourth argument of

\IfPackageAtLeastTF{parskip}{2018-08-24}{\PassOptionsToPackage{indent}{parskip}}{}

is executed irrespective of parskip's version. In this case, you could use

\IfFileExists{parskip-2001-04-09.sty}{\PassOptionsToPackage{indent}{parskip}}{}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .