Questions tagged [expandafter]
The expandafter tag has no summary.
43 questions
1
vote
1
answer
44
views
How to get rid of the double quotation mark produced by `\string\eta`?
Trying to implementing this :
\RegistVarType{obj}BG{pink}Font{\sf} will produce a command named \obj,
\obj c will display a "c" in \sf font with pink background color; also,
\RegistVarType{...
8
votes
3
answers
192
views
Combine numbers from custom commands into a range
I’m defining datas in LaTeX with a custom command that stores both a label and a number:
\documentclass{article}
\usepackage{parskip}
\newcommand{\data}[3]{%
\expandafter\newcommand\csname #1\...
5
votes
2
answers
178
views
Copy command with cs names
I want to copy a cs name to another name:
\documentclass{article}
\newcommand{\renewcommandcopycs}[2]{%
\expandafter\RenewCommandCopy\expandafter
{\csname#1\endcsname}%
\expandafter{\csname#...
3
votes
2
answers
154
views
How to check if a macro exists when its name is constructed from a user-defined macro in LaTeX?
Problem
I'm writing a LaTeX macro system to manage acronyms in Overleaf, and I need to dynamically check whether a macro like \acronym@CH@used exists. The acronym key (e.g., CH) is stored in another ...
1
vote
1
answer
78
views
Using \expandafter and custom commands with multiple arguments
I'm trying to use a defined list with the \forcsvlist command. From my understanding, I have to expand the defined list before the \forcsvlist command executes. I have tried so many iterations using \...
3
votes
1
answer
119
views
Expandafter for environment argument
I have an environment page where
\begin{page}{some page id}
is not equivalent to
\def\pageid{some page id}
\begin{page}{\pageid}
I desire an incantation which allows me to take a \pageid and expand ...
2
votes
2
answers
128
views
Expansion of arguments in commands [closed]
I have madethis command \RepNum{#1}{#2}. This command is created to indicate the number of times the argument #1 is repeated in the list #2, separated by commas.
\def\RepNum#1#2{%
\begingroup
\...
0
votes
1
answer
129
views
Expand a little complicated macro
The macro \usevar{} is defined in the below code and it can be expanded with \ExpandArgs{e} command. Is it hard to expand it with expandafter instead ?
\documentclass{article}
\usepackage{etoolbox}
\...
1
vote
3
answers
190
views
a two steps expansion
I defined command \a and \b in the following code. Expanding \a just need one step and \b should take two steps. How to expand \b only using \expandafter ?
\documentclass[12pt]{article}
\usepackage{...
5
votes
6
answers
379
views
creating named control sequences
I have a csv file with typical row content ["66,"primary description","description for LoF","myjpeg.jpg"] and I want to create a named macro for each row e.g for ...
1
vote
2
answers
129
views
Is this code idiomatic?
I am writing a math paper consisting of several Definitions, Lemmas, Theorems, Corollaries, etc. Every such part can have a title and/or a reference. In the text, I would like to have both the title ...
1
vote
1
answer
174
views
Expanding Variables to Input as Arguments for Macro
I have an issue when trying to use variables in a command (\ResearchModule). I read up to 8 lines from a text file and have them set to elements of an array (using code thanks to egreg!), with \...
4
votes
1
answer
87
views
Generate \charge arguments with a macro
I'm trying to use a macro to generate arguments that should be passed to \charge. I'm trying this:
\documentclass{minimal}
\usepackage{chemfig}
\begin{document}
\charge{-135:1pt=5}{C}
\...
7
votes
3
answers
435
views
How to expand a command with \csname and \expandafter
I get it when I write:
\expandafter\def\agent{Hello}
\expandafter\def\expandafter\agent\expandafter{\agent World}
\agent
result: Hello World
It doesn't work for me when I write:
\expandafter\def\...
3
votes
3
answers
251
views
Define a new command as a loop of existing Latex commands
I want to define a new command, which is a composition of commands already defined within the \csvsimple package. Therefore I've written the following code, which correctly works for my purpose:
\...