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
1answer
55 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 \\ ...
1
vote
0answers
29 views

Ignore specific lines when numbering lines - how to do it?

This may also be a potentially trivial question, but did not find the answer. Answers relate to other packages. ... \usepackage{lineno} ... \begin{linenumbers} \begin{verbatim} A B C \end{...
1
vote
1answer
39 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
1answer
40 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
36 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
50 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
23 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
35 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
74 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
46 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
33 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
194 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
103 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
46 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 ...
0
votes
1answer
53 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
208 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
68 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
19 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
64 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
50 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
225 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
53 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
83 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 ...
3
votes
2answers
198 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 ...
3
votes
1answer
60 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
1answer
66 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): ...
4
votes
1answer
206 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
219 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
71 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
46 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
45 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? ...
10
votes
3answers
447 views

\newcommand: Using one parameter as the default for the other

I would like to define a macro that takes two arguments, one of which is optional. If it is not given, then it should take the other one as default value. Unfortunately, \newcommand{\mycommand}[2][#...
0
votes
0answers
30 views

How to pass argument for `\includegraphics[width=..]..` without causing “Runaway argument?”? [duplicate]

I'm going to despair: It seems nobody has a problem when passing an argument for the width of \includegraphics, but I always get Runaway argument?. Whenever I remove the [#2\textwidth] from my command ...
10
votes
2answers
568 views

Euler and minus sign

I'm trying to define a macro to typeset Eulers complex e-power with or without a minus sign in its argument. I would like the macro to automatically detect if its argument starts with a -. I have the ...
16
votes
2answers
820 views

Why do people specify date as an option for \usepackage?

In LaTeX code written by other people, I sometimes see a date specified as an optional argument for \usepackage: \usepackage{iftex}[2013/04/04] Intuition tells me that this is some way to ensure ...
0
votes
0answers
50 views

Using optional argument in closing statement of new environment

The answer 969/29410 showed that it is possible to use optional arguments in environment definitions: \documentclass{article} \newenvironment{hello}[1][world]{\noindent Hello #1, }{Bye now!\\} \begin{...
0
votes
1answer
41 views

Creating a custom definition environment, with an optional argument and non default punctuation

This seems like it should be the most basic question, but I can't find a comprehensible answer on the site, I'm afraid. I'm trying to define a definition environment that 1) replaces the ...
2
votes
3answers
160 views

Different behavior if no arguments

This is similar, but not a duplicate of Special behavior if optional argument is not passed and Different macro behavior when supplied an argument. I want to define a macro \XXX such that \XXX{1} and ...
2
votes
1answer
80 views

Command defined with \NewDocumentCommand and specifiers {O{strict} m} not receiving all of the mandatory parameter

I defined a command using \NewDocumentCommand with specifiers {O{strict} m}. I expected #1 to default to strict when calling the command with only a parameter enclosed in {}, and to pick up all of the ...
1
vote
1answer
68 views

Pass option to each occurence of command (especially \printbibliography with biblatex)

In a large book with many sub-bibliographies, I want to ensure that crucial bibchecks are executed at every call to \printbibliography. Normally, one would simply call \printbibliography[check=...] ...
6
votes
1answer
132 views

Fail to pass arguments to orbital module of chemmacros when used inside chemfig

While illustrating atomic orbitals for 1,3-butadiene guided by examples in chemmacros' manual, I receive the following error: Argument of \orbital has an extra }. } MWE: \documentclass{article} \...
1
vote
2answers
61 views

Arrival atom numbering doesn't work with \chemabove

Consider the following MWE: \documentclass{article} \usepackage{chemfig} \begin{document} \chemfig{ X -[:30,,,2]^{18}\chemabove{O}{H} -[:-30]X } \end{document} This code returns an ...
0
votes
1answer
68 views

Using command with optional arguments inside tikzcd arrows

I have defined a command for the jacobian matrix, such as follows \newcommand{\Jacobian}[2][]{\operatorname{J}_{#1}{#2}} The problem comes if I try to use it inside a tikzcd arrow, probably because ...
2
votes
1answer
28 views

How to correctly convert size passed as argument to an environment?

I am trying and failing to adapt diagrams-latex.sty to do what I want. It takes optional parameters width and height that are passed on to an external script, but wants them as a dimensionless value ...
1
vote
1answer
113 views

How do I draw an optionally colored circle/square/ellipse around a symbol

In this thread, @HenriMenke showed how to put a circle around a symbol. It's easy to modify his code to color the circle, see below, but I don't understand how to make the color an optional ...
8
votes
2answers
213 views

How to define a comma separated list of arguments for includegraphics

I have a large set of pictures, and I want to apply predefined settings to each using the optional argument of the \includegraphics macro from the graphicx package. I would like to define the ...
1
vote
1answer
269 views

Add optional argument to new environment template

I'm attempting to create two new environments, one for writing exercises and another for its solutions, with the following characteristics: The Exercise environment should have: By default, have no ...
0
votes
2answers
196 views

AUCTeX prompting for optional arguments

My general question: is there a way to get AUCTeX to prompt me automatically for an optional argument of a command when I invoke it with TeX-insert-macro (i.e. C-cRET)? (like it does when you invoke, ...
1
vote
1answer
125 views

LaTeX Grammar and Nesting Rule

Is there any grammar and rule describing the allowed nestings and combinations and the allowed format of the arguments in LaTeX? E.g. \section{\verb|mySec|} \section{\begin{huge}mySec\end{huge}} \...

1 2 3 4 5 8