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

6
votes
1answer
33 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}{ ...
7
votes
2answers
125 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 ...
3
votes
1answer
123 views

Xparse macro not working when \obeylines is in effect

This is the most strange and hard-to-debug situation I have encountered in latex. When \obeylines is in effect, it seems that macros with optional argument defined by xparse will have some trouble. ...
6
votes
1answer
77 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}} ...
2
votes
1answer
46 views

Retrieving text from a “database text” file

I refer to my question and the solutions in String comparison in \ifthenelse I hope I can make my question clear enough, I am not a technician. I use a kind of database file (simple text file) with ...
7
votes
2answers
94 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 ...
2
votes
1answer
53 views

How to convert command parameters into optional ones?

LaTeX allows the use of optional parameters. Sometimes one wants to rewrite a command by making certain parameters optional: \newcommand{\foo}[2]{ #some commands } to: \newcommand{\foo}[2][a]{ ...
5
votes
1answer
41 views

Using longtable inside xparse \NewDocumentEnvironment

I am trying to create a wrapper for the longtable environment and it works fine with the standard \newenvironment command. Now I want to use \NewDocumentEnvironment from the xparse package to allow ...
4
votes
2answers
95 views

Greek `\chi`'s subscript expressions: how to make it smaller or offset lower?

I am unsatisfied with the way subscript is rendered for the Greek letter \chi. This particular letter is rendered with a small downward offset. I occasionally have to prefix the subscript with ...
4
votes
1answer
109 views

How to declare a macro with a variable argument list?

I am looking for a macro with two optional arguments and tried the following code: \documentclass{tufte-handout} % \usepackage{xparse} \usepackage{lipsum} \usepackage[demo]{graphics} ...
0
votes
1answer
47 views

Fine-tuning footnote style

I need to get a grip on a custom footnote command that could be sum up by this couple of xparse commands: \documentclass[11pt, a4paper, frenchb]{report} \usepackage{xparse} ...
7
votes
3answers
526 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 ...
0
votes
0answers
14 views

When defining a new macro inside a new macro (in xparse) how do I make the internal map long?

I would like to use a DeclareDocumentCommand in order to be able to define a different command (using arguments from the first). I would like to make the internal arguments long. Here is the code I ...
4
votes
2answers
82 views

In \DeclareDocumentCommand signaling first optional argument is missing

In \DeclareDocumentCommand if I have two successive optional arguments how can I signal the first one is missing? For example: \documentclass{article} \usepackage{xparse} \begin{document} ...
5
votes
2answers
85 views

Passing * arguments using xparse

In xparse I want to define a command Command-One which calls a command Command-Two and calls the *ed version if and only if the *ed version of Command-One was called. Specifically I would like to do ...
5
votes
1answer
145 views

\edef in LaTeX 3?

Is there a version of \DeclareDocumentCommand (in LaTeX 3) which performs like \edef? I.e. where the argument is evaluated at the time of definition as opposed to the time the macro is called? For ...
5
votes
2answers
146 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 ...
4
votes
1answer
79 views

Test for empty value in xparse

Following the recommendation of the answers to this question, I use the following code \ExplSyntaxOn \DeclareExpandableDocumentCommand{\IfNoValueOrEmptyTF}{mmm} { \IfNoValueTF{#1} {#2} % true ...
5
votes
2answers
101 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
69 views

\rowcolor in \NewDocumentCommand

It seems to be impossible to wrap \rowcolor in a macro defined with \NewDocumentCommand, while everything is fine with \newcommand. Is ist possible to fixe this? \documentclass{article} ...
1
vote
0answers
32 views

Looking for trouble: the κ letter, the combining ⃗, ucharclasses and xparse… (error with κ⃗ but not with k⃗)

Now I'm seriously puzzled. Here's the MWE (using xelatex). \documentclass{article} \usepackage{xparse} \NewDocumentCommand{\li}{v}{\texttt{#1}} \usepackage{fontspec} \usepackage{xunicode} ...
6
votes
1answer
68 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 ...
2
votes
1answer
41 views

Float(s) lost in newly defined environment (possible \vbox/\hbox problem)

The following gives me LaTeX Error: Float(s) lost. I saw on Lost float in exam class that this might have to do with the \vbox. Replacing it with an \hbox gives Something's wrong--perhaps a missing ...
4
votes
1answer
181 views

Alternate lefthand/righthand width and check odd page in tcolorbox

I am creating a new environment using the tcolorbox package in the define options pos=t,b,r,l and lwidth and rwidth for margins, using the scheme key=value of pgfkeys. My idea is to create two new ...
8
votes
1answer
59 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 ...
4
votes
1answer
88 views

Create a package with optional mode and key values

I'm trying to create a package with three options as follows: \usepackage[swpl]{mypack} swpl option provides the environment \begin{myexample}[forced bracketed options]...\end{myexample} ...
6
votes
2answers
95 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$ ...
0
votes
0answers
34 views

Texstudio: Autocompletion of xparse commands

I have defined a new command using xparse, but the command doesn't show up in the autocomplete. Furthermore the definition of the command is in red: The command is working, but it just doesn't show ...
6
votes
3answers
142 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 ...
4
votes
1answer
51 views

Expand macro into xparse \SplitList macro

I had help making a macro to process a list of arguments separated by ; into an itemize environment. To achieve this, xparse was used. When I tried to wrap the lists of arguments in a macro, nothing ...
1
vote
1answer
47 views

tabular operators in a custom environment code?

My question concerns the combination of the tabular environment and the \DeclareDocumentEnvironment command (from the xparse package). How do I set up an environment that contains in its code some of ...
3
votes
0answers
37 views

Experimenting with l3box and l3skip's dim variables

Note: The following MWE has no significance in use or further application of any kind rather than just for experimenting with the packages explicitly written on the question title. ...
5
votes
0answers
27 views

Comparing last character(s) of the output of \ref to manipulate output [duplicate]

I am trying to write a command that will replace \ref in a special way. It will add some text next to the number based on the last character(s) of the number \ref outputs. I will try to explain this ...
10
votes
2answers
159 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]{% ...
2
votes
1answer
46 views

Mix value and key/value with xparse

Following an earlier question I switched to xparse. Now I am sitting in a compatibility trap and try to allow old and new stuff at the same time. The point of origin is the infamous macro with two ...
5
votes
2answers
75 views

How can I achieve \verb like behavior with an xparse argspec?

How can I use a previously scanned token as an argument to u{} in an xparse argspec? \documentclass{article} \usepackage{xparse} \NewDocumentEnvironment {some-cool-env} {D<>{\stopscan} u{#1}} ...
6
votes
2answers
104 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 ...
5
votes
1answer
145 views

Forcing the first choice of an newtcblisting environment

I have created a new environment based on "tcblisting" from package "tcolorbox" is code (MWE) is as follows: \documentclass[10pt]{article} \usepackage{tcolorbox} ...
4
votes
1answer
52 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
96 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 ...
36
votes
2answers
572 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 ...
9
votes
1answer
109 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
108 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: ...
7
votes
1answer
125 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 ...
2
votes
1answer
112 views

How can I pass optional arguments as optional arguments?

I have the following environments which are being used in my document. As you can see, a lot of unnecessary complexity is being added by my arcane optional argument handling using \IfValueTF. Is there ...
6
votes
1answer
71 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} ...
10
votes
1answer
156 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: ...
4
votes
0answers
65 views

xparse with underscore and optional argument [closed]

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 ...
7
votes
1answer
86 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 ...
5
votes
1answer
80 views

Using filecontents inside of xparse

I'm trying to reproduce this using xparse: \begin{filecontents}{sections/autogen/somefile.tex} % Line to auto-produce \begin{myotherenvironment} Do lots of stuff \end{myotherenvironment} ...