Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by h1439878.stratoserver.net (8.14.4/8.14.4/Debian-2ubuntu2.1) with ESMTP id t4HHYvf4008785 for ; Sun, 17 May 2015 19:34:58 +0200 Received: from relay.uni-heidelberg.de ([129.206.100.212]) by mx-ha.gmx.net (mxgmx009) with ESMTPS (Nemesis) id 0MT71K-1YmrT32hS2-00S8jO for ; Sun, 17 May 2015 19:34:51 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id t4HHWxYd012295 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 17 May 2015 19:32:59 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id t4HGnXJI023139; Sun, 17 May 2015 19:32:59 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 12114709 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Sun, 17 May 2015 19:32:59 +0200 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id t4HHWwxC025730 for ; Sun, 17 May 2015 19:32:58 +0200 Received: from mail-oi0-f43.google.com (mail-oi0-f43.google.com [209.85.218.43]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id t4HHWo46012264 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Sun, 17 May 2015 19:32:53 +0200 Received: by oign205 with SMTP id n205so113972143oig.2 for ; Sun, 17 May 2015 10:32:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=eAW4DKUqyG+b82Jpm+B9S8l4yAg/cJw4HzfIcfzBoj0=; b=AuGFF2JbmISPkbVIsTkiz0VXxcU/JHU/CCLMvfcOYrAm9KKBV6ytrOGA35/2yf0lD6 XKCkyxhM/xtfb/EAbznE/MwasFdMCLOh2ZSVXvCryREaKceHpw1Uofl0SH3/6iWjc3kd +XecQfWHn6CY14FEOn+uW3gu9kgjnL2prdQlhUm+g8HR3f2Mipli1a7yXOGV3+40itdh i5LedvYKJRMTa7ZNDjFjjyap/dElz5azhkif1pISfi1J5gbsMYJ53qipYMXhwm2ST4r9 w4fPQJ48uDsa3dY4a2jAskM3/DYN9i6Som579CyIXqw0JQgpqnYRW0nBAfr/kvVCYdKK bzFg== X-Gm-Message-State: ALoCoQk+u6joGKQ7nPE5JBFJt0ktdv4J74PaaHXZ7F5+4A4INJfOOLsKTYbwE5TKvVxfDmowR0+d MIME-Version: 1.0 X-Received: by 10.60.47.165 with SMTP id e5mr15544520oen.52.1431883970241; Sun, 17 May 2015 10:32:50 -0700 (PDT) Received: by 10.202.204.2 with HTTP; Sun, 17 May 2015 10:32:50 -0700 (PDT) References: Content-Type: text/plain; charset=UTF-8 X-MIME-Autoconverted: from quoted-printable to 8bit by listserv.uni-heidelberg.de id t4HHWxxC025731 Message-ID: Date: Sun, 17 May 2015 19:32:50 +0200 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Manuel Blanco Subject: Re: New arguments for sub and superscripts in xparse To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-MIME-Autoconverted: from 8bit to quoted-printable by relay.uni-heidelberg.de id t4HHWxYd012295 Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:trIYTA51VZ8=:3zIfXfoaBeS4aQVaYue3rnBb2Q jE0pB9KLPgjr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s 2kSu2k29h7pN6SeSENyGMWpmP3P7IV9CpIUjDXBKGiczH2SkpE5E8ZE5YG3XVpcWGf/jyXaH1 HV2h5bn9VHN5SDdE1/oL+PJhNaj4yc0mzHaic+E91qx163vaqR0Vw4SM6F4/bqP8x8yieS/sC tPMWJYjw9eY5d6ivo42z5V3KgRqNi8OtUf8PKOZ9kd40CZVVNy9XZpIieoYkhSLFMRPnpSDnw zPMmaI2WOyO0VMs3mNNGBqEIq9LoYWGMwnDojtHnVhoxikxyEV0st6M0b+bN7o474UvJMdsO8 igMTBRceJhzDY4KjAYFNKk5+fuUllB7kk/IZGqZdCN5XDwE9LtqVzy4tpHPC1ctyVevrB+qel EUnK0zKDW75yZIYS5IIFWm/0QNK6qdd+Lje7pNwD2VpkBpvpEX X-UI-Loop:V01:4YdCkgCiHhY=:3bqP/jRq4+J7AXwUEPWkyg9iUaCOmSgAP8zKQOXHND8= X-UI-Out-Filterresults: notjunk:1; X-Scanned-By: MIMEDefang 2.71 on 85.214.41.38 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by h1439878.stratoserver.net id t4HHYvf4008785 Status: R X-Status: X-Keywords: X-UID: 7713 Well, after playing a little bit, I think I found a way. The name of the function is k (and K, like d and D), it takes the one token to check, and if it's present, grabs the next (delimited or single token) argument. k K {} Once that is defined, my sub and superscripts are easily defined as shorthands with \prop_put:Nnn \c__xparse_shorthands_prop { a } { k \sb } \prop_put:Nnn \c__xparse_shorthands_prop { b } { k \sp } \prop_put:Nnn \c__xparse_shorthands_prop { A } { K \sb } \prop_put:Nnn \c__xparse_shorthands_prop { B } { K \sp } Here's the full code (may be with errors), in case someone is interested in the future Thanks, Manuel \cs_new_protected:Npn \__xparse_count_type_k:w #1 { \__xparse_single_token_check:n { #1 } \quark_if_recursion_tail_stop_do:Nn #1 { \__xparse_bad_arg_spec:wn } \__xparse_count_mandatory:N } \cs_new_protected:Npn \__xparse_count_type_K:w #1 #2 { \__xparse_single_token_check:n { #1 } \quark_if_recursion_tail_stop_do:nn { #2 } { \__xparse_bad_arg_spec:wn } \__xparse_count_mandatory:N } \cs_new_protected:Npn \__xparse_add_type_k:w #1 { \exp_args:NNo \__xparse_add_type_K:w #1 { \c__xparse_no_value_tl } } \cs_new_protected:Npn \__xparse_add_type_K:w #1 #2 { \__xparse_flush_m_args: \__xparse_add_grabber_optional:N K \tl_put_right:Nn \l__xparse_signature_tl { #1 { #2 } } \__xparse_prepare_signature:N } \cs_new_protected:Npn \__xparse_add_expandable_type_k:w #1 { \exp_args:NNo \__xparse_add_expandable_type_K:w #1 { \c__xparse_no_value_tl } } \cs_new_protected_nopar:Npn \__xparse_add_expandable_type_K:w #1 #2 { \__msg_kernel_error:nnx { xparse } { invalid-expandable-argument-type } { K } \__xparse_add_expandable_type_m:w % May be create this? } \cs_new_protected:Npn \__xparse_grab_K:w #1 #2 #3 \l__xparse_args_tl { \__xparse_grab_K_aux:NnnNn #1 { #2 } { #3 } \cs_set_protected_nopar:Npn { _ignore_spaces } } \cs_new_protected:Npn \__xparse_grab_K_long:w #1 #2 #3 \l__xparse_args_tl { \__xparse_grab_K_aux:NnnNn #1 { #2 } { #3 } \cs_set_protected:Npn { _ignore_spaces } } \cs_new_protected:Npn \__xparse_grab_K_trailing:w #1 #2 #3 \l__xparse_args_tl { \__xparse_grab_K_aux:NnnNn #1 { #2 } { #3 } \cs_set_protected_nopar:Npn { _ignore_spaces } } \cs_new_protected:Npn \__xparse_grab_K_long_trailing:w #1 #2 #3 \l__xparse_args_tl { \__xparse_grab_K_aux:NnnNn #1 { #2 } { #3 } \cs_set_protected:Npn { _ignore_spaces } } \cs_new_protected:Npn \__xparse_grab_K_aux:NnnNn #1 #2 #3 #4 #5 { \exp_after:wN #4 \l__xparse_fn_tl ##1 { \__xparse_add_arg:n { ##1 } #3 \l__xparse_args_tl } \use:c { peek_meaning_remove #5 :NTF } #1 { \l__xparse_fn_tl } { \__xparse_add_arg:n { #2 } #3 \l__xparse_args_tl } } \prop_put:Nnn \c__xparse_shorthands_prop { a } { k \sb } \prop_put:Nnn \c__xparse_shorthands_prop { b } { k \sp } \prop_put:Nnn \c__xparse_shorthands_prop { A } { K \sb } \prop_put:Nnn \c__xparse_shorthands_prop { B } { K \sp } 2015-05-16 19:54 GMT+02:00 Manuel Blanco : > Hello, > > I'm looking for two new argument types in xparse (say L and U, but you > can choose the names yourself) to grab sub or superscripts as optional > arguments. I write here since I'm looking for non-hackish solutions, > so probably written in the same way as xparse itself. > > For instance, if we have a command \foo defined with { m o L U } it > should be able to grab \foo{a}[b]_{c}^{d} with `c` and `d` as #3 and > #4. That is, that arguments should check for tokens _ and ^ (like t_ > and t^) and in case they are pressent grab the next argument. > > There's a problem with the naming, since l and u are already taken, L > and U should be followed by the “default” of the optional arguments, > but that would live us without the option to say > \IfValueT{#3}{\sb{\mathrm{#3}}}. I think that with L{} and > U{} is enough (but if you think of a better naming tell!). > > And I think that's all the important. > > --- > > (Now this are just thoughts.) > > In any case, may be not now, but in the future, it would be nice to > have certain control over subscripts (and super..). Right now > subscripts are the most “uncontrolled” optional arguments. But xparse > seems pretty good to add control over them within a macro. > > In an ideal future it would be perfect if xparse could process them > even if they are in different order like ^{a}_b, but for now it's okey > if they are just grabbed in the order they are written (i.e., L{} U{} > => _{a}^{bc}). > > That, with an acceptable interface, would bring us certain power about > limits within the commands we define. Thinking, it may be better > suited as a package alone and not for xparse. > > Thanks! > Manuel