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

learn more… | top users | synonyms

4
votes
2answers
78 views

Creating a new array column type dynamically

I am evaluating toks registers for various uses - they are still fairly new to me. I'm using them to construct a table column-wise. During this, I have come across an issue I have failed to find a ...
10
votes
1answer
73 views

\toks register expansion issue - or is it?

I am trying to assemble a table that occurs multiple times throughout a document. It always consists of some fixed columns, followed by a set of columns that appear in one table but are not needed in ...
4
votes
1answer
61 views

Can I expand a macro argument once without using a scratch register?

I'm still trying to get my head around how expansion works in TeX. One thing I can't figure out is how to expand a macro argument once without having to use a scratch register as an intermediate. As ...
3
votes
1answer
65 views

Differentiate reference based on type (problem with argument expansion)

Since I use unnumbered sections, I'd like to have a variation of \autoref that uses names instead of numbers in the case of sectioning, but keeps its usual behaviour for other environments. I've come ...
5
votes
1answer
56 views

Clarification about how TeX/LaTeX decides it's fully read in a number

I started off a bit confused about how \romannumeral works. Then I tried several experiments testing various ways of incorportating numbers into LaTeX and got even more confused. The following table ...
9
votes
2answers
184 views

Still having difficulty with use of `\expandafter`

Firstly, my apologies for any previous confusion, I've separated out various questions onto distinct pages. This problem came up in the context of trying to split a decimal number. Good solutions to ...
8
votes
1answer
97 views

Implement functionality equivalent to many thousand \savebox

I have a large (approx 600 pages) index of files, and for each file entry significant computation is required so that additional links can be added. The computation of these links takes quite a bit ...
4
votes
4answers
218 views

How to repeat text

I get interesting errors with the following macro. Mostly it works, but I get extra spaces after \noindent (but not after \newline). I tried using \loop or \whiledo (from ifthen) but get stack ...
2
votes
1answer
45 views

Short syntax for including multiple times the same pages in pdfpages

Using the pdfpages package I can do something like this to merge some pages of a document. \includepdf[page={1,1,1,2,2,10,10,10,10},nup=1x2]{mypdf.pdf} In this case 3 times pages 1 and 2 times ...
5
votes
1answer
111 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
32 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
63 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
231 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
57 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
118 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
134 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
84 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
152 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
120 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
188 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
148 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
162 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
158 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
121 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
66 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
99 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
121 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
105 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
105 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
104 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
84 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
105 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
63 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
96 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
153 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 ...
2
votes
0answers
89 views

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
140 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
168 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
246 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
69 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
144 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} ...
13
votes
2answers
266 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
189 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
177 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
460 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
86 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
262 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
93 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
124 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
164 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} { ...