Linked Questions
10 questions linked to/from What are the differences between \def, \edef, \gdef and \xdef?
225 votes
5 answers
74k views
When to use \edef, \noexpand, and \expandafter?
I'm quite happy hacking TeX macros and cobbling together bits and pieces from different style files to suit my own ends, but I have a suspicion that my resulting hacks are not quite as elegant as they ...
17 votes
2 answers
864 views
Is there a simple way to retroactively add the \long prefix to a macro's definition?
According to chapter 20 of the TeXbook, a macro that is defined as "long" (by saying \long just before \def\<macroname>) allows arguments with \par tokens (i.e., paragraphs). Suppose I encounter ...
14 votes
1 answer
11k views
Increment/Decrement variables in TikZ
I need to increment/decrement variables in TikZ, i.e., I have \def\a{0} and then I need to perform \a=\a-1.5; The code compiles, but it does not change the value of the variable \a. How do I do ...
6 votes
2 answers
542 views
Cannot use \textit or \url in \edef
I'm trying to write a Tex command that automatically prints out attribution information for images I use in my document. I created 2 different commands. The first one is \nounattr (with 3 parameters) ...
2 votes
2 answers
341 views
Printing an element of a non-numeric array as the node label
I want to retrieve a member of a non-numeric array passed to a TikZ pic as an argument, to use it as a node label. \foreach easily does it while iterating over the array, but I cannot do it for the ...
4 votes
0 answers
772 views
Define variables local to tikzpicture
I'd like to understand how to properly use variables in TikZ. I've read a large number of Q&A's and, so far, I've encountered \{g,x,e,}def, \newcommand, \pgfmathsetmacro, and \let. The objective ...
4 votes
1 answer
173 views
Optimizing code for a line and snowflake composition
I have defined a \newcommand {atest} to draw a line composed with a snowflake, as in the figure 1. To adjust the length of the composition to the right margin of the page I use two parameters and I ...
2 votes
2 answers
177 views
Unable to reuse variable using \pgfmathsetmacro
\documentclass{article} \usepackage{tikz} \begin{document} \newcommand\routine[1] { \pgfmathsetmacro\temp{0} \foreach[parse=true][remember=\temp] \i in {1,...,#1} { \pgfmathsetmacro\...
0 votes
1 answer
147 views
How to cumulate computed durations?
My current code generates a result as shown in the image below. My problem is: how to cumulate the "Car" durations?. When the line 95 % \global\let\routeCarTotalDuration\tempd% is uncommented, I ...
0 votes
1 answer
199 views
Using \xdef in \foreach errors when using another \foreach inside the \xdef
I'm using TeXShop 5.0.4 and encountering a cryptic error ! Incomplete \iffalse; all text was ignored after line 15. <inserted text> \fi where my code contains no explicit "...