LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

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

Print Reply
Sender: Mailing list for the LaTeX3 project <[log in to unmask]>
Date: Fri, 24 Sep 2010 08:39:46 +0100
Reply-To: Mailing list for the LaTeX3 project <[log in to unmask]>
Message-ID: <[log in to unmask]>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
In-Reply-To: <[log in to unmask]>
Content-Type: text/plain; charset=UTF-8; format=flowed
From: Joseph Wright <[log in to unmask]>
Parts/Attachments: text/plain (29 lines)
On 24/09/2010 07:15, Arno Trautmann wrote:
> Hi all,
>
> again, a question about xparse, still hoping this is the right list for
> that.
> I want to do something like
>
> \NewDocumentCommand\mycommand{O{#2}m}{#1 and #2.}
>
> which should give the same result for \mycommand[a]{a} and
> \mycommand{a}, i.e. “#1 is equal to #2 if #1 is not given“. Is there a
> simple way to do this to avoid an if-construct:
>
> \IfNoValue{#1}{\def\temp{#2}}{\def\temp{#1}}
>
> and then use \temp instead of #1? If not, would this be possible (and
> wanted) to be implemented?

Well, \IfNoValue is expandable so you can carry through

   {\IfNoValueTF{#1}{#2}{#1}}

to further stages without any issues (i.e. without needing the \def). 
That's probably not quite what you want, though.

I'll have a think about this.
--
Joseph Wright

ATOM RSS1 RSS2