Hot answers tagged

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 (...
user avatar
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{\...
user avatar
  • 993k
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 ...
user avatar
  • 53.6k
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 ...
user avatar
  • 2,243
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-⟨...
user avatar
  • 23.5k
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{...
user avatar
  • 993k
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 ...
user avatar
  • 23.5k
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\...
user avatar
  • 53.6k
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 ...
user avatar
  • 2,913
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{} \...
user avatar
  • 2,243
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}, ...
user avatar
  • 255k
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 ...
user avatar
  • 2,243
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
user avatar
  • 53.6k
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 ...
user avatar
  • 23.5k
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.
user avatar

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