Questions tagged [arguments]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
49 views

Is it safe to use \globaldefs for setting global pgf key-value pairs?

With the help of this post (Is there a way to set a *global* key value using `pgfkeys`?), I found a simpler way to implement a solution to my own question (How can I create commands using multiple ...
user avatar
0 votes
0 answers
16 views

Argument of \cvskill has an extra } when trying to override an existing command

I'm using the moderncv package which already defines the \cvskill command. I'm trying to override/redefine this command with \renewcommand: % ... % param 1: name of the skill / tech / etc. % param 2: ...
user avatar
  • 101
0 votes
3 answers
66 views

How can I create commands using multiple arguments with pgfkeys in custom environments with tabulars?

I am trying to create my own template package. In this package, there are several custom environments defined. One of those environments starts and ends a table, i.e: \newenvironment{customenvtab}{\...
user avatar
3 votes
5 answers
605 views

Easy way to convert \command{x}{y} to \command{x,y}

This is certainly a duplicate but I cannot find a straightforward and simple conversion method. Is there a universal way to convert \command{x}{y} to \command{x,y} ? (The question is general, this is ...
user avatar
0 votes
1 answer
96 views

Pass tabular arguments from \newcommand

So I asked this question yesterday but I realized I didn't do a good job of explaining it. I basically need to read different csv files with different numbers of columns and I need to build a command ...
user avatar
0 votes
0 answers
37 views

pass tabular argument from \newcommand

I want to pass the tabular argument|p{5cm}| p{1.5cm}| p{8cm}| from the newcommand \csvautotabularcenter{2.csv} since it will change as the number of columns change based on the input file . I know you ...
user avatar
1 vote
0 answers
56 views

Detect \end of an environment

I'm trying to create a macro that grabs everything till the end of the current environment and parses it. At first, I just want to put ! right after my macro and another one ! before the end of ...
user avatar
  • 2,345
3 votes
2 answers
70 views

Can xparse distinguish arguments inside braces and single-token arguments without braces?

The \foreach command from pgffor package has a good feature that it can distinguish arguments inside braces and single-token arguments without braces: \foreach \i in {1,2,3} {do some thing} \def\...
user avatar
  • 8,650
2 votes
2 answers
58 views

Create an environment with optional arguments

I want to create environments with two optional arguments like that : \begin{myenvir}[] Title #1 \end{myenvir} \begin{myenvir}[s] Titles #1 \end{myenvir} \begin{myenvir}[a] ...
user avatar
0 votes
0 answers
34 views

Understanding some aspects of the philex package

In Philex, you can refer locally to an example (2b) by just typing \rnx{label} and it will return just (b), otherwise just type \rn{label} and it returns (2b). Here is the syntax of the two commands: \...
user avatar
0 votes
1 answer
47 views

Environment with a mandatory or optional argument behind the \end{env}

I would like to create a custom environment, let's say foo, with an optional and a mandatory argument. This could be an approach: \NewDocumentEnvironment{foo}{O{default} m}{start #1 #2}{end} This ...
user avatar
2 votes
1 answer
72 views

Passing a token list variable as an argument

The code below parses out a comma-delimited bit of an argument, then passes that bit to a function, as a token list variable. It works, by using \exp_args:Neee, but I suspect that there's a better way....
user avatar
0 votes
0 answers
49 views

Boolean flags with xparse, and xparse in general

I would like to define an environment whose syntax works like this \begin{myenv}{arg1,arg2}[opt_1,opt_2,...,opt_n] body, taking several lines \end{myenv} One of the optional arguments is to be a ...
user avatar
0 votes
2 answers
58 views

Passing nested argument specifier to hook

Consider a macro that declares some other document command, but by accepting their body as an own argument (simple indirection) also adds the invocation of itself to some hook as in \...
user avatar
3 votes
2 answers
133 views

PGFPlots: Trying to create a non-linear axis using trafo/.code in \newcommand - how to escape the #1 argument?

I would like to make my Y axis non-linear. I have found an answer but the problem is that my code for charts is encapsulated in the \newcommand environment. When I use something like this: \...
user avatar
  • 133
6 votes
1 answer
441 views

How LaTeX "understands" optional arguments?

The most common notation for commands I have seen is the following: \command[optional]{mandatory} What I am trying to understand is how the optional arguments are understood. For example they can be ...
user avatar
  • 183
0 votes
0 answers
11 views

Arguments in the destructor for an environment [duplicate]

The \newenvironment command allows the environment to take arguments: \begin{article} \newenvironment{preecho}[1]{#1}{} \begin{document} \begin{preecho}{Hi!}\end{preecho} % => Hi! \end{document} ...
user avatar
  • 1,140
0 votes
1 answer
33 views

packaging a matrix/tikzpicture into a newcommand while keeping the arguments within the style

I've got a SWOT matrix that works well when used in the main body of the text. I would like to package this and use something like: \swotfigure{foo}{bar}{frut}{boo} i.e. a newcommand with 4 ...
user avatar
3 votes
1 answer
116 views

Use command argument in foreach

When I define a new command to draw an axis I want to use one argument to calculate the step size of the tick numbers. I tried this but it didn't work: \newcommand{\axistest}[2]{ \draw[->,color=...
user avatar
3 votes
1 answer
99 views

Define arguments in a command

I am using the skak and xskak packages to make notes about chess. Everytime I need to print a board, I have to manually set the optional parameters, like the code below: \chessboard[ %--> ADD ...
user avatar
  • 1,214
3 votes
1 answer
70 views

Latex3: handling of sub-functions with shared name sub-parameters

I am using latex3 to write a set of macros. I have defined the nomeclature class, and a nominal case which comprehends all the possible combinations to be used in the test cases_i ( i = 1:N ). Now I ...
user avatar
  • 139
0 votes
2 answers
37 views

\special, html: URLs, and trouble with the pound sign

EDIT: Ulrike Fischer has provided the correct answer. Thank you, Ulrike. I've been given an interesting project involving creating syntax diagrams for a webpage. Because they use things like large ...
user avatar
  • 101
1 vote
1 answer
91 views

Using xargs to define custom environment

I want to define a custom environment for the following LaTeX box using xargs package, but currently I am running into errors and a bit confused on how to properly make the environment. First, here's ...
user avatar
  • 163
3 votes
2 answers
65 views

expl3 empty variable when called by another macro

Here is the boiled-down extract of what I'm trying to do. Apologies beforehand if some of the computations do not make sense, I've modified them for the sake of simplicity. Basically, I've a function ...
user avatar
  • 1,945
2 votes
1 answer
85 views

Conditional color in a newtcolorbox

Consider the file that is presented below that defines 3 new color box environments through \newtcolorbox: bluecolorbox, redcolorbox, greencolorbox. Instead of the current strategy, I was wondering ...
user avatar
  • 4,263
0 votes
1 answer
105 views

Put \lstinline inside \chapter, \section, etc. commands

How can I place \lstinline code inside commands like \chapter, \section, \subsection, etc.? Or it's a bad or tasteless practice?
user avatar
1 vote
1 answer
68 views

How does "\usepackage[table]{xcolor}" compare to "\usepackage{xcolor}" in terms of features provided?

How does "loading a package with no arguments" e.g. \usepackage{xcolor} compare to "loading a package with an argument" e.g. \usepackage[table]{xcolor} ?! In other words, are the ...
user avatar
2 votes
1 answer
68 views

Optional argument for newcommand

Suppose we define the following macros: \newcommand*{\G}[1][G]{\mathbb #1} \newcommand*{\Cop}[1][]{\Delta_{#1}} For the first one, if we use $\G$ it produces in the pdf what $\mathbb{G}$ does and if ...
user avatar
  • 23
1 vote
2 answers
72 views

Passing #1 to \pgfkeys

I have the following setup to apply macros to certain data of a command: \makeatletter \def\myqu@rck{\myqu@rck} \pgfkeys{/mykeys/macro/.code=\mykeys@defmacro{#1}} \def\mykeys@defmacro#1{\mykeys@@...
user avatar
0 votes
0 answers
66 views

xparse/expl3 - is there an interface for checking whether a set of tokens fits a pattern specifiable by means of a list of argument-specifiers?

Is there already an (expandable and extendable) interface in xparse/expl3 for testing whether a set of tokens, probably coming from an expl3-n-type argument or an xparse-m-type argument, matches a ...
user avatar
  • 23.5k
1 vote
1 answer
35 views

Automatically register arguments a command is used with

I am wondering whether it is possible to create some sort of set to keep track of elements in latex. One intended usage would be to automatically generate a list of arguments that have been passed to ...
user avatar
  • 187
7 votes
2 answers
151 views

Simplify \SplitArgument construction?

I want to exploit the interval package to obtain "French" notation for intervals, that is, with an open interval appearing as "]0, 1[", etc. But the package's \interval command is ...
user avatar
  • 6,557
1 vote
1 answer
27 views

Check whether a color passed as argument to a package is defined

I'm trying to write a small package that defines an accent color based on a choice of faculty for use in a template. If the faculty doesn't exist, I want to generate an error message. I currently have ...
user avatar
1 vote
1 answer
74 views

Passing arguments from a Latex command to a Lua command

I read the post Automatically alter letterspacing (intra-word spacing) to avoid loose lines with LuaLaTeX which I would like to adapt to create a command \InterletterGlueEnable with two arguments. The ...
user avatar
  • 313
1 vote
1 answer
85 views

How to pass an argument to lua tex.print with maths

I want to create a blank exercise, in which answers can be text or mathematical expression, and to have below a list of all answers in disorder. In the MWE i made with LUA, the text appears below as ...
user avatar
5 votes
6 answers
240 views

Access parameters of macro by index

For a pstricks project I have a macro with 9 parameters every of which is to be proccessed by the macro in the same way. Instead of writing the same code 9 times for each parameter I'd obviously ...
user avatar
0 votes
1 answer
62 views

How to define an environment inside which any undefined environment is "defined"?

I need to define an environment inside which I can simply do \begin{some string}some stuff\end{some string} with arbitrary strings, and have it process these as environments (which output e.g. \textbf{...
user avatar
  • 315
1 vote
1 answer
42 views

Inserting a condition in a macro with more than 9 arguments

I have an excel table with several entries describing documents in an archive. Then I wanted to convert the whole table into formatted paragraphs in which every row appears as a unit. I then produced ...
user avatar
  • 97
1 vote
2 answers
94 views

Multiple named arguments to tikz pic using keys

I am passing an argument to a pic like so pic[n=3]. Am I doing it right? And how about passing several arguments, say two like so pic[n=3, r=1]? I really like being able to write the argument ...
user avatar
  • 2,653
2 votes
1 answer
161 views

What is wrong in this definition of a newcommand with variable number of parameters in its argument?

I want to define a command to draw schemas of the type shown in the following figure, but for an indeterminate number of branches. The inputs will always be positive integers. The numbers of the ...
user avatar
0 votes
0 answers
49 views

Starting a new series of subequations within the same parent equation

This is a follow-up question to this previous question I asked. Basically I asked for an environment that not only stores the parent equation value, but also the number of a subequation so a series of ...
user avatar
  • 153
4 votes
1 answer
77 views

Creating a New Command w/ 4 Arguments for Quickly Referencing the Gradient Equation?

I'm trying to create a new command of the form, \gradeq{T,x,y,z} That takes the four arguments provided and displays, \pdv{T}{x}\xhat + \pdv{T}{y}\yhat + \pdv{T}{z}\zhat This is how I've tried it, \...
user avatar
1 vote
2 answers
96 views

Define command for which its arguments must be present and encased in (curly) brackets

I want to create a command that explicitly requires its user to give the arguments in the curly brackets, or else throw an error. For instance, take the following command definition: \newcommand{\...
user avatar
  • 13
0 votes
0 answers
42 views

Problems with \\ in XeLaTeX when using Mac

I currently faced a problem with a XeTeX file I wrote using Windows 10 when I tried compiling it with MacOS Sierra 10.12.6. I had a .cls file containing following code snippet: ... \newcommand{\cover}[...
user avatar
  • 749
0 votes
2 answers
80 views

How to redefine a product command to add an optional argument?

I would like to redefine the product commands (\times, \cdot, \otimes, \wedge, \odot) to add an optional negative spacing argument, but I don't know how to do this in a proper way. I need the new \...
user avatar
  • 2,034
6 votes
2 answers
296 views

Define a macro for a vector to display differently in inline/display math mode

I'd like to define a command that defines a vector based on whether it's in display or inline math mode. I've tried this so far, but it hasn't worked: \newcommand{\ve}[1]{\ensuremath{% \mathchoice{...
user avatar
  • 173
3 votes
3 answers
257 views

Keeping default optional argument when adding to command

TeX FAQ's "Patching existing commands" gives a method to add to existing commands that have an optional argument: \documentclass{article} \usepackage{letltxmacro} \newcommand{\rough}[2][\...
user avatar
0 votes
2 answers
68 views

How to escape #1 using xpretocmd

Take this MWE: \documentclass{article} \usepackage{acro} \DeclareAcronym{ram}{short=RAM, long=random access memory} \newcommand{\test}[1]{RAM} \usepackage{xpatch} \begin{document} \test{ram} % This ...
user avatar
  • 5,142
1 vote
1 answer
32 views

Macro on argument not behaving as expected

I'm trying to substitute a comma separated argument for a macro. The code below works fine: \documentclass{article} \usepackage{listings} \lstset{ literate={->}{\texttt{->}}{2} } \begin{...
user avatar
6 votes
2 answers
269 views

Is it allowed to put spaces after macro parameter?

As shown below, a macro is defined, and can be used without problem without spaces after macro parameter, $$ \def \SpinOrb#1#2{ \chi_#1(\x_#2) } \SpinOrb i 2 \SpinOrb j 1 $$ As shown below, the ...
user avatar
  • 207

1
2 3 4 5