Questions tagged [arguments]

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

Filter by
Sorted by
Tagged with
11
votes
4answers
876 views

Using the compulsory argument for the optional argument?

I am trying to define a command that takes two arguments, where one is optional. If the optional argument isn't given I would like the compulsory argument to be used for the optional argument. For ...
7
votes
2answers
365 views

Handling _ (underscores) in a macro's comma-separated list of arguments

Context: I created a "\citep-like" macro. I use it in the body of my document to refer to some code found in appendix. My macro takes a comma-separated list as input, and prints each element of the ...
5
votes
2answers
770 views

Remove extra curly braces

In this MWE, I demonstrate my problem: \documentclass{article} \usepackage{seqsplit} \newcommand{\dosomething}[1]{\uppercase{#1}} \newcommand{\dosomethingelse}[1]{\seqsplit{#1}} \begin{document} \...
2
votes
1answer
345 views

Referring to delimiter separated arguments in new commands

Another question gave me hope that there is an elegant way (without using additional packages) to refer to a comma separated argument in \newcommand, maybe something like (just a guess, not tested): \...
5
votes
2answers
173 views

Reading the arguments of my command and using them in the command

My question is about reading and using the arguments of a custom created command using \def. Let's say I have the command \mytestcommand and I want to read and use it's arguments (optional and ...
5
votes
2answers
198 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 ...
7
votes
3answers
272 views

How to test if argument is a single space?

I am currently writing a document, that sometimes requires me to alternate the colors of the letters in a sentence. I thought it would be easy to find a way to create a macro that does that, but I've ...
2
votes
2answers
75 views

Probably just another gdef-expansion problem

In continuation of the post, I try to make the following (simplified) code to work. \timedelta uses 2 arguments. Using a \gdef as the first argument is Ok. Using a \gdef as the second argument is Nok....
5
votes
2answers
151 views

Plain LuaTeX: Detecting if displaymath is ended by $$ or \Ustopdisplaymath

In the TeX Book (chapter dirty tricks) there is mentioned a way to left align displaymaths. https://arxiv.org/macros/cp-aa.tex A macro \displaysetup whose argument is delimited by $$ is used. So it ...
5
votes
3answers
733 views

Variable number of arguments in a command

Code \documentclass{article} \newcommand*\test[2]{#1\textsuperscript{#2}} \begin{document} The player ended as no.~\test{1}{} and her friend came in \test{2}{nd}. \end{document} Output Question ...
5
votes
1answer
1k views

Several arguments in tikzset pic

I want to pass more than one argument to a pic defined with \tikzset. I tried this and it works: \tikzset{ Piece/.pic={ \draw (0:1) -- (120:1) -- (240:1) -- cycle; \draw (0,0) ...
3
votes
2answers
135 views

how to expand a keyval argument

I'm trying to expand a value for an argument which will be the range of pages included in the document, but I can't figure out how to do that. At first, I was getting ERROR: Missing = inserted ...
2
votes
0answers
207 views

change or patch a command using parameters

Assume I want to use a command \foo from some package takes a number of arguments, let's say #1 to #5. I want to change the behavior of \foo in ways that might involve these arguments. For example ...
1
vote
1answer
128 views

Parse Argument by Character while Executing Embedded Macros

I am interesting in parsing a string of input character by character, and doing something to each character. In this MWE, I merely apply a \textbf to each successive character as an example, to ...
16
votes
3answers
580 views

\NewDocumentCommand: Why can't I put args on an own line?

I encountered a peculiarity concerning \NewDocumentCommand arguments. In a case where I had real long names in the arguments, I wanted to put them each on its own line. The first ones are OK, the 2 ...
12
votes
1answer
249 views

About the definition of textcolor

I was curious and found the following definition for the macro textcolor defined in the package xcolor: \def\textcolor#1#{\@textcolor{#1}} \def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}} ...
8
votes
4answers
373 views

Runaway argument? with \newcommand[2]

I have a date (in the format YYYY.MM.DD) and a time (format HH:MM). From these, I want to compute a kind of TimeStamp/Total of minutes. \documentclass{article} \makeatletter % Timestamp \...
7
votes
3answers
931 views

Biggest depth of a character in a string

I need to find depth of a string, for this end i would like to loop over the string and ask for depth of every character. I ask for depth like this: \dimen=\fontchardp\expandafter\font`\a And loop ...
4
votes
2answers
147 views

\def'ed plain-text argument behaves differently from plain text

So this is my example, closely related to Remove extra curly braces. Apart from my application, trying to line-break the labels in the margin even if they do not have spaces in them, I am trying to ...
3
votes
1answer
61 views

newcommand says missing number

I plan to write a command which rounds a number with n digits. n is an optional argument and it is 2 by default. However, I keep receiving error message: Missing number, treated as zero. Let's see ...
3
votes
1answer
160 views

How to create a table macro that takes more than 10 arguments

I want to create a macro that creates several tables. In the example below, the command that creates the tables \chungeltable will use one argument for each column in the table (More than 10 columns). ...
3
votes
1answer
1k views

\verb illegal in command argument in task

Following this: Make two-columned list start at same line as its section, I did: \documentclass{article} \usepackage{cprotect} \usepackage{tasks} \begin{document} \section{Languages} \...
3
votes
2answers
509 views

Force expansion of counter value in command argument

In the following MWE I would like to expand both \envnum as well as \itemnum while passing them to \cmdwithexpandedargs but only the first one got expanded. Note the different output between \wlog ...
2
votes
1answer
78 views

How to add an argument to a \cline-like macro?

I want utility macros that allow me to change (a) the thickness and/or (b) color of \hlines or \clines in tabulars. I want to do so without redefining \arrayrulewidth but rather by modifying the ...
2
votes
1answer
133 views

LaTeX Nesting \verb in \section

Why is \section{\verb|mySec|} invalid LaTeX code.
2
votes
2answers
89 views

Probably a gdef-expansion problem, but how to solve?

Trying to integrate the answer of this post it into my real code, I face the error Argument of \timedelta@i has an extra } when calling the proposed method. Upto now, I've not been able to fix it. ...
1
vote
1answer
69 views

Is there option in any IDE to display available options for specific function?

Does any IDE support feature to show all available arguments for specific function? For example instead just showing circle(nothing) like this: To show something like this (similar like Visual Studio ...
1
vote
1answer
81 views

Macros taking code as an argument which can access parent arguments in LaTeX 3

In Latex 3 I would like to be write a macro which takes as an argument code which can internally define a macro. How do I do this in a way that allows the code being passed to access arguments of the ...
0
votes
1answer
42 views

Finding out the number of needed macro arguments

How can I find out how many arguments (i.e. {} pairs) are used when 'calling' a macro? (my favorite error, that I extend a macro, i.e. it needs one more argument, then I use it to compile a text ...