4
votes
2answers
80 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} ...
4
votes
1answer
86 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} ...
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: ...
2
votes
1answer
111 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 ...
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 ...
4
votes
1answer
100 views

Problems with xparse and enumerate

I am trying to get the following document to work \documentclass[10pt]{article} \usepackage{enumitem} \newcounter{foo} \newcounter{bar}[foo] \addtocounter{foo}{1} \usepackage{xparse} ...
5
votes
1answer
137 views

Switch on number of arguments given to a macro

I want to define a macro that does different things depending on the number of (optional) arguments given to it. Is this possible? How? \documentclass{standalone} \usepackage{xparse} ...
5
votes
1answer
414 views

Optional argument within another optional argument in biblatex \cite

What is the right way to define a macro with an optional argument that can be called within the <postnote> optional argument to biblatex \cite? The last two \cite below don't work. (Unless ...
1
vote
0answers
120 views

xparse regression? Unable to create environment with single optional argument [closed]

I've created a custom environment for displaying code examples in a beamer presentation (for an introductory LaTeX couse no less), but compiling my "old" code suddenly results in an error. According ...
7
votes
3answers
500 views

xparse empty arguments

I have defined a command using xparse as \DeclareDocumentCommand\mymacro{o o o} and I want to call it with various numbers of arguments (up to 3) \mymacro, \mymacro[test][two], \mymacro[][][test] ...
4
votes
4answers
446 views

Writing a multiple option command for a package

I am a newbie at LaTeX programming, so please be patient. :-) I am writing a .sty file which I want to include a command \dan which is overloaded with three separate versions depending on whether ...