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 manual should mention how to use star arguments when invoking macros like \NewDocumentCommand #463

Closed
fmitha opened this issue May 24, 2018 · 17 comments
Labels
documentation Issues in the documenation xparse Historical: see latex3/latex2e

Comments

@fmitha
Copy link

fmitha commented May 24, 2018

As mentioned in the TeX Chat Room, discussion starting around here, I think that the xparse manual should present a reasonably self-contained overview of how to invoke macros.

The issue that I stumbled upon was that star arguments need to be added to end of the macro name as a *. While this is perhaps obvious to those sufficiently knowledgeable, it certainly wasn't obvious to me. Perhaps because I haven't written enough macros. But I think such a document should strive to be self--contained. A usage section at the end, where the experts won't be bothered by it, would be a very reasonable addition, I think.

@blefloch
Copy link
Member

After reading the discussion, I think that that confusion is reasonable. In LaTeX2e's \section* the star is described as part of the command name rather than being an argument, while in xparse the star is described as an optional argument and it shows up as a boolean argument #1 in the code. Despite being an argument, it mustn't be wrapped in braces.

We should certainly have some example usage of each argument type and of processors if we don't yet have these.

@blefloch blefloch added xparse Historical: see latex3/latex2e documentation Issues in the documenation labels Sep 23, 2018
@eg9
Copy link
Contributor

eg9 commented Sep 23, 2018 via email

@josephwright
Copy link
Member

At one point I did add some code that turned

 \begin{foo*}

into

\begin{foo}*

but it was confusing ...

@FrankMittelbach
Copy link
Member

FrankMittelbach commented Sep 23, 2018

what was confusing: the code or the explanation for it?

I think from a 2e interface perspective we should seriously think about doing just that, ie

\NewDocumentEnvironment{foo} {s m m} {...}{...}

internally define \begin{foo} to call the internal begin env with a "false" as first argument and \begin{foo*} calling it with "true" as the first argument.

And \begin{foo}*{xx} would then have a * as the second argument and xx as the third

@josephwright
Copy link
Member

I can pull the code back out: perhaps we need better documentation of this ...

@josephwright
Copy link
Member

BTW, I backed out the idea in ccddf9b: probably worth looking at that to see what was wrong.

@josephwright
Copy link
Member

@FrankMittelbach I think there are a couple of concerns. First, the fact that foo* is foo with * as #1 makes tracking arguments a bit 'interesting': everything is 'out by one'. Second, in LaTeX2e, foo and foo* are entirely independent. In particular, they can have different arg specs. That's not the case if we force * to be #1 of a common foo environment.

Of course, as we've done with [[ ... ]] or \\ [], we could just document that xparse-declared environments have a different logic here.

@FrankMittelbach
Copy link
Member

I don't see the problem with the tracking as on definition level every would track correctly with

\NewDocumentEnvironment{foo} {s m}{code-begin}{code-end}

The code-begin would just use #1 as the result from checking inside the document for a star (only that in the document that is done by looking at \begin{foo} viz \begin{foo*} and not by scanning for a star after \begin{foo}.

That doesn't seem any different than looking at internal definitions in 2e where the internal arg number have not much relation to what the external syntax is.

However the fact that star forms can have (in theory) totally different argument specs is indeed a bigger difference between 2e syntax and xparse possibilities. You can't do that with xparse for commands either --- and in my opinion we wouldn't want to extend xparse in this way.

@davidcarlisle
Copy link
Member

davidcarlisle commented Sep 24, 2018 via email

@FrankMittelbach
Copy link
Member

@davidcarlisle ... yeah in practice too (though the number of cases is low). My point was just that xparse doesn't support this for the commands. For the environments you could currently make that happen and even after the proposed handing of star envs above it would be still possible but for commands it isn't supported or only in the same roundabout manner as currently done by 2e code.

@eg9
Copy link
Contributor

eg9 commented Sep 24, 2018 via email

@FrankMittelbach
Copy link
Member

FrankMittelbach commented Sep 24, 2018 via email

@pablgonz
Copy link
Contributor

@josephwright I think this is clear from the current documentation.

@wspr
Copy link
Contributor

wspr commented Apr 15, 2020

Like Joseph I don't really like the proposal (and old implementation) of having the s behave (quite) differently between commands and environments.

And the idea of having \begin{foo*}\begin{foo}* is creative but also pretty odd.

Why not just have an extra argument type like S to capture this case?

@pablgonz
Copy link
Contributor

@wspr I think that xparse takes so long with that implementation that it would produce more than one headache [I'm thinking of tcolorbox :( ]

@car222222
Copy link
Contributor

@wspr ”I don't really like the proposal (and old implementation) of having the s behave (quite) differently between commands and environments.“

Such differences are Definitely very bad.

@josephwright
Copy link
Member

I think current docs here are clear enough, and any adjustments would now be in the 2e repo in any case, so closing here.

@josephwright josephwright closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues in the documenation xparse Historical: see latex3/latex2e
Projects
None yet
Development

No branches or pull requests

9 participants