All Questions
14
questions
3
votes
1
answer
80
views
How do I move a macro expansion outside of the current semi-group, without defining the macro globally?
I've written a macro \measureHbox{} which calculates the height and width of a breaking \hbox where the lines are separated with \breaks:
\long\def\measureHbox#1{%
\begingroup
\def\break{\...
4
votes
2
answers
87
views
smuggling macro out of a group in tex core results in undefined control sequence
I am trying to re-apply changes done in a group directly afterwards with the following code similar to the approach in here
\def\smuggle#1\endgroup{%
\expandafter\endgroup\expandafter\edef\...
1
vote
1
answer
34
views
Advancing a pseudo-counter in an align environment
I'm getting some strange results I don't really understand with the following code:
\documentclass{article}
\usepackage{pgfmath}
\usepackage{amsmath}
\newcommand\initializecount{\def\aecnt{0}}
\...
2
votes
1
answer
77
views
When do curly braces disappear in macro definitions? (e.g. \documentclass expansion)
I've been looking into how \documentclass and friends are actually defined, and I noticed something peculiar which I'd like to understand.
Let's say I have \documentclass[11pt, titlepage]{article}. ...
1
vote
1
answer
175
views
Writing expanded macro with space to file
I'm trying to write an expanded macro to a file without the expansion eating the space after it.
I could replace the {} empty group with an explicit \space, but I want this to be fairly robust. Is ...
6
votes
3
answers
575
views
Questions about `\cs_new:...` and friends and their TeX relatives regarding global, local, long, nopar, protected, expandable and naming
This question is two-fold. Unfortunately, one side is opinionated, i.e. something to close-vote, so I put that part at the end and hope no one notices... The other side (coming first) are serious ...
2
votes
2
answers
470
views
Remove extra curly braces for def'ed argument
I am trying to combine the answers of Remove extra curly braces and \def'ed plain-text argument behaves differently from plain text, and I am failing. Here's an MWE:
\documentclass{article}
\...
2
votes
1
answer
126
views
Need help with grouping and expansion control [closed]
I am trying to define macros, which take a delimited list and pass each element to a macro (that takes one argument). I have fully working versions of them that iterate over
all elements in a list,
...
9
votes
3
answers
200
views
Problems getting \expandafter\<controlsequence>\endgroup to work as expected
I have a scenario where I'm testing for a condition within a group which will then trigger inputting a corresponding outside file. The problem is that the outside file may contain control sequences ...
11
votes
3
answers
1k
views
Arguments possibly delimited by \bgroup and \egroup
I still don't see (and haven't thought about) pros and cons of making available the arguments as \foo{…} or \foo\bgroup …\egroup (or even unbalanced, \bgroup …} and {…\egroup). But I'm curious about ...
4
votes
1
answer
141
views
How do you define a command to select nested groups?
Assuming a pair structure (2-tuple) is defined using groups
{{<tokens1>}{<tokens2>}}
is it possible to define a command \first#1{...} (and \last#1{...}) taking the surrounding group as ...
13
votes
2
answers
963
views
\expandafter within a \begingroup ... \endgroup [duplicate]
Possible Duplicate:
What does \begingroup\expandafter…\endgroup do?
In many of Heiko Oberdiek's packages one sees this type of construction:
\begingroup\expandafter\expandafter\expandafter\...
31
votes
3
answers
7k
views
What does \begingroup\expandafter…\endgroup do?
I often see code of the following form in package implementations (this example is from the LaTeX3 sources):
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname directlua\...
5
votes
2
answers
552
views
Macro behaviour different inside tabular environment
I have a lot of problems lately with macros expanding (or not expanding) at unexpected times, so thought I was having a related problem here. But, in this case, things are working as I want outside of ...