0
votes
0answers
22 views

Nested definitions [duplicate]

I have the impression that if one defines a macro inside the definition of another one, then #1 and so on indicate the outer macro's arguments, while ##1 indicates those of the inner one. Is that ...
0
votes
2answers
58 views

newcommand with variable number of arguments

I have seen several related questions, but none seems to address specifically this. I would like to define a command that accepts a variable number of arguments. Something like ...
3
votes
3answers
141 views

Append to an argument

I have a command that receives some argument, like: \newcommand{\myappend}[1]{ \ifthenelse{\equal{#1}{aaaBB}}{\dothis}{\dothat} } Assume that the argument is 'aaa'. How to append (inside the ...
11
votes
2answers
130 views

Passing parameters to \g@addto@macro

I'm a complete newbie but have a little background in programming. I've been looking at a MWE located here provided by Yiannis Lazarides. In the macro definition, we have %% add an image to the DB, ...
3
votes
1answer
97 views

Quotation around text without using brackets

I am using the csquotes package and its \enquote{TEXT IS HERE} very often. Instead of \documentclass[12pt]{article} \usepackage[top = 1in, bottom = 1in, left = 1in, right = 1in]{geometry} ...
4
votes
1answer
100 views

Generating lists and tables of items from commands in the document

I would like to define objects all over my document and later evaluate certain components from these objects. Example: \documentclass{minimal} \newcommand{\requirement}[3]{#1, #2, #3} ...
4
votes
1answer
321 views

How to pass two parameters to a \newenvironment?

I have defined this new environment for handling my images in my document I want to pass two parameters: #1 to refer to pathname to the imagefile #2 to refer to the string I want to pass to the label ...
3
votes
1answer
65 views

Get confused about the `command` option in some ConTeX \setup*

Since I switched to ConTeXt from plain TeX, I always get confused about macros in it. Now it is the command option in \setup* of ConTeXt. In ConTeXt, some macros, like \setuphead, \setuplist, have ...
13
votes
2answers
306 views

TeX Parameter Processing imitating key-value pairs

I am thoroughly confused by this answer to How to generate n points on a circumference and connect all of them while having constraints on the image size as I don't understand how the parameter ...
6
votes
3answers
124 views

How do I handle a closing brace in a 'character scanning' macro?

Problem I need to define a command that grabs all numerical digits following it and leaves the rest alone. Eventually I came up with this: First Solution \RequirePackage{xstring} % for \IfInteger ...
7
votes
1answer
284 views

Storing unexpanded macro definitions (including #1, #2, …) for later use (now includes full usecase)

Preliminary Info I'm working on a new LaTeX package to make scoping more flexible. To do this I'll be capturing and reintroducing user defined commands behind the scenes. (For a comprehensive ...
2
votes
0answers
49 views

Escape hash symbol (#) in inner macro definition [duplicate]

Possible Duplicate: What is the meaning of double pound symbol (##1) in an argument? I'm quite sure this question has been asked many times but I can't find the answer. I'd like to make a ...
11
votes
2answers
3k views

New command with variable number of parameters

I would like to create new command with functionality like this (pseudo code): \newcommand{\myCommand}[numOfParameters] { for (i = 0; i < numOfParameters / 3; i++) { \somecommand1{#(i*3 + ...
3
votes
2answers
167 views

Sharing parameters between a command and an environment

(This question is related to Using \total of totcount package in section title) I'd like to keep track of the papers I review, and I have written a code (MWE shown below). The code keeps the count of ...
3
votes
1answer
98 views

\takeargs{n} = take n arguments and print them, space separated?

I'm looking for a command \takeargs{n} (in either TeX or LaTeX) such that f \takeargs{n} {x_1} ... {x_n} = f\ x_1\ ...\ x_n , that is (if I understood that part) \takeargs{0} = \takeargs{n} ...
4
votes
2answers
3k views

variable-name \newcommand with parameters within another \newcommand

In "Defining a newcommand, with variable name, inside another newcommand" we learned how to use \newcommand within a command definition with another \newcommand, when the name of the inner command ...
2
votes
2answers
557 views

Passing nodes as parameters to a macro in TikZ

I would like to define a macro which would take two nodes as arguments and "connect" them using a third, predefined node. Like this: \documentclass{minimal} \usepackage{tikz} ...
14
votes
2answers
342 views

Macro to take a character as argument, make it active, then \def it.

I have a XeLaTeX document in which I want some unicode symbols to be auto-substituted, like ¼ → 1/4, » → >>, « → <<. But instead of a long list like \catcode`\¼=\active\def¼{1/4} ...
3
votes
2answers
879 views

Macro that inserts arguments into an environment

I'm having a bit of an issue trying to get a piece of code up and running. I'm working on extending python.sty file for embedding python into a LaTex document (adding persistent data and the ability ...