{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

2
votes
3answers
348 views

Itemize - set default option

I have plenty of lists, all with the [noitemsep] option: \begin{itemize}[noitemsep] \item foo \item bar \end{itemize} Is it possible, to setup itemize to use this option by default? Or do I ...
5
votes
1answer
121 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} ...
10
votes
3answers
274 views

Defining a list environment with multiple optional arguments

I'm trying to define a list environment with multiple optional arguments and with a default values for those arguments. For example, creating a new environment with a name newenv, which accepts two ...
7
votes
2answers
327 views

A macro for optimization problems

This question is an extension of Using an array environment inside an xparse command. I was advised to make a separate question for the extension. I would like to thank egreg very much for his help. I ...
4
votes
2answers
401 views

Line break (continuation) for commands (options, arguments)

How to do proper line breaking (continuation) for commands, i.e. their options and/or their arguments? For example, in order to transform this: \usepackage[top=1.0cm, bottom=1.0cm, left=1.0cm, ...
10
votes
2answers
168 views

Flexible parenthesing command

I would like to create a smart parenthesing command without using the xparse package. \p(1) prints (1) \p[1] [1] \p{1} {1} \p(1|2) (1|2) I tried this code but it ...
5
votes
1answer
331 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 ...
10
votes
2answers
769 views

A new environment based on enumerate

I have defined the following simple environment: \newenvironment{renumerate}{\begin{enumerate}\raggedright}{\end{enumerate}} I wonder how the above can be modified to use with, say, the following: ...
7
votes
2answers
120 views

Using a required argument as a default for an optional one in \newcommand

I'd like to create a new subsection command with the same calling structure like the original one, but I have no idea on how to handle the case when the optional argument is omitted. Basically I want ...
2
votes
0answers
66 views

\let, \renewcommand, and optional arguments [duplicate]

Possible Duplicate: When to use \LetLtxMacro? I have a problem in redefining a command with an optional argument in terms of its old definition. Here is what I did: ...
5
votes
1answer
105 views

Is a command with an argument before and after the command possible?

I'm trying to create a LaTeX3 command that works the same whether its argument comes before or after the command. For example, I'd like to define \squared to be used as either \m\squared or \squared\m ...
13
votes
2answers
292 views

TeX Parameter Processing imitating key-value pairs

I am thoroughly confused by this answer to How to generate n points on a circumference and connect all of them while having constraints on the image size as I don't understand how the parameter ...
14
votes
1answer
184 views

How to read a stream of tokens up to one of two different delimiters

The core question How can I process text delimited by one of two terminators? For instance, if I want to process text up to the next \A, I can just write \def\CmdA#1\A{...} But suppose that \A ...
3
votes
1answer
475 views

Creating a custom environment

I'm using the following syntax for my code snippets \begin{minipage}{\textwidth} \begin{lstlisting}[caption=<something>, label=<something>] The REST Endpoint URL is ...
8
votes
2answers
912 views

LaTeX: optional arguments with square brackets

LaTeX is trying to add a missing $ that I don't want to the following code: EDIT: replaced stricken lines from original question with minimal working example: \documentclass[letter,12pt]{article} ...
8
votes
1answer
164 views

How can I make a custom theorem for a definition?

Looking at the wikibooks article on theorems has me wondering... I'd like to do something, if possible, similar to the default "proof" theorem style, whereby I can add a custom name to each theorem as ...
9
votes
3answers
269 views

Create macro with several options

I struggle to create a macro that can take several options. What I want to create is for \mycommand[up,middle]{Macro} to output Macro with 'up' and 'middle' specified. Using etoolbox in the MWE below ...
4
votes
2answers
248 views

Different macro behavior when supplied an argument

I want to define a macro, call it \func, so that \func will output\phi, and \func[i] will output \phi(i). what is the easiest way to achieve this? I know there are other questions that address this ...
6
votes
2answers
2k views

Keyval Error with \includegraphics: options undefined

I'm trying to make a class file to help me draft bylaws for clubs, but I'm running into a problem with \includegraphics. I want to be able to define a club logo using a \logo command (see class ...
11
votes
1answer
318 views

Bug? LaTeX misparses nested optional arguments

LaTeX seems to be having problems handling nested optional arguments. I've included a minimal code example that generates the error: \documentclass[12pt,oneside]{book} \begin{document} ...
0
votes
1answer
359 views

Pass multiple options to \newcommand

I have defined a new command for each of the team members in my project group to add individual todo-notes with different color and name. Now I would like to add another option, but is having trouble ...
5
votes
2answers
263 views

Redefinition problem with \maketitle from KOMA class (with optional argument)

I try to redefine the \maketitle command as shown below. If I use an optional argument in the redefinition I get the TeX capacity exceeded error. Any suggestion why? MNWE: \documentclass{scrreprt} ...
1
vote
0answers
113 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 ...
10
votes
1answer
214 views

New command with default does not work

Hello I have the following new command (a bit simplified for readability): \newcommand{\xz}[1][0]{x_{#1}} I'm expecting the following behavior: $\xz$ outputs as $x_0$ $\xz{1}$ outputs as $x_1$ ...
6
votes
2answers
269 views

How to extend a macro for e-mail addresses to support multiple arguments?

I prepared the following macros to format e-mail adresses in a e-mail header. \usepackage{xifthen}% Provides \ifthenelse and \isempty % E-Mail header strings with format. ...
1
vote
1answer
398 views

Undefined control sequence Error with moderncv+Hebrew

I would like to use modernv to create a right-to-left CV document in Hebrew. I have downloaded and installed culmus-latex, and Hebrew+English LaTex documents compile without a problem. I took ...
6
votes
1answer
146 views

ctable extensions: colored horizontal and extended vertical rules - need help

I'm working on my ctable LaTeX package, planning to allow for optional key=value arguments for \FL, \ML, \LL, such that one can make a 3pt thick, red-colored toprule with \FL[w=3pt,c=red]; also, ...
2
votes
1answer
1k views

File name with underscore as figure caption [duplicate]

Possible Duplicate: Escaping from the escaping hell I did scour the internet for solution but I found no satisfactory answer for this problem. I have a bash script that searches my folder ...
4
votes
2answers
224 views

Iterating over a list of optional arguments

I'm defining a new command which should take an optional list of arguments (integers or ranges): \doit[3,5-7,9]{something} What I have so far: \def\doit{\@ifnextchar[{\@with}{\@without}} ...
5
votes
1answer
968 views

Boolean variables in LaTeX

I am trying to use "boolean" variables in LaTeX but am unable to have any success... I have a macro which takes 5 arguments, the last argument being optional. This macro is named educationItem and it ...
6
votes
3answers
404 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] ...
13
votes
2answers
1k views

New command with optional argument being first argument [duplicate]

I know I can create a new command with an optional parameter with \newcommand{\mycommand}[2][Hello]{\textbf{#1} #2} I would like to have the command such that there is an optional parameter which ...
9
votes
3answers
556 views

Are commands defined by \newcommand[.][.]{.} robust?

This question is from the comments at the foot of Abbreviations for AM, PM (small caps) for use within \textbf. Readers will get the remaining gist from there. With ...
5
votes
1answer
2k views

a “… doesn't match its definition” problem, that I don't understand

I managed to extract from my code the following MnWE which shows the problem i encounter : Example 1 \begin{document} \newcommand{\createDATA}[1]{ \xdef\DATA{} \newcommand{\test}[2][]{ ...
10
votes
3answers
5k views

Creating a new environment with one optional argument

I want to create a new environment with one optional argument in LaTeX. Here is what I used: \newenvironment{argument}[1][]{% \par \noindent \textbf{Argument#1:} \noindent} {} When there is no ...
0
votes
1answer
5k views

Optional argument for newcommand? [duplicate]

Possible Duplicate: Different command definitions with and without optional argument I would like to define a macro which takes an optional argument, and behaves in different ways depending ...
12
votes
4answers
2k views

Optional arguments in \def

I want to re-define the \sqrt command (as detailed in Nice-looking p-th roots), and so far I have the following: \documentclass{article} \usepackage{fouriernc} % use the New Century Schoolbook font ...
4
votes
4answers
365 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 ...
6
votes
4answers
395 views

List parsing with special input/optional arguments

I’d like to parse a list where the elements can be given as either [<pre>]<text>[<post>], where <pre> and <post> are optional, or (<special text>). I found a ...
1
vote
1answer
39 views

kprefix in \krddefinekeys seems to be not optional

Maybe I misunderstood something but the following example doesn’t compile with out a optional argument defining the kprefix \documentclass{article} \usepackage{keyreader} % [KV]------\/ ...
2
votes
2answers
3k views

\newcommand gives errors in math mode (with or without arguments)

I'm trying to define a custom command for use in math mode, defined as \newcommand{\deriv2}[2]{\ensuremath{\frac{\partial^2 {#1}}{\partial {#2}^2}}} Other non-math mode \newcommands work in my ...
2
votes
1answer
220 views

Definining a new enviroment depending on a parameter

I want to create a new environment which depend if a parameter exists or not. The basic definition, which works fine, is: \newrgbcolor{bcolor}{1. 1. 1.}% \newenvironment{pbox} ...
0
votes
0answers
120 views

how to define a newcommand with several optional arguments? [duplicate]

Possible Duplicate: More than one optional argument for newcommand Is it easy to define a new command with several optional arguments, that one would call as follows : ...
8
votes
3answers
711 views

Optional arguments in pgfkeys?

I need an optional argument in a pgfkey? Something like the following: \pgfkeys{example/.code = (Argument: #2, optional argument: #1)} \pgfkeys{example=[other]{some}} should result in (Argument: ...
6
votes
3answers
542 views

Optional argument to an environment inside align

I have lots of matrices so I want to define a mat environment. I sometimes need the matrix to have right-aligned columns so I am using mathtools and I want to have an optional argument that is ...
9
votes
2answers
925 views

creating beamer themes with options

Is it possible to create beamer themes that take options? I have three themes that are essentially the same yet each beamertheme<name>.sty overrides certain aspects of the inner, outer and ...
4
votes
3answers
267 views

Own document variables with and without arguments

I use the following to introduce new document variables to my document. They should behave like \author or \title. So when they're used without parameter, they should print the corresponding variable. ...
3
votes
2answers
168 views

Command representing an expansion of a summation

I am very new to using LaTeX to write equation. And I am now learning how to create my own command. I am going to write a command \Listn to help me to do this: \Listn{\sumup}{(#1)}{+} $\sumup{n}$\\ ...
1
vote
4answers
119 views

Add a possibility for zero optional inputs to own command

Some very nice people here helped me write the code snippet below. And the code works great it prints out the correct subtext, and have a optional argument by typing * ...
5
votes
2answers
254 views

Putting a function into a new command with optional arguments

I know I have asked this before. But I just can not wrap my head around some things in LaTeX. Like the optional arguments. I have gotten some clues how to do it for comands, but not quite sure how to ...