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

2
votes
2answers
45 views

Check options in \newcommand or \NewDocumentCommand?

I'm trying to implement a custom command that is called like this: \mycommand[hello][world]{mandatory1}{mandatory2} OR: \mycommand[hello,world]{mandatory1}{mandatory2} However, I can't figure ...
8
votes
1answer
66 views

xparse's \DeclareDocumentEnvironment gives error on already-defined environment

I'm trying to redefine an existing environment subfigure defined by the subcaption package. To do this, I'm using xparse's DeclareDocumentEnvironment since that's suppose to declare a new environment ...
5
votes
1answer
58 views

Conflict between NewDocumentEnvironment and enumerate

I have the following document: \documentclass{article} \usepackage{enumerate} \usepackage{xparse} \newcounter{probctr} \NewDocumentEnvironment{prob}{o} {% \par \addvspace{.15in}% ...
3
votes
1answer
76 views

How to define a command that defines another command?

I have a command defined with xparse that looks like this: \NewDocumentCommand{\ME}{sogd<>}{\added[id=ME,remark={#1}]{#2}} (for the full code see Passing complicated argument patterns to a ...
1
vote
1answer
43 views

Missing \endcsname in xparse

I am trying to make my own class, with options for referencing. Short quotes work absolutely fine, but when it gets to longer quotes, for some reason, I get errors. essay.tex: ...
2
votes
1answer
47 views

Extending xparse for new arguments

I was looking for a way of grabbing sub and superscripts as optional arguments to a command in xparse. That is, \foo_{a}^{b} would receive a as an optional argument and b as another optional argument. ...
4
votes
1answer
61 views

pgfpositionnodelater with nested \tikz environments (Issue with PGF 2.1 -> 3.0 upgrade)

I'm trying to use \pgfpositionnodelater to create and measure nodes before placing them. (Their size influences where they should be placed) This works fine until I try to use \pgfpositionnode later ...
4
votes
1answer
53 views

How can I use the ampersand (&) as a delineator for tabs in LaTeX3 (expl3)/xparse syntax?

This idea evolved from the question: How can I get a count of the optional arguments with xparse? Problem I cannot get the ampersand to function as a delineator (for tab stops) inside the ...
3
votes
2answers
21 views

Trying to use collcell.sty with an optional argument

I'm trying to use collcell.sty with xparse. If I have macro with an optional argument, using it with collcell.sty does not seem to pick up the optional argument. For example: \documentclass{article} ...
2
votes
1answer
79 views

How can I get a count of the optional arguments with xparse?

Question Is it possible to get and store a count of the optional arguments actually passed to an xparse declare argument/environment? Purpose Regardless of the number of arguments provided ...
4
votes
1answer
63 views

Multiple uses of pgfpositionnodelater

I'm trying to generate and measure multiple nodes before placing them. Currently I'm using the following macros: % some helper / wrapper commands around \pgfplacenodelater % #1 = identifier for ...
2
votes
1answer
56 views

“Underfull \vbox while \output is active”, adjusting stretch/shrink does not make the error vanish

I intend to use the sidenote package along with David Carlisle's implementation of \marginpar based on \pdfsavedpos from the answer here: http://tex.stackexchange.com/a/52436/44160. I've simplified ...
4
votes
1answer
43 views

Converting xparse commands to html

I've had a varying level of success converting LaTeX documents into HTML, but one of the major problems I've encountered is converting expressions which contain commands defined through the xparse ...
4
votes
3answers
118 views

NewDocumentCommand with argument specifiers stored in macro

I am trying to write some macros that in turn automatically generate other macros, depending on options etc. I wonder, if it's possible to use \NewDocumentCommand{\somename}{\standardargs}, i.e. the ...
3
votes
1answer
62 views

rewrite comand like a [key=value] using xparse or latex3 syntax

I've written a macro to use some command like a ltxdoc (\oarg,\meta,\marg) without using the textcomp and ltxdocto colorate and decide the font style with which the angle, brackets and text in ...
3
votes
2answers
118 views

Passing complicated argument patterns to a new command

I am using the nice changes package. Which basically provides three commands \added, \deleted and \replaced. Because of the structure and the fact that the optional arguments it takes, I think it is ...
1
vote
1answer
79 views

A clean interface for hooking into sectioning commands

Is there an easy way to hook LaTeX's sectioning commands, short of the good ol' \let + \def (or, with xparse, \let + \RenewDocumentCommand{s O{} m})? I'm looking for something in the spirit of ...
3
votes
1answer
49 views

Wrap natbib macros \citep and \citet

How can I patch the natbib commands \citep, \citet and the like? I have tried xparse (MWE below), etoolbox (the \pretocmd and \apptocmd commands) and xpatch (the \xpretocmd and \xapptocmd commands) ...
1
vote
1answer
54 views

Detect when a white space is needed after calling a command

Say I have an expression I often use so I build a command shortcut to typeset it: \documentclass[11pt]{report} \usepackage{xparse} \ProvideDocumentCommand \es{s}{expression ...
3
votes
1answer
34 views

number formatting macro using xparse and pgfmathprintnumber not working for one option

I am trying to write a macro that prints numbers with a couple of options. The macro takes one optional argument that is the precision of the output and a starred version that attaches a unit to the ...
5
votes
2answers
84 views

Strange behave of index and l3regex

I am experimenting with LaTeX3 features and get a strange behaviour in a combination from index and l3regex. I try to replace all occurrences of :<space> with the exclamation mark sign, so that ...
2
votes
0answers
66 views

Determine whether the macro/function is in subscript, in superscript, or neither

I would like to provide different formatting for an xparse command, depending on whether the command is expanded in superscript, in subscript, or neither. That is, I would like to know inside the ...
2
votes
1answer
58 views

Background color around paperwidth figure

The question could have been subtitled: "how to force a caption to appear always on top of object float". I have a complex set of configurations and commands which I could resume to that MWE. % !TeX ...
11
votes
3answers
168 views

Use a macro to define a \NewDocumentCommand macro without backslash

Or as, Werner simplified it: "How to define a command without backslash in xparse". Background: I am trying to set up a macro to define a macro for me (which will also do some other things which ...
3
votes
1answer
67 views

Go through a list of numbers in an argument of a macro

I would like to write a macro background which takes 2 arguments and each argument can contain a list of numbers separated by ,, such that the following code draws two boxes with borders inside. ...
4
votes
1answer
61 views

Conditional code based on token

This is a follow-up question to Xparse Adding backslash after each command. xparse allows for conditional tokens to be inserted into the parameter text for a macro using the t<token> directive ...
4
votes
3answers
100 views

Xparse Adding backslash after each command

I want to write a command. This is the example the commands should achieve: \begin{alignat}{1} Hello \\ Hello two \\ Hello three \end{alignat}{1} This should the commands look like: \mycommand { ...
6
votes
1answer
75 views

Getting an optional title with nameref and xparse

Suppose I defined an environment with an optional argument (using xparse) as in \documentclass{article} \usepackage{hyperref,xparse} \newcounter{exercisecounter} \stepcounter{exercisecounter} ...
4
votes
1answer
528 views

Why a `Missing = inserted for \ifnum` error for empty l3seq sequences?

I'm trying to use expl3 sequences in order to stored 0, 1 or more affiliations to 1 or more authors stored in a datatool database. The following MWE works nicely: \documentclass{article} ...
3
votes
0answers
33 views

\SplitArgument with underscore [duplicate]

Is there a way to use \SplitArgument macro with the _ sign? The following example don't works. \documentclass{article} \usepackage{expl3,xparse} \ExplSyntaxOn \NewDocumentCommand{ \testone }{ ...
3
votes
1answer
98 views

Indentation inside tcolorbox

I have a environment solution created with xparse and tcolorbox. I do not understand why package \usepackage{indentfirst} does not work inside solution. \documentclass[12pt]{book} \usepackage{xparse} ...
2
votes
1answer
40 views

If used insdide \cs_new(_protected), \IfNoValue(TF) doesn't detect -NoValue- at document-level

I guess my problem is related to Commands from xparse inside functions created by \cs_new:Npn? but I still don't understand what's going on: in the following WE (not minimal, sorry for this), why ...
0
votes
0answers
67 views

Show Answer Key with letter alternatives at the end of document

I have a document in which between some explanation texts I insert some numbered questions (it's a book, actually). Here's the basic of the code I have now: \documentclass[10pt,a4paper,oneside]{book} ...
6
votes
1answer
318 views

Color each letter in document

I am trying to define a command that changes the color of every letter in the whole document to a specified color. I already tried different approaches from this thread, but I was not able to color ...
6
votes
1answer
49 views

More robust macro for ranges AND series of lines, measures, etc

Starting with @egreg's marvellous xparse answer to my question about a Macro for abbreviated ranges (pages, music measures), how to define a similar command that can also handle non-contiguous ...
4
votes
1answer
116 views

NewDocumentCommand with an alternative to s

I'd like to make a \NewDocumentCommand using the s argument, but with + or - or ... instead of * and then be able to test witch special character was used. \documentclass{article} ...
5
votes
1answer
92 views

Combine todonotes with mdframed to highlight paragraphs and write notes

I am trying to combine todonotes with mdframed to create a unifying command that allows to write todos and and highlight paragraphs at the same time. The syntax is ...
6
votes
1answer
58 views

Defining a command to define commands where the name uses the argument using xparse

Using xparse I want to create a command which defines other commands. However I want the secondary command to consist of text and then the argument to the first command. For example For example in ...
8
votes
1answer
94 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}{ ...
9
votes
2answers
182 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
135 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
120 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
80 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
127 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
91 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
101 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 ...
8
votes
4answers
296 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
175 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} ...
1
vote
1answer
91 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
557 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 ...