LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Bruno Le Floch <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Sat, 8 Jan 2011 08:25:36 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (54 lines)
Dear all,

As those who have followed the list for some time know, there were
discussions of introducing verbatim arguments in xparse. This was rejected
for a very good reason: if the verbatim-like commands are not having the
first look at the argument, then comment characters and spaces have been
lost irretrievably. Thus, the user has to be made aware that nesting is a
problem for verbatim. The proposal I describe below forces the user to
explicitly indicate that the command that he is using will contain verbatim
text.


Namely, in the package `cprotect.dtx`, I introduced the command
`\cprotect` that acts somehow like a prefix: the argument of the
following macro is read verbatim, and `\scantoken`ed when it
is used. A typical example of use is

\cprotect \section { Title \cprotect \footnote { Foot \verb|^^|. } }

This will put the expected verbatim in a footnote attached to the section
called "Title". This works in moving arguments (e.g. Table of Contents).
So far, the implementation (is dirty and) only works for one argument. I
plan to extend it to any command declared using xparse.


It might be possible to do error checking: each `\cprotect` should check
somehow that it is "at the top" (i.e., it is the first one to look at its
argument), or that it is within a `\cprotect`ed command.
   Any idea how to do that?
If the error checking fails, throw an error, and try to recover by using the
harmless character sequences mentionned a few times in the past on this
list.


For the syntax, the naive thing is to simply get `\cprotect` to grab all
the arguments verbatim, and reread them when needed, but for
performance reasons, it could be better to say explicitly for each
argument whether it needs `\cprotect`ion. Any suggestions for the
syntax in this case?


Best regards,
Bruno Le Floch,
new to the list.


PS: Also, a small crazy idea (I see no practical application for that):
In LaTeX3, we can generate variants of macros with different types
of arguments (using \cs_generate_variant:Nn). Could/should the
same thing be done at the layer above? In other words, should it be
possible to take a DocumentCommand, and change the delimiters, or
change an argument from being optional to being mandatory, or from
being mandatory to being optional with default, ...?

ATOM RSS1 RSS2