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
0answers
27 views

NewDocumentEnvironment not working as expected with listing and tcolorbox

I have the following code macro which is just a tcblisting: \newtcblisting{code}[2]{ listing engine=minted, minted language=#1, minted options={autogobble,breaklines,breakanywhere,bgcolor=...
2
votes
1answer
38 views

Continue to load xparse in new packages?

I am writing a package and intend to use the command NewDocumentCommand, which is available for newer installations of LaTeX (since 2020). Should I still load the xparse package with \RequirePackage{...
0
votes
2answers
87 views

\tl_if_eq doesn't recognise match

I'm working on a command that involves checking several arguments to see if they're colours, and doing something with those that are. I can't get \tl_if_eq to recognise matches. \documentclass{article}...
1
vote
2answers
30 views

Loop through lines of a .txt file to generate nomenclature

I am a complete newbie in the world of macros but I need to define a command that takes the content of a .txt file and uses it to add nomenclature entries. My .txt file looks like this: hPSCs: Human ...
2
votes
2answers
46 views

How to do if-else logic on missing optional keyval parameters

I'm trying to make a macro using the xparse library together with xkeyval for optional key value pairs. Here's a minimal example of what I'm trying to do cmd.sty \NeedsTeXFormat{LaTeX2e} \...
1
vote
1answer
16 views

latex3 clist put inside an environment definition

I'm puzzled as to why the following doesn't work: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \clist_new:N \l_test \clist_set:Nn \l_test {a,b,c} \NewDocumentCommand{\putitem}{m}{ \...
1
vote
1answer
52 views

Passing arguments from a parent function to an auxiliary/child function in xparse

Motivation I'm working on a custom \Colour command/environment. I'd like to have two mandatory arguments, one taking comma-separated parameters and the second taking the body. My approach for the ...
2
votes
1answer
33 views

Star argument in \NewDocumentEnvironment with variable name

I am trying to construct a command which would automatically redefine an environment of given in both starred and not starred version. The goal is to have \setenviron{foo} redefining environments foo ...
0
votes
0answers
29 views

Generate answer keys for multiple choices using xparse and tasks

I am using the following code to generate answer keys. When I try it in a long document, which is needed to add \answerkey in every section, answer keys printed repeat the counterparts of previous ...
2
votes
1answer
75 views

Comma-separated arguments for an adscript command

Is it possible to give the optional arguments in this command a comma-separated syntax, i.e. \ads{A,1,2,3,4} or \ads{A}[1,2,3,4]? (I think I'd prefer the first variant.) Despite reading all the ...
8
votes
1answer
83 views

xparse's 's' argument returns \Gamma and \Delta, instead of \BooleanFalse and \BooleanTrue

The xparse documentation says, But that's not what I get when I test s. \documentclass{article} \usepackage{xparse} \NewDocumentCommand{\myfunc}{s}{#1} \begin{document} \myfunc % should return \...
0
votes
2answers
70 views

Color selection in TikZ from numbered list

I want to draw a stack of boxes in TikZ where the boxes get their color from a numbered list of colors. This question explains how to do a numbered list of colors with different colored text. I tried ...
2
votes
1answer
33 views

Change multicolumn column spec with a star command

I am trying to make a macro that will wrap the column specification of a \multicolumn command with @{} if a * is passed to my macro. I can achieve the behaviour I want in the first definition below, ...
0
votes
0answers
37 views

Starting a new series of subequations within the same parent equation

This is a follow-up question to this previous question I asked. Basically I asked for an environment that not only stores the parent equation value, but also the number of a subequation so a series of ...
2
votes
1answer
55 views

How to pass key=value pairs expanded from a defined macro to a keyval-based macro?

I would like to define a simpler alias for \includegraphics using this synthax : \Img[width x height][other_opts]{filename} ...wich would be equivalent to : \includegraphics[width=width, height=...
2
votes
0answers
58 views

Macros: From Arguments to Keys, with Expl3: Optional Arguments

When declaring a new command with multiple optional arguments next to each other, e.g. \NewDocumentCommand{\mycmd}{ o o o }{} one is implicitly excluding the option of passing a value for #2 without ...
2
votes
2answers
54 views

Process Comma Separated List from Key Value (expl3)

I'm trying to \SplitList / \ProcessList a clist set in a wrapper command's argument as the value of a key. Unfortunately, it seems that the original command (\mycmd below) doesn't recognize the input ...
0
votes
0answers
42 views

LaTeX 3: NewDocumentCommand with more than 9 arguments

I read an article on this website introducing \NewDocumentCommand. However, it does not answer such a question: does it breaks the limit that one \newcommand can have at most 9 arguments? I found ...
0
votes
1answer
56 views

How can I pass the output of \SplitArgument to a function with optional arguments?

Suppose that I have an xparse function like \NewDocumentCommand \prob { m o } {\mathbb{P}\!\left(#1\IfValueT{#2}{\;\middle\vert\;#2}\right)} and I want to make a second version of the function \...
1
vote
2answers
34 views

How can I process each element of \SplitArgument succinctly?

I am trying to create some functions that handle conditional probability nicely. So far, I have the following: \usepackage{xparse} \NewDocumentCommand \prob { >{\SplitArgument{1}{|}} m } { \...
3
votes
1answer
34 views

Apply style to “i”th node, if “i” appears in a list of pairs

I have written a command to make the following image with TikZ: Calling the command that created this image looks like this: \drawmatching{% G,A,T,T,A,C,A}{% G,C,A,T,T,G,C,A% }...
10
votes
4answers
435 views

Programmatically define macro within the body of \foreach

I am trying to write a macro \RR, allowing me to type \mathbb{R} in text, with an optional parameter for an exponent. The desired functionality is shown below: I can now write \RR\ in text. % --> ...
1
vote
1answer
107 views

How to add notes to an artificially created margin?

I am aggregating a document class for taking Cornell-styled notes. For this purpose, I am using the tcolorbox package and arrange them into two columns. terms on the left and notes related to these ...
0
votes
0answers
28 views

Unexpected result using sys_get_shell in argument of hypersetup

I would like to include the content of an environment variable inside a PDFs metadata. (More specifically the commit inside of a CI pipeline). To do this I used an old(ish) macro of mine to get the ...
0
votes
1answer
63 views

Set tcolorbox overlay bookmark to be above its parent

I added a new environment to my Cornell-styled notes: titlednote It allows adding a title to a note which should also generate a bookmark below its term. But since terms are implemented with a ...
3
votes
2answers
62 views

Manually set bookmarks jump to wrong location when used with tcolorboxes

I am extending a class to take Cornell styled notes. For this the class heavily relies on tcolorboxes. I want to add bookmarks to the resulting PDF for some of these tcolorboxes but no matter what I ...
0
votes
1answer
50 views

Preserving newlines in body of \NewDocumentEnvironment when writing to an external file

I am working on a system for providing hints for exercises in a different location of the typeset document. The current approach is based on saving the content of the hint environment to a file. This ...
1
vote
1answer
33 views

Store values in their SI units

So I have to do a bunch of calculations with both imperial and metric units. What I am looking for is a way to store values in their SI form Just an idea was to define \storeval{name}{quantity}{unit} ...
1
vote
1answer
64 views

How to write this xparse code more elegantly?

I'm currently trying to write a command using xparse, which translates into \A \A{Test} \mathbb{A} \mathbb{A}(Test) Also the full functionality of paired delimiters should work (\A[\Big]{Test} or \A*...
2
votes
1answer
47 views

Accessing sqlite3 with xparse (under XeLaTeX)

I was very happy when I read egreg's 2019 Addendum about how to launch a shell script from LaTeX and grab the output. But when I tried to use it to connect with a SQLite database, I got a LaTeX3 error....
7
votes
1answer
92 views

Problem when using the specifier `b` of `xparse` with tabulars

Edit: Phelype Oleinik has opened an issue in the bug tracker of LaTeX3 for that issue: https://github.com/latex3/latex3/issues/839 The following code provides an error. \documentclass{article} \...
6
votes
2answers
273 views

xparse creates infinite loop

this MWE creates on my machine a infinite loop. Can someone explain to me why? \documentclass{article} \usepackage{booktabs,xparse} \NewDocumentCommand\hlineX{ m O{0pt} O{#2} }{% \...
1
vote
1answer
59 views

A row of CSV data is not saved after checking for its emptiness and existence

Following up this answer and the ensuing discussion, \getRow is expected to check the existence and emptiness of the target row of a CSV data, then save that row columns to another macro. In other ...
0
votes
0answers
33 views

Problem with \par in argument of a macro defined with \NewDocumentCommand [duplicate]

In following MWE, \newcommand is used to create \myFoo macro which just forwards its unique argument, then \NewDocumentCommand is used to create \myBar with the same behavior. The former accepts \par ...
2
votes
1answer
126 views

xparse: How to conditionally get a warning or error when retrieving empty or non-existent CSV data?

Following up this great answer of reading a CSV file and saving it, I need to have the following: A compilation-halting error is required when I try to index into a non-existent row or column since ...
1
vote
1answer
71 views

Storing a CSV row columns in a list/array and indexing into it

Following up this answer, how to extend the code of its second method to store each row value columns in a list or array and be able to index into it? In other words, I need another macro (along with \...
1
vote
2answers
97 views

Insert verbatim content inside a NewDocumentEnvironment

I work on an environment for setting up exercises with zero or more associated hints. If I try to insert verbatim content in the body of the exercise, the latex interpreter hangs without specifying an ...
-2
votes
2answers
75 views

How create/redefine document command where command name is variable?

This question connected with question about tagging of sections. I found solution,how to do it,but i dont know,how create/redefine document command,if command is argument of some other command. When i ...
0
votes
1answer
42 views

key_define option

Consider the following MWE: \documentclass[letterpaper]{article} \usepackage{l3draw} \ExplSyntaxOn %---------------------------------------------------------------------------------------- % ...
1
vote
1answer
122 views

How do I convince the l3 team that g-type arguments are necessary? [closed]

I claim that g-type xparse arguments are strictly necessary and should be supported directly in the LaTeX kernel, rather than being officially deprecated as they are right now. If you disagree with me,...
1
vote
1answer
74 views

Column color and l3colors

Consider the following MWE: \documentclass{article} \usepackage[table]{xcolor} %\usepackage{l3color} %\usepackage{colortbl} %\usepackage{l3draw} \definecolor{sampleredexpl}{RGB}{21,71,158} %\...
9
votes
2answers
225 views

Using the \int_step_function

Consider the following MWE: \documentclass[letterpaper]{article} \usepackage{l3draw} \ExplSyntaxOn \NewDocumentCommand{\miconcentric}{ O{0.08ex} } { \mathicon_concentric_circles:n { #1 } } ...
3
votes
1answer
80 views

Cannot use 'macro parameter character #' in horizontal mode error with xparse and pgfkeys

I have the following not working code, where I'm trying to replace the standard \title command with one that sets a pgf key and then calls back to the original standard command. \documentclass{article}...
2
votes
1answer
61 views

Key values using l3keys (pencil symbol)

Consider the following MWE: \documentclass[letterpaper,11pt]{article} \usepackage{l3draw} \ExplSyntaxOn \dim_new:N \l__pencil_dim \fp_new:N \l__pencil_linethickness_fp \cs_new_protected:Nn \...
1
vote
2answers
81 views

Problem after an update to TeX Live 2020 from 2018

The following command works fine with a TeX Live 2018, but after I have updated to TeX Live 2020, I have this error. I can't find what is the problem : ! Missing \endcsname inserted. <to be read ...
0
votes
0answers
48 views

Using l3draw to recreate \cplus

Consider the following MWE: \documentclass{article} \usepackage{amsmath} \usepackage{l3draw,xparse} \ExplSyntaxOn %--------------------------------------------------------- \box_new:N \...
0
votes
0answers
52 views

\hrulefill and \dotfill

The LaTeX2e sources defines \dotfill and \hrulefill as follows: Interestingly, I noticed that in the multicolrule package, the author makes use of TeX primitives defined in L3 syntax as follows: Of ...
2
votes
1answer
38 views

Declaring sum globally

Consider the following MWE: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\shcpoint}{ m } { \azetina_shcpoint:n { #1 } } \NewDocumentCommand{\printtotal}{ } { \...
0
votes
0answers
49 views

Vertical skips in paragraphs in L3

Consider the following: TeX features some macros for fixed-length spacing. \smallskip Inserts a small space in vertical mode (between two paragraphs). \medskip Inserts a medium space in vertical mode ...
7
votes
2answers
180 views

L3 equivalent to ifcase

Consider the custom code of date showing the month and year only: \def\shccustomdate{% \ifcase \month \or January\or February\or March\or April\or May\or June\or July\or August\or September\or ...

1
2 3 4 5
12