{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

4
votes
2answers
362 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 ...
12
votes
1answer
410 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} ...
1
vote
1answer
490 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
366 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
126 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
258 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
292 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
570 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
170 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
3k 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 ...
5
votes
2answers
274 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
1k 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 ...
7
votes
3answers
554 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] ...
15
votes
2answers
2k 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 ...
10
votes
3answers
777 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 ...
6
votes
1answer
3k 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][]{ ...
15
votes
3answers
9k 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 ...
3
votes
1answer
7k 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 ...
13
votes
4answers
3k 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
502 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
436 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
44 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
4k 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
240 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
128 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 : ...
9
votes
3answers
778 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
691 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 ...
10
votes
2answers
1k 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
310 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
183 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
123 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
286 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 ...
3
votes
2answers
365 views

Sections with optional counting arguments

I am back for more... =) I am actually trying to fix my own problems, and i feel i learn so much here. Thank you so much for helpin someone as clueless as me ^^ I am attempting to make a text, with a ...
47
votes
5answers
8k views

More than one optional argument for newcommand

The \newcommand macro allows to use an optional argument for the first parameter #1 with: \newcommand{\mycommand}[3][defaultfor1]{blah blah blah} Is it possible to have more than one option with ...
5
votes
1answer
649 views

How to expand several arguments in an environment?

I have an environment that I've defined as follows: \newenvironment{regularEnumerateEx}[2][0em] {begin{listSkeleton}[#1]{enumerate}{#2}} {\end{listSkeleton}} The problem is that I need to ...
24
votes
3answers
2k views

How can I use \patchcmd with commands with optional arguments?

This question led to a new package: xpatch This is likely a simple question, but I'm getting stuck on the small details. I have an internal command, defined by a package as ...
4
votes
1answer
123 views

Where to look up argument for a function in TikZ?

For instance, (q_5) edge [loop above] node {a} (q_5) This is Automaton package, the one I want to look up is [loop above], I want to know what other options can I put in ...
7
votes
3answers
3k views

How to redefine the caption command with optional arguments

I'm writing a thesis that has double spacing on by default throughout the document. However, captions on figures need to be singlepaced. I can do that like this \normalsize \singlespace \caption{ ...
10
votes
3answers
3k views

Citing inside theorem header

How do I create something like this without getting any errors? \begin{thm}[\cite[page 10]{ABC2011}] ... \end{thm} I tried putting various things into {...} brackets, but not eliminating any ...
11
votes
1answer
2k views

Cite in theorem environment argument

When I try to cite a book in such a way \begin{theorem}[\cite[p.~90]{bibitem}] Theorem body. \end{theorem} I've got an error because of multiple use of [ and ]. Is it possible to cite in such a way ...
17
votes
1answer
2k views

Define same command with different amount of parameters

I want to define two versions of the command \Set, depending if I provide one or two parameters. I.e. like this: \newcommand{\Set}[1]{\bigl\{ #1 \bigr\}} \newcommand{\Set}[2]{\bigl\{ #1 \bigm| #2 ...
28
votes
1answer
3k views

How can I make a package that accepts an optional argument?

I am writing a package that has a bunch of values that are going to be the same most of the time, but that I might want to change in select cases. I want to do this by giving this package an optional ...
13
votes
2answers
2k views

How do you define your environment such as to use […] for some parameter(s)?

In an environment, say \newenvironment{whatever}[3]{...}{...} you instantiante it (if that's the word for it in LaTeX) by \begin{whatever}{first}{second}{third} ... \end{whatever} But how do ...
13
votes
2answers
5k views

A macro with either one or two arguments

I am trying to define a macro with variable number of arguments. For example I want to define a macro with two arguments that can work with one argument as well. So the same macro works in two ways. ...
11
votes
3answers
1k views

How to pass an optional argument to an environment with verbatim content?

This is an attempt to make clear what happened in this question of xport (now deleted, sorry). The now deleted question included code that tried to make my answer to this question of xport work for ...
21
votes
2answers
6k views

Escaping square braces

I want to use some text as the optional parameter to some command. The text includes square braces ([ and ]), but since the optional parameter goes within square brackets, unexpected things happen. ...
17
votes
2answers
320 views

Why do some commands use []s, some use {}s, and some use both?

I find it confusing to remember which commands take {} arguments, and which ones take [] arguments. Is there a rule-of-thumb or semantic difference between these two? If so, what? (Because they seem ...
5
votes
1answer
707 views

Can BibTeX ignore optional arguments?

Is it possible to get BibTeX to ignore certain optional arguments? For example, if the .bib file has many entries with language = {English}, and you wish for a certain file's bibliography to not say ...
26
votes
5answers
1k views

How can I use one argument as the default value for another?

I'd like to define a command that takes 1, 2 or 3 arguments, and where the 2nd gets the same value as the 1st if it is not defined. I tried \newcommand\codefrom[3][#1][Matlab]{ ... } but I get an ...