Questions tagged [arguments]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
69 views

xpretocmd: Why are my arguments not working?

I just tried to keep track of my current chapter name, because I use the first letter for certain namings in my document, so I wrote this code to save it: \documentclass[12pt,a4paper]{scrreprt} \...
6
votes
2answers
184 views

Variable argument macro to define splitting polynomial

I need a macro that behaves the following: \mpoly{x}{1}{2} outputs (x+1)(x+2) \mpoly{x}{1}{2}{3} outputs (x+1)(x+2)(x+3) \mpoly{x}{1}{2}{3}{5} outputs (x+1)(x+2)(x+3)(x+5) and so on. I am not at ...
0
votes
0answers
69 views

Mathpartir: How to insert “\\” between entries with macro?

I'm using a tool to generate large amounts of LaTeX, which contain inference rules that I'm typesetting using mathpartir. Below, I've got a MWE that's very similar to the code I've got generated. ...
4
votes
2answers
124 views

Use N type for own macros

Background In LaTeX3 I’m programming some macros to store and read contents from a variable like \tl_set:Nn does. An thus I’m generating variants using the N type, which causes a warning. The warning ...
2
votes
1answer
64 views

Regex within new command to prevent making tooltips of tooltips

I'm making a document where I want the definitions of entries in the glossary to appear as tooltips. The tooltip code itself is from the answer: Can't embed hyperlink references in a tooltip ...
1
vote
2answers
64 views

why is the directory trimmed from my path argument in includegraphics?

Hi community I have a weird problem. It seems that includegraphics won't accept the entire argument, it always trims off the directory part! The argument was manipulated and concatenated in another ...
2
votes
1answer
292 views

How to pass literal comma as argument

I am using minted for code highlighting. I have defined a new minted file format, with the code \newmintedfile[plaintextfile]{text}{ ... breakafter=<values to break lines on>, ... }...
4
votes
4answers
526 views

Detect no argument in \newcommand

I wonder if there is a way to create a command which can discriminate when there is an argument or not. I don't mean empty argument, I mean no argument at all. Here an example \newcommand{\mycommand}...
2
votes
1answer
92 views

Using greek characters in commands' arguments without braces

First I want to make clear that I'm a LaTeX beginner, so I'll be detailed because I just have no clue about the origin of my problem. I'm using TeXstudio 2.12.6 I'll provide context: I have been ...
0
votes
1answer
106 views

How to know all the optional arguments of Latex commands\environments? [duplicate]

For external packages CTAN provides the needed documentation, however, for built-in Latex commands I am not aware of any proper documentation except for The (not so) short introduction to Latex which ...
2
votes
2answers
108 views

Using a line number reference as an argument for footnote

The \footnote{text goes in here} command takes an optional argument for numbering, so if I want to skip straight to footnote #5 or override the default numbering, I can do that: \documentclass{...
1
vote
1answer
63 views

Bugs in conditional structure in a newcommand definition with optional arguments

I am trying to create a new command for add a caption and/or the label to an equation. The not optional parameter is for the text of the equation and first optional parameter is for the label, the ...
2
votes
2answers
88 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. ...
2
votes
2answers
73 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....
2
votes
2answers
428 views

How can I make a list with variable parameter size inside of a custom environment?

I have a custom environment that I am using as part of a template. Right now this is the code for the template file. %----------------------------------------------------------- % customtemplate....
0
votes
1answer
70 views

Macros with 0, 1 or 2 arguments

Is it possible to build a macro accepting 0, 1 or 2 arguments ? Why ? I want to have the following functionalities. \exercice will print Exercice alone. \exercice{2} will print Exercice (2 pts). \...
0
votes
1answer
163 views

expandafter and csname

I was recently looking for the creation of commands that use the name of another command and I recently discovered \expandafter and \csname instructions. I manage to create simple one using these ...
2
votes
1answer
209 views

\IfNoValueTF - How to force “no value” if there (are brackets but there) is no value for an argument

This code uses LaTeX3, the xparse-package and in particular the \IfNoValueTF command as explained in Will Robertson's answer to the OP "Different command definitions with and without optional argument"...
2
votes
1answer
84 views

Print counter received as argument

I'm trying to print a counter whose name I receive in the argument #1. I tried \the#1, which doesn't work and also tried the solution given in this answer, which gives me the error "You can't use \let ...
1
vote
1answer
334 views

Passing arguments to LuaLaTeX with LuaSQL [duplicate]

I am using LuaLaTeX with LuaSQL and I have two files which are test.tex and test.lua. When I compile with lualatex test.tex, first test.lua is ran and it reads user values from my database for rows ...
1
vote
2answers
85 views

How to reference a node's anchor by optional parameter (#2) inside a style when that node is referenced by parameter (#1) itself?

I have a style (POSITION) that references a node by parameter \documentclass{standalone} \usepackage{tikz} \usetikzlibrary {% positioning, shapes.geometric } \tikzset {% ...
1
vote
1answer
131 views

How to pass a caption as an argument of newenvironment

I make a next newenvironment to insert the code of a tikzfigure in the document \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[spanish]{babel} \usepackage{minted} \usepackage{tkz-...
4
votes
2answers
135 views

In TeX how can I define a list of data such that I can use a numerical argument to call for one entry out of the list

I would like to be able to have a defined macro something like this: \def\testmacro[1]{[54.7],[74.1],[98.5]} Such that when I call \testmacro{2}, in a document, 74.1 is printed. Is this ...
3
votes
2answers
212 views

Using \foreach with \SplitArgument

Why does the \test command not split the argument when called from a foreach loop? \NewDocumentCommand{\test}{ >{\SplitArgument{3}{|}} m }{\printtest#1} \NewDocumentCommand{\printtest}{mmmm}{ (...
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 ...
1
vote
1answer
158 views

Getting arguments of any LaTeX command

I do not like R and LaTeX. I simply love them. In R, I can get the arguments of any function using args(function_name) on command line. I wonder if we can get the list of all possible arguments of any ...
1
vote
1answer
79 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 ...
7
votes
2answers
305 views

Understanding \@firstofone

I was looking over this answer and trying to understand the code, I am a super newbie (my second day) in LaTeX and I stuck at the following part of the code that i could not make it work in a not ...
0
votes
1answer
44 views

Only last value of a variable goes into \psfrag function

I make two calls, but it seems like only last value of \lRaise goes into the function, so both boxes are raised by -5pt: \newlength{\lRaise} \setlength{\lRaise}{-0.97pt} \psfrag{low-order}[B][][0.8]{\...
3
votes
1answer
159 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
106 views

Environment with optional argument configuration in TeX4ht

I am tried to create configure the below environment with optional argument in TeX4ht \newenvironment{proof}[1][Proof]{\textit{#1}:\ \ignorespaces} {} MWE \documentclass{...
10
votes
1answer
185 views

Omitting argument in command definition

Sometimes I define model commands (\foo in the example below) and then particular commands based on that model (\fool in the example below). However, I am not entirely sure I am using the correct ...
4
votes
2answers
144 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 ...
1
vote
1answer
148 views

Command with argument and several results inside command (inside command…)

I want to reuse a command that performs the same type of action (a specific parsing of the incoming expression) inside the other command, which should form the contents of the document and can also ...
7
votes
2answers
359 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 ...
7
votes
3answers
925 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 ...
3
votes
2answers
132 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 ...
1
vote
1answer
365 views

How to globally define different task bar colors in a gantt chart?

I've been working with this gantt chart example here. I would like to add user specific colore bars. Essentially, I don't want to have to type bar/.append style={fill=green} into every new bar command....
9
votes
4answers
639 views

How to write a macro that takes a variable number of arguments

I am trying to make a new command called \com which can do the following: If no argument is provided to \com, $\com$ produces the symbol $\lambda$. If one argument is provided, e.g. $\com{f}$, the ...
5
votes
2answers
728 views

One `\newcommand` for inserting figures differentiating two cases with/without captions

I have written the following two \newcommand for inserting figures with or without a caption, respectively. % for fig with caption: #1: width/size; #2: fig file; #3: fig caption \newcommand{\...
1
vote
3answers
100 views

\def\foo#1:#2:#3 can be called with \foo{a:b:c} but not \foo{a:\bc}

This works: \def\myfunc#1{\expandafter\myfuncdoit#1\relax} \def\myfuncdoit#1:#2:#3\relax{ First: (#1), Second: (#2), Third (#3) } \foreach \p in {x:foo:int,y:bar:float,z:baz:bool}{ (\myfunc{\p}) } ...
1
vote
1answer
80 views

\foreach doesn't compose with my string-splitting command

I wrote \myfunc which splits a colon-delimited string into two parts. It works, in and of itself, as does a simple \foreach over comma-separated colon-delimited strings. But if I try to call \myfunc ...
6
votes
2answers
170 views

Anonymous commands with Expl3

The following code allows me to produce series easily (see examples below the code): \documentclass{article} \ExplSyntaxOn \NewDocumentCommand \simpleseq { m m m } { \seq_set_split:Nnn \...
11
votes
4answers
845 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 ...
3
votes
2answers
592 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
62 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
93 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
726 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
467 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{...