0

I wrote a library which requires a recent enough xparse version. Because I would like my package to be as portable as possible, I included (in the git repository only) a copy of a recent enough xparse.sty: that way (more or less) anybody cloning my repository could compile the demo directly.

However, it seems that on new LaTeX distributions, xparse is "built-in" (not sure if it's technically true), and therefore compiling something as simple as:

\documentclass{article}

\usepackage{xparse}

\begin{document}
Hello
\end{document}

will fail with the following error (assuming you put the file xparse.sty available for instance here):

! LaTeX3 Error: Control sequence \l__xparse_arg_spec_tl already defined.

For immediate help type H <return>.
 ...                                              
                                                  
l.37 \tl_new:N \l__xparse_arg_spec_tl
                                     
? 
! Emergency stop.
 ...                                              
                                                  
l.37 \tl_new:N \l__xparse_arg_spec_tl
                                     
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on demo.log.

Is there a way (maybe by changing the xparse.sty file?) to use the system xparse if it is more recent than 2019-03-05, and use the provided xparse.sty otherwise? I tried to put a \@ifpackagelater{xparse}{2019-03-05}{}{...} around the whole file, but then I get another error:

! Text line contains an invalid character.
l.1736 ...e_all:Nnn \l__xparse_split_list_tl { ^^@
6
  • 2
    Quite apart from the technical issue, there is a license one - you can't distribute just the .sty file ...
    – Joseph Wright
    Jun 8, 2021 at 19:27
  • 3
    don't provide local versions of such styles. That is a pain for the users. Either write your code so that it works also with older xparse, or require a current tex system. Jun 8, 2021 at 19:27
  • 2
    “not sure if it's technically true”: it is. See: tex.stackexchange.com/q/600353/134574. xparse was carefully modified to be compatible with recent LaTeX, which already have the code built in, so your “recent enough” version is not recent enough for LaTeX since last year. I'd suggest you require a recent system (that's not a big issue nowadays) Jun 8, 2021 at 20:13
  • 1
    You also can, of course, just not load xparse if it's already there: \@ifundefined{NewDocumentCommand}{\usepackage{xparse}}{}, but that still leaves the license issue Jun 8, 2021 at 20:23
  • 3
    In my experience the best instruction you can give to users of older distributions is: I don't support old systems. Sounds heartless or rude, but there is a limit to what you can reasonably support.
    – Skillmon
    Jun 8, 2021 at 21:13

1 Answer 1

3

If you have \usepackage{xparse} in your document and don't distribute your own copy then the document will work in any tex distribution from the last 10 years or so, There is no advantage at all in distributing a version of xparse. Each distribution of whatever age will have a compatible version of xparse.

If you use

\usepackage{xparse}[2020-01-01]

or whatever date you choose then users will get an error message if their xparse is too old for your library.

4
  • 1
    Perhaps worth adding that the 'basic' argument types (m, o, O, s) and + syntax have been there for at least a decade if not longer. So unless one needs say e-type arguments, any at-all-recent xparse will be fine.
    – Joseph Wright
    Jun 9, 2021 at 6:24
  • I need to use the b argument type, and this one is quite recent (it was not present in 2018, making it hard to import in overleaf which was using 2018 distribution by default). But I guess I'll do that, thanks.
    – tobiasBora
    Jun 9, 2021 at 10:41
  • @tobiasBora overleaf has texlive 2020 by default for all new projects and you can switch old projects to that. I just tested a b definition on overleaf and it works fine overleaf.com/read/pmhrrbcnsdzy Jun 9, 2021 at 18:40
  • Yeah I know, I just updated the code thanks!
    – tobiasBora
    Jun 9, 2021 at 19:02

You must log in to answer this question.

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