Questions tagged [arguments]
The {argument} tag is used for specific questions about macro parameters and arguments.
294
questions
3
votes
2
answers
97
views
Using `\<char> notation to work in replacement text (macro argument) - plain TeX
I'm still trying (again) to not succumb to the TeX syntax.
I'd like to create a "if/when" that checks if a character is letter (catcode 11).
\def\whenletter#1{\expandafter\expandafter\...
0
votes
2
answers
86
views
Moderncv package provides error for optional arguments: why?
So I'm writing my CV using moderncv from TeXLive on Arch Linux. Note that I am on Emacs, where an expanding snippet for cventry gives me this suggestion: \cventry{year}{job}{employer}{city}{...
0
votes
1
answer
42
views
Grab variable number of tokens – xparse macro
I'm trying to create the following macro:
\adddescr{<comma separated list>}{<description 1>}...{<description n>}
this macro should print element -- description \par accordingly, so ...
2
votes
1
answer
74
views
How to avoid typing \leavevmode before a citation macro that already starts with \leavevmode?
Control sequences with optional arguments inside optional arguments must
be "hidden" with braces.
Using the abntex2cite package to handle my citations, I often want to write:
\begin{teor}[{\...
1
vote
2
answers
108
views
Is there any way to pass variables to commands?
Right now I'm doing some math homework that has lots of ordered pairs. Being lazy, I got tired of writing \langle x, y \rangle and so I was wondering if there's a way to define a command, say \ordered,...
1
vote
1
answer
113
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 ...
0
votes
0
answers
84
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: ...
0
votes
3
answers
147
views
How can I create commands using multiple arguments with pgfkeys in custom environments with tabulars? [duplicate]
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}{\...
3
votes
5
answers
720
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 \commandEnhanced{x,y} ?
(The question is general, ...
0
votes
1
answer
353
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 ...
0
votes
0
answers
71
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 ...
2
votes
0
answers
94
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 ...
3
votes
2
answers
86
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\...
2
votes
2
answers
246
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]
...
0
votes
0
answers
51
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:
\...
0
votes
1
answer
110
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 ...
2
votes
1
answer
144
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....
0
votes
0
answers
145
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 ...
0
votes
2
answers
128
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
\...
3
votes
2
answers
200
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:
\...
6
votes
1
answer
968
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 ...
0
votes
0
answers
15
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}
...
0
votes
1
answer
96
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 ...
3
votes
1
answer
224
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=...
3
votes
1
answer
114
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 ...
3
votes
1
answer
79
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 ...
0
votes
2
answers
90
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 ...
1
vote
1
answer
320
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 ...
3
votes
2
answers
110
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 ...
2
votes
1
answer
408
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 ...
1
vote
1
answer
325
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?
1
vote
1
answer
294
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 ...
3
votes
1
answer
102
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 ...
1
vote
2
answers
84
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@@...
1
vote
0
answers
95
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 ...
1
vote
1
answer
67
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 ...
7
votes
2
answers
324
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 ...
1
vote
1
answer
35
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 ...
1
vote
1
answer
193
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 ...
1
vote
1
answer
143
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 ...
5
votes
6
answers
369
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 ...
0
votes
1
answer
195
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{...
1
vote
1
answer
60
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 ...
1
vote
2
answers
192
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 ...
2
votes
1
answer
221
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 ...
0
votes
0
answers
66
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 ...
4
votes
1
answer
98
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,
\...
1
vote
2
answers
264
views
Define command for which its arguments must be present and encased in (curly) brackets [duplicate]
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{\...
0
votes
0
answers
89
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}[...
0
votes
2
answers
119
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 \...