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
43 views

Expanding command with optional arguments: \edef

I have defined a LaTeX command with an optional argument, e.g., \newcommand*{\commA}[1][opt]{A#1}, and I cannot get it to be part of an expanded command defintion with \edef, e.g., \edef\expcom{\commA}...
1
vote
1answer
49 views

Macro with optional parameter returning calculated length

I'm trying to define a macro returning a calculated length, but making the parameter optional breaks the macro (error Missing number, treated as zero.): \documentclass{article} \usepackage{xfp} \...
3
votes
3answers
54 views

Using Starred Version as Optional Argument

I have been reading this page on defining commands with *-options. I have got completely stuck, though. I'd like the following. A command with an optional argument and a star option. Optional ...
1
vote
0answers
22 views

Behavior of environment with optional argument changes when optional argument is not passed

Recently, when I've been working with environments with an optional argument, I've noticed that the behavior changes when I introduce a set of square braces, even when there is nothing inside them. ...
1
vote
1answer
34 views

Multiple optional arguments with tcolorbox

I would like to produce boxes from tcolorbox which can take two optional arguments, but I'm not sure where to start with. Here is my current MWE : \documentclass{article} \usepackage[utf8]{inputenc} \...
8
votes
1answer
86 views

xparse's 's' argument returns \Gamma and \Delta, instead of \BooleanFalse and \BooleanTrue

The xparse documentation says, But that's not what I get when I test s. \documentclass{article} \usepackage{xparse} \NewDocumentCommand{\myfunc}{s}{#1} \begin{document} \myfunc % should return \...
2
votes
1answer
37 views

Change multicolumn column spec with a star command

I am trying to make a macro that will wrap the column specification of a \multicolumn command with @{} if a * is passed to my macro. I can achieve the behaviour I want in the first definition below, ...
1
vote
1answer
27 views

Custom proof environment preserving optional argument

I basically want to obtain the result (replace Proof -> Solution, and mdframed around the environemnt) simply by the code: \begin{solution} Set Theory Best Theory. \begin{align*} 2 =...
1
vote
1answer
77 views

Any reference and tutorial on writing .cls file class?

I was trying to re-edit the report.cls file to adapt to our institution thesis presentation format. I was stuck at declaring and executing options,also with error flag on xcolor file execution. Having ...
2
votes
2answers
45 views

\newtcblisting with multiple optional arguments and defaults

I have a custom environment for code like this (it is a modified version of the code here): \documentclass[12pt,a4paper]{report} \usepackage[many]{tcolorbox} \tcbuselibrary{minted,skins} \definecolor{...
2
votes
1answer
47 views

How to use optional arguments of the original commands in a macro?

I'd like to use sectioning commands inside macros in order to enhance them, i.e. put some kind of line before and thing after the heading. Is it possible to use/address the optional arguments of the ...
0
votes
2answers
59 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
57 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
156 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
28 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
30 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
22 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 ...
2
votes
3answers
75 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
38 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
47 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
546 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
83 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
104 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}}% } ...
5
votes
1answer
66 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
22 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
78 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_\...
1
vote
1answer
29 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
91 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
50 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
64 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
81 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
69 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
36 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
43 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
80 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
100 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
379 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
372 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
77 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
283 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
165 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
30 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
221 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
102 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
68 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
552 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
268 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
2 3 4 5
8