Questions tagged [optional-arguments]

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

Filter by
Sorted by
Tagged with
0
votes
2answers
44 views

How to redefine a product command to add an optional argument?

I would like to redefine the product commands (\times, \cdot, \otimes, \wedge, \odot) to add an optional negative spacing argument, but I don't know how to do this in a proper way. I need the new \...
2
votes
1answer
55 views

Changing \newcommand to have optional argument breaks command

Simply put, I have a command defined for an edge when using the tikzpicture environment. Command: \newcommand{\bendangleundiredgenodes}[6]{(#3) edge [-] [bend #2=#1] node [#5] {#6} (#4)} Usage: \...
3
votes
3answers
122 views

Keeping default optional argument when adding to command

TeX FAQ's "Patching existing commands" gives a method to add to existing commands that have an optional argument: \documentclass{article} \usepackage{letltxmacro} \newcommand{\rough}[2][\...
2
votes
1answer
26 views

Empty command with one optional argument after an equation causes an extra horizontal indentation

Consider the following minimal example: \documentclass{minimal} \newcommand{\CMDI}[1]{} \newcommand{\CMDII}[2][]{} \begin{document} \begin{equation} 3.14 \end{equation} \CMDII[...
2
votes
2answers
29 views

Omit punctuation after optional argument in glossary

I'm building a glossary of German Mathematics terms. I would like to omit the comma after the optional argument #2 when #2 is empty. I tested \IfNoValueF and \IfNoValueTF. They work perfectly without \...
0
votes
1answer
20 views

Adding an argument to \part macro

I want to be able to call the part macro like this: \part{Introdução Geral}{(2015)} Having the year as a kind of subtitle. I can call: \part{Introdução Geral\\\\ \Large(2015)} But this applies the ...
1
vote
1answer
40 views

What is the correct syntax for a macro with >1 parameter where 2nd etc have defaults but not the 1st?

The document that I am working with has a macro with 1 parameter: \newcommand{\emailTo}[1]{The email address that #1 is sent to.} I have to add another parameter with a default value of email address ...
0
votes
0answers
34 views

Issue involving bookmarks and newcommand with optional argument

Why results of an optional argument don't appear at bookmarks? I was writing a text using some commands to insert formatted text. At some moment I added an optional argument and then I realized that ...
0
votes
2answers
36 views

can't pass optional arguments to a \newenvironment using fancyvrb

I am trying to define a new script environment built on fancyvrb's Verbatim environment. Preamble: \usepackage{fancyvrb} \newenvironment{script}[1][firstnumber=1] {\VerbatimEnvironment\...
6
votes
5answers
518 views

Add optional argument to newcommand for integration dx

In my preamble I use \newcommand\dx{\,dx}so that I can change formatting of all instances if it is needed. What I would really like is to add an optional argument so that I can type \dx whenever I ...
1
vote
3answers
75 views

TikZ - foreach, expansion problem, optional argument and node

I am trying to use foreach to simplify the 1st env. code in my MN(ot)WE below. There is an expansion problem regarding the optional argument in the 2nd code. Here is the output. How can I fix this ? \...
1
vote
1answer
83 views

Problem in definition of newcommand with optional argument

I'm trying to define a newcommand in a .cls file as follows: \newcommand{\test}[2][]{% \ifthenelse{\isempty{#1}}% {\raggedright\itshape{#2}}% {\raggedright#1 \hfill \itshape{#2}}% } ...
4
votes
1answer
61 views

How to include an obligatory argument in the definition of a default optional argument?

I want to implement something with the same structure as the next command: \documentclass{article} \usepackage{xargs} \providecommandx*{\countryinfo}[4][{3=undefined},{4=In #2 people like drinking #1....
2
votes
1answer
21 views

Optional savebox with options

I'm working on a modified version of the report.cls for internal documents that might have a standard disclaimer text included. Ideally, I'd like to have something like \disclaimer{some category}{...
4
votes
2answers
77 views

Problem with newcommand and the optional argument

I want to have a command that does the following: \documentclass[a4paper]{letter} \newcommand{\stuffing}[2][]{\ensuremath{W_{\mathtt{#2}}^{^{\left[#1\right]}}}} \begin{document} what I want: $W_\...
0
votes
1answer
26 views

pgfkeys: Read one key and ignore the others

In my own command \includegraphicsextended I want to add a caption to the pdf page containing File [filename] Page [pagenumber] therefore from the keys in %1 I want to just read the page=... key ...
0
votes
2answers
73 views

Command with optional argument in parentheses and subscript

I'd like to have a shorthand command for math that accepts an optional argument which gets put into parentheses if it exists and where the operator also optionally has a subscript. How can I position ...
5
votes
1answer
47 views

optional argument breaks multicolumn

If you are using a command to append a multiline to a tabular, it will stop working if the command has optional arguments. It will work without them: \documentclass{standalone} \newcommand{\mwe}[2][1]...
1
vote
2answers
61 views

Can you pass no optional argument to a command inside a command?

Is there any way to pass no value for the optional argument of a command called in another command, instead of passing an empty argument ? I've compiled my code to better explain my issue. \...
1
vote
1answer
59 views

New environment issues arguments xargs.Missing Number and Illegal unit of measure

I'm trying to make a general environment for delineating sections of math with indented bodies, (proofs, definitions, etc). I found that using the 'adjustwidth' environment in the 'changepage' ...
1
vote
1answer
67 views

Optional argument in a tikz environment

I use the following resizedtikzpicture environment in order to rescale my tikzpictures. Would it be possible to add an optional argument, taking into account the tikz option? For example the color or ...
1
vote
1answer
33 views

Redefine \citet command (two optional arguments case)

I need to redefine "\citet" command to have its output printed in red. I did: \let\oldcitet\citet \renewcommand*\citet[2][]{{\color{red}\oldcitet[#1]{#2}}} that works for the "one optional argument" ...
2
votes
1answer
42 views

Custom argument specification: Defaults of '\Foo' have circular dependency

I have a command, \Baz, that takes one optional argument which must be inline code. It relies on an external variable to store the default inline code (1). As standalone it works, but it does not meet ...
2
votes
2answers
79 views

Is there a way to use < and > as delimiters to optional command or environment parameters?

Say I want to define an environment like "color description" which would be the same as "description" except that one could add an optional color background to the label: \begin{colordescription}[red] ...
0
votes
0answers
25 views

position of optional arguments

\documentclass[a4paper]{article} \usepackage{amsmath} \newcommand*{\price}[2][17.5]{\pounds #2 excl VAT @ #1\%} \begin{document} \setlength{\parindent}{0pt} \price{100} \\ \price[20]{30} \end{...
2
votes
1answer
40 views

How to allow optional e-type arguments in the middle?

For example, if I want to define a command produces functions with given name, I use the following code: \NewDocumentCommand \fun { m e{\sp\sb} O{} } { \operatorname{\mathrm{#1}} \...
0
votes
1answer
95 views

Make a \newcommand argument optional without consequence

I have this code block in my .cls file - \newcommand{\ExperienceEntry}[5]{ \noindent\makebox[\width][l]{#1} \hfill \makebox[\width][l]{#2} \\ \noindent\makebox[\width][l]{#3} \hfill \\ ...
4
votes
3answers
303 views

Ignore specific lines when numbering lines

This may also be a potentially trivial question, but did not find the answer. Edit: It may be nontrivial... ... \usepackage{lineno} ... \begin{linenumbers} \begin{verbatim} A B C \end{verbatim} ...
1
vote
1answer
216 views

Set new filecontents-environment to overwrite globally

I recently updated my LaTeX-Distribution and found out afterwards that the filecontents and ltxtable combination was broken. Only one table was loaded multiple times in my document. Afterwards I found ...
0
votes
2answers
67 views

Defining a new environment that utilizes the optional package inside

I have been using the optional package in order to conveniently create solutions in the same document. I had been writing solutions longhand by placing it inside: \opt{optS}{\color{blue} \textbf{...
2
votes
1answer
219 views

Defining optional arguments for `\newtcolorbox`

\documentclass[12pt,a4paper]{ctexart} \ctexset{ section = { name = {Week}, number = {~\arabic{section}} } } \usepackage{amsmath,enumerate} \usepackage[top=2cm,left=1cm,right=...
0
votes
1answer
129 views

Why isn't “.style n args” working in my TikZ pic?

I suspect there's something simple and obvious that I'm missing, but honestly, it's not for lack of trying :-) I've created a pic that draws a small Hasse diagram. I've even succeeded in giving it ...
2
votes
2answers
27 views

subtitleabovelinecolor option not taken into account

I'm using the mdframed package to draw a theorem command. However, the option subtitleabovelinecolor of the subtitle frame is not taken into account, while the command subtitleabovelinewidth is. ...
0
votes
1answer
135 views

Beamer frametitle: increase spacing for multi-lined titles

I am using a custom beamer theme and I am having an issue with long frametitles which occupy multiple lines. In that case, the title slides upwards, but I would prefer that it uses the space downwards:...
2
votes
3answers
94 views

TikZ: \foreach within Bracketed Arguments

I am trying to efficiently draw two concentric ellipses with four equally spaced dots at the cardinal directions using TikZ. Currently, I have the following code which generates the following image. \...
1
vote
1answer
47 views

Define optional distances to use with `to path` of TikZ

I would like in the code below to have the possibility to give optional arguments for the shift distances. What is the best way to do that ? \documentclass[12pt]{article} \usepackage{tikz} \...
1
vote
1answer
59 views

using commands in optional parameters

If I define a new command like \newcommand{\command}{htb} why can't I use this command to set for example the float options of an figure enviroment? \begin{figure}[\command] \centering \[ f(...
6
votes
2answers
372 views

Looseness for Bezier controls. Or how to bend in circularly symmetric tikz-drawings (without bend left, etc.)

If I want to draw a something with circular symmetry, e.g joining pair of points by arcs as shown in the picture with only two, I face the problem of not being able to use the edge bending. This is ...
4
votes
3answers
215 views

Optional Arguments Based on Position

We all know how \newtheorem works. It takes a third optional argument and it matters where you put it: \newtheorem{lem}[thm]{Lemma} is different to \newtheorem{lem}{Lemma}[thm] I'm getting into ...
1
vote
0answers
58 views

Conditional compilation within documentclass option?

This works fine and produces letter-size PDF. \documentclass{article} \usepackage[\ifdefined\afive a5paper \fi]{geometry} \begin{document} Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed ...
1
vote
2answers
114 views

Issue passing arguments to a LaTex file

I am trying to use the suggested answer to passing arguments to a LaTeX document, posted here as solution#Three. I am passing the argument as follows in my Windows Command Prompt: C:\Users\afp\...
2
votes
1answer
231 views

Expand keyval into TikZ's node optional argument

I am willing to create matrix-like nodes, so I implemented a draft function \DrawMatrixx below. Also, I have general style for nodes called Matrixx/body for matrix, or body, itself and for dimensions,...
2
votes
2answers
132 views

How to undefine a command with arguments?

I am trying to define \d as \delta in mathmode, but apparently \d is defined as a dot below and it needs an argument: \d{a} would give an a with a dot below. How can I do this? Here are the packages I ...
0
votes
0answers
25 views

How to use equation containing “]” in optional argument? [duplicate]

When I try to use a command like \begin{theorem}[Something $x[y]$ something], I get an "extra } or forgotten $ error message". It seems like the ] in the equation is closing the optional argument even ...
3
votes
1answer
85 views

Mysterious horizontal space when using conditional macro

In order to deal with both burdensome expressions $K$-vector space and $K$-vector space $E$ at once, and this in both text and math mode alike, I defined a fine working shortcut taking two arguments, ...
1
vote
1answer
78 views

How to maintain several versions of a document in a single LaTeX file?

I want to maintain several versions of my CV in a single LaTeX file, for example: version "period1": from 2014 to 2016 version "period2": from 2017 to 2019 version "all": from 2014 to 2019 Until now ...
3
votes
1answer
1k views

How to pass parameters to \tikzstyle?

I am using multipart shapes to create two-sided nodes and want to change the background color of the left node based on a user-provided (color) parameter. Changing the default parameter at \tikzstyle{...
19
votes
2answers
2k views

Are all commands with an optional argument fragile?

Here is a discussion of fragile command in LaTeX. And it says that any commands that have an optional argument are fragile, for instance \footnote[2]{myfoottext} and \footnot{myotherfoottext}. I have ...
1
vote
1answer
64 views

Conditionally set bibliography title

I am writing a class and would like to offer the option of changing the bibliography title as a class option. If no title was given I would like to just use the default one. Unfortunately I can't seem ...
3
votes
3answers
96 views

Allow Optional Delimited Params To Appear In Any Order (EASILY) (e.g. \REset[s](X){e}=\REset(X)[s]{e})

My package rec-thy has a number of macros that allow the optional specification of both a stage (as part of a stagewise approximation) as well as a relativization. I've adopted the convention that ...

1
2 3 4 5
8