A high-level package from the LaTeX3 project that provides a powerful mechanism for defining new commands with various types of arguments.

learn more… | top users | synonyms

36
votes
2answers
570 views

How “safe” is it to use LaTeX3 (l3packages, l3kernel)?

Are l3kernel and l3packages present in most of the LaTeX distributions? Are they "stable enough"? I am asking this because I am preparing a .tex document for a client. I have found convenient to use ...
16
votes
3answers
248 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 ...
14
votes
1answer
819 views

How to transpose a table in expl3

I've been very impressed with xparse and expl3, and have written a wonderful document command using \ProcessList that takes a comma separated list and turns it into a (basically) 1 column table. ...
13
votes
3answers
962 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 ...
12
votes
1answer
292 views

Text being output when none should be

I am confused as to why the MWE below produces any black text. As the code is below, the output is: However, if you comment out the \IfStrEq line then it works fine and the black text goes away? ...
12
votes
1answer
572 views

Suppress xparse message “Redefining document command”

I am trying to suppress messages of the form: ************************************************* * LaTeX warning: "xparse/redefine-command" * * Redefining document command \MyMacro with arg. spec. ...
10
votes
2answers
155 views

Changing \newcommand into xparse \NewDocumentCommand

I would like to change the \newcommand \shcpoint into an xparse \NewDocumentCommand. How can I achieve this? \newcounter{totalpoints} \regtotcounter{totalpoints} \newcommand{\shcpoint}[1]{% ...
10
votes
2answers
293 views

How do I pass an expanded optional argument using expl3/xparse?

I have a command defined using xparse syntax: \DeclareDocumentCommand \foo { O{} m } {} Inside some other command (say, \bar), I want to call this command. The calling command (\bar) has to ...
10
votes
2answers
533 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 ...
10
votes
2answers
130 views

Is it possible to use \index{\command} inside a \DeclareDocumentCommand?

So I've been writing a book of sorts where I've used xparse to create some commands and environments. Now, when the thing is almost done, I realised a index would be great to have! One of the ...
10
votes
1answer
153 views

Processing a sequence of pairs

I want to process a list of pairs like this: {{a1,b1},{a2,b2},{a3,b3}} where the first items in each pairs are distinct. So, for each pair of those {ai,bi} I would need the following data: ...
9
votes
3answers
158 views

Test whether last letter of a string is upper case or not

I would like to define a command that will behave according to the nature of the last character fed it. But I'm having difficulty just getting the components of my command to work. I thought I could ...
9
votes
2answers
172 views

recursive multiple subscript and superscript with xparse

How can I define a new command with xparse, something like this: \NewDocumentCommand\tensorkor{ m >{\SplitList{,}}o >{\SplitList{,}}o } { ????? } that i can execute $ ...
9
votes
1answer
135 views

Using an array environment inside an xparse command

I would like to define a macro for optimization problems. My attempt is given below. I am wondering why \optimizationproblema works, but \optimizationproblemb does not (I get a "misplaced alignment ...
9
votes
1answer
459 views

Wrapping \cmidrule in a macro

In my earlier solution for Multivariate polynomial long division using LaTeX I had wrapped \cmidrule in a macro as its syntax alowing to shorten the end points was not standard: ...
9
votes
1answer
106 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 ...
8
votes
2answers
202 views

Automating table creation

I have the following table that I need to recreate quite a few times Due to its size and complexity (yes, I am a tex novice) I am looking into ways of automating the creation of said table. I try ...
8
votes
2answers
279 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 ...
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} ...
8
votes
2answers
354 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, ...
8
votes
1answer
155 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
1answer
167 views

TikZ path doesn't work with xparse generated macro

I am trying to use TikZ together with a macro that I defined via \NewDocumentCommand (for multiple optional arguments), but it doesn't behave as expected. TikZ is giving up on the path instead of ...
8
votes
1answer
53 views

Collecting environment content with support for xparse arguments

I'm trying to create an environment which uses xparse style arguments but I have to be able to use the whole environment content in the environment definition, e.g. as an argument. Ideally I'd like ...
8
votes
1answer
122 views

Can I temporarily supress xparse's log messages?

I know that I can suppress all those annoying xparse logging messages about redefining commands using the log-declarations=false package option. I find that I can do this after xparse has been loaded ...
7
votes
3answers
521 views

Defining 3*(2^4) complex macro at once

An Automata can be 1- or 2- ways, With Several Heads or a Single head Deterministic or Non-deterministic With a stack or not That makes 2^4 = 16 possibilities. However, for each combination, I'd ...
7
votes
3answers
486 views

xparse empty arguments

I have defined a command using xparse as \DeclareDocumentCommand\mymacro{o o o} and I want to call it with various numbers of arguments (up to 3) \mymacro, \mymacro[test][two], \mymacro[][][test] ...
7
votes
2answers
118 views

Workaround how to use expl3 functionality in tikz

What I want to do I want to create a command \planfigur{<edges>}{<angles>} which draws a triangle using TikZ. \planfigur should have 2 mandatory arguments, which let me specify edges ...
7
votes
2answers
90 views

Redefine \newcommand to insert code at start and end of custom macros

I would like to be able to insert code into the definitions of my custom macros, without having to modify each macro definition. This seemed like a simple case of redefining \newcommand, but this ...
7
votes
1answer
121 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 ...
7
votes
1answer
135 views

Removing strange vertical space after first (customized) \item

I have a custom environment properties (that is almost ready for release to Github) that works like so: \begin{properties} \item[no max in reals] \forall a \in \Re, \exists b \in \Re : a < b ...
7
votes
1answer
506 views

Use the s (star) argument with \NewDocumentEnvironment

Would it be possible to use the s argument specifier of xparse in \NewDocumentEnvironment so that we get an environment an a starred version of it? Actually it works, but the star goes to the wrong ...
7
votes
1answer
85 views

Filling a table by iterating over a sequence produces an orphan cell

I'm trying to fill a table with content that is stored in a sequence by a custom command. \documentclass{article} \usepackage{xparse} \usepackage{expl3} \ExplSyntaxOn \seq_new:N \my_sequence ...
6
votes
4answers
148 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 ...
6
votes
3answers
430 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 ...
6
votes
3answers
139 views

Define a \dots-aware command

edit: changed the MWE to show the problem with french babel So, I was wondering about in TeX.sx and came upon this question How do magic \dots work in amsmath?, I wanted to do the same thing (have a ...
6
votes
2answers
351 views

How can I create an oddly-delimited macro, using xparse?

I have a partial version of this macro working, without xparse, but I needed to tweak it and it got too unwieldy, so I'm trying to use xparse instead. It's admittedly a farfetched macro, but I'm ...
6
votes
1answer
69 views

Different result using \newcommand and \NewDocumentCommand

I am writing a text which references a whole bunch of Brazilian norms. All of these norms are prefixed with "NBR". I therefore created the following command \newcommand*{\NBR}[1]{NBR #1\cite{NBR#1}} ...
6
votes
1answer
69 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} ...
6
votes
1answer
944 views

How to convert to odt using xparse and mk4ht oolatex

Both tex4ht and htlatex compile documents with package xparse. But mk4ht oolatex doesn't. Running it on a document as simple as: \documentclass{article} \usepackage{xparse} \begin{document} a ...
6
votes
1answer
97 views

Conflict between xparse and pstricks: pstricks doesn't believe xparse function is defined

I want to create a pspicture with a variety of parameters which are interdependent. I'm using expl3 for the interface. But I get an error when I try to use \getr Error: /undefined in \getr Operand ...
6
votes
1answer
63 views

Could someone explain the branching in xparse's \SplitList?

I was digging through xparse.sty to better understand how \SplitList works and am confused about some branching that is happening there. \SplitList is essentially letted to be \__xparse_split_list:nn ...
6
votes
1answer
101 views

Is there something like a scope of \NewDocumentCommand?

Following along the line of my (confused) post on xparse and expl3, but this time hopefully with no typos or missing characters, I've devised a small package just to check a l3keys-based definition ...
6
votes
2answers
101 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 ...
6
votes
1answer
26 views

SplitArgument on colon doesn't work under expl3 syntax

\documentclass{article} \usepackage{xparse} \DeclareDocumentCommand\TestA{>{\SplitArgument{1}{:}}m}{% \Example #1 } \ExplSyntaxOn \DeclareDocumentCommand\TestB{>{\SplitArgument{1}{:}}m}{ ...
6
votes
2answers
93 views

Nested indentation with xparse

this is my first question, so any help is appreciated. I want to achieve an indentation effect as shown in the image: Which can be obtained as follows: \begin{itemize} \item $a$ ...
6
votes
1answer
115 views

\def variables with xparse and other questions about variables

I'm writing a documentation for a REST API. So there's very much information that has to get repeated. So I'm trying to figure out a few things: Consider the following code: ...
5
votes
2answers
143 views

Define a New Macro via a Macro Using xparse Syntax

I am trying to set up a macro that defines a macro that is to be executed only once. With what I learned from Define a Macro via Macro if Given Macro is not defined I can do that via the ...
5
votes
2answers
98 views

Transforming a list with xparse

I would like to be able to turn a list A,B,C into A \\ B \\ C, where A, B, C are LaTeX expressions. It would be quite simple to do with a package like xstring, but for the possibility that A, B or C ...
5
votes
1answer
136 views

Switch on number of arguments given to a macro

I want to define a macro that does different things depending on the number of (optional) arguments given to it. Is this possible? How? \documentclass{standalone} \usepackage{xparse} ...
5
votes
2answers
82 views

How can I refer to an absent value in expl3?

The xparse package has a concept of -NoValue-, a kind of '\null' token used to represent the absence of any value (where \null would probably be considered a value). If I would like to manually use ...