Skip to main content

Questions tagged [xparse]

Now integrated in the LaTeX kernel as {ltcmd}. Formerly, {xparse} was a package from the LaTeX3 project that provided a powerful mechanism for defining new commands with various types of arguments.

Filter by
Sorted by
Tagged with
1 vote
2 answers
67 views

Function to output array in itemize

I tried to create a single function that would output inline and function return arrays represented as clists in itemize. I didn't succeed to create such function, only separate ones. This function ...
Intolighter's user avatar
0 votes
2 answers
70 views

compute a scale factor for use in includegraphics

I want to compute a scale factor for use in includegraphics. I want to do this using the declarations from xparse. What I have so far (based mostly on https://tex.stackexchange.com/a/437494/293199): ...
troy's user avatar
  • 89
1 vote
1 answer
40 views

TikZ, polyglossia, \footnote interference? [duplicate]

With this MWE I can either setotherlanguage{latin} or get the tikz picture to print as desired in a footnote, but I haven't figured out how to do both. Doing both causes "missing \endcsname" ...
richardson's user avatar
0 votes
0 answers
33 views

Create alias of verbatim environment with optional arguments

I'd like to create an alias of the verbatim (xsim-based) environment \begin{CacheMeCode}{tikzpicture, optional arguments} \end{CacheMeCode} to \begin{tikzpicture}<optional arguments> \end{...
tobiasBora's user avatar
  • 8,944
0 votes
1 answer
52 views

How to create a LaTeX3 environment in paracol without delimiter issues?

I would like to turn this answer into an environment. Therefore, I use xparse to define a LaTeX3 environment, but I am missing a little something because it creates errors. It seems, I have issues ...
R. N's user avatar
  • 1,126
0 votes
1 answer
37 views

How to use NewExpandableDocumentCommand with a foreach inside a TikZ-matrix

Follow-up question to https://tex.stackexchange.com/a/714853/46023 I have the command \NewExpandableDocumentCommand{\test}{O{} m}{% \foreach[count=\no from 0] \No in {1,...,#2}{%% \node[draw, yshift=-...
cis's user avatar
  • 8,912
2 votes
3 answers
187 views

Find Text Between tabs [closed]

I copied a sheet from google sheet into a *.txt and want to format it to a pdf. I could separate it with \loop\unless\ifeof\mytextfile \read\mytextfile to\mytextline So I have in every loop one of ...
CHP's user avatar
  • 23
1 vote
1 answer
42 views

tcolorbox and ifmtarg: bad argument specification when checking for empty argument using @ifmtarg

Problem I am trying to put a bunch of optional arguments in a new tcolorbox definition, and trying to use the ifmtarg so I can skip some optional arguments like in the following syntax: Example 1: A ...
BrightBulb123's user avatar
1 vote
1 answer
121 views

Macro with verbatim argument

Is it possible to define a macro \foo such that it can accept verbatim code like: \foo{cos(16 % 2)} without interpreting them as latex code first? I know I can use an environment for that, but I ...
tobiasBora's user avatar
  • 8,944
4 votes
4 answers
369 views

\def vs xparse \NewDocumentCommand with delimited arguments

Based on my previous question I noticed (IMHO) that it is not so easy to make macros with delimited arguments with xparse instead plain-TeX's \def. As far as I know the LaTeX way - \newcommand - has ...
sergiokapone's user avatar
  • 5,598
3 votes
5 answers
223 views

\NewDocumentCommand with delimited arguments

How can the following command be implemented with \NewDocumentCommand?: \def\bracket<#1|#2>{ \left\langle #1 \right|\left. #2 \right\rangle } MWE \documentclass[]{article} \def\bracket<#...
sergiokapone's user avatar
  • 5,598
4 votes
4 answers
112 views

Nested SplitList Problem for quick expansion

I'm thinking whether I can write a new command for quick inserting any number of small groups of vectors in vector space. Here is what I want: $\basis{x; u; v}$ will automatically resolve to: $x_1, \...
Zhuoqun Chen's user avatar
0 votes
0 answers
57 views

v-type argument in \NewDocumentCommand ignores spaces

Consider the following code: \documentclass{article} \usepackage{listings} \NewDocumentCommand{\hey}{v}{\lstinline|#1|\ignorespaces} \begin{document} \hey|a |b \lstinline|a |b \end{document} Why ...
Gargantuar's user avatar
  • 1,154
3 votes
1 answer
130 views

Add aliases for command while defining command

I'd like to have a command \NewDocumentCommands which allows for multiple commands to be defined at once using the same definition. For example: \NewDocumentCommands { \powerset, \Powerset, \PowerSet }...
steve's user avatar
  • 2,256
2 votes
2 answers
118 views

Command that expands to `{ <output> }` instead of `<output>`

I'd like to define a command which expands to { <output> } instead of <output>. I've tried wrapping the command contents with additional { / } \bgroup / \egroup \begingroup / \endgroup \...
steve's user avatar
  • 2,256
1 vote
1 answer
60 views

Having label and caption optional for custom tabularray environment

This is a followup question to a similar problem: I like to create a table environment and to have the option creating a label/caption. This is my MWE: \documentclass{scrbook} \usepackage{xcolor,...
lukascbossert's user avatar
1 vote
1 answer
87 views

Name of glossary entries containing command defined with \NewDocumentCommand

I defined the following latex command: \NewDocumentCommand{\invokeWithCSV}{m>{\SplitList{,}}m}{#1#2} It takes as input the name of a command and a list of comma separated arguments and invokes the ...
atti6j's user avatar
  • 11
1 vote
1 answer
59 views

Renew qtyrange with default precision value

i would like to have a default round-precision value for \qtyrange that is different from the rest of the package, im having some problem changing it MWE: \documentclass{article} \usepackage{siunitx,...
Felipe9's user avatar
  • 339
1 vote
1 answer
38 views

Command color not working with the name of a color built through macros

Consider the following code and especially the command \nicecolorname which builds the name of a color following the pattern ["nice"][shade][hue]. In its current name, the command \color is ...
Vincent's user avatar
  • 5,327
3 votes
1 answer
130 views

Parse every character and transform it into a table column

I am trying to produce an array that will output most ascii characters in a given LaTex font. Currently, I have the following awful code that works: \documentclass{standalone} \usepackage[utf8]{...
Vincent's user avatar
  • 5,327
1 vote
1 answer
101 views

Use parameters as delimiters in \NewDocumentCommand

Using \NewDocumentCommand, it's possible to specify a delimited argument (e.g. r() for a required argument in parentheses). Is it possible to use other arguments in the same command as those ...
Gravitron's user avatar
0 votes
1 answer
77 views

I can't create command with \DeclareDocumentCommand{}{omv}{}

I have to make list environment based on description that should be used to describe code functions. Here is the prototype: % !TeX program = lualatex \documentclass[11pt]{report} \usepackage{enumitem}...
Vladyslav Rehan's user avatar
1 vote
1 answer
92 views

luacode works with \newcommand but not with \NewDocumentCommand

Imagine the following code: \documentclass{book} \usepackage{luacode} \usepackage{xparse} \NewDocumentCommand{\HelloWorld}{}{Hello World} \newcommand{\DefaultHelloWorld}{Hello World} \begin{luacode}...
Dave's user avatar
  • 327
1 vote
1 answer
51 views

You cannot use \raise in vertical mode error

\documentclass{article} \usepackage{mwe} \usepackage{pdfpages} \usepackage{tikz} \NewDocumentEnvironment{Insert}{m}{% \AddToHookNext{shipout/foreground} \bgroup \put(0,-\pdfpageheight) \...
Display Name's user avatar
  • 47.2k
4 votes
2 answers
82 views

Expand conditional in the outer specification for a tabularray table

I am trying to create a custom tblr environment for a schedule which I reuse often. I want to include an optional label for cross-referencing. I'm using the xparse \NewDocumentEnvironment command ...
jw5801's user avatar
  • 157
0 votes
1 answer
47 views

Custom command in \NewDocumentCommand documentation

I'm seeing a rather unexpected result with \NewDocumentCommand. Suppose I have a custom-defined command \mybold{}, like this: \NewDocumentCommand{\mybold}{m}{\mathbf{#1}} Or \oybold[]: \...
Abhimanyu Pallavi Sudhir's user avatar
1 vote
1 answer
32 views

Skipped line in `\iftoggle` gives error: paragraph ended and too many }'s

I'm trying to make a new command that outputs the first or the second argument depending on a toggle (with a specific counter -- it's basically to output question and answer for an exam). However, if ...
Nora NICOLAS's user avatar
1 vote
1 answer
72 views

Expanding an xparse \NewDocumentCommand before \bar

I would like vector variables to be bold faced, and scalar variables to be in plain font. The components of vector variables should then follow the scalar (nonbold) convention. To this end, using the ...
AndreasT's user avatar
  • 815
2 votes
2 answers
361 views

How to simplify the code below by using cycles?

\documentclass{article} \newcommand[3]{\mycounter}{a=#1, b=#2, c=#3} \begin{document} \mycounter{1}{2}{3} \mycounter{4}{5}{6} Too much… and the last line is \mycounter{28}{29}{30} \end{document} I ...
Meiu's user avatar
  • 514
3 votes
1 answer
79 views

Redefining \input with itself leads to unexpected behaviour

I am trying to intercept calls to \input and branch of functionality for some filetypes. However, I have run into the following strange error: Consider the M(n)WE given below, where the macro \input ...
marc's user avatar
  • 701
1 vote
1 answer
88 views

expl3/xparse: expansion, comparing tokens and xparse-defined macros

What is the correct (preferred?) way to do comparisons of whether a particular token---in my examples, it's typically a single character, but it could be something like \mathcal{A} or \mathbf{b} and ...
karlh's user avatar
  • 754
1 vote
1 answer
54 views

How to extract the text typed by user in \NewDocumentCommand

In order to solve this issue, let us start from a simpler task: how could I get the text typed by the user when defining a \NewDocumentCommand, to get a result close to what I would get when typing \...
tobiasBora's user avatar
  • 8,944
0 votes
0 answers
42 views

Bottom-aligning columns with tikzposter and TexLive 2022

The script found in Bottom-aligning columns with tikzposter works fine with TexLive 2021. However, since TexLive 2022, the script raises ! Missing number, treated as zero. \xparse function is not ...
Jingbei Li's user avatar
2 votes
2 answers
46 views

Setting beamer label from xparse option

I want to write a custom environment that handles some layouts that default beamer slides aren't designed to do. I use xparse's \NewDocumentEnvironment to achieve this, but have problems passing down ...
fhred's user avatar
  • 43
0 votes
1 answer
142 views

Unexpected LaTeX cmd Errors

I have a tex-document with the scartcl class. In the preamble I redefine \it by \RenewDocumentCommand{\it}{...}{...}. Moreover, I have to different environment in which I want to comple the document ...
Franz's user avatar
  • 175
5 votes
4 answers
199 views

Grouping multiple matches with \str_case:nnF

Consider the following: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\demo}{m}{ \str_case:nnF{#1} { {a} {Run case 1\\ % Actually super long code } {b} {...
Clément's user avatar
  • 5,651
2 votes
0 answers
48 views

How to put the section line into tcolorbox

The contents of chapter are put into tcolor by below code. How can we modify the code for section. My code have created the \mysectionnamebox to add a contentline of section. Thank you for help! \...
Nam Tran Le's user avatar
2 votes
1 answer
88 views

How to make verbatim option optional in my \NewDocumentEnvironment?

How to make the below \NewDocumentEnvironment 3rd argument optional verbatim (optional that escapes special LaTeX characters)? Below is the 3 ways for how to the custom style: (Keep in mind that the ...
Omar Shawky's user avatar
0 votes
1 answer
67 views

LaTeX count number of occurrences within an argument

I've been trying to count a particular character within a string (an argument of a new environment I've defined). I came across this question, where one of the answers pointed me in the right ...
coreuter's user avatar
  • 103
1 vote
0 answers
118 views

Use of xparse macro and expl3 key-value pairs [closed]

I'm trying to set up a family of key-pairs to be used in a \NewDocumentCommand. The goal is to have a function with two key-pairs. I want to be able to get the values of the two keys within the macro, ...
user1850133's user avatar
  • 1,028
4 votes
2 answers
186 views

example of \if_true: \fi: \else \reverse_if:N

it seems expl3 language is not yet very popular, i have not found even a single example of this test. I tried it but it fails. What i understood is that \reverse_if:N <primitive conditional> ...
user1850133's user avatar
  • 1,028
3 votes
1 answer
304 views

Answer key for multiple choice bubble sheet

Consider the following MWE: \documentclass{article} \usepackage{tikz} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\answergrid}{ m m m }{ \begin{tikzpicture}[x=0.75cm,baseline] ...
azetina's user avatar
  • 29.1k
6 votes
1 answer
119 views

How to use for loops in a custom command?

I have this nice code snippet to generate a DI table for integration by parts: \documentclass{article} \usepackage{xparse} \usepackage{amsmath} \usepackage{tikz} \usepackage{pgffor} \usepackage{...
Shai Avr's user avatar
  • 909
0 votes
1 answer
49 views

Number rows of table in decimal and hexadecimal with multiple counters

TL;DR My code to automatically number a table with two running counters in decimal and zero-padded hexadecimal (using the fmtcount and array packages) is not working. I'm trying to automatically ...
Ben Zelnick's user avatar
1 vote
2 answers
70 views

Iterate over list with xparse

I have this code with xparse package \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\addexercise}{m m m} { \prop_gput:Nnn \g_exercise{ #1 } { {#2} {#3} } } \...
user69507's user avatar
1 vote
1 answer
69 views

Macro without arguments to define macro with arguments

I'm trying to use xparse and generic TeX/LaTeX commands to write a macro (that takes no arguments) to define another macro that does take arguments: \documentclass{minimal} \RequirePackage{xparse,...
Ben Zelnick's user avatar
0 votes
0 answers
22 views

How to get xparse to accept an argument as multiline one? [duplicate]

In xparse, the argument specifier +b in environment allows for entering multiple lines in the body of the document. Is there any equivalent when using \NewDocumentCommand. For example, the following ...
Al-Motasem Aldaoudeyeh's user avatar
0 votes
0 answers
62 views

How to pass xparse optional parameters to other commands, preserving ability to check for `-NoValue-`?

I'm running into a situation using xparse where \IfValueT{#2}{#2} yields -NoValue-. My \NewDocumentEnvironment poem omo environment is passing its three parameters up to \NewDocumentCommands for ...
Josh Hansen's user avatar
0 votes
1 answer
61 views

Creating an edge command with iteration

i intent to create the command \graphEdge to streamline drawing graphs edges, it would take a list of arguments separated by , the function would then divide the arguments and iterate on it, creating ...
Felipe9's user avatar
  • 339
6 votes
2 answers
116 views

\NewDocumentCommand: Mandatory types r / R and their “default values”

The documentation of xparse states (emphasis mine): r Given as r⟨token1⟩⟨token2⟩, this denotes a “required” delimited argument, where the delimiters are ⟨token1⟩ and ⟨token2⟩. If the opening ...
O'Neil's user avatar
  • 209

1
2 3 4 5
16