{expansion} is about expanding tokens, including the manipulation of expansion order and the suppressing of expansion.
5
votes
1answer
243 views
A \typeout (or expandable command) that can expand once - or with variable levels of expansion?
Consider the following MWE:
\documentclass[12pt]{article}
\begin{document}
\def\aaa{something}
\typeout{=1==\aaa==}
\typeout{=1==\meaning\aaa==}
\typeout{}
\def\bbb{else \aaa, else}
...
5
votes
1answer
198 views
Why am I processing a comma-separated list incorrectly when using etoolbox and kvoptions?
I'm trying to pick something out of a list that has been passed from some package options by kvoptions, but docsvlist doesn't appear to be recognising the commas.
I suspect this may be something to ...
5
votes
1answer
603 views
Jobname of inputted file?
\begin{filecontents}{foo.tex}
\def\foo{\jobname}
\end{filecontents}
\documentclass{article}
\begin{document}
\input{foo}
\foo
\end{document}
This outputs the jobname of the main file not "foo". How ...
5
votes
1answer
134 views
How to extend the \romannumeral-based \fullyexpand to handle empty/all-space arguments?
In Expandable full expansion of tokens that preserves catcodes, Joseph Wright presents the following code:
\long\def\fullyexpand#1{%
\csname donothing\fullyexpandauxi{#1}{}%
}
...
5
votes
1answer
306 views
Evaluation order during macro expansion.
From this question Creating PDF bookmarks in custom order arose another. (I hope it is correct to create a new question instead of commenting or editing/answering my old question.)
Using this macro ...
5
votes
1answer
105 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 ...
5
votes
2answers
197 views
Preparing macro content in a loop (calling \foreach from \edef)
I need to do something like \def\MyArray{{1, 2, 3, 4}} but with a dynamical number of elements.
The following command makes the string:
\newcommand{\MakeArray}[1]{\{ 1 \foreach \x in {2, ..., #1}{ , ...
5
votes
2answers
334 views
Using \input vs. \scantokens in section title (with package hyperref)
I meet the following issue when trying to use \scantokens in section titles, together with the hyperref package (whithout this package, all is fine).
\protect\input... can appear in a section title. ...
5
votes
1answer
227 views
\unexpanded fails with undefined LaTeX symbols?
I'm actually not sure if the title of this post is correct. However, what is happening is that the following MWE
\documentclass{article}
\begin{document}
\unexpanded{$\undefsym{x}$}
\end{document}
...
4
votes
2answers
180 views
Define command either with or without \csname
I'm trying to do the same as this one, but with \def, \gdef or \xdef instead.
Very quick summary of the other question:
I wanted to print the command (not the contents of the command) regardless of ...
4
votes
3answers
1k views
Can (pdf)LaTeX recognize text strings and replace (expand) them?
I'd like LaTeX to replace e^ with \mathrm{e}^. I know I could just make a macro \e that does this, but I know I'll forget using it..
Can LaTeX find and replace and replace letter combinations (I ...
4
votes
2answers
57 views
expl3: \cs_generate_variant broke with the last update: undefined control sequence \::T [closed]
The last expl3 update broke my "continue" detection for the index. Here is a MWE:
(EDIT: I realized it is possible to reduce it even further)
\documentclass{minimal}
\usepackage{expl3,xparse}
...
4
votes
3answers
85 views
Expanding an argument of code added by \g@addto@macro
I would like to have the following (it's a part of a large code block):
\def\C{foobar}
\def\A{}
\g@addto@macro\A{\B{\C}}
Now \show\A outputs \B{\C}
I would like to modify the 3rd line so that ...
4
votes
2answers
42 views
How to write \StrGobbleLeft output to an external file?
I have not learnt how the TeX expansion works behind the scene. Shortly speaking, how to write \StrGobbleLeft output to an external file?
\documentclass{article}
\usepackage{filecontents}
...
4
votes
2answers
218 views
expand macro in single byte encoded code
In this minimal (not) working example, I try to use single-byte latin10-encoded source file, and expand a command-macro containing a character with \catcode254:
% -*- mode: latex; unibyte: t; ...
4
votes
3answers
196 views
Saving the value of a text macro at the start of the page.
I have a macro that stores some text. I'd like to print the text of that macro as it was at the start of the page in the header, and as it is at the end of the page in the footer. I can do this for ...
4
votes
1answer
53 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}
...
4
votes
2answers
155 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 ...
4
votes
1answer
71 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 ...
4
votes
1answer
54 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 }
...
4
votes
1answer
76 views
How to use a counter in a \bookmark dest name within \BookmarkAtEnd?
I'm trying to do something similar as in this question.
I would like to use the value of a counter in the name of a \hypertarget and in addition, I want to be able to refer to this name in a ...
4
votes
1answer
125 views
\forcsvlist and expansion
I've got an expansion issue with the following code:
\def\sizes{huge, LARGE, Large, large, normalsize, small, footnotesize, scriptsize, tiny}
\forcsvlist\sampletext{\sizes}
My problem is that ...
4
votes
2answers
197 views
Expand within \label
Is there any way to use a macro within a \label tag?
\edef\num{1}
\label{test\num}
\ref{test1}
4
votes
2answers
326 views
Strange expansion of a macro inside an environment
I'm, I should confess, a total newbie. I'm trying to generate invoices with LaTeX, so I'm using the fp package.
But the strange thing is that calculations occur many times when they should only ...
4
votes
1answer
112 views
Preprocessing Latex: What is your workflow? Your tools?
I know, for various reason, some users preprocess their latex file using Perl or sed, say.
I'm considering doing this to, so I would like to seek your guidance, to smooth my entry in this area.
My ...
4
votes
1answer
72 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:
...
4
votes
1answer
302 views
pgfmath expansion - call a command from within a pgfmath environment
I am trying to define a newcommand using pgfmath. This commands calls a previously defined command but it fails. It propably has to do something with expansion.
I've read this question about ...
4
votes
1answer
61 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}
...
3
votes
3answers
102 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:
...
3
votes
2answers
58 views
How to append commands to a macro without expanding them
I'm working on building an expenses package. The intention is to be able to write
\expense{someone}{something}{something a bit longer}{10}{GBP}
\expense{someone else }{something else}{something a bit ...
3
votes
2answers
84 views
List of tokens from TeX mouth
Is it possible to get list of tokens which comes from TeX "mouth"? If I understand correctly: in mouth all macros, conditionals and special operations (like \the and \input) are expanded and then goes ...
3
votes
2answers
127 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 ...
3
votes
3answers
173 views
Using a macro evaluating to a set of xkeyval arguments as argument to another command
I am trying to code a macro that adds xkeyval arguments contained in a macro to a list of default xkeyval arguments.
The following minimal example explains better what I want to do.
...
3
votes
2answers
76 views
How to use a TeX macro with a CSV list to filter an external file
The code below produces the results I desire, which is a list of the lines with XXX={<value>} with a <value> which is not one of the allowed list of values:
However, this solution ...
3
votes
1answer
53 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 ...
3
votes
2answers
154 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 ...
3
votes
3answers
209 views
Arguments expansion in IfSubStr
EDIT: Simplified question
How can I make the following code print "Yes"?
\IfSubStr{\textbf{AAA}}{AAA}{Yes}{No}
Full question
I'm playing with xstring's IfSubStr, but I don't really understand ...
3
votes
3answers
330 views
Expand directory names using nested macro definitions
Background
Would like to use values from macros that reference other macros (n-levels deep) and apply their values to the \path command.
Problem
(Scenario A) The following works:
\usepackage{url}
...
3
votes
1answer
221 views
LaTeX3: expansion of argument to function
I would like to define functions which extract the PDF object number from a PDF object reference, such as 12 from 12 0 R.
I defined two versions of such a function, a low level one and a high level ...
3
votes
1answer
68 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}}
...
3
votes
3answers
295 views
Problem with expansion of \BODY
In the following MWE, the command \testStringNotEmpty tests if the argument is empty. This test is robust in the sense that the argument can contain a command or an environment...
The environment ...
3
votes
1answer
316 views
\rule doesn't work inside an \xdef command
This code:
\documentclass{article}
\begin{document}
\def\a{}
\newcounter{mycounter}
\def\b#1{
\def\p{#1}
\ifnum\value{mycounter}=0
\long\xdef\a{\a\rule{3mm}{3mm}\par #1} ...
3
votes
2answers
199 views
Can super/sub-scripts bind more tightly than macro expansion?
By "bind more tightly" I refer to the order in which operations are carried out by default.
Experimenting shows that if \ab is ab and \cd is cd then \ab^\cd is ab^cd. I would like it to be ...
3
votes
2answers
38 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, ...
3
votes
1answer
60 views
How to use commands in table specs, and still support array package?
For a package, I want to write code that creates tables, where the exact type of table is configurable (tabular, longtable, tabularx, ... [Update: David rightly remarked that formats like tabularx ...
3
votes
1answer
108 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 ...
3
votes
2answers
106 views
Can Texinfo's @value macro be made to work in the filename argument to @xref and friends?
Given a file xref-and-value.texi with contents:
\input texinfo @c -*- TeX-PDF-mode: t; -*-
@setfilename xref-and-value.info
@settitle @code{@@xref} and @code{@@value} in \pdftex
@set fngccint ...
3
votes
1answer
128 views
Showing expanded `\let` command with `\typeout`
I have already seen the related page macros - What is the difference between \let and \edef?, but I'm afraid it still doesn't expain to me the following MWE:
\documentclass{minimal}
...
3
votes
2answers
137 views
Command representing an expansion of a summation
I am very new to using LaTeX to write equation. And I am now learning how to create my own command. I am going to write a command \Listn to help me to do this:
\Listn{\sumup}{(#1)}{+}
$\sumup{n}$\\
...
3
votes
1answer
54 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 ...
