Questions tagged [arguments]

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

Filter by
Sorted by
Tagged with
3
votes
2answers
619 views

How to pass optional arguments to command?

I'm trying to write my own command that wraps the \VerbatimInput command. I'd like my command to take optional arguments (those given inside [...]) and pass those directly to \VerbatimInput[...]. Of ...
6
votes
3answers
240 views

Strange argument absorption, using \color

I just noted a strange behavior, when ending a macro with a \color{<color>} invocation, the net effect of which seems to absorb the subsequent space. I realize the easy thing to do is just ...
3
votes
1answer
64 views

Break newcommand arguments by '/' for different use?

I'm creating a presentation with a lot of frames with one figure per slide. So instead of having hundreds of the same code over and over again I created a simple \newcommand for it where one of the ...
3
votes
1answer
94 views

Raw postscript (!ps) do not expand in argument of \psaxes

The (!ps) syntax is supposed to expand to a pair of coordinates by executing some raw postscript code. In the following example it works well in argument to \rput but not with \psaxes; why is it so? \...
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 ...
11
votes
3answers
478 views

Can \cref be made to ignore spaces?

I think this MWE says it all. \cite can ignore spaces in its argument, while \cref cannot. I wonder if \cref could be improved that way. \documentclass{article} \usepackage{cleveref} \usepackage{...
12
votes
2answers
608 views

How are parameter tokens (#1,#2,…,#9) processed?

I wonder how the TeX token muncher processes parameter arguments. It seems that parameter arguments are sent token by token. Is this true? Consider the following code based on wipet's answer used to ...
2
votes
1answer
63 views

\environment Definition with Parameter

I digged around and found no answer to the following problem: I defined the environment myroman but using I failed. It is not clear for me why. % \documentclass{scrartcl} \usepackage{enumitem} ...
4
votes
1answer
191 views

Coding a *short* newcommand with a variable number of arguments for a very specific use-case

Is it possible to create a simple, robust command with a variable number of arguments for the following specific use-case ? Consider \newcommand{\bigmap}[7]{% #1\!\begin{pmatrix}#2\\ #3\\ #4 \end{...
12
votes
3answers
439 views

how to determine the number of characters in the argument of a command

I want to define a command that behaves differently for single-character arguments than it does for longer arguments. How do I retrieve the number of characters in, e.g., #1? The specific application ...
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 ...
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} \...
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 ...
2
votes
1answer
87 views

Using an undefined token as argument

I have a (probably) quite uncommon problem. Pseudocode: \def\head{\titel } % \titel = undefined \func{\head} % func is defined and handles \titel without any issues \func{\titel} % throws an ...
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) ...
4
votes
1answer
162 views

Robust handler of arguments with conditionals and complex elements

Context This question is a follow up of the answer of this question Spurious space on moderncv \cventry using \if Problem The problem is that complex content (for example, itemize on the content of ...
2
votes
1answer
519 views

Underscores in function arguments seem to change file names

I have been trying to pass a file name that contains underscores to a couple of nested commands. Since escaping each and every _ isn't really an option, I thought a group \catcode_=12 (had to remove ...
7
votes
7answers
2k views

newcommand with comma separated argument, and optional arguments

I want to define a command (not with \def) the simplest possible way that it takes arguments separated by a comma, supports an optional argument (the first one). maybe another solution with extra ...
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
0answers
402 views

How to pass a color as an argument [closed]

Before explaining my problem, sorry if this is a repeated question, but I was not been able to find one answered/asked question in which the problem was the same as mine. In order to create a ...
4
votes
2answers
447 views

Newcommand inside foreach: multiple arguments and minipage environment

I am trying to define multiple, sophisticated newcommands within a foreach loop. This sounds so simple, but why is it so hard ? Naive attempt: \documentclass{report} \usepackage{tikz} \foreach \i ...
2
votes
1answer
156 views

Followup on \def@ [closed]

Trying to understand \def\def@ sintax primitives As a followup to this question, I'm currently working on a BA, using a set of definitions I found on a template's .cls file. Currently: % The year ...
1
vote
0answers
105 views

Trouble with frame in newcommand [duplicate]

I'm making a slideshow with LaTeX beamer class like this : \documentclass[xcolor=dvipsnames]{beamer} \usepackage[french]{babel} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{...
4
votes
1answer
682 views

Arithmetic operation between command arguments and latex parameters

I'm defining a new command that places two images one next to the other and I want to add an horizontal space between the two images which corresponds to one third of the space that remains blank. The ...
4
votes
1answer
508 views

Passing arguments to class in a key=boolean value manner

Assume I have a bunch of flags which I want to pass to my class, how do I do this? If you see the example below, I am looking for passing flags in the form: key=<boolean value from flag> to ...
2
votes
1answer
79 views

Check for sufficient number of tokens left

I want to use a command that takes a large number of arguments, possibly more than left in the input stream. \def\consumeseven#1#2#3#4#5#6#7{} \consumeseven \space In this scenario \consumeseven ...
3
votes
2answers
604 views

How to patch with \xpretocmd and \xapptocmd a command by applying to it a macro with argument?

Suppose I'd like to patch a very complicated macro, say \autocite. For this, xpatch package is my friend. If the patch consists in applying a modal command which doesn't take arguments, such as \...
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 ...
2
votes
1answer
57 views

Calling macro from a macro breaks argument formatting causes odd environment behavior

I'm trying to write a little Latex package to learn more about Tex and to help me out with writing long and annoying proofs for a course by creating macros to retrieve rule names from a table given ...
4
votes
1answer
132 views

Arguments to macros in mathmode lose their mathmode typesetting

I'm writing a little semantics package(I know that there already exists some good packages for this) in latex to help me and my friends out with our assignments. but im having a broblem that ...
2
votes
1answer
346 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): \...
2
votes
1answer
545 views

TikZ Macro With Multiple Arguments

I am trying to create a simple (hopefully) macro for myself that will make drawing number lines with TikZ more efficient. I can make such lines manually, but since I will need so many similar pictures,...
2
votes
1answer
182 views

How to use \makebox in \tl_map_function?

While trying to answer LaTeX for music I came to the problem that I can’t use a \makebox inside the function for a \tl_map_function:NN call. The problematic line is commented out in the following code....
5
votes
1answer
208 views

Why do braces around a single-letter argument of a macro affect its output?

I thought \ul 8, \ul8, and \ul{8} are identical ways of passing an argument 8 to a command \ul. However, they produce different output. Why? MWE: \documentclass{article} \usepackage{soul} \...
1
vote
1answer
294 views

\nameref inside custom command

I have created my own command with \newcommand and it Works fine with "static" input in the arguments. But, when I give e.g. a \nameref{sec:title} it is throwing errors like these: Undefined control ...
1
vote
2answers
162 views

Definition of a macro with multiple arguments and usage of \csname

Why does the following code not work ? \Requirepackage{amsthm} \renewcommand\newtheorem[2]{% \NewEnviron{\csname #1\endcsname}[1]{% ##1 : \BODY } } I have seen examples of the use of ...
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 ...