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
32 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
499 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
66 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
70 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
60 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
70 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
24 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
49 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
42 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
41 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
60 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
30 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
38 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
76 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
24 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
38 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
76 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
233 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
126 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
61 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
143 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
91 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
81 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
90 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
51 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
282 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
164 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
52 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
93 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
225 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
111 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
22 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
80 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
72 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 ...
2
votes
1answer
754 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
60 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 ...
4
votes
2answers
389 views

Passing optional arguments to \printbibliography as variables

title and keyword are optional arguments to the Biblatex command, printbibliography. Is it possible to pass a title and keyword as variables to printbibliography? The use case is the production of a ...
4
votes
1answer
98 views

How to specify language dialect in \lstline option?

First, here is some code that works fine: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \begin{document} \lstinline[language=algol,keywordstyle=\color{blue}]{int a} \end{document} ...
0
votes
2answers
115 views

Defining a custom environment with tabularx

I use this code: \begin{tabularx}{\textwidth}{c|X} \emph{17:49} & Very long text... \end{tabularx} to get this (I want to use LaTeX to keep a personal diary and notes should look like that): ...
5
votes
1answer
234 views

Avoid passing an empty [optional argument] an environment (with verbatim content) using xparse?

this query is related to How to pass an optional argument to an environment with verbatim content? (whose solution did not work in my case) and with Emulating @ifnextchar in expl3 (which is the one I'...
5
votes
2answers
239 views

Use second argument for optional first argument if not provided in macro

I'm trying to construct a command with one optional and one mandatory argument and I'd like the default if the optional argument is not provided to be #2. Why does this not work? (error: Illegal ...
0
votes
0answers
179 views

Add multiple arguments to figure

I am placing a figure in my document using the following code: \begin{figure}[H] \centering \includegraphics{AlgorithmFlow.png} \caption{Caption} \label{fig:myLabel} \end{figure} I ...
0
votes
2answers
74 views

How to detect whether the option citecounter was enabled on biblatex?

I think this is the definition of the citecounter option on the biblatex package: \DeclareBibliographyOption[boolean]{citecounter}[true]{% \ifcsdef{blx@opt@citecounter@#1} {\csuse{blx@opt@...
1
vote
1answer
62 views

How to detect whether \PassOptionsToPackage was already called?

If I call: \PassOptionsToPackage{backend=biber,style=numeric,backref=false}{biblatex} % And later someone else call again \PassOptionsToPackage{style=abnt,backend=biber}{biblatex} What will happen? ...

1
2 3 4 5
8