The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [xparse]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
25 views

How to recognize the enumerate shortlabels in my custom environment?

On How to create a enumerate list adding a custom prefix before each item number? I learned how to create a custom environment to create labels. But now, it is missing the enumitem shortlabels feature:...
1
vote
0answers
48 views

Dependencies of xparse package

Recently I have used a xparse package, and, surely some preprint servers doesn't have this package in their system, like, for example, https://arxiv.org. While you try to submit [to arXiv] the ...
1
vote
2answers
39 views

“Missing { inserted.” error when using \NewDocumentCommand command as a subscript

I'd like to create a custom command with an optional parameter, which could be used in math mode as a sub- or superscript. However, the following code: \documentclass[pdftex,11pt]{report} \...
1
vote
1answer
32 views

Count Number of Occurrences as Numerical Input for Other Macro

I am trying to make lingmacros gloss automatically be aware of the number of columns it will need to produce. Basically, for the \shortex command, one of the inputs is the number of columns you want ...
2
votes
0answers
75 views

NewDocumentEnvironment with tcolorboxes and conditional typesetting

For the homeworks of my course I would like to create an Exercise environment for the statement of problems (continuing with the idea presented here) and another Answer environment, which will only ...
1
vote
3answers
39 views

Passing a macro to function expecting optional star

Initially this was meant as conditional typesetting using xparse rather than the other packages proposed here. Perhaps there are better approaches than the one I am pursuing, for that purpose, but in ...
1
vote
1answer
30 views

How to use an environment to load a vertical coffin that will be used outside the environment

I would like to use an environment to fill a vertical coffin. I find that I can fill the coffin this way, but that the poles get lost, in the sense the top pole (t) is treated as if it lies at the ...
5
votes
1answer
121 views

Keyboard TAB character in argument v (xparse)

I'm trying to understand how the TAB character of the keyboard behaves within verbatim. I have defined a new command using the v argument of the xparse, but, I get errors and a rather strange output ...
3
votes
4answers
88 views

Is there an `\edef` version of `\NewDocumentCommand` or `\newcommand` with optional arguments?

In a \foreach loop I want to define a bunch of macros with an optional argument (not shown in my example code). For this I use \NewDocumentCommand, but \newcommand would work, too. But how do I get ...
1
vote
1answer
35 views

How to check if a command contains an url

I need to check if a url is the argument of a command. My first instinct would be to convert the argument to a string, then check if "\url" is in that string. This is what I tried so far. The ...
1
vote
1answer
66 views

Override package with local package [Overleaf]

For a rather large project I unfortunately need to use Overleaf. The problem with this is that it uses TexLive 2017. My question is: Is there an easy way to use packages from the newest TexLive ...
2
votes
1answer
47 views

Make xparse not gobble end of line character on optional argument

When using xparse to define a new environment with an optional argument O{}, the first end of line character is gobbled as can be seen in the following example document: \documentclass{article} \...
1
vote
2answers
42 views

Access nth argument after use of \SplitArgument in \NewDocumentCommand?

It is a bit artificial, but assume the following as context: First, I want to add labels for tables as tab:label, for figures as fig:label and so on. Second, I want to create some commands to include ...
2
votes
1answer
31 views

Defining command with asterisk

I have a command which takes multiple arguments, one of which is a star: \NewDocumentCommand{\foo}{ s m m }{ \IfBooleanTF{#1}{Asterisk is here.}{Asterisk is not here.} #2 #3. } I would like to ...
2
votes
1answer
59 views

Labeled input parameters

I am creating a frontpage for various exams and I am looking to automate it a bit further. At the moment I write in (or rather copy paste), a ton of commands in the preabmle as follows: \newcommand{\...
3
votes
2answers
58 views

Create unique sorted list

I am trying to create a simple function that takes in some lowercase letters a,b,r,e,r etc removes any duplicate letters, and sort them. Then I want to list the output in a list Input: \...
2
votes
1answer
54 views

Efficiency of xstring (2e) vs. xparse (l3) in simple parsing

I understand string processing can be done on either LaTeX2e using xstring and expl3 using xparse (originally based on the 2013 thread "Tokenizing and parsing") I will be running a relatively simple ...
0
votes
0answers
95 views

Issue with xparse and lualatex

I have the following code \documentclass{article} \usepackage{luacode,xparse,amsmath} \begin{luacode*} local matrix = require "matrix" local complex = require "complex" function add(m,n) m=...
1
vote
1answer
38 views

Problem with expansion in xparse

I am trying to use function from this answer \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewExpandableDocumentCommand{\switchcondition}{ O{string} m m m } { \use:c { ...
3
votes
1answer
54 views

Processing separated list of separated lists

Is it possible to create function foo that takes list of arguments and this argument is also a list, e.g. to require the following semantics \foo[x:1,z,y:2], i.e. it takes three comma separated ...
0
votes
0answers
42 views

Naming \NewDocumentCommands

As much as I tried to find a definition in the xparse document of what characters are and are not allowed in NewDocumentCommnands, I did not find one. I know from experimenting that names like ...
0
votes
1answer
62 views

Underscore Usage in Xparse

This is a macro for producing vector length symbols. The mandatory argument m receives vector notations, which the optional argument o receives whatever should be added as subscripts if they are ...
5
votes
3answers
179 views

Calculating the partial sum of a expl3 sequence

How can I compute the partial sum of a sequence of integers? This is what I have so far \documentclass{article} \usepackage{calc, forloop, xparse} \ExplSyntaxOn \seq_new:N \g_tmp_seq \seq_new:N \...
2
votes
1answer
71 views

Counting days and years in personal journal

The code below is taken from this post. Is it possible to create a sequence/array that contains all the different years, and another that contains how many entries per year there are? \documentclass{...
1
vote
1answer
29 views

How to avoid (xparse) environment box from breaking interline-spacing and getting inside space of preceding environment's box?

Interline spacing of the last line of the first environment is being infringed upon by the first line of the following environment. How do I retain proper interline spacing in such case? \...
0
votes
0answers
64 views

key={v,a,l} argument separated by commas in xparse [duplicate]

I'm trying to create a command to show the distributive property of multiplication (for school effects) using tikzmarks and xparse. So far so good, the code is a bit long and I would like to know if I ...
6
votes
1answer
104 views

How to stop macros from processing arguments?

Disclaimer: I don't know how to word this properly so the title might be misleading - edits and comments of advice or correction are very welcome! I use the minted package to add code to my documents,...
0
votes
3answers
58 views

How to automatically place number of occurrences of a certain command inside xparse environment at every occurence of that command?

There is an (xparse) environment \myEnv, and there is unspecified number of \myCo commands provided by the user inside that environment. I need to write a code for the environment which would count ...
2
votes
1answer
80 views

How to automatically capture \prevgraf value (inside xparse environment) every time text ends with \par?

I need to declare an environment with \NewDocumentEnvironment such that every \par provided by the user inside that environment would automatically set an integer variable (inside environment-...
3
votes
3answers
77 views

Allow Optional Delimited Params To Appear In Any Order (EASILY) (e.g. \REset[s](X){e}=\REset(X)[s]{e})

My package rec-thy has a number of macros that allow the optional specification of both a stage (as part of a stagewise approximation) as well as a relativization. I've adopted the convention that ...
2
votes
3answers
164 views

Why \NewDocumentEnvironment within \ExplSyntaxOn/Off removes spaces from content passed to it outside of \ExplSyntaxOn/Off?

I thought turning syntax on/off at appropriate places would make everything work, but I can't use \ExplSyntaxOn/Off inside \NewDocumentEnvironment so the following code sample doesn't work: \...
2
votes
1answer
84 views

ocgx2, xparse, expl3: splitting comma separated OCMD/OCGs lists of arguments for references automation

On an applicative level, this question follows a previous one about quizzes (MCQs) with OCGs. But it seems (I suspect) that the issue might come from expansion concept and/or LaTeX3 syntax on how to ...
2
votes
1answer
115 views

Making an environment to draw over a picture with TikZ

Following up on this answer, I've decided to just make this a new environment. Below is my MWE using packages xparse and tikz: \documentclass[10pt,a4paper]{article} \usepackage{xparse,tikz} \...
4
votes
2answers
54 views

Implementing a keyword / token / tag system

I want to have a keyword / tag / label / token system for my documents. There will be a hard coded list of allowed keywords and all theorems/examples/exercises will (optionally) be tagged with one of ...
0
votes
2answers
81 views

How to call a command accepting 2 optional args defined with `\NewDocumentCommand` and pass only 2nd optional arg to it (skipping the 1st)?

If \myB accepts two optional arguments, \myB sets both of them to default values, \myB[5] sets first to 5 and second to default value, \myB[5][10] sets first to 5 and second to 10. But how do we set #...
4
votes
2answers
244 views

Expl3 and recent xparse on overleaf: No expl3 loader detected

I'm currently writting a library that requires a recent xparse (to have the +b option for environments). Unfortunately, my computer does not have such recent xparse, so I downloaded the package here, ...
0
votes
1answer
39 views

Use environment into (new) xparse environment

I'm writing a small library, and for some reasons, it seems that I can't nest environments with xparse's new way of defining environments. It's quite annoying as my users may want to nest environments....
3
votes
3answers
92 views

Summing the values of a sequence using expl3

In the code below, what should the definition of \sumcounters be to make it sum the current values of the counters thm and lemma? \documentclass{book} \usepackage{amsthm} \usepackage{xparse} \...
2
votes
1answer
118 views

Define double environments

TLDR; How can I define a "double" environment like in theorems/proofs (with an optional proof)? I'm defining a small library that is supposed to behave more or less like theorems/proof environments (...
0
votes
0answers
84 views

How to update a specific package from ctan

In the answer to this thread it is advised to use the package xparse released 05/03/2019 or later. I've been trying to update this specific package, but without success. First I updated all the ...
1
vote
0answers
19 views

Problems with an automatic theorem list

I took the code from this thread and modified it a little to fit my personal needs. Everything works fine until I add a second theorem environment, which in the MWE I'm posting is the lemma ...
4
votes
1answer
187 views

Avoid passing an empty [optional argument] an environment (with verbatim content) using xparse?

this query is related to How to pass an optional argument to an environment with verbatim content? (whose solution did not work in my case) and with Emulating @ifnextchar in expl3 (which is the one I'...
0
votes
1answer
55 views

xparse: forward empty optional argument

I'd like to use tcolorbox to call a theorem environment. My tcolorbox is supposed to ask for an optional title, and a mandatory label, so in the xparse specification I chose O{}m. Then, in the ...
1
vote
1answer
150 views

How to expand a \macro (or a copy) to save in a list at end of environment in xparse (expl3)?

I am trying to encapsulate a couple of environments to pass them to lists using xparse/expl3. I have defined a one command and two environments and I have had a problem with one of them. I use the ...
1
vote
1answer
95 views

xparse: Starred commands and \IfBooleanTF

In some longer redefinition of existing code I am using a construct like \documentclass{book} \usepackage{xparse} \makeatletter \NewDocumentCommand{\mymacro}{smO{}m}{ \def\blabla{#1}% % ...
3
votes
1answer
59 views

Add parentheses if double superscript or double subscript

I've already got an answer for Add parentheses if double superscript. I want to go a step further as proposed below. However lualatex complains of “missing $” when using the e{_}-type argument… \...
1
vote
1answer
100 views

Keep a key locally passed from multicols to enumitem using xparse

I have a small problem when trying to keep a key=val locally defining using xparse to pass multicols to enumerate (enumitem package). I have redefined the environment enumerate to accept the columns=...
0
votes
1answer
44 views

How much negative space needed? To recognizably remove a space by letting something be added? For macros whose argument is another macro?

Suppose that one has brea + (notice the space at the end). brea + is not printed yet. A macro \m{brea +} will replace + with \added ... how then does one define added, imagine it prints a d but only ...
0
votes
0answers
32 views

Using an xparse macro inside parenthesis adds an extra space [duplicate]

I've defined a macro using xparse to have one or two arguments, and to use different commands depending on the number of arguments given. It's been working very well until I had to put one of the ...
3
votes
3answers
80 views

Environment with comma separated optional arguments

Using xparse, how does one get something like this to work? \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentEnvironment{ anenvironment }{ >{\SplitArgument{1}{,}}o }{ \...