Skip to main content

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.

2 votes
2 answers
144 views

Memory usage of new commands requiring several intermediate commands

The following command \newcommand{\PDef}{\mathcal{P}_{\operatorname{Def}}} can be defined, alternatively, by iterating several new commands: \newcommand{\CP}{\mathcal{P}} \newcommand{\PDef}{\CP_{\...
Matemáticos Chibchas's user avatar
0 votes
0 answers
53 views

Rules upon % at end of line [duplicate]

When writing macros, the trailing comment character is used to ignore the rest of the input line, suppressing spaces, and the end of line character that is appended gets ignored too. Which aspects of ...
Liccu's user avatar
  • 33
1 vote
2 answers
44 views

Can I change the effect of a command depending on the environment in which it's invoked?

I need a user-defined command to behave differently depending on whether it's invoked inside a \begin{quotation} environment or not. Is that possible? I don't know where to start!
digitig's user avatar
  • 125
3 votes
1 answer
70 views

Modify command for sum so that substack unnecessary

Is there a way to modify sum so that \sum_{...} behaves as \sum_{\substack{...}}? It is of course possible to have a command containing the underscore, but I'm interested in if the underscore can be ...
user2472071's user avatar
1 vote
2 answers
40 views

Counter value not displayed in \foreach loop

I try to write a command that displays a table with the number of lines passed as parameter. It's working fine except that in this MWE, the value of the \i variable is not displayed. I have no idea ...
Sylcha's user avatar
  • 43
0 votes
1 answer
68 views

Getting the Maximum Width of a List of Items

I'm trying to write a command to get the maximum width of a (comma separated) list of items, for example \myLengthCommand{lorem,ipsum,lorem ipsum} should return the width of the text "lorem ipsum&...
Dave's user avatar
  • 317
0 votes
1 answer
52 views

LaTeX command for sets of elements set using \mathtt?

I teach a course in automata and computability theory and often have to define alphabets (sets of symbols). Typically, using amsmath, I write things like this: Let $\Sigma = \set{\mathtt{a}, \mathtt{b}...
templatetypedef's user avatar
2 votes
2 answers
110 views

hyperref warning: Token not allowed in a PDF string - macro Refactoring as a fix

I have a macro that takes a comma-separated list of lists and applies some formatting to it. The list consists of the first and last names of the document's authors. I managed to create a macro - \...
Mycroft_47's user avatar
3 votes
2 answers
67 views

Add "identifiers" to questions for printing

So, I have this code that lets me number questions/ exercises according to chapters ("Exercise 1.1", etc). I have one count to "identify" the question and one count to display the ...
Vebjorn's user avatar
  • 1,884
0 votes
1 answer
44 views

Numbering exercises by chapter and printing solutions by chapter in appendix

So, I have a basic tcolorbox that I want to write my exercises in. I want the exercises to be numbered by chapter, i.e. Exercise 1.1 is exercise 1 in chapter 1 (and still be able to print the answers ...
Vebjorn's user avatar
  • 1,884
2 votes
1 answer
41 views

Nested custom commands not working

I have defined the following commands for my latex document: \newcommand{\uat}[2]{\ifthenelse{\equal{#2}{}}{\boldsymbol{u}_{#1}}{\boldsymbol{u}_{#1}(#2)}} \newcommand{\opt}[1]{\ifthenelse{\equal{#1}{}}...
Trb2's user avatar
  • 123
2 votes
1 answer
66 views

How to properly expand expl3 Macros within tblr environment (from tabularray package)

I've been working on a macro that takes a comma-separated list of lists and converts it into a table that spans the full width of the page, with specific text formatting applied to certain columns. ...
Mycroft_47's user avatar
1 vote
0 answers
44 views

Issues with Misplaced Alignment Tab Character and Table Width in tabularray Environment [duplicate]

I've adapted the code below from this answer to switch from the tabular environment to the tblr environment from the tabularray package. While the original code works perfectly with tabular, I'm ...
Mycroft_47's user avatar
0 votes
1 answer
35 views

Create static variable inside of \pgfplotstableset definition

I try to understand, how to create a variable inside or outside of the \pgfplotstableset environement which is static and will not be resetted all the time. Probably this is a generic question for ...
PascalS's user avatar
  • 750
2 votes
1 answer
50 views

`already defined` error with scoped newcommand

I want to make it easier on myself to write large commands like this by "naming" the arguments. I did this: % Define the command for vector projection with named arguments \...
Boris Month's user avatar

15 30 50 per page