Questions tagged [macros]
{macros} is for questions specifically concerning TeX's macro processor. Note that, because TeX uses macros ubiquitously, most questions about code that uses macros are not looking for information about how macros work, and so are not appropriate for this tag.
8,562 questions
5
votes
1
answer
53
views
How to properly generate nested pgfkeys procedurally?
Task
Consider the following: One needs to store a over time varying amount of pgfkeys entries with a nested data structure. All the entries have the same structure, but the content may vary. So one ...
7
votes
2
answers
173
views
Bizarre interaction between `microtype` package and \eqref macro
I would have thought that if I declare \let\stdeqref\eqref, then the \stdeqref macro and the \eqref macro would be interchangeable. But here is an example where it fails! Moreover, this failure is (...
3
votes
2
answers
87
views
an error with using a variable defined by pgfmathsetmacro in "let...in..."
An error occurs when I try to create the point C1. How can I fix this?
\documentclass[12pt,a4paper]{book}
\usepackage[left=1cm, right=1cm, top=2cm, bottom=2cm]{geometry}
\usepackage{mathtools, amssymb,...
3
votes
3
answers
240
views
What are the advantages of environments over macros (and of \NewDocumentEnvironment over \NewDocumentCommand)?
I noticed that when I start from a custom environment, and then decide to do something slightly non-trivial with its content (like hide it, or typeset in a different color), I end up switching to a ...
9
votes
1
answer
192
views
Why cannot \par be printed here?
I ask this question only out of curiousity's sake. I am not actually planning on defining a new command called \cmd because the usual \cs macro has superior syntax. (\cmd<command name, including ...
8
votes
3
answers
180
views
Combine numbers from custom commands into a range
I’m defining datas in LaTeX with a custom command that stores both a label and a number:
\documentclass{article}
\usepackage{parskip}
\newcommand{\data}[3]{%
\expandafter\newcommand\csname #1\...
6
votes
4
answers
236
views
Create macro with named arguments
I am new to latex.
I need to create a text that has a bunch of entries that have the same structure, so I thought I would create a macro for it. However there are 7 moving parts, so it needs 7 ...
3
votes
5
answers
269
views
Check if a macro internally contains inner macros
To make my library (robust-externalize) more robust, I need to check if a list of macro contains internal macros like \foo@bar (I may also need to do that for latex3 macros, but let's start simple). I ...
4
votes
1
answer
63
views
Expansion of ~ in \index entries
I have defined a command called \defn which formats its argument in bold and creates an index entry for it. I use it when defining a term in the text of the document. Here's a MWE showing a ...
0
votes
2
answers
116
views
How to globally turn OFF a macro from the preamble?
Consider the epigraph macro in the following MWE:
\documentclass[11pt,twoside]{report}
\usepackage[T1]{fontenc}
\usepackage[tt=false]{libertinus}
\usepackage[french]{babel}
\usepackage[stretch=50]{...
5
votes
1
answer
68
views
Environment that conditionally collects its content
Disclaimer: This is a bit a XY problem, or rather: I have a problem X and I have a solution Y which works but does not really make me happy.
Background: I have an environment, say {foo}, which I use ...
3
votes
2
answers
102
views
How to customize the quote environment?
I'm trying to customize the quote environment for a novel (citations at the beginning of each chapter), and I'm having troubles in setting custom vertical line spacing, horizontal line length, the ...
4
votes
4
answers
199
views
Confusing Recursive Macro definition with LaTeX
I came up with a resursive macro method to achieve my previous plot question:
\documentclass[tikz,border=10pt]{standalone}
\def\totalwidth{8}
\def\totalheight{2}
\def\mysep{0.5}
\newcommand\mynode[3]{%...
5
votes
2
answers
92
views
Using TikZ with a command only defined on second pass
I have a number of commands that work a lot like the \ref command in that its true typeset value is only defined after an initial pass is performed. In the first pass they typeset ? - like the \ref ...
3
votes
2
answers
191
views
Implementing certain unicode-math symbols
I came across the following extensive list of symbols defined by unicode-math and am struggling to implement them in my document. Attempting to to use certain commands mentioned in the linked list I ...