# Tag Info

## Hot answers tagged expansion

12

Searching for \edef or \xdef (global variant) with command to be defined and argument in TeX Live 2015 and filtering out possible false positives (when the command is constructed with \csname): egrep -r '\\[ex]def\\[a-zA-Z@]+#1' texmf-dist/tex/ | grep -v '\\[ex]def\\csname' Result are 219 lines. I do not want to discuss all findings, thus I restrict ...

7

Curly braces An one-liner to remove the curly braces: \expandafter\def\expandafter\mycommand\mycommand Explanation: \mycommand contains {"/home/user/di rect ory/"/}. When the \expandafter commands have done their job, the following remains: \def\mycommand{"/home/user/di rect ory/"/} The curly braces are now used for the definition text. Quotes ...

5

Let's see what happens when you have \makeatletter \newcommand{\reflines}[1]{% \begingroup \edef\temp@a{\getrefnumber{start:#1}}% \edef\temp@b{\getrefnumber{end:#1}}% \ifnum\temp@a = \temp@b line \temp@a% \else lines \temp@a\ and \temp@b% \fi \endgroup } \makeatother and try to do ...

5

After a completely false understanding of the question, I have rewritten my answer to show how \edef with an argument can be used to "fix" the selected equation citation style. An \edef is evaluated at time of definition, whereas \def is evaluated at time of execution. If \edef\eqcite#1{} is used in preference to \def\eqcite#1{}, then changes to the ...

4

There is a usage of \edef with parameter in special expansion control. One nice (yet quite complicated) example can be found in skeyval-core.tex v1.3 on line 1997 \skvrobustdef*\skvpopfunctions#1#2{% \begingroup \edef\skv@elt{\skvnoexpandcs{\skvremovescape{#1}@skv@stack}}% \expandafter\skvifdefTF\skv@elt{% \expandafter\ifx\skv@elt\@empty ...

4

Your problem is caused by the fact \reflines is not expandable due to the presence of a group and assignments (\def). Those are not needed, so we can just drop them \newcommand{\reflines}[1]{% \ifnum\getrefnumber{start:#1}=\getrefnumber{end:#1} % line \getrefnumber{start:#1}% \else lines \getrefnumber{start:#1}\ and ...

3

keyval parsers typically don't expand the arguments (otherwise things like font=\small would blow up badly as \small would expand too early. so the simplest thing is to use \newenvironment{sss}{% \begin{itemize}[label={$\bullet$},topsep=0mm, parsep=0mm,% leftmargin=3mm,rightmargin=0cm,labelwidth=5mm,labelsep=3mm% ]} {\end{itemize}} \begin{sss} \item gugus ...

3

The posted example is completely misleading and runs without error. If the array package is used, then macros in the alignment are not expanded, and \newcolumntype can be used for abbreviated column alignment constructs. \documentclass{article} \usepackage{array} \begin{document} \newcolumntype{a}{|l|c|} \begin{tabular}{a} 1 & 2 \\ \end{tabular} ...

3

Here's a LuaLaTeX-based solution. A LaTeX macro called \DeleteQuotes is set up, which removes all " characters from its argument. No assumption is imposed or required regarding either the location or the number of " characters in the argument of \DeleteQuotes. In particular, no difficulty arises if the argument of \DeleteQuotes contains no " characters at ...

2

Delete the trailing comma from here: \foreach \x / \y in {0/0,5.65/2.65,3.12/0.16,0.83/0.03,0.20/0.03,} otherwise, TikZ attempts to place something on an empty coordinate. The complete code: \documentclass{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ xmin = -1, xmax = 6, ymin = ...

1

First time I play with this kind of things, so probably it's not right. I let everyone correct this answer if he wants. A four liner. It's a completely expandable solution, and the \edef part is there to show two things: first, that it's completely expandable, and second, so that the \detokenize shows that the { and } are not in the result. ...

1

This assumes the format of the token list is {..."..."...} The \normalize macro receives as a mandatory argument the token list to normalize, possibly in “stored” form. The optional argument should be a control sequence that will receive the normalized string as replacement text (no check about it being defined is performed). If no optional argument is ...

1

The problem is \directlua{Semaine("\unexpanded{#1}")} At least it prevents, that #1 is expanded too early. But #1 is user contributed content, which might contain anything, including quotes, which would break the intended Lua syntax. Therefore LuaTeX provides \luaescapestring, which can be used as \luatexluaescapestring in LuaLaTeX. It automatically ...

1

Usually a key value parser needs to see the syntax characters = and , directly. Therefore, the macro \sss should be expanded once. This can be done with lots of \expandafter: \expandafter\begin\expandafter{\expandafter i\expandafter t ...\expandafter}\expandafter[\sss] or the whole expression can be expanded as macro: \edef\next{% ...

1

You need to insert the uppercasing into the result of \ac, but \ac does not work by expansion so \expandafter does not help. (If it had worked by expansion, your expression would still have been wrong as it passes \empty to \MakeUppercase) \documentclass[a4paper, 10pt]{report} \usepackage[utf8]{inputenc} \usepackage[printonlyused]{acronym} ...

Only top voted, non community-wiki answers of a minimum length are eligible