Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [expansion]

{expansion} is about expanding tokens, including the manipulation of expansion order and the suppressing of expansion.

0
votes
1answer
26 views

Problem calling \creflabelformat from a command

I'm using the cleveref package with some customizations, using \creflabelformat. Because cleveref should be the last package to load, and because the customization commands should come after cleveref ...
1
vote
2answers
30 views

forcsvlist to use the expanded result of another forcsvlist

My problem is, that I have a list of authors, that I use at several places for several things. For example I would like to generate an Author's index. In the code below I would like to "rework" the ...
7
votes
3answers
524 views

Who ate my space? (How to stop \exp_args:Nf from consuming a space?)

I have a macro that uses \prg_replicate:nn to produce a number of spaces, then pass those spaces, after f-expanding \prg_replicate:nn, to another macro. The problem is that when I use \exp_args:Nf, it ...
9
votes
2answers
491 views

Is there a list of expandable TeX primitives? LaTeX? e-TeX? others?

According to Christian Hupfer's comment I understood that calculations are possible in a keyval list when the macro is expandable. The macro \numexpr being expandable, calculations are possible. ...
3
votes
1answer
163 views

Check if macro is fully expandable

Question Is there a way to check whether a macro is fully expandable (or rather "safe in an expansion-only context" [1])? Consider this code: \def\a{Just a string} \def\b{\a} \def\c{\def\unsafe} \...
0
votes
0answers
30 views

Prevent macro expansion within setbox

Following code is the quintessence of a problem i'm facing: \documentclass{minimal} \newbox\boxa \newbox\boxb \newbox\boxc \parindent=0pt \begin{document} \setbox\boxc\hbox{Hello World!} \def\...
2
votes
1answer
61 views

Using exam question counter as an argument

I am trying to use the exam class to create a study guide for my students that has all of the answers at the end of the document. I would like to have the answers automatically labeled by question ...
3
votes
4answers
183 views

Expanding macro twice

How would you expand a macro twice in LaTeX 2 (or 2epsilon). I am aware of the question What is the preferred way of expanding twice in expl3?, but I'm curious as to how you'd do it in LaTeX. I'd ...
15
votes
2answers
480 views

Passing arguments to a macro hidden in the text

Context: I'm trying to write a macro that behaves somewhat like C's printf family of functions. For instance, the following C code: #include <stdio.h> int main() { printf("Hello %s! Today'...
10
votes
3answers
318 views

Expanding macro defined by \csdef to define a style via \tikzset

I need to store tikz option in a \csdef{}: \csdef{My Node Option}{draw=red, thick, fill=yellow} How do I use this definition to define a style via \tikzset? I attempted to use .expand once as per ...
1
vote
2answers
44 views

Storing options for pgfkeys inside macro

I want to define some options as a list of key-value pairs inside a macro and use that macro inside a command that takes pgfkeys-style options. Here is a MWE: \documentclass{standalone} \usepackage{...
4
votes
2answers
123 views

Formatting phonenumbers with phonenumber-package and macros as argument (expand-problem)

I try to use the phonenumbers-package to format phonenumbers. As argument I want to use a macro (in the actual document the macro will be defined with pgfkeys!) What I tried so far: \documentclass{...
2
votes
1answer
28 views

\centering leads to cascade of errors

Context: I'm developing a title page (writing my own titlepage environment) and I'm writing my own \thanks command (to give me control over where I spew the footnotes). Not knowing how \footnote does ...
0
votes
1answer
39 views

Protect fragile variable in file path. Case of \ifthenelse in \includegraphics{}

In this script: \documentclass{article} \usepackage{ifthen} \usepackage{graphicx} \newcommand{\myfigure}[1]{% ...
9
votes
2answers
204 views

What is the difference between \unexpanded and \protected in ConTeXt?

EDIT: It turns out that \unexpanded in ConTeXt is different from \unexpanded in ε-TeX, so the earlier description doesn't apply. I'll update the question accordingly. From the ε-TeX manual: ...
2
votes
1answer
28 views

using commands in pgfkeys not working

The following latex code works as expected. It allows to draw a line parallel to the z axis: \documentclass[border=10pt]{standalone} \usepackage{tikz} \begin{document} \tikzset{ parallel to z axis/....
2
votes
1answer
40 views

How to protect a fragile command in a moving argument? The case of macro containing \ifthenelse in \caption

This script works as expected: \documentclass{article} \usepackage{ifthen} \usepackage{graphicx} \newcommand{\foo}[1]{ \newcommand{\capt}{ \ifthenelse{\equal{#1}{ORIG}} {original}...
2
votes
1answer
68 views

“Missing \endcsname inserted” error after \expandafter chain

Solved Thanks to @PhelypeOleinik for the solution! And thanks to everyone else who responded so quickly to provide assistance. For anyone who finds this post in the future, the error really had ...
0
votes
0answers
36 views

Weird \hfill behavior with custom length calculations?

I asked a question earlier about trying to write a macro/environment that would take in a number of \choice commands and then write them out in a way to minimize vertical space consumed, but still ...
1
vote
1answer
47 views

passing a parameter to nested macro inside caption

I'm having a really hard time understanding this error in a massive document. I took the time to work out a "minimal example", so I could post the error with precision. Please, when trying to answer, ...
6
votes
2answers
97 views

What are the values for parameters of an \edef at the time of definition?

Suppose we have the following short document \documentclass{article} \def\foo#1{\if#1XX\else not X\fi} \edef\bar#1{\if#1XX\else not X\fi} \begin{document} foo: X = \foo{X}, Y = \foo{Y} bar: X = \...
3
votes
1answer
40 views

How to expand pgfkeys value when the key path contains macros?

This question represents a second, more simplified, attempt at a problem I asked about some time ago but for which I received no answer. In short, I need to put the fully expanded result of a call to ...
0
votes
1answer
31 views

Avoid expansion of `\marginpar` argument

I'm trying to make a margin par that will show the value of some macro defined after the placement point of the marginpar (think of it as something like \footnotemark vs \footnotetext). However, the \...
4
votes
3answers
100 views

Trying to get \zap@space and \lowercase to work on string comparison

I am trying to do a non-case-sensitive check on two strings that may or may not have spaces in them. I have googled this and there is quite a lot of literature on either of these problems, but I can't ...
2
votes
2answers
41 views

Control space not expanding in label command

Somehow a control space \ used in \label doesn't expand. \foo gives the following newlabel in the aux file: Anonymous\ 1. Mind the backslash. The log gives: "! Missing \endcsname inserted." \baz does ...
0
votes
1answer
44 views

`\def`, `\edef` math and commands

I have this command that's part of something bigger \newcommand{\customParagraph}[2][1]{% Title, Name \ifthenelse{\isempty{#1}} {\def \customParTitle{}} {\edef\customParTitle{ -- #...
1
vote
1answer
68 views

Defining a macro for tabularx line that expands counter values but doesn't error on &

I can do this with brute force, but I've run into this problem in several settings and can't seem to get the macro expansion to work out the way I want. Here's my current code (which is pretty close ...
3
votes
3answers
44 views

Execute condition in “last” environment typeset of it's type

I am trying to write some code that will clean up some future notes for me. In essence I want to be able to "turn on" or "turn off" an environment (proofs of results) via a simple command. I managed ...
8
votes
1answer
116 views

Distinguish active characters from non-active pendants with expansion-methods only?

(Please take the following question rather for a moot point than for an everyday-problem.) Is there an expandable method for distinguishing an arbitrary explicit non-active character token from its ...
2
votes
1answer
38 views

How to send the present value of a counter to the index

The following is a simplification of the behavior of pagnote package, when you send all the notes to the end of the book. When some name in a note has to be indexed, it's better to make the number ...
6
votes
2answers
275 views

Fully expand macro argument

I am sure this has been answered already, but I cannot seem to find any answer that explains it in core TeX primitives and that I understand on a token level, e.g. I definitely don't want to get into ...
0
votes
1answer
31 views

including graphics from multiple directories

I have tried two approaches to including graphics from multiple directories, one using graphicspath and another using macros. The graphics path approach is: \documentclass{beamer} \usepackage{...
3
votes
1answer
77 views

Adding content to nonexpandable commands without a huge hassle

I'm wondering if there is a package or method to add content around delicate commands without changing the command's name. For example, let's say I want to change \sqrt[#1]{#2} command to yield \...
2
votes
1answer
57 views

Tikz: can I not create any macro?

So far I have written this: \node (A) at (0, 0) {A}; \node (B) at (2, 0) {B}; \draw (A) -- node[midway, above=-.5ex] {\tiny connects} (B); in order to produce this: Since I am about to do this a ...
0
votes
1answer
47 views

Using a macro inside a \draw

I am facing some - probably very silly - problem. I want a multi-version document - one for me, one for my students and one complete version. The idea is that you just change the versioning in the ...
4
votes
1answer
39 views

Macro Substitution/Expansion in Environment Names

I've noticed that you can use macros for substitution into environment names: \def\itmz{itemize} \begin\itmz \item Item the first \item Item the second \end\itmz % works It also works ...
0
votes
0answers
77 views

Expandafter, but with full expansion?

Problem. I want to write a macro, that effectively replaces \MyMacro\SomeOtherMacro{arg1}{arg2}StuffAfter by SomeOtherMacrosExpansionWithArg1Arg2\MyOtherMacro StuffAfter i.e. essentially \...
1
vote
1answer
58 views

boxplot prepared from table, accessed using row names instead of numbers

I have csv files1 that I want to plot as boxplots. I found the solution to that part of the problem here (courtesy of Jake), and that constitutes a large part of my MWE. The difference here is that I ...
4
votes
0answers
86 views

\string-primitive works in unexpected ways in LuaTeX — Where can I find exact documentation of the \string-primitive in LuaTeX?

Where can I find exact documentation of the \string-primitive in LuaTeX? I ask this question because I encounter some unexpected (at least by me) behavior when compiling the example below with LuaTeX....
0
votes
0answers
55 views

Change the output of the sage function latex() on a string

Currently if you run the sage command latex('a string') using sage (or sagetex) the latex output looks like: \text{\texttt{a{ }string}}. I would like to eliminate either of these (preferably the \...
2
votes
1answer
71 views

Expansion of siunitx glossary entrys using a csv file

I'm try to create a custom latex class based on scrbook. I make heavy use of glossaries for my math symbols, for which pdftool tips are created showing the description and units when a mouse pointer ...
1
vote
1answer
91 views

How to use \exp_not:N and \exp_after:wN to prevent the expansion of \input in a expl3 list?

I have been working on the implementation of an environment (which never nests) and a command to save different parts of a document and use them within it later using a expl3 list andxparse. So far ...
1
vote
1answer
108 views

How can expand a counter of auxiliary file and save in list with xparse?

I am using the modification of a macro to save to lists using expl3 and xparse. I have managed to create a small interface type [key = val] and using the environ package I have been able to achieve my ...
3
votes
6answers
115 views

Etoolbox Equivalent: Define Control Sequence via Macro

When using normal macro names I can set the value of a macro as \newcommand*{\SetMacro}[1]{\def#1{42}} \SetMacro{\Answer} and \Answer will have the value of 42. Is there an etoolbox way of invoking ...
7
votes
2answers
209 views

Macro not working in foreach loop

I'm trying to color the cells in a few columns with different colors, depending on bounds passed as an argument. I would like to have one macro that takes two arguments: a .csv file and a comma ...
4
votes
1answer
124 views

\lipsum redefinition doesn't expand well with lcg random integer

I'd like to redefine the \lipsum command provided by the lipsum package such that \lipsum{} outputs not a predefined amount of lorem ipsum paragraphs, but a single, random, lorem ipsum paragraph (that ...
3
votes
1answer
57 views

Non-trivial nested environment expansions with lualatex dependent packages

In the following MWE I have an environment that needs lualatex to compile. In brief, I'm trying to create an environment that creates a very specific instance of another environment, i.e. with a ...
2
votes
1answer
141 views

Error of \begin{problem} ended by \end{problem}… huh?

So, I know if I get a mismatch error like error: \begin{problem} ended by \end{document}, that means I have mismatched number of \begin and \end commands. But here, I am getting the following error: !...
6
votes
2answers
86 views

Expansion issue in tasks package

I'm trying to switch from enumitem lists to tasks lists, but the following, which works in an ordinary enumerate environment, generates a "Something's wrong--perhaps a missing \item" error in the ...
9
votes
3answers
341 views

How to avoid input stack overflow during recursion

Although there is already a ↗qestion with a similar title, I take the risk of asking again, because the linked topic is a bit bloated in my opinion, the answers/solutions too complicated. So here is ...