6
votes
Accepted
\let equivalent in LaTeX2e
There is no need to replace \let in your example, your \newcommands are simple. But if you define commands with an optional argument or robust commands then you should copy them with \NewCommandCopy (...
4
votes
Accepted
Recursively update macro
Your code seems to work. Let's add some tracing in order to better see what happens:
\documentclass{article}
\begin{document}
\def\temp{}
\def\update#1_#2{
\xdef\temptemp{\temp}
\gdef\temp{\...
4
votes
Recursively update macro
You are doing full expansion (\xdef) of previous macro declated by \update but \underbrace is more complicated macro which uses \halign with # in its preamble and this cannot be fully expanded without ...
4
votes
Accepted
Accessing TeX's internal tokens
No idea why nobody have posted an answer for the \endwrite token, but here it is.
%! TEX program = pdflatex
\documentclass{article}
\begin{document}
\ExplSyntaxOn
% starting state of the input ...
4
votes
How to define \newcommand as number from file using \input
In LaTeX the TeX-primitive \input is renamed to \@@input and \input is redefined to be a macro which does not work out in expansion-contexts like gathering and expanding tokens that belong to a TeX-⟨...
4
votes
How to define \newcommand as number from file using \input
It cannot work, because \input is not expandable.
\documentclass{article}
\usepackage{catchfile}
\newcommand{\foo}{}% for safety
\CatchFileDef{\foo}{page.tex}{}
\setcounter{page}{\foo}
\begin{...
3
votes
Recursively update macro
\temp with many LaTeX-packages is a scratch-macro. So code not stemming from you might override (re)definitions of \temp stemming from code written by you.
In order to prevent such clashes in the ...
3
votes
Accepted
How do I create macros that take + (plus) or - (minus) separated arguments as inputs and stores them to variables (e.g., coefficients of polynomials)?
You can read numbers to registers \coefnum and \expnum and run next macro using \afterassignment.
\newcount\coefnum
\newcount\expnum
\def\polycoeff#1{\polyA#1\relax}
\def\polyA{\afterassignment\...
3
votes
TikZ \foreach loop with macro-defined list
Starting with version 3.1.7 (November 2020), TikZ supports the expand list option for \foreach.
From the TikZ & PGF manual:
/pgf/foreach/expand list={<boolean>} (default false)
If this key ...
3
votes
Recursively update macro
underbrace is a robust command protected by LaTeX's \protect mechanism. For the mechanism to work properly you need the protected@ functions.
\documentclass{article}
\begin{document}
\def\temp{}
\...
2
votes
How to use new line command while using multicolumn in tabular?
Like this?
With talltblr defined by the tabularray package:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{talltblr}[
caption = {Overview of statistic. Diff.: Differened},
...
2
votes
Advantages and disadvantages of fully expandable macros
Some other points, which I think is not mentioned or only briefly mentioned in other answers.
Only fully-expandable functions can conveniently "return result" as argument to another ...
2
votes
How to define \newcommand as number from file using \input
Your problem is that you are using LaTeX, no plain TeX. If you use plain TeX then the task can be simply solved:
\newcount\page
\page=\input page.tex
The page is \the\page.
\bye
1
vote
Accepted
Is it safe to use \globaldefs for setting global pgf key-value pairs?
As David Carlisle pointed out in his comment:
"It is never safe to use \globaldefs anywhere, unless you have reviewed every line of code in its scope, and you personally maintain
that code, so ...
1
vote
Math Symbols Palette?
Check out:
https://www.caam.rice.edu/~heinken/latex/symbols.pdf
This is a pdf document listing all mathematical symbols with Latex coding.
Nice document to have for reference.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
macros × 7554expansion × 441
tikz-pgf × 437
environments × 396
math-mode × 354
conditionals × 321
tex-core × 301
tables × 263
spacing × 248
optional-arguments × 197
errors × 183
xparse × 173
expl3 × 161
cross-referencing × 130
counters × 128
sectioning × 122
arguments × 119
packages × 117
formatting × 111
programming × 109
strings × 97
etoolbox × 96
symbols × 95
beamer × 94
loops × 92