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

learn more… | top users | synonyms

2
votes
1answer
73 views

Specify file name shell access via \@@input

Background: I need to perform a conditional branch based on the first three characters of a file. I found a rather simple solution (on a Unix system, or PC with cygwin installed): head -1 ...
14
votes
2answers
332 views

LaTeX3: How to get reliable control over the level of expansion?

Say you want to write LaTeX3 code that manages user data. Sometimes you want to process that data, but other times you just want to store it, move it around and return it unchanged (when developing a ...
15
votes
3answers
301 views

Parsing strings containing diacritical marks (macros?)

I apologize that this question may seem very much like several other recent ones I have asked (Parsing leading hardspaces, Parsing a \$ as part of an improved \getargs command). They are all related ...
6
votes
1answer
114 views

\def variables with xparse and other questions about variables

I'm writing a documentation for a REST API. So there's very much information that has to get repeated. So I'm trying to figure out a few things: Consider the following code: ...
4
votes
1answer
256 views

Expand macro immediately in \pagenote

I'm trying to use the contents of a macro in a \pagenote, using the memoir class: \documentclass{memoir} \makepagenote \def\myvar{Good morning.} \begin{document} In the morning\pagenote{\myvar} ...
5
votes
2answers
185 views

Variadic arguments macro

I am trying to make macro with variadic arguments, iterating over them. The final result is supposed to be: \foreach[x]((var = \x )){foo}{bar}{baz}\null evals to var = foo var = bar var = baz My ...
7
votes
3answers
704 views

\uline within a pgfmath expression produces an error

Why does using \uline within a pgfmath expression result in an error? \documentclass{article} \usepackage[normalem]{ulem} \usepackage{tikz} \begin{document} \pgfmathparse{width("\uline{blabla}")} ...
7
votes
1answer
140 views

Forcing macro expansion with keyval

While trying to provide an answer to this question, I've run into a stumbling block that I can't seem to get over. The listings package (like many others) uses keyval to handle configuration. What ...
7
votes
2answers
114 views

Is there a way of defining a command \nullifyifmoved{arg} that will normally act like its argument but act like a no-op if the macro is “moved”?

I'm interested in a macro \nullifyifmoved that takes one argument arg and acts like arg in normal contexts, except it acts like a no-op wherever it is written to a file. Some background: Martin ...
3
votes
1answer
68 views

List Version of \str_if_eq

I am using \str_if_eq:xxTF{\A}{\Target}{<true>}{<false} to execute the <true> or <false> code if \A=\Target. What is the list version equivalent of this? So I am looking for ...
9
votes
1answer
153 views

Is there a way of defining a command which is automatically converted to a no-op after its first execution?

Is there a way of defining a command that can be executed only once and is then redefined to be a no-op? Related: Is there a way of defining a command \nullifyifmoved{arg} that will normally act ...
4
votes
3answers
131 views

Macro to be used in a \section command that has no effect in the table of contents

I need a macro that is executed only in the main document (within a section title) and then disappears (for the table of contents). A minimal example where this occurs is this: ...
5
votes
3answers
140 views

Metacommand for commands that dynamically select a parameter?

Original question I would like to create a metacommand for creating new projection commands. Specifically, \newproj{\cmd}{<n>}{<m>} should create \cmd as a new command of <n> ...
5
votes
2answers
105 views

passing current content of commands to a macro

I am sorry for this is probably a current question with a well known answer, but I was not able to google it out. I am trying to build a macro adding content step by step; at every step I need to ...
4
votes
1answer
127 views

Expanded StrSubstitute

I am trying to use \StrSubstitute, but what I want is to expand it all the way to get the result string. \StrSubstitute{Řepa}{Ř}{Rzzz} then i use it with % somehow define \a as the result string ...
13
votes
2answers
934 views

Allow underscore in PGFPlots tick labels read from table

I'm trying to use the text data from a table column as the tick labels in a plot. The text data contains underscores, which makes LaTeX throw a Missing $ inserted error. I'd usually get around this by ...
24
votes
3answers
621 views

A guide to understanding expandability: when to write protected functions and when not to

I'm having difficulty understanding (and appreciating) the concept of expandability. I'm very murky about understanding when and how expandability impacts me in writing code for my documents. I've ...
2
votes
1answer
132 views

Passing name ending with number to \csname does not work [duplicate]

Possible Duplicate: macro names with special characters When I use \yyy defined bellow it does not print yyy, but if I use \xxx it prints xxx. How can I make \yyy work? \def\P1{yyy} ...
9
votes
1answer
1k views

Difference between \newcommand and \pgfmathsetmacro used in TikZ \coordinate

Consider the following code: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \newcommand{\MA}{4} \pgfmathsetmacro{\MB}{4}; \coordinate (V11) at (0,0); ...
8
votes
3answers
180 views

Nested use of \ifcsname needs protection

I have a macro \command to ensure that the names of macros in my documentation are consistently formatted. Been work great, until I had an urge to procrastinate and had this brilliant idea that I can ...
5
votes
1answer
305 views

How to use macros in command \dirtree of package dirtree?

I want to print a tree structure and started using the package dirtree (v0.32, see Making a (simple) directory tree). Following calls work smooth: \dirtree{.1 root. .2 child1. .2 child2. .3 ...
3
votes
1answer
482 views

Using “German” quotation marks inside \newcommand [duplicate]

Possible Duplicate: babel shorthand "| doesn’t work in macros I know there is a deeper non-understanding of LaTeX mechanics at work here, but I have no idea how to phrase my question ...
7
votes
1answer
95 views

Define macro based on Datatool contents

I can define a macro of the form \csname../dirX Color\endcsname manually and use it as desired. However, I am unable to do the same thing based on the contents as read by the datatool package. The ...
6
votes
3answers
132 views

reproduce section at different position

I would like to reproduce a \section at a later position, with the same number as at the original position. I tried \newsavebox{\meinebox} \savebox{\meinebox}[80mm][l]{\section{Hier}} ...
7
votes
1answer
203 views

\ifmmode self-contradictory in amsmath (OK in just LaTeX)

File: \documentclass[11pt]{article} \usepackage{amsmath} \newcommand{\argghhh}{\relax\ifmmode\bar\else\expandafter\=\fi} \begin{document} $ \argghhh a $ \end{document} produces error (but ...
3
votes
1answer
97 views

using \ForEach to input chapters in a document

I have several chapters in the folder /Chapters and I have the following LaTeX code: \newcommand\chapnames{Chap1, Chap2, Chap3, Chap4, Chap5, Chap6} \ForEach {,} {\input{./Chapters/\thislevelitem}} ...
18
votes
1answer
317 views

Unusual numbering: combine alph, Alph, arabic

I would like to have an unusual numbering aAa going as follows: 0 -> * ------------------------- 1 -> a 2 -> b ... 25 -> y 26 -> z ------------------------- 27 -> A 28 -> B ...
2
votes
1answer
72 views

Pass the contents of an \input command to a macro

I am having some difficulty with the expansion of LaTeX. I would like to expand the contents of an \input command before passing them to macro, in a pattern similar to the following: \outer{\inner} ...
8
votes
1answer
103 views

Omitting arguments in macro expansion

Changing a simple TeX macro like \def\macro#1 #2{#1 #2} into \def\macro#1 #2{#1} alters the output of \macro Hello world surprisingly for me to Helloorld My expectation would have been to ...
4
votes
1answer
130 views

Expansion Issue with omit list provided to \DTLdisplaydb

In my DB the number of columns is rather large. Hence, I am trying to eliminate any columns which contain only 0 entries. The number of columns, nor the column keys, are know upfront. So, I step ...
5
votes
1answer
90 views

String lowercase equality (newbie question)

i'd like to test if a string, once transformed into lowercase is equal to a given string. Here a MWE of what i'm talking about : \documentclass[a4paper,10pt]{report} \usepackage[francais]{babel} ...
10
votes
3answers
179 views

\expandafter and counters not playing nicely

My google-fu has finally failed me... I'm trying to write a package that will allow you say \addauthor{name, email} several times and have the title page properly formatted. Here is a minimal example ...
10
votes
1answer
120 views

Environment with delayed expansion

I'm trying to define an environment test that stores its contents unexpanded in a macro \testcontents. For example, the code \newcommand{\cmd}{bad} \begin{test} \cmd \end{test} ...
9
votes
3answers
271 views

Write on a file and input it

I'm trying to redefine a \tableofcontents-like command. I proceed this way : the displayed elements are written to a file, and the file is input when I want the display. If I know the toc will be ...
9
votes
5answers
309 views

Parse dotted string, extracting last part

I want a macro that will separate a string like "1.2.3" into two parts: the part until the last dot (call that the context) and the last number. This seems a pretty basic application of a helper ...
9
votes
1answer
226 views

Using \typeout behaviour different with \newtoks vs. \def

I feel as I really should know this, but sadly I don't. Why is the output of \typeout{\the\myToken} not the same as having it printed in the PDF as \the\myToken. No problem with a \def, just with ...
3
votes
1answer
84 views

how to return protected command with one argument already validated in latex/tex?

I want a command that will create an unevaluated bit of LaTeX/TeX code (to be evaluated at the end of an environment, but this is not necessary information) that has been created using an evaluated ...
16
votes
3answers
414 views

(Why) Can't we get 'fully expandable' versions of every command?

I'm just starting to figure out what 'expandable' means in LaTeX, and why it is useful to have commands that expand as far as possible. In particular: If you want to \typeout some string to the log ...
6
votes
3answers
144 views

Expansion issue when adding to CSV list from within a \foreach

Another expansion issue that I am unable to guess at the correct combination of \edef/\expandafters to get to work. Background: Below I have defined \AddToCommaSeparateList which uses \g@addto@macro ...
2
votes
1answer
137 views

Use result from pgfmath with xifthen

I try to use the results of pgfmath calculations with cnttest from xifthen, but it fails: \documentclass{article} \usepackage{pgf,xifthen} \begin{document} \pgfmathparse{42+77}% ...
4
votes
1answer
82 views

Error with expansions

I am getting an error while trying to compile this minimal example: min.cls: \ProvidesClass{min} \LoadClass{minimal} \NeedsTeXFormat{LaTeX2e} \newenvironment{myenv}{}{ \def\aaa{test } ...
3
votes
2answers
347 views

How to expand an argument defined with \csname…\endcsname?

Similar to the situation described in Expand after all that stuff?, I have a macro looking like \somecommand{Some Argument}{\secondarg}. I also need to expand the argument \secondarg before using ...
8
votes
2answers
298 views

How to create an inline list via a macro

I want to create a macro that yields an inline lists. I can easily do this using enumerate* form the the enumitem package, but when I attempt to wrap this in a macro, I get: Extra }, or forgotten ...
0
votes
2answers
103 views

suppress expansion in macro call

What I would like is to suppress the expansion of the group as a parameter to a macro so that it can be expanded later. For example we want to pass the paramater unmodified as a string to lua or to a ...
13
votes
1answer
135 views

\( \) don't work with TOC?

If i write this line of code \subsection{Ranger \( n \) boules distinguables dans \( M \) boîtes} I obtain an error over the second \) (./Probabilité.toc ./Probabilité.toc:8: LaTeX Error: Bad ...
5
votes
2answers
342 views

Expand command and put result into a macro: Use of \value doesn't match its definition

I still struggle with the expansion of Latex. I try to calculate the a real number from a date format and put this into a macro \value. I need to expand the command with \edef because I plan to use ...
5
votes
1answer
223 views

Use macro to draw inside pgfplot/axis

I would like to implement a gantt chart function inside pgfplots. To draw the tasks, I have a macro that calculates the start and finish time of a task. However, when I use multiple tasks, the values ...
4
votes
1answer
106 views

Expanding command in \addchaptertocentry

I'm using a counter to increment months in a journal and the datetime package to turn the counter into months. The months then become chapter titles in the document, so I have something like this: ...
6
votes
1answer
110 views

Package providing fully expandable conditionals

Is there a package providing a collection of fully expandable conditionals like this one: \newcommand\myif@num[1] {\ifnum#1\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} Background: ...
3
votes
2answers
221 views

Providing data series for sparkline environment

I would like to have the data series for a sparkline defined in terms of a macro -- or some alternative -- as opposed to have it set explicitly in the sparkline environment itself. My attempts so far ...