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

learn more… | top users | synonyms

4
votes
2answers
51 views

How can I write <section counter value>:<section title>:<page>:<file>:<line> to the log whenever (and whereever) a macro is called?

I am working on context-based log entries. Each time a selected (patched) macro is called, it should provide its contents along with a meaningful log entry. "Meaningful" log entry defined: The ...
9
votes
1answer
226 views

Using {\AA} when \r is redefined

I'd like to use {\AA} to input a capital A with a ring above. However, the document I am writing has to import some definitions which I have no control over. One of the definitions changes \r: \...
1
vote
1answer
27 views

Why does embedded \g@addto@macro sometimes fail?

I decided to test my understanding of expansion and embed \g@addto@macro within another three macros. \g@addto@macro \appendmacro \layertwo \activatelayerone From my understanding, the ...
5
votes
4answers
194 views

Macros that define other macros, which also define other macros

I would like to define a TeX 'macro-building' command (let us call it \buildmacro) that takes as argument a string of 'normal' characters (e.g., Title) and which satisfies the followings: the ...
3
votes
1answer
40 views

“Something's wrong--perhaps a missing \item” error in \newenvironment using a \vtop box

In attempting an answer to "How to label a list / make a line before list stick with the list?" I answered using a \vtop box to contain the entire list including the label. I then, trying to improve ...
4
votes
2answers
37 views

Detect first character in list with macros

I have a comma separated list that I process with \foreach. This has been working for quite some time. Decided to make a minor tweak and that is to allow for an optional leading * in which case I want ...
3
votes
1answer
37 views

\expandafter to expand macro before macro call

I am trying to include an image: \documentclass{article} \usepackage{graphicx} \begin{document} \newcommand{\ext}{.pdf} \def\incPIC#1{ \expandafter\includegraphics{#1}} { \tracingmacros=1 \...
2
votes
0answers
86 views

How to force edef to execute def [closed]

Since I haven't given up on my problem from yesterday, I've been messing around with \edef, \def, \unexpanded, \expandafter and some other stuff. I also read about fragile commands and robust commands....
3
votes
2answers
42 views

PDF plain text for a macro with a starred version

I'm typesetting a document with PDFLaTeX. In some section titles, I use a macro which has a starred version. In the PDF index (the table of contents that PDF viewers typically show in a side pane), I ...
0
votes
2answers
29 views

How to span or expand a a table

How can I expand a table like the one in the picture? I tried the following code: \begin{tabularx}{\textwidth}{x x} \hline \textsf{Australia} & \textsf{OECD} \\ \hline \rowcolor{gray!40} \...
2
votes
1answer
57 views

Alternative to `foreach` loop to use an `edef`

I need to create some dynamic name macro and I want to create them from a coma separated list of parameter in #1 in one loop. foreach is not the solution because it forces the use of gdef and I want ...
2
votes
1answer
55 views

Expansion problem

In this example, I want to create nodes generically named (for the user) \N{a}, \N{b} ... in each macro but named differently (for tikz) to avoid confusion and overwriting when calling macro ...
5
votes
4answers
174 views

Tricky macro expansion and list

I posted these two question Tricky macro expansion Tricky list Now I would like to merge the two issues: \documentclass{article} \makeatletter \newcounter{a@c} \newcounter{b@c} \newcounter{c@c}...
4
votes
2answers
248 views

Tricky expansion in macro

I wrote the following code \documentclass{article} \makeatletter \newtoks\a@toks \newtoks\b@toks \newcounter{a@counter}% \newcounter{b@counter}% \setcounter{a@counter}{0}% \setcounter{b@counter}...
6
votes
2answers
75 views

counter in TOC fails when using xparse command instead of LaTeX2e command

Here I define a custom sectioning command, \Unit, which prints a numbered subject heading and adds it to the table of contents. If I use \newcommand for the command that creates the numbered label, ...
5
votes
2answers
39 views

How can I use \apptocmd within a macro, passing the appended's macro's parameter back to itself?

Let's say I have the following \newcommand\app[1]{\textbf{#1}} % <- #1 is appended's macro's parameter \apptocmd{\app}{#1}{}{} % <- passing appended macro's parameter to appended macro again \...
9
votes
2answers
173 views

How to save and restore the nodes between tikzpictures?

My English is not good enough so I beg you to excuse me if the question is long The next code is not very interesting but it may illustrate correctly my problem. I have a lot of macros and I need ...
3
votes
2answers
48 views

How do I perform an expandable string comparison?

I need to perform a string comparison (string equality). If the macro is non-expandable (e.g. contains \def or \let), it causes problems in the place where it is used. I tried using \ifthenelse from ...
1
vote
0answers
24 views

Need help with grouping and expansion control

I am trying to define macros, which take a delimited list and pass each element to a macro (that takes one argument). I have fully working versions of them that iterate over 1) all elements in a list, ...
4
votes
3answers
62 views

Inserting hyphenation file into \babelhyphenation

\documentclass{article} \usepackage[british]{babel} \usepackage{filecontents} \begin{filecontents*}{english.yp} hom-ony-mous gene-ral-ly \end{filecontents*} \makeatletter \babelhyphenation[...
1
vote
1answer
18 views

Inputting a separate hyphenation file

\documentclass{article} \usepackage[english]{babel} \usepackage{filecontents} \begin{filecontents*}{english.yp} hom-ony-mous gene-ral-ly \end{filecontents*}{english.yp} \hyphenation{ \...
2
votes
1answer
36 views

Getting user defined constants into the preamble

I think this is a problem of expandable content, a concept I haven't quite got the hang of yet... Lets say I have a preamble or cls file that is trying to configure hyperref. If I have manually setup ...
0
votes
1answer
20 views

\expandafter \the\everypar - undefined control sequence

From here, I got this snippet: \everypar=\expandafter{\the\everypar\loosness=-1 } However, this produces this error: ! Undefined control sequence. <everypar> ...ubpenalty \everypar {}\fi \...
4
votes
4answers
102 views

Generating a table from key-value pairs

I want to automatically generate a table from a comma separated list of key-value pairs such as {{x=1,y=2},{x=3,y=1},{x=2,y=3}}. In each "row" the "keys" are always the same (they become the column ...
1
vote
1answer
56 views

Convert text from mixed case to start case

I'd like to change the capitalization of a macro from mixed case to start case. Let's say the following macro is already defined: \newcommand{\tostring}{toString} I can change the first letter to ...
4
votes
1answer
54 views

How do I expandably extract the length of a box

I thought that the construction \wd\bopxcontrolsequence was expandable. But in mucking around in things, it seems not to be. At least in the following, the code demonstrates that \wd\aetmpbox never ...
0
votes
2answers
56 views

reverse expansion order with optional parameters

Trying to implement a command with more than nine parameters (that also reverses things about) when there are, e.g., 8 of them, the first invocation is temporarily saved with \def\mytemp{\mycommandtwo{...
3
votes
1answer
49 views

How can I set the PDF TrimBox dynamically (with a macro) and compiler independent?

Introduction At the moment I’m preparing a custom class which is likely to be compiled with XeTeX or LuaTeX. It is for a book layout that should be professionally printed and therefor I want to set ...
4
votes
2answers
50 views

How to use \nameref with xstring package to check string length

I need to measure a number of characters in string, that I returned from label through \nameref command. Here is my MWE: \documentclass{article} \usepackage{hyperref} \usepackage{xstring} \begin{...
3
votes
1answer
62 views

xdef and cedille

I need to xdef some data. In rare cases it'll contain cedilles like: \xdef\xxx{spam\c{e}eggs} \bye Unfortunately this failes. Is there a chance to get this working? (I'm on LaTeX in my code, using ...
7
votes
2answers
129 views

Expansion of \char in \def

In answering another question, I ran into some issues trying to use a combination of \def and \char. Consider the following example: \documentclass{minimal} \usepackage{etoolbox} \usepackage{xstring}...
1
vote
1answer
130 views

Expandability: LaTeX3 VS LaTeX

The expandability is the heart of macros/functions. I wonder to know: If a better understanding of expandability in LaTeX3 can only be through a good background of expandability in LaTeX. How far ...
3
votes
2answers
182 views

Drawbacks of csname method to avoid spaces after command

I had a similar problem as this one: Space after LaTeX commands My first attempt was something like this: \newcommand{\satip}{SAT\textgreater IP} This leads to the known Problem, that spaces after ...
2
votes
0answers
47 views

Macro with \afterassignment syntax?

Say for some reason I want to make a macro with input stream behaviour mimicking that of \afterassignment and \aftergroup. Namely, I want to absorb exactly one token from the input stream following ...
3
votes
3answers
44 views

Macro expansion and biocon package

I'm using the biocon package to organize plants in an academic work. I created new taxons as needed in the text, for instance, the family. In the final chapter of the work, I have a large table (about ...
4
votes
1answer
43 views

\ThisStyle \SavedStyle painfully slow … alternatives?

While working with customised hat glyphs using the first version of this solution, pdflatex started taking a long time compiling a document. That linked answer notes that it's a slower solution, but ...
6
votes
3answers
391 views

Expansion? dirty tricks?

Consider \documentclass{article} \usepackage{titlesec} \def\bl#1 #2 {#1\textsuperscript{#2}\,} \titleformat{\section}[runin]{}{}{0pt}{}[. ] %\titleformat{\section}[runin]{}{}{0pt}{\bl}[. ] \begin{...
4
votes
4answers
171 views

Expandable macro with loops and advanced string functions?

This might be a very basic problem (as a follow-up to this question) but I cannot figure out how to do it: I need a macro \mycmd{sometext} that yields a string depending on the first character of its ...
5
votes
1answer
82 views

How can I use a tl variable in TikZ options

Im setting up a command with some options via l3keys. One of the options is tikz-options and it should take a list of TikZ options and pass them to a {tikzpicture}. \documentclass{article} \...
4
votes
4answers
198 views

Identifying and writing the font size

I am trying to identify whether the current font size is small. So here is a MWE of what I am trying to do \documentclass{article} \usepackage{ifthen} \begin{document} \makeatletter \ifthenelse{\f@...
3
votes
2answers
101 views

Using redefined \c and Turkish characters in citation

I once redefined the command \c since I need a shortcut for some formula that I use quite frequently. Unfortunately, I now need to cite a turkish author that has a \c{C} in his name. So, what I did is ...
3
votes
1answer
41 views

How to make \tl_upper_case:n in section's argument bookmark compliant?

Thanks to recent revision of the coverage of UTF-8 input for pdfTeX and accents with the expl3 (see updated answer of http://tex.stackexchange.com/a/286703/18401), the following code works nicely: \...
3
votes
1answer
123 views

How can I expand the font size within a heading (section, subsection, etc.)?

I'd like to make a list of headings with their font sizes: I envision something like the following: \documentclass{article} \begin{document} \section{{\textbackslash}section \makeatletter\f@size pt\...
4
votes
2answers
92 views

How to force-expand a \def for \in@?

Take the following code as an example: \documentclass{standalone} \def\myvar{foobar} \begin{document} \makeatletter \in@{foo}{foobar}\ifin@ Yes\else No\fi, \in@{foo}{\myvar}\ifin@ Yes\else No\fi \...
2
votes
1answer
100 views

Need help with macro-driven tables and expantion

This is a project I have been working on for a while now and I am stuck on implementing this new function, cell coloring. My function works by taking in an unknown amount of data called 'weapons' and ...
9
votes
3answers
128 views

Problems getting \expandafter\<controlsequence>\endgroup to work as expected

I have a scenario where I'm testing for a condition within a group which will then trigger inputting a corresponding outside file. The problem is that the outside file may contain control sequences ...
4
votes
1answer
58 views

How to make \tl_upper_case:n applied to diacritics work in section argument?

The LaTeX3 Interfaces' documentation claims, page 224: In package mode, the case change system will also convert text stored using the LaTeX 2ε “LICR” approach. This will upper/lower case tokens ...
5
votes
2answers
83 views

\lowercase with \IfSubStr and \StrDel

I'm trying convert an argument to lowercase, strip out the spaces, and then search for the resulting string in a list. Thus far, I've had no luck. Here's the code I would instinctively expect to work:...
5
votes
2answers
88 views

Build table in new command results in too long vertical lines

I am trying to build a table inside a LaTeX 3 command. A MWE: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\createTable}{ m m }{ \begin{tabular}{|c*{#2}{|c}|} ...
5
votes
2answers
175 views

Manually expanding a macro within a definition

When defining macros using \edef (which by default expands every macro within the definition as much as possible), I can declare some macro within that definition to not expand by using \noexpand ...