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

learn more… | top users | synonyms

2
votes
1answer
48 views

How to compare and see if an expanded command is equal to another

Okay, I'm processing a CSV file using datatool: "TRANSID","DATE","QUANTITY" "141f8b4a-e83e-4222-911a-5a977b4d0afca","11/9/2015","10" "88cdad7e-eb21-4010-94c5-acca8ac2e559a","11/9/2015","5" ...
3
votes
1answer
67 views

Producing expandable environments with only optional arguments with LaTeX3 syntax

I am trying to create a new document environment to complete the assembly of a table (simplified for MWE) but I am having a problem combining an expandable environment with an optional only argument. ...
10
votes
2answers
145 views

Ignore expansion in edef

I would like to populate a tabular environment programmatically using an edef. For simplicity, I brought a simple example: \let\\=\relax \let\hline=\relax \edef\mmm{\hline A & B\\} ...
1
vote
1answer
82 views

Use path replacement command inside tikzpicture/pgfplots table

After using the answer of Using \nameref within \path I tried to use that command inside a 'pgfplots' table as file name. Here's the (shortened) code: \newcommand*{\expath}[1]{/Users/jo/{#1}} ...
6
votes
1answer
58 views

Command that outputs at the end of the document the pages and line numbers where it was used

I need to a command that outputs at the end of the document the pages and line numbers where it was used. I've tried different variants of the following code but my knowledge of latex is limited. I'm ...
2
votes
2answers
25 views

Manipulating arguments to a macro inside an argument

In LaTeX, I have a macro \p (okay, it's \paragraph, but perhaps the specific macro is not relevant?) with one argument. Sometimes I use it as \p{plain text} and sometimes as \p{\t{alternate ...
4
votes
1answer
53 views

Is it possible to defer expansion of an object's contents until all content has been created?

I want to provide author-usable macros in my package to store data that will later appear in a table, but it would be nice to allow authors to define the data in that table at any time, even after the ...
6
votes
2answers
133 views

How to extend existing macro with \edef?

\edef does expansion, but does not execute the commands. How in the following example make so that \foo will do assignment to \tmp at the moment of its call, not when it is defined? Why \foo produces ...
6
votes
3answers
143 views

How should I /protect this command for use in \csname?

In the process of learning how to use \csname, I'm trying to create a macro that allows one to specify integers as arguments and then will yield some content specific to the arguments, like this: ...
3
votes
1answer
46 views

Changing content of variables in toc (in ConTeXt): nested \def s

I try to define a "variable" for a category. Using it for the first time, the value should be reset until it is set again. This is the desired output: Fruit: Apricot (also in category) Banana (also ...
5
votes
1answer
91 views

Trouble nesting multiple commands using \newcommandx

First Question in this forum, so go easy on me :) I made a few meeting minutes documents for my business and I wanted a custom command for adding a note in a document. I wanted the color of the text ...
25
votes
4answers
484 views

Expandable (quick) sort array macro?

I'm trying to implement a (quick) sort algorithm. Here is what I can do : \documentclass[preview, border=7mm]{standalone} \usepackage{pgffor} % \push{xs}{\i} add \i in the array \xs ...
2
votes
0answers
55 views

Defining and expanding macros In loops

I want to define and expand macros in a \foreach loop. The names of the macros depend on the iteration step. The macros I define are interpreted as strings rather than sets of numbers that I actually ...
6
votes
3answers
154 views

Write to file: using a macro as the filename

I'm setting a complex user manual, made of several independant documents. For the overall TOC, I want each document to write some data into a file which is then parsed by the TOC file later. Here's ...
2
votes
1answer
26 views

Loading data from csv into arrays [arrayjobx]: problems retrieving values

As a follow-up to several questions, I've come up with the following MWE, with the aim of filling an array (via arrayjobx) with values loaded from a CSV file. The desired output is to print something ...
5
votes
1answer
37 views

The Environ package misbehaviour on empty content

I have encountered a problem with the environ package. It returns a wrong \BODY value when the content of an environment is empty. Here is an example: \documentclass[12pt]{article} ...
5
votes
1answer
185 views

\edef, \xdef and \ifmmode

I don't understand the difference between \edef and \xdef in the following code. Clearly, the \xdef does what I'm expecting but why? AFAIK, $ does not start a group. ...
6
votes
2answers
102 views

new command is expanding as blank

So I'm trying to import a large list of values that are used throughout my report. However when i do this the results are always blank... \documentclass{scrreprt} \usepackage{csvsimple} % ...
0
votes
1answer
63 views

Using \MakeUppercase on expanded macro with argument

I would like to have the first letter in an expanded macro shifted to upper case but I can not seem to manage this. In the minimal example below, I would like the two rows to produce the same output, ...
1
vote
2answers
156 views

How to expand macro in a macro call

How can I expand a macro inside an optional argument list \newcommand{\sss}{% label={$\bullet$},topsep=0mm, parsep=0mm,% leftmargin=3mm,rightmargin=0cm,labelwidth=5mm,labelsep=3mm% } ...
1
vote
1answer
84 views

How can I use \foreach to place nodes in a pgfplots axis?

I am trying to foreach over some coordinates to place nodes at whilst inside an axis environment. I followed the advice here, but I am getting nowhere; the following fails with error ! Argument of ...
2
votes
1answer
82 views

Using a macro for table alignment

I am trying to use a macro to define the alignment of a table as shown below: \documentclass{article} \begin{document} \def\align{|l|c|} \begin{tabular}{\align} 1 & 2 \\ \end{tabular} ...
12
votes
4answers
283 views

Useful applications of \edef with macro arguments

Well, it's been in my head for some time, but I haven't got anything out of it, so I ask here. At what places could be useful to have \edef\foo#1{..}? What applications could it have? Is it useful at ...
3
votes
1answer
78 views

Lualatex : how to avoid this “unnatural” \\

I have a lua function to withch I want to pass some extra optional latex code (basycally a macro with a parameter, macro can change, parameter too). I have to double backslash the name of the macro, I ...
4
votes
4answers
557 views

One-liner for removing characters from a string

I have a predefined command \mycommand which, for some reason, outputs {"/home/user/di rect ory/"/}. (Yes, there's a slash after the quotation mark, and there are curly braces.) Could one think of a ...
6
votes
3answers
95 views

Why does \def fail inside \edef?

An answer to one of my previous questions provided this code for referencing a range of lines in which a line labels were placed at the beginning and end of the line range. \makeatletter ...
3
votes
1answer
102 views

Robust handler of arguments with conditionals and complex elements

Context This question is a follow up of the answer of this question Spurious space on moderncv \cventry using \if Problem The problem is that complex content (for example, itemize on the content of ...
11
votes
3answers
311 views

How to delay expansion

Consider the following document: \documentclass{article} \usepackage{polynomial} \begin{document} \def\a{-3} \def\b{-2} \def\c{-4} \[ \polynomial{\a,\b,\c}\quad\polynomial{-3,-2,-4} \] ...
1
vote
0answers
44 views

how to expand some macros in latex file [duplicate]

I have a latex file that uses some of my own macros (a mix of tex & latex macros). I need to post the latex source, but don't want to expose the macros (some of which are nasty hacks that just get ...
6
votes
3answers
142 views

Check occurrence of a macro inside another macro

With the substr (or xstring) package you can, of course, identify whether a control sequence contains some text string: \documentclass{article} \usepackage{substr} \def\somecontrolseq{some silly ...
1
vote
0answers
75 views

what is the change in macro expansion when using environ and newenviron as compared to the standard environment

The packages environ and newenviron both provide an alternative to the standard environment macros included with LaTeX. The main difference is that they make it possible to refer to the environment ...
3
votes
1answer
56 views

Undefined control sequence at definition

Why would I be getting an error that the control sequence is undefined while I'm trying to define it? ! Undefined control sequence. <argument> * \cs_set:Nn \obj_this:n ...
4
votes
1answer
84 views

How to expand control sequence in argument of a macro

Consider the following: \def\foo#1#2 {% \if#1a% \message{#2} \fi} \def\x{abc} \edef\y{\foo\x} \y The result: ! Argument of \foo has an extra }. The expected result: bc
3
votes
1answer
386 views

HowTo make beamer's \insertauthor all uppercase?

So I was finally able to create a MWE for this one: I am creating my own beamer style which has some areas, where all text is supposed to be all caps. Using \MakeUppercase with the beamer class' ...
0
votes
0answers
14 views

\edef together with microtype generates an error [duplicate]

In a previous question, I asked why \edef produced an error when trying to expand commands that takes an argument in the belief that this was the cause of it. But in actuality, I've realized that the ...
3
votes
1answer
107 views

How can I use \noexpand and \unexpanded without appending a space to the unexpanded tokens?

One of my current tasks involves composing an auxiliary file with extra commands to be loaded at a separate compilation. Here's an MWE: \documentclass{memoir} \newwrite\testaux ...
29
votes
1answer
756 views

What does “expanding” mean in (La)TeX?

You can often read about expanding a macro or when a macro does expand, sometimes about expansion. But what does this mean - in English?
7
votes
1answer
132 views

How can I \typeout a percent sign?

I want to \typeout a message containing a percent sign. I know that if I want to \typeout a macro followed by a space, as in: The name Name is unknown. I have to use \space, not \␣, because \space ...
1
vote
0answers
37 views

Passing background color to \lstinputlisting

In question Passing parameter in presence of an xkeyval value I received two ideas for dealing with passing an option to a macro. Namely, \expandafter\lstset\expandafter{\ME@options} and ...
1
vote
1answer
20 views

error when using expandafter for databib command in indexing command in foreach loop

I'm trying to create an author index using the databib package (datatool) bundle. I can loop over the entries in a BibTeX database and for each entry, loop over the authors using the \foreach command ...
1
vote
2answers
74 views

Pre-expansion of moving macro argument

I am using databib package (datatool bundle) to get information out of a BibTeX database for arbitrary use in a LaTeX file. It provides a command to loop over the BibTeX entries. Within such a loop, ...
8
votes
5answers
327 views

How do I expand exactly once a macro which takes an argument

I thought I was finally understanding expansion, but then I wrote something along the following lines, and it has me a bit stumped. \documentclass{article} \usepackage{xcolor} \usepackage{etoolbox} ...
4
votes
2answers
140 views

Expansion in forest

I am trying to expand a macro as part of a style within a forest tree. Here's an MWE: \documentclass[tikz,border=5pt]{standalone} \usepackage{forest,ifthen} \begin{document} \bracketset{action ...
0
votes
1answer
50 views

Using fully expanded result as a simple string (with citet and \IfSubStr)

I am breaking my head with that problem, without finding anything that could help on Internet : The initial problem is that I write an essay in French but I need to include some articles written in ...
3
votes
1answer
91 views

index, acronym and sorting, macro expansion

I want to use index together with acro: Whenever I use an acronym, I want it automatically in the index. However, not the abbreviation but the long name! What I did: I created a new command: ...
9
votes
2answers
130 views

What is the preferred way of expanding twice in expl3?

expl3 includes the o, f, and x argument specifiers for one-level and the two kinds of full expansion, respectively, before passing the argument to the base function. What is the preferred way of ...
4
votes
1answer
86 views

Setting a counter to a value obtained by expansion

I use the glossaries and minitoc packages. Minitocs are generated for all glossaries printed in the table of content, eg with the toc option for the glossaries package. When one prints the glossaries ...
1
vote
1answer
80 views

Expansion problem in a grid-like tikz figure

My goal is to automate a process where I have many pictures from a movie sequence and I would like them to be typeset in descending rows. For that, all my images rest in a folder and of course, they ...
5
votes
2answers
206 views

Use \foreach loop to execute macro with parameters of macro provided in a list

I have to execute a macro a number of times, and would like to provide a list of the parameters to be executed. So, instead of \FormatLinks*[Main Search Site]{Google}{http://www.google.com} ...
4
votes
1answer
52 views

How can I set a style in `\forestset` which requires delayed calculations with the results of node walks?

What is the correct way to wrap the specification for the tree below into the my binomial style defined in \forestset and why? The following code works fine: ...