Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xparse: eats space token while looking for not provided, trailing optional argument #466

Closed
frougon opened this issue Jul 8, 2018 · 6 comments
Assignees
Labels
bug Something isn't working xparse Historical: see latex3/latex2e

Comments

@frougon
Copy link
Contributor

frougon commented Jul 8, 2018

Hi,

With more or less recent xparse, a function definition such as
\NewDocumentCommand \foobar { m o } { ... }
results in strange behavior when \foobar is called without the optional argument. The strange behavior is that the following space token (at least) gets eaten. This did not happen in TL 2016 (Debian stretch), but does happen in TL 2018 (Debian unstable, xparse 2018-04-30; I also manually added xparse.sty 2018-05-12 for testing, same problem). Here is a MWE:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xparse}
\usepackage{expl3}

\ExplSyntaxOn

\NewDocumentCommand \foobar { m o }
  { #1 -#2- }

\ExplSyntaxOff

\begin{document}
Hell\foobar{o} .
\end{document}

Note that there is a space token between the \foobar{o} and the following period. In TL 2018 (Debian unstable, xparse 2018-04-30, and also with manually added xparse.sty 2018-05-12), the resulting PDF file after running pdflatex contains Hello—NoValue—. (there is no space before the period). In TL 2016 however (Debian stretch, aka "stable"), the output is what I expected, that is Hello—NoValue— . (one space before the period).

Thanks!

@josephwright
Copy link
Member

We know about this, and there is work ongoing.

There was a deliberate change made to do with how we deal with trailing optional arguments: this comes down to the need to allow space skipping to be turned off in some cases. However, where commands with trailing optional arguments are used in the document body, this reveals an issue with the expl3 peek functions: they do no reinsert 'skipped' spaces if no match is found. We are currently sorting an appropriate syntax to extend peek functions to deal with this.

(In LaTeX2e, the only commands with trailing optional arguments are intended for the preamble, so the question of how to handle this scenario doesn't arise.)

I'd expect to get something concrete sorted during the TUG2018 meeting at the end of next week.

@josephwright josephwright added expl3 xparse Historical: see latex3/latex2e bug Something isn't working labels Jul 8, 2018
@frougon
Copy link
Contributor Author

frougon commented Jul 8, 2018

Thank you very much for your answer, great to see the problem is under such tight scrutiny. :)

@josephwright
Copy link
Member

@blefloch is reviewing and thinking about the low-level support issues here.

@blefloch
Copy link
Member

I haven't worked out the low-level peek issues but I'm committing a fix in xparse.

@agrahn
Copy link
Contributor

agrahn commented Sep 25, 2018

Thank you for fixing this!

@frougon
Copy link
Contributor Author

frougon commented Sep 27, 2018

Hi,

I confirm that after installing the latest l3kernel and l3packages from CTAN, the problem disappeared. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working xparse Historical: see latex3/latex2e
Projects
None yet
Development

No branches or pull requests

4 participants