Skip to main content

Questions tagged [arguments]

The {argument} tag is used for specific questions about macro parameters and arguments.

Filter by
Sorted by
Tagged with
0 votes
1 answer
25 views

New command optional arguments for sub, supra, and argument of an operator

I'm trying to specify a command that allows to display an operator, its evaluation at a certain argument, and add sub and supra indexes. That is, the commands \f \f{a} \f{a}{i} \f{a}{i}{j} Should ...
Aguazz's user avatar
  • 3
1 vote
1 answer
52 views

Expanding Variables to Input as Arguments for Macro

I have an issue when trying to use variables in a command (\ResearchModule). I read up to 8 lines from a text file and have them set to elements of an array (using code thanks to egreg!), with \...
MrOakPlanks's user avatar
0 votes
1 answer
53 views

Add a hook to the argument of a command based on its other arguments [closed]

Take \textcolor{#3}{#4} as a simple example. However, the actual command contains asterisked and optional arguments. If the argument #3 is green or blue, then \textcolor{#3}{#4} should produce ...
Inverted Pastry's user avatar
0 votes
1 answer
68 views

Getting the Maximum Width of a List of Items

I'm trying to write a command to get the maximum width of a (comma separated) list of items, for example \myLengthCommand{lorem,ipsum,lorem ipsum} should return the width of the text "lorem ipsum&...
Dave's user avatar
  • 317
4 votes
2 answers
173 views

Anonymous macro with #1 argument specifier

\def\foo#1{a#1b} creates \foo that expects for a mandatory argument when used. I'm trying to create so called "anonymous" or "lambda" macro that is essentially a token list with a ...
antshar's user avatar
  • 4,652
2 votes
1 answer
50 views

`already defined` error with scoped newcommand

I want to make it easier on myself to write large commands like this by "naming" the arguments. I did this: % Define the command for vector projection with named arguments \...
Boris Month's user avatar
0 votes
3 answers
74 views

Passing arguments to \cs_new_protected [closed]

I have a document command that uses names to set specific page widths and heights. Now I would like to have the capability of changing the left, right, top, and bottom values from the command. And ...
Bulldrive's user avatar
  • 161
3 votes
1 answer
45 views

Generate \charge arguments with a macro

I'm trying to use a macro to generate arguments that should be passed to \charge. I'm trying this: \documentclass{minimal} \usepackage{chemfig} \begin{document} \charge{-135:1pt=5}{C} \...
ttsc's user avatar
  • 415
1 vote
0 answers
31 views

Record the content of an environment as a property

I came up with this question since I saw copy and reuse the content of an environment and thought that this might be solved using ltproperties. I want to record the content of an environment as a ...
NemoYuan2008's user avatar
0 votes
1 answer
75 views

Printing by matching argument with a string

I want to 1) print Robert when the argument is not present, and 2) print Alice when the argument matches some string or print Robert when the argument does not match it. \documentclass[a4paper,10pt]{...
Veak's user avatar
  • 1
1 vote
1 answer
78 views

Defining a Set of Keys in Terms of Another Set of Keys

If I have 2 macros, one inside the other, while the top-most one has a bit more parameters, I would like to be able to set the top-most macro's keys as an extension of the bottom one, something ...
psygo's user avatar
  • 438
1 vote
2 answers
88 views

Is it possible to name macro (`\newcommand`) parameters and do math with them?

I'm new to creating commands in LaTeX, and I would like to do something like adding a more helpful name inside my command, as I do calculations with it; while also doing some math with said parameter. ...
psygo's user avatar
  • 438
2 votes
4 answers
349 views

Leaving blank arguments in a new command

If I am using this simple new command... \newcommand{\Lem}[3]{ \begin{lemma} {#1} \begin{itemize} \item{#2} \item{#3} \end{itemize} \end{lemma} } how can I use it if for example I only have one item ...
Paul A's user avatar
  • 1,117
3 votes
1 answer
111 views

"unexpected $ after $$" and "unclosed $$ found at $" errors with inline math inside display mode

I am trying to define a new command for different types of homomorphisms. The command is: \newcommand{\Hom}[2][]{% \operatorname{Hom}_{\textnormal{#1}}\left({#2}\right)% } The outputs of this ...
Lorenzo Carozzo's user avatar
3 votes
1 answer
53 views

ifmtarg testing a macro that is empty?

The following code works as expected: \NewDocumentCommand{\checker}{m}{\@ifmtarg{#1}{empty}{not empty}} \checker{} % Prints "empty" \checker{x} % Prints "not empty" However, how ...
Vincent's user avatar
  • 5,327
1 vote
1 answer
102 views

Use parameters as delimiters in \NewDocumentCommand

Using \NewDocumentCommand, it's possible to specify a delimited argument (e.g. r() for a required argument in parentheses). Is it possible to use other arguments in the same command as those ...
Gravitron's user avatar
7 votes
1 answer
172 views

#1# signature in macro definition

I'm reading the source code of xcolor and I'm a little bit confused about the following definition: \documentclass{article} \usepackage{xcolor} \makeatletter \def\testclr#1#{\@testclr{#1}} \def\@...
Stephen's user avatar
  • 4,524
0 votes
2 answers
74 views

Remove all instances of {} interior to argument to a command

Is it possible to remove all instances of {} which are passed as parts of an argument to a command? I would like to use the Tensor package with LyX. The problem is that LyX always puts subscripts ...
Mike Pugh's user avatar
  • 329
0 votes
0 answers
65 views

Runaway Argument Error [duplicate]

I got this error. Can someone please help me how to resolve this error? {This paper presents the hardened properties of a high-performance fi\ETC. ! File ended while scanning use of \field. <...
Sabanda Athauda's user avatar
4 votes
3 answers
203 views

Usage of comma separated arguments in a macro

I've defined a macro \mychapter having an argument which is a list of two comma separated arguments (Author and Title). The macro creates a \chapter and assigns the author and the title to a fancy ...
wolfrevo's user avatar
  • 523
0 votes
2 answers
54 views

Argument string that applies different code expressions based on the specified option

I want to pass an argument string to \NewDocumentCommand that allows me to apply different code expressions based on the specified option. For instance, consider a command named product with an ...
Veak's user avatar
  • 1
4 votes
4 answers
255 views

Using \input for command arguments

I'm making an rpg system. I want to separate the contents of the spell from the formatting of the spell to, for example, be able to format the spells differently for character sheets vs a dedicated ...
Amit's user avatar
  • 43
-1 votes
1 answer
72 views

Referring to arguments in newcommand not working in math mode [closed]

I would like to create a command given the arguments $g,n,d,X$, generates the output $\overline{M}_{g,n,d}(X)$. If no $g$ is given, I would like the default to be 0. What I thought was correct was to ...
Irit's user avatar
  • 1
0 votes
1 answer
88 views

Dependency of arguments

I would like to have a secondary environment named \defin that uses a parent environment, the latter taking three arguments. \defin will call \statement with a hard-wired first argument, the rest of ...
Veak's user avatar
  • 1
1 vote
1 answer
163 views

The argument specifier N and n

I am reading the documentation about Argument Specifiers in 1.1 Naming functions and variables of interfaces.pdf, where each argument is represented by a single letter. I am confused of the argument ...
Veak's user avatar
  • 1
1 vote
0 answers
38 views

Double subscript error on ${\tilde a_0}_0$? [duplicate]

${a_0}_0$ compiles fine: ${a_0}_0$ ${\tilde a_0}_0$ yields a "double subscript" error. Why is that and how can I fix it?
Andi Bauer's user avatar
14 votes
1 answer
682 views

TeX jargon - Difference between "argument" and "parameter" in TeX?

What's the difference between the term "parameter" and the term "argument" in TeX jargon? Are outermost enclosing pairs of matching curly braces of undelimited arguments to be ...
user avatar
6 votes
1 answer
116 views

How can I disable shadows (and similar preaction/postaction effects) in TikZ or PGF?

Is there a general way to disable preactions/postactions in TikZ on which effects such as shadows depend? If not, is there a straightforward way to enable users to add options to an existing style so ...
cfr's user avatar
  • 208k
4 votes
3 answers
409 views

Is there a way to add optional and/or named argument to command

I'm writing a handbook for my students and I want to create a command which should draw a task definition, its type and possible features, like source and link to the solution on YouTube. In my plan ...
Nikita Vasiliev's user avatar
3 votes
1 answer
42 views

Trying to modify multiaudience environment

I'm using the multiaudience package - works pretty nice. Here is an example \usepackage{multiaudience} \SetNewAudience{internGER} \SetNewAudience{externGER} \DefCurrentAudience{internGER} ... \begin{...
Georg's user avatar
  • 51
0 votes
1 answer
67 views

Is it possible to define commands that accept different argument types?

This is actually a more general question, but since a MWE is almost universally called for, consider David Carlisle's code \documentclass{article} \usepackage{fontspec} \usepackage{nopageno} \...
Mike Pugh's user avatar
  • 329
2 votes
2 answers
101 views

Tikz Calendar - how to pass argument with '\def'

Given the following code \documentclass[a4paper,20pt]{extarticle} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[czech]{babel} \usepackage[czech]{translator} \usepackage{graphicx, ...
JoudaBouda's user avatar
2 votes
1 answer
80 views

How to properly set optional boolean parameter for pic in tikz?

I try to draw beam on tikz with the possibility to hide its axis. I created the following: \documentclass{article} \usepackage{tikz} \usetikzlibrary{math, shadings} \usepackage{ifthen} \tikzset{ ...
Sindzicat's user avatar
  • 143
1 vote
1 answer
57 views

Use of \readrecordarray with macro arguments [closed]

I'm trying to use readarray package to load several multi-line files with \readrecordarray command for the next processing. Due to processing of several files \readrecordarray is used in a command ...
Andrii's user avatar
  • 11
1 vote
1 answer
71 views

Macro without arguments to define macro with arguments

I'm trying to use xparse and generic TeX/LaTeX commands to write a macro (that takes no arguments) to define another macro that does take arguments: \documentclass{minimal} \RequirePackage{xparse,...
Ben Zelnick's user avatar
2 votes
2 answers
74 views

Early expansion of \newcommand or another macro-like statement

I would like to store a list of arguments within \newcommand, \def or any other macro. Such a list would then be passed to another command. However, it turns out that the list in question is treated ...
scriptfoo's user avatar
  • 283
6 votes
2 answers
116 views

\NewDocumentCommand: Mandatory types r / R and their “default values”

The documentation of xparse states (emphasis mine): r Given as r⟨token1⟩⟨token2⟩, this denotes a “required” delimited argument, where the delimiters are ⟨token1⟩ and ⟨token2⟩. If the opening ...
O'Neil's user avatar
  • 209
2 votes
4 answers
882 views

What are some examples of LaTeX commands which accept three or more arguments?

The \binom command is an example of a LaTeX command which accepts two inputs. We have the following example: \binom{n+1}{2k} What is an example of a LaTeX command with three or more parameters?
IdleCustard's user avatar
  • 1,260
2 votes
1 answer
90 views

Command that creates new command based on argument

I want to have a command called \ensureinfocommand that can be called like this: \ensureinfocommand{studentid} This call will check if the command \studentid already exists and if not, it should ...
Luke's user avatar
  • 159
0 votes
0 answers
59 views

How can I highlight certain argument fields

I have this environment with 9 arguments. I want to highlight some of the inputs of the argument (#1). Is it possible to do so? \documentclass{article} \usepackage[margin=1in, a4paper]{geometry} \...
Fahad's user avatar
  • 43
0 votes
0 answers
127 views

Is there a way to remove specific characters from argument of a macro?

Suppose we have a macro saying, \NewDocumentCommand\foo{m}{#1} When it eats an argument, I want it to print whatever is in the argument without specific characters. For instance, I want to remove ...
Gau-Syu's user avatar
  • 473
2 votes
3 answers
189 views

LaTeX3 keyval forwarding

Say I want to write a command igtest, which works identically as \includegraphics from graphicx, except that if the page number is given, e.g. \igtest[page=5]{someimg}, then the page number is ...
Yijun Yuan's user avatar
1 vote
1 answer
120 views

\NewDocumentCommand embellishments/tokens syntax

Edited: David Carlisle kindly provided the answer in a comment, which is the definition after \makeatletter. I'm trying to use embellishments in \NewDocumentCommand to define a macro to kern ...
John Bourke's user avatar
1 vote
1 answer
77 views

Can you not pass argments to commands using keys?

I use my own LaTeX preamble for university, so I am fairly used to creating macros using tools such as xparse. However, I am unsure why I cannot do something that will choose between two images on my ...
TimeTravelPenguin's user avatar
0 votes
1 answer
22 views

Can't pass argument to second part of newenvironment [duplicate]

This code works: \documentclass{book} \newenvironment{testenvironment}[1][] {\begin{quote}#1} {\end{quote}} \begin{document} \begin{testenvironment}[testargument] test text \end{...
Steeven's user avatar
  • 1,427
2 votes
2 answers
280 views

Passing Boolean as Arg to a command

\usepackage{ifthen} %booleandeclaration \newboolean{istest} \setboolean{istest}{false} %Set boolean in if % \newcommand{\activate}[1]{% % \ifnum#1>0{\setboolean{istest}{true}}\fi } \newcommand{\...
d4rkshad0w's user avatar
2 votes
1 answer
147 views

How does tabularray's 'cmd' key work?

A demonstration of the issue by way of a minimal working example I saved the following LaTeX code in ~/Test.tex. \documentclass{article} \usepackage{tabularray} \begin{document} \begin{tblr}{column{2}=...
Evan Aad's user avatar
  • 11.1k
0 votes
2 answers
42 views

Concatenating macro parameter and string adds unwanted space [closed]

I wanted do define a simple macro like the following: \newcommand{\testcommand}[1]{ \includegraphics[]{pictures/#1.jpeg} } But this does not work because it adds a space between the argument #1 ...
Pa Dalton's user avatar
1 vote
2 answers
111 views

Creating "static" arguments in a string

Is there a trick to integrate arguments "statically" in a given string, to use this string in another command that will then process the argument ? Something like : \edef\mystring{Hello #1 !...
Jean-Louis Brabant's user avatar
2 votes
2 answers
221 views

Simplify arithmetics +-, -+, --, 1x, -1x

I made some command \pcoef and \mcoef that simplifies +- and -+ to -, and -- to + in arithmetic expressions, and a \coef that simplifies 1x and -1x to x and -x respectively. They are not really ...
mathteacher's user avatar

1
2 3 4 5
7