11

Some recent change of the xparse package or of the LaTeX3 fundament seems to yield some changed behaviour regarding parameter processing. In some situations, at least one character is gobbled where it should not.

The following MWE shows a rather harmless situation, but my real problem is that an enironment based on xparse with verbatim text removes the first character of this text, see https://github.com/T-F-S/tcolorbox/issues/43

The MWE constructs an environment myenv with one optional argument. If this argument is not used, the whitespace is gobbled. Used in a more complicated scenario, as mentioned above, crucial stuff can be gobbled.

There is a second environment myENV without arguments to show the expected behaviour.

\documentclass{article}
\usepackage{xparse}

\NewDocumentEnvironment{myenv}{ O{} }{Alpha}{Omega}

\NewDocumentEnvironment{myENV}{}{Alpha}{Omega}

\begin{document}

\begin{myenv}[parameter]
Test
\end{myenv}

\begin{myenv}[]
Test
\end{myenv}

\begin{myenv}
Test
\end{myenv}

\begin{myENV}
Test
\end{myENV}

\end{document}

If this code is compiled against an installation of xparse (2018/02/21), the output is as expected:

enter image description here

But, if this code is compiled against an installation of xparse (2018/04/30) or xparse (2018/05/12), the output is:

enter image description here

I consider this to be a bug. But, if this is a feature, how can I get rid of it? Is there a way to have the old behaviour back with clean or dirty tricks which could help to solve my real problem (see above)?

  • 2
    Maybe https://www.texdev.net/2018/04/21/xparse-optional-arguments-at-the-end/ explains the change you are seeing – moewe Jun 04 '18 at 14:50
  • 1
    !O{} as optional argument works. – Ulrike Fischer Jun 04 '18 at 14:57
  • @moewe Yes, that's it! Would you like to add an answer which I could accept? – Thomas F. Sturm Jun 04 '18 at 14:59
  • @UlrikeFischer I feared that it is a feature... At least ! gives back the old behaviour. Unfortunately, a lot of documents have to be changed now... – Thomas F. Sturm Jun 04 '18 at 15:02
  • 2
    Yes, but I'm not completly sure that it is a feature, the blog describes spaces before the argument. @JosephWright is needed. – Ulrike Fischer Jun 04 '18 at 15:04
  • Indeed, seeing that the blogpost is (as I read it exclusively) about spaces and in your real-world bug report more than that goes missing, I'd rather not answer and leave the field for an expert instead. – moewe Jun 04 '18 at 15:06
  • 2
    Yes, I also think it is wise to wait, whether the implementation is really as intended before changing many documents... – Thomas F. Sturm Jun 04 '18 at 15:12
  • I've got to adjust few things here ... – Joseph Wright Jun 04 '18 at 15:13
  • 1
    @UlrikeFischer The former behaviour meant that [..] had to follow immediately \begin{} else it would not be recognized as optional argument. The new behaviour by default relaxes this. But from far away it looks strange to make default the behaviour which will cause [] with a space before, which was not recognized as optional argument so far, be now recognized as optional argument. –  Jun 04 '18 at 15:13
  • 1
    One would normally expect environments such as the ones given to be \ignorespaces at the start ... in any case, we know we need to adjust a few things here – Joseph Wright Jun 04 '18 at 15:15
  • @JosephWright Yes, but the MWE is just to show the effect. – Thomas F. Sturm Jun 04 '18 at 15:17
  • 5
    We may need to think about environments as needing separate treatment from commands ... – Joseph Wright Jun 04 '18 at 15:17
  • I cannot reproduce the error with xparse (2019-05-28), so I assume the bug is fixed and will vote to close this question. – schtandard Jul 24 '19 at 15:08
  • 4
    I'm voting to close this question as off-topic because it was based on a bug that has been fixed. – schtandard Jul 24 '19 at 15:08

0 Answers0