7
votes
3answers
203 views

When to use or avoid grouping?

For writing my own TeX code, grouping (\begingroup, \endgroup) helps on automatically saving and restoring TeX "variables". (La)TeX "variables" are either macros or registers. The registers can ...
13
votes
1answer
111 views

Difference between “hbox group” and “adjusted hbox group”?

eTeX's \currentgrouptype distinguishes two types of \hbox group types \hbox{\showthe\currentgrouptype} % 3 "adjusted hbox group" \noindent \hbox{\showthe\currentgrouptype} % 2 "hbox group" Looking ...
19
votes
2answers
235 views

global confusion

Simply put, when should I care if something is global or not? What does this really mean? If my package, for example, provides \newcommand*{\setfooter}[1]{\def\mypackage@footer{#1}} And I later ...
1
vote
1answer
189 views

Unexpected scoping issue using \XeTeXinterchartoks

Minimal example (compile with xetex): \XeTeXinterchartokenstate = 1 \newXeTeXintercharclass \classa \XeTeXcharclass `\a \classa \XeTeXinterchartoks 255 \classa = {\begingroup} \XeTeXinterchartoks ...
11
votes
2answers
453 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: ...
10
votes
1answer
127 views

Emulate TeX's grouping

In TeX, various kinds of groups must match properly, for instance, the following is wrong: $ \begingroup $ \endgroup I would like macros which allow such mismatched grouping. They would keep ...
11
votes
2answers
176 views

What combinations of mode and \currentgrouptype exist?

I am trying to predict in any given situation what TeX does if a closing brace reaches its stomach (apart from reverting local assignments). For instance, \vbox{\tracingall H} shows that if it is in ...
9
votes
3answers
373 views

Making register declarations local, Undefining a register (count, toks, etc.)

Is it possible to make \newcount, \newtoks, etc. respect grouping, so that, e.g., \newcount\temp\temp=2{\newcount\temp\temp=1}\showthe\temp gives 2 (instead of 0)? Relatedly, is it possible to ...
55
votes
1answer
8k views

When should one use \begingroup instead of \bgroup?

Is there ever a case when the use of \begingroup is preferred to \bgroup? Obviously, \bgroup is necessary in cases where you need to have balanced braces and thus cannot use {, but when is it ...