Questions tagged [arguments]
The {argument} tag is used for specific questions about macro parameters and arguments.
302
questions
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 \...
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 ...
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&...
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 ...
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
\...
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 ...
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}
\...
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 ...
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]{...
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 ...
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. ...
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 ...
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 ...
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 ...
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 ...