6
votes
2answers
86 views

Three-way optional argument in xparse

I am trying to programme a command in x parse that has one optional argument, but which can behave in three ways in the following situations: a) no argument specified, b) optional argument specifies a ...
4
votes
1answer
49 views

xparse command with just optional argument fails

I am trying to define a command with xparse that takes an optional argument but no mandatory argument. The optional argument is a number, which works fine with a single digit but not with more. The ...
1
vote
0answers
63 views

frame in NewDocumentEnvironment

With beamer frames, this does not work. \newenvironment{itemframe}[1]{ \begin{frame}{#1} \begin{itemize} }{ \end{itemize} \end{frame} } Adding fragile, environment=itemframe as an ...
8
votes
1answer
86 views

Optional arguments: xparse vs. xargs

To implement a macro that takes one or more optional arguments that do not have to be placed in the first position, xargs can be used as well as xparse. The latter seems to have more recent updates ...
3
votes
1answer
93 views

Xparse macro with optional parameter breaks value for PGF foreach

I write a document class and want to execute something a certain number of times, depending on a user-defined quantity. So I thought I'd use a foreach loop from PGF together with accessor macros: ...
6
votes
1answer
94 views

NewDocumentCommand-defined command in bookmark

I have a scenario where xparse's \NewDocumentCommand has a regression compared to any alternative I know, including ones defining robust commands. So I'm avoiding \NewDocumentCommand in this case, but ...
6
votes
1answer
63 views

Behavior of xparse and “token”-type argument

Please consider the following example: \documentclass{minimal} \usepackage{xparse} \NewDocumentCommand{\f}{tx}{\IfBooleanTF{#1}{true}{false}} \begin{document} \f{x} \f[x] \f x \end{document} ...
4
votes
0answers
55 views

xparse with underscore and optional argument

I need a macro which handles its input as follows: \foo A > #2 = A \foo{A} > #2 = A \foo(B) > #3 = A (round brackets) \foo_m A > #1 = m, #2 = A \foo_m{A} > #1 = m, #2 = A \foo_m(B) > #1 = m, #3 = B ...
8
votes
2answers
219 views

xparse and key value arguments

I'm trying to learn how to do macros. I want to use xparse as it seems the most powerful tool. I also want named arguments, as numbered arguments make me, as a programmer, uncomfortable. I had some ...
6
votes
4answers
126 views

How can I capture both superscripts and subscripts after a macro

This question piggy-backs on the answer to Capture a macro's subscripts/superscripts by the macro by egreg. I'm attempting to use the xparse package to create some macros and I'd rather not have ...
15
votes
3answers
227 views

Defining Extensible macros

Question: For a macro that has only one parameter, are there any issues with defining it as follows: \NewDocumentCommand{\MyMacro}{% s% #1 = starred variant (*** unused as of yet ...
8
votes
2answers
303 views

Package xparse \SplitList last token

I need to create a macro to render lists with a variable number of arguments (1+), e.g. \mylist{1,2,3} should expand to $\tilde{1}$--$\tilde{2}$--$\tilde{3}$. I'm trying to use xparse and \SplitList, ...
5
votes
1answer
64 views

How to redefine \str_if_eq:xxTF for backward compatibility

I just updated all the packages for TeXLive 2012 today and it appears that \str_if_eq:xxTF has been deprecated. How do I define a macro so that I can use the latest TeX Live but still be able to run ...
4
votes
2answers
479 views

New command and the corresponding star counterpart with xparse

The following works as expected: \newcommand{\engl}[2]{#1 (en. \textsl{#2})\index{en-ro}{#2}} However, what I want to achieve would be a * version of it which only adds to the indices, without the ...
2
votes
1answer
273 views

Redefine existing command

My question is whether I can redefine an existing command for example \multicolumn and make the required arguments optional, without loosing the content of multicolumn? Another option would be to get ...
3
votes
1answer
127 views

Passing environment to \luatexluaescapestring fails

Can anyone explain why the macro \makequesone below fails and/or suggest a fix? The verbatim option works (as in the MWE) but I would like the content of the argument to be able to contain relatively ...
0
votes
1answer
103 views

Defect of measuring into the count of alphabet width

Question: Why in the example below I get (with CM at 10pt) \alphabet=342.93138pt and \myalphabetwidth=342.6536pt why I have this difference between the two measures? What is the more correct? ...
3
votes
1answer
182 views

Support for the punctuation symbols into a macro for characters count

Question about this macro: Is possible to have a higher precision with this macro by adding some punctuation symbols like ,.;:?!'() into the final count of the characters? ...
13
votes
3answers
833 views

Latex dynamic macro definition

I am trying to dynamically define variables. What I want to do is be able to define a person in the following way \definePerson{MrTestKey}{Mr Test}{0400 000 000}{mr@test.com} and then subsequently ...
6
votes
3answers
393 views

\NewDocumentCommand with constructed csname

In the spirit of my previous questions Defining \xthinspace: Thin space only if not followed by certain characters and Ellipses & Correct Space Factor, I’m trying to define a generic \xspace-like ...
8
votes
1answer
148 views

On pitfalls of robust commands

These days, I’m more and more defining robust commands, e.g., using \newrobustcmd (etoolbox package) or \NewDocumentCommand (xparse package). Robust commands seem advantageous to me in many respects ...
8
votes
2answers
449 views

Why using a backslash in command definitions?

I want to know the reasoning behind the (La)TeX inferface for defining commands with leading backslashes. I see why a backslash has to be used to call (expand) a command (macro), but I do not ...
4
votes
2answers
373 views

Passing multiple arguments from ProcessList (xparse) to a macro. Result to be used in tabular

I am making a macro that will take user input of a grading scheme and place it into a tabular environment. I would like the syntax to be as simple as possible and decided on: \tabulate{ eval1,%1 ; ...
-11
votes
2answers
981 views

Stringified commands to macros sequence

First, what is the proper terminology for a "string" in TeX/LaTeX that is an argument for a macro? e.g., \macro{somestring} Obviously somestring is a token, set of tokens, string, argument, etc. I ...
4
votes
4answers
370 views

Writing a multiple option command for a package

I am a newbie at LaTeX programming, so please be patient. :-) I am writing a .sty file which I want to include a command \dan which is overloaded with three separate versions depending on whether ...
8
votes
2answers
2k views

xparse: Define new command with multiple optional parameters

I'd like to define a new command with optional parameters using the xparse package. Please consider the following example: \documentclass{minimal} \usepackage{xparse} ...
5
votes
1answer
296 views

Using \IfNoValueTF within a TikZ style specification.

In an answer to Flushing PGF commands and local variable Matthew had suggested using \IfNoValueTF within a TikZ \node specification to determine the text. This solution works great for me. However, ...