{optional-arguments} concerns commands and environments that accept optional arguments. For example the \sqrt command can be used as \sqrt[3]{x}.

learn more… | top users | synonyms

6
votes
3answers
154 views

Special behavior if optional argument is not passed

I am looking to define a command (actually, an environment, but that shouldn't matter for the purposes of this question) that does some default behavior, and if an optional argument is passed, does ...
3
votes
1answer
19 views

Use Variable as optional input in enumerate

Can anyone tell me how to fix the following problem: The following code produces the error Package enumitem Error: topsep=0em,partopsep=0em undefined \documentclass[11pt]{amsart} ...
2
votes
1answer
24 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 ...
4
votes
2answers
91 views

Processing “List” of “List”

I implemented a short macro that processes a comma separated argument list to format them. So by calling \macroa{ABC, DEF} it will format the text to ABC DEF Now what I would like to have is ...
1
vote
1answer
31 views

Inserting command with optional argument as optional argument Problem

If I define the following two commands: \newcommand{\TestA}[1][]{a^{#1} aaa} \newcommand{\TestB}[1][]{#1} and then call it by $\TestA[\TestB[111]]$ I get the error: "Argument of \\TestB has an ...
4
votes
1answer
64 views

Macro for abbreviated ranges (pages, music measures)

I would like a semantic, configurable way to input ranges of pages, poetic lines, and music measure numbers. Using a macro would enable me to make sure all such ranges are formatted consistently, and ...
7
votes
3answers
92 views

Defining default arguments for a macro?

Quick question, is there a way to define default arguments for a macro? For example, I have a page filled with these: \TextField[width=2cm,height=10pt,bordercolor=stuff]{Question 1} ...
1
vote
1answer
68 views

pgfplots: Optional graph range arguments in a macro

I defined a macro that inserts a plot that I can re-use the same graph style in multiple places. Mine actually loads data from a file, but a similar MWE looks like: \newcommand{\drawGraph}[1]{ ...
2
votes
1answer
73 views

Can't use command with square brackets in matrix environment

I've defined a command that uses square brackets, and when I use it within a matrix environment, the command is not parsed. I stumbled upon a solution to my problem here: "[" Square bracket ...
4
votes
1answer
86 views

Optional arguments and &

I defined a simple diagram environment with \usepackage{tikz-cd} \newenvironment{diagram} { \begin{equation}\begin{tikzcd} } { \end{tikzcd}\end{equation} } and it worked fine. In particular ...
6
votes
1answer
73 views

Loading a package as an option in a personal style file?

I'm sure this has been answered many times before, but all my reading has just got me more confused. Anyway, I'm trying to create a little style file containing all my personal definitions and ...
8
votes
1answer
121 views

Defining a command that scans every arguments' macro “looking for” a token

Knowing that every command declaration with conditionally optional arguments, as \foo{...} expanding into \foo[default]{...} can be defined by \newcommand\foo[1][default]{...} or the safer version of: ...
4
votes
2answers
97 views

Defining a macro with combine many options to one bracket

I am beginner in writing macros with multi options. What I want to do, is to combine many options to one pair of brackets. \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} ...
4
votes
1answer
111 views

Providing optional key without value

I would like to prepare a macro with an optional argument like [wide], using xkeyval. (something whether to use \figure or \figure* inside) My test program below presents the output test0=false ...
4
votes
1answer
60 views

specifying line width globally

\documentclass[11pt]{article} \usepackage{tikz} \usetikzlibrary{arrows,shapes,positioning} \usetikzlibrary{decorations.markings} \usetikzlibrary{decorations.pathmorphing} \tikzstyle ...
4
votes
1answer
94 views

What is the difference between passing optional and mandatory arguments?

I wanted to define a macro which makes a program listing, and finds out a program language from an optional argument. The output I receive from the MWE below is Language set = 'Verilog' Passed ...
10
votes
2answers
229 views

Can I define a command with optional argument coming after the mandatory ones?

Is it possible to define new commands having the following form: \command{<marg>}[<oarg>] I have seen commands of this form in the fontspec package. But not sure how to achieve this.
0
votes
0answers
51 views

Prepend and append options to options list in environment

I need to define a macro superenv that expands to the usage of an environment which accepts key-value options. superenv should have three arguments: the environment name, the list of options, and the ...
4
votes
2answers
102 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} ...
2
votes
2answers
72 views

keyval error on passing macro as an optional argument to includegraphics [duplicate]

I am trying to include an image in my document: \documentclass[a4paper,10pt,twoside]{book} \usepackage{graphicx} \begin{document} \def\foo{scale=0.1} \includegraphics[\foo]{fig1.eps} ...
5
votes
1answer
186 views

Defining a LaTeX macro with optional arguments as keywords inside square brackets

I want to define a macro to insert pictures in figures, called \centeredfigure, which I am hoping to use the same way as \includegraphics. In \includegraphics, all optional arguments are given in the ...
2
votes
0answers
114 views

Adding an argument/variable in `sequencediagram` (pgf-umlsd)

My aim is to have the possiblity to configure in the figure tex either if the vertical bar of a sequence diagram is dotted, plain, thick, etc. Depending on the diagram, I wish I could have the choice ...
0
votes
1answer
31 views

\newcommand to create a command with optional arguments

In Latex, I always use \mathbb{something0}_{something1}^{something2}, wheres sometimes 'something1' or 'something2' can be empty. So I had the idea to create a newcommand using the \newcommand. So I ...
1
vote
0answers
88 views

Tabularx moving table to next page, ignoring optional arguments [closed]

Using the tabularx and booktabs packages to include tables I have a problem in my Appendix. A table, when inserted, appears on the start of the next page, above the next appendix's designation and ...
4
votes
1answer
76 views

Define a macro with an optional argument that is a space

I'm trying to define a macro replaces a phrase by a single latex expression, e.g., I want \myPhrase to return the phrase "this is the dog". The trouble is that when you do this in the obvious way ...
2
votes
2answers
75 views

Name of the proof instead of just proof

Packages I'm using: \usepackage{amsmath} \usepackage{graphicx} \usepackage[colorinlistoftodos]{todonotes} \usepackage{amsthm} \usepackage{amssymb} \newtheorem{thm}{Theorem} ...
4
votes
1answer
93 views

mdframed: how to change the separator between the label and the title of a non-numbered thereom?

The problem There seems to be a bug in mdframed package. With the theoremseparator key, one should be able to change the text between the "label" and the title of a theorem ("Theorem" being the label ...
2
votes
2answers
91 views

mdframed: how to put the optional argument of a theorem-like environment between brackets?

The classical case With the classical \newtheorem command of amsthm, one gets the following result for optional arguments: from this code \documentclass{article} \usepackage{amsthm} ...
1
vote
1answer
135 views

naming argument and optional-argument for \def, \newcommand and newenvironment

I know how to create a new command or an environment. I think it will much better if I can specify name of the arguments. For example in framebox command and array environment below, we know exactly ...
10
votes
1answer
173 views

Optional argument problem

This example works but if I try to put an optional argument changing \newcommand\TBLdiag[5]{% in \newcommand\TBLdiag[5][\tabcolsep]{% it does not work anymore. Of course I call \TBLdiag with ...
5
votes
1answer
213 views

How do I remove parentheses from theorem optional argument?

This is a MWE: \documentclass[12pt]{article} \usepackage{amsfonts, amsthm, amsmath, amssymb} \theoremstyle{definition} \newtheorem{Theorem}{Theorem}[section] \newtheorem*{Pythagorean ...
6
votes
1answer
76 views

Problem in using comment line in tcolorbox in a bash code

I am recently introduced to tcolorbox, which is a great package. I am trying to use it to highlight computer codes such as bash, python, and c++ in my document. When I run the following MWE, I get the ...
2
votes
1answer
265 views

Beamer template with different style options for frames

I am working on a beamer template which tries to mimick an existing .ppt-template from my institute. My problem now is, that the beamer template should be able to have frames with different styles for ...
4
votes
1answer
90 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} ...
8
votes
1answer
97 views

Automatically Insert Environment Arguments

How can I automatically insert [<+->] arguments to the itemize environment when I'm in a beamer frame so I get pretty incremental display during presentation?
14
votes
3answers
268 views

How to define a new command based on \section with its optional argument?

I've defined a new command called \mysec like the below: ‎‎‎‎‎‎ \documentclass{article} \newcommand{\mysec}[1]{\section{#1}} \begin{document} \mysec[Foo foo]{Bla bla bla} \end{document} But in the ...
0
votes
0answers
16 views

Re: LaTeX - Subfloat caption apparently can't include optional arguments for citations? [duplicate]

I would be very grateful for any help with the following problem, as a LaTeX novice. I am trying to create two subfigures, each with their own captions, to include quotations with the optional ...
6
votes
2answers
70 views

Different Behaviors Digesting \csname x\endcsname and Digesting \x (expansion issue)

This question has been significantly EDITED, as I learned more of the problem. If I was good, I would be able to create macros with multiple optional arguments, but not only can't I, but in this ...
1
vote
1answer
213 views

Using variables to draw a tikz diagram

I am defind my own command to plat a diagram with tikz. Instead of constant values I rather want to pass numbers to my command which determine the height of the bars in my diagram. Problem: I am ...
6
votes
2answers
136 views

Use of optional argument stretch in \parbox

I'm having some difficulty on how to use the "stretch" optional argument of \parbox. Is it supposed to equally interspace lines of text inside a box of determined size? If I code it like: ...
5
votes
1answer
90 views

How to put the character ] inside the short version of caption on list of table? [duplicate]

I'm using winedt and would like to insert something like \caption [blabla [-1, 1]V] {blabla [-1, 1]V...} in one of the tables, but I do not know how to escape the character ]. I've tried \\] ...
8
votes
2answers
121 views

Passing an if-else option to a custom sty file

I have a custom .sty file loading needed packages and defining some commands and environments. Is there an easy way to either: define an if-else option define option's default value I am using the ...
11
votes
1answer
111 views

Processing document class options with l3keys

How can I parse (that is, access) the entire option list given to the current document class with l3keys? This would obviously need some sort of \keys_define:nn { document-class-?? } { default ...
11
votes
1answer
170 views

Parsing commands with multiple optional arguments

Some LaTeX commands accept multiple optional arguments. Here are some examples: \makebox[<width>][<pos>]{<text>} \framebox[<width>][<pos>]{<text>} ...
9
votes
2answers
190 views

Defining a macro with three optional arguments in the form \newmacro{a}{b}[c]{d}[e][f] and \newmacro{a}{b}[c]{d}*[f]

I am defining a macro in LaTeX2e for writing function declarations. I want that the macro has tree compulsory arguments: the name of the function (v.g f), a depiction of the type of variable it takes ...
5
votes
6answers
2k views

How to create new commands with multiple arguments?

I'd like to create a new command \add that accepts 2 arguments, called entity and title. In other words, the command should look like this: \add{entity}{title}. The output should have the following ...
7
votes
1answer
192 views

Gobble optional arguments

You can use \@gobble, for instance, to restrict the usage of a macro like: \documentclass{article} \makeatletter \newcommand*{\cmd}[1]{% #1 \global\let\cmd\@gobble } \makeatother \begin{document} ...
1
vote
1answer
100 views

Predefined enumerate settings

I have multiple enumerates across some files, for which I want a consistent style (same enumitem options): \documentclass{article} \usepackage{enumitem} \newcommand{\enumSettings}{noitemsep, ...
9
votes
1answer
130 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 ...
8
votes
1answer
72 views

Moving the optional argument

When I create macros using \newcommand, I usually provide default variants setting some of the first arguments in a sort of partial application style \newcommand\five[5]{#1,#2,#3,#4,#5} ...