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

learn more… | top users | synonyms

5
votes
1answer
137 views

How can I define a macro with literal square brackets in the body?

The following macro works correctly for enclosing an expression in parenthesis. \def\group#1{\left ( #1 \right )} I want to write the equivalent macro for enclosing an expression in square ...
1
vote
0answers
34 views

limiting expansion in marks

I'm trying to pass something complex (e.g. tabular) to output procedure through marks. Is there any natural way to protect from expansion everything that should be protected (presumably because of ...
4
votes
1answer
72 views

Preventing argument expansion

TikZ is able to define parametrized styles using arguments like #1. If used in \newcommand or \newenvironment, they mix up with the arguments of the command. The effect is so severe that the following ...
9
votes
2answers
268 views

How can I encode the current document as a QR code with pst-barcode?

\documentclass{article} \usepackage{pst-barcode} \begin{document} \begin{pspicture} \psbarcode{\input{\jobname.tex}}{}{qrcode} \end{pspicture} \end{document} I tried placing \expandafters before ...
7
votes
2answers
61 views

How to manage expansion for this case?

My objective is to automatically compile parameterized template from within a main input file. For each compilation, a unique jobname and parameter are passed to the compiler. The problem is, passing ...
5
votes
1answer
134 views

Capitalization of datetime format

In languages like dutch, the first letter of the names of days and months are not capitalized unless they occur as the first character of a sentence. So I added the following code in the preamble of ...
1
vote
1answer
217 views

Defining a `\subtitle` macro - `\reserved@e` undefined

I want to define a general-ish \subtitle macro that simply adds to the \@title macro set by the user-level \title. Here is what I've got: \documentclass{article} \RequirePackage{xparse,expl3} ...
4
votes
1answer
94 views

Using complicated macro in \thanks command of abstract package

The \saythanks command chokes when \thanks has been called with a macro that takes (and executes!) another macro as argument: \documentclass[twocolumn,a5paper]{paper} \usepackage{abstract} ...
11
votes
3answers
170 views

How to pass a macro as the argument to \selectlanguage

The following mwe throws the error You haven't defined the language lang yet. \documentclass{article} \usepackage[american]{babel} \newcommand{\lang}{american} \selectlanguage{\lang} \begin{document} ...
7
votes
1answer
128 views

I'm confused about how expansion is happening here

I was really pleased that I could come up with a means of building the contents of a tabular environment using \foreach \x in {...} {...} structure. But I was curious about what exactly it would take ...
4
votes
2answers
200 views

Some misunderstanding about macro expansion

I have the following code which doesn't work: \documentclass[12pt]{article} \tracingcommands=2 \tracingmacros=2 \tracingall \makeatletter \let\sep\relax \def\put@stack@#1#2{\edef#2{#1\sep#2}} ...
7
votes
2answers
168 views

Expand LaTeX macros to modify

I am using the polynom package for polynomial long division. For example: \documentclass{article} \usepackage{polynom} \begin{document} \polylongdiv{x^3-x^2+d}{x-2} \end{document} Notice that I ...
17
votes
3answers
173 views

How do I have to invoke \expandafter for a macro with multiple arguments?

\documentclass[pstricks,border=12pt]{standalone} \usepackage{pst-node} \begin{document} \begin{pspicture}[showgrid](-5,-5)(5,5) \pnodes{A}(-2,3)(3,4)(2,-1)(-2,-4)(-4,0) \def\points{(0,0)} ...
9
votes
3answers
181 views

Command doing the same job as StrBefore but being expandable

I am looking for a command allowing me to get 3 as output if the input is 3.2. \StrBefore{3.2}{.} works fine for this purpose but is not expandable and I need to call it in another macro inside a ...
6
votes
2answers
144 views

Use of a macro to set counter value in another macro

I am trying to simply set the value of the counter try which I defined previously to the value of the output of the \foo command. However this does not work. I guess that the problem is coming from ...
3
votes
1answer
74 views

Moving arguments inside group

I have a setup similar to the MWE below in which I have a macro that needs to be called in the document, and also regularly becomes a moving argument (in this case, inserted into the index, though it ...
1
vote
2answers
102 views

Use the argument command itself instead of its argument in newcommand

I want to implement a macro, that uses the command passed in the first argument as the command itself, not as the content passed by evaluating it. Something like: \newcommand{\foo}{bar} % definition ...
6
votes
2answers
134 views

Using an expanded macro for optional environment argument

I'd like to open an environment, passing the content of a macro to the optional arguments. Up to now I tried different approaches using \expandafter, however I could not get the expected behaviour. ...
1
vote
1answer
129 views

Using a macro inside the axis options for pgfplots

I want to create an macro to replace the string '{a,b,c}' in my code: xticklabels={a,b,c} so I set \newcommand\inputnames{a,b,c} xticklabels=\inputnames but this gives me the same result as ...
4
votes
2answers
125 views

Parsing rows (`\\`) and tab characters (`&`)

I have a use for parsing what would look like tabular input data, except that it isn't part of a tabular environment, but rather the argument to a macro. So I developed two macros, \readTABrow which ...
5
votes
1answer
138 views

Amsmath and tikz - conflict?

I have a problem with: \documentclass{minimal} \usepackage[T1]{fontenc} \usepackage[french]{babel} \usepackage{amsmath} \usepackage{tikz} \begin{document} \pgfmathparse{ifthenelse(1<0, ...
9
votes
2answers
92 views

How to expand \ifthenelse so that it can be used in \parshape?

How do I get the following MWE to work: \documentclass{article} \usepackage{xifthen} \usepackage{lipsum} \newboolean{bar} \setboolean{bar}{true} \def\foo{\parshape = 2 ...
8
votes
1answer
136 views

Formatting code fragments extracted from file with minted

I would like to use the catchfilebetweentags package to grab code snippets from a source file and use minted to highlight them. Imagine I have the following in program.scala: //<a def ...
3
votes
0answers
72 views

Difficulty saving formatting to a sequence to be called later in my code

I had an idea about how to answer this question and started putting some things together. I wanted to put something together that was fairly powerful and could handle simplification of linear ...
4
votes
1answer
116 views

I need a fully expandable function to expand in an “f” type argument

I really hope that I'm asking the correct question. What I'm actually working on if far more convoluted than what's happening in the MWE here. I think I've narrowed down things to real problem. I ...
5
votes
3answers
172 views

How can I remove outer brackets without expanding content?

I'm trying to use pgfkeys to collect information that will be passed to a clist. But, I'm not able to get this to work correctly. It seems that I'm getting brackets around the list and is prevent ...
5
votes
1answer
169 views
+50

Use input inside a spreadtab environment with calculations

My aim is to create a command for inserting tables, which will format the table, and add calculations on its values, given a file containing the raw data of the rows only. ...
9
votes
3answers
148 views

Problem with ^^<HEX>

I have small problem with ^^<HEX>. If I have a <HEX> part of the ^^<HEX> in the macro \def\attemp{<HEX>}, I cannot write ^^<HEX> as ^^\attempt or ...
11
votes
1answer
178 views

expandable unit conversion

I'm writing a package to assist typesetting documents for some special Pen & Paper Fantasy RPG. In this fantasy setting, there are three types of coins: gold, silver and copper pieces, which ...
10
votes
4answers
263 views

why can't \the be expanded?

\documentclass{article} \begin{document} \tracingmacros=2 \newlength{\len} \setlength{\len}{1cm} we want to write out \verb$\len$ in cm \the\len { oops, answer in pt} \setlength{\len}{0.0352\len} ...
5
votes
1answer
75 views

newsavebox named after counter

I am trying to write a macro creting automatically a certain number of saveboxes. Therefore I would like to use the concatination of the value of a string and a counter to name the saveboxes. I tried ...
5
votes
2answers
154 views

Color Management with a Family of Curves

I am struggling with following fairly simple looking problem of plotting a family of curves. \documentclass[border=1mm]{standalone} \usepackage{pgfplotstable} \pgfplotsset{compat=1.8} ...
15
votes
2answers
333 views

How to display command name and its value

Latex displays the command values by default - I am finding it more difficult to display the command names along with the values. I have a list of commands that I would like to loop over and print ...
9
votes
1answer
213 views

Expansion inside \AtBeginDocument

I'd like to expand a macro inside \AtBeginDocument, although I guess the concrete macro does not matter. \documentclass{article} \makeatletter \@for\x:=1,2,3\do{% ...
4
votes
1answer
184 views

Are there any programs that will attempt to preprocess simple LaTeX?

I find myself in the awkward, although apparently not uncommon, position of being ordered to write, or at least end up with, documentation in the Word format. I don't have anything that fancy in my ...
6
votes
1answer
657 views

How to use \ifnum for arguments (expanding macros)?

I want to count my section's, figure's etc. using the totcount package. To get a general useable template I want to show only counters which are larger than zero. But it seems that total{counter} ...
8
votes
1answer
97 views

How do the \xx_case: functions work?

In the process of answering expl3 switch for booleans: Is there a \bool_case:Nnn?, I tried to make sense of the various \xx_case: functions Expl3 provides. Here, for example, is \tl_case:Npn: ...
8
votes
1answer
267 views

\href is not working inside \xdef

this is my first question here. I've already spent a substantial amount of time searching this before posting it here. This is my code: \documentclass[]{article} \usepackage{hyperref} ...
4
votes
2answers
102 views

Wrapper around xdef to check for conflicts

How can I write transparent wrapper around xdef that, depending on package options, report error, override or obey previous definition without sacrificing all flexibility? I have no idea how to pass ...
7
votes
3answers
131 views

Command that expands to the contents of a file

I'd like to make a macro that expands to the contents of a file. Basically something like \def{\mycommand}{\input{file.txt}} % file.txt contains "Hello%" \anothercommand{\mycommand} ...
11
votes
4answers
191 views

Partially expanding a command

My \john command is defined like so: \def\john{\DontExpandMe} I would now like to repeatedly change its definition, to keep adding some extra stuff on the front. \foreach\i in {ape,bat,cow,dog} { ...
8
votes
1answer
74 views

A proxy command for deprecation

I'm interested in defining a macro to deprecate other macros. The system on which we are working goes through a lot of refactorings and is used by more than a couple people, so we want to be able to ...
9
votes
2answers
255 views

Expansion problems with pgfkeys

I'm using pgfkeys, and a fairly adventurous syntax in which the values for some keys contain additional key/value pairs. (For instance, the value of the nodes key is a list of pairs, and the second ...
6
votes
2answers
414 views

Expand command read from file

I have a file, that contains a list of latex commands each command per line. Now I want to read this file line per line and execute/expand the macros automatically. I tried the following but this only ...
6
votes
4answers
183 views

Expansion of commands in errmessage

When I run \documentclass{article} \def\pet{dog} \errmessage{My \pet\ is {sick}} \begin{document} My \pet\ is {sick}. \end{document} the error message is: My dog\ is {sick}. but the PDF ...
10
votes
2answers
156 views

Preserving (and Controlling) Expandedness

In most cases, by the time output gets to your screen, arguments are fully expanded and my question is moot. But sometimes (verbatim being a common example), one wishes to operate on arguments with ...
19
votes
2answers
324 views

Difficulty with macro expansion

I'm not getting the output I want from my LaTeX code, and I think the problem is that I'm not expanding things at the right times. Code \documentclass{article} \usepackage{tikz} ...
7
votes
1answer
145 views

String Comparison with a \protected\def

I am using a \protected\def as that solved an earlier issue of mine. I need to compare this value of the token to see if it is initialized to the same value as the \protected\def in different ways. ...
3
votes
2answers
315 views

Undefined control sequence \pgfmath@

Why does the following code give me this error message? Error ERROR: Undefined control sequence. --- TeX said --- \pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@ l.28 \draw ...
8
votes
2answers
363 views

Package xparse \SplitList last token

I need to create a macro to render lists with a variable number of arguments (1+), e.g. \mylist{1,2,3} should expand to $\tilde{1}$--$\tilde{2}$--$\tilde{3}$. I'm trying to use xparse and \SplitList, ...