Skip to main content

All Questions

Tagged with
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{\...
Lupino's user avatar
  • 2,762
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\...
Fabian Schneider's user avatar
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}} \...
A.Ellett's user avatar
  • 50.7k
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}. ...
Dennis Müller's user avatar
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 ...
TeXhnically Challenged's user avatar
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 ...
Robert Siemer's user avatar
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} \...
bers's user avatar
  • 5,464
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, ...
Aayla Secura's user avatar
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 ...
A.Ellett's user avatar
  • 50.7k
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 ...
Manuel's user avatar
  • 27.2k
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 ...
FK82's user avatar
  • 683
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\...
yannisl's user avatar
  • 118k
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\...
Andrey Vihrov's user avatar
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 ...
Peter Grill's user avatar