Questions tagged [grouping]
{grouping} is about the grouping mechanism in TeX, and about local and global assignments.
281
questions
152
votes
2
answers
61k
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 ...
53
votes
2
answers
84k
views
Temporarily increase line spacing
How do I temporarily increase line spacing? I have some text on my title page:
\begin{center}
{ \Large \textbf{The Great Thesis About Some Very Great Things Indeed With
a Pretty Long Title That Will ...
46
votes
1
answer
4k
views
] inside an optional argument
I accidentally discovered (here) that a closing square bracket within an optional argument delimited by [ ] can cause problems.
Here is example code illustrating the issue:
\documentclass{article}
\...
41
votes
3
answers
13k
views
When to use @ in an \if statement
I am new to LaTeX and so this question might come across as rather basic.
It might also reflect my biases/assumptions from my C/C++ programming days.
I was seeing the code of the 'exam' class and ...
40
votes
3
answers
15k
views
Limit macro/newcommand scope to section
How can I limit the scope of a \newcommand to a \section? This is what I'd like to have:
The command is defined only inside the \section, not globally;
The command scope is that \section and cannot ...
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\...
29
votes
1
answer
6k
views
Is there a way to have an "empty" environment to merely limit scope of declarations?
I am fairly new to LaTeX, so I apologize if this is a beginner question, but I have not found a good way to query for it otherwise.
I have observed that when I use an environment like \begin{itemize}....
28
votes
3
answers
8k
views
\global\renewcommand equivalent of \global\def
The following MWE works just fine, but I had to resort to using \global\def (not that there's anything wrong with it). The intent of the MWE is to provide access to the value of macro as set in an ...
28
votes
4
answers
2k
views
Kerning between bold and non-bold text
I'd like to write a word in bold followed by a comma and a non-bold word, like this:
\textbf{why}, blah
If I just write why, TeX inserts a kern to shift the comma a little closer to the "y". But ...
27
votes
6
answers
2k
views
How do I get a value out of a group?
I've just recovered from my first real foray into LaTeX3 programming. It was ... an experience. Not a completely unpleasant one and once I'd gotten used to the syntax then I found it a lot easier ...
27
votes
5
answers
3k
views
Is there a way to set a *global* key value using `pgfkeys`?
The simple answer to this question appears to be "No"; quoting from the pgf manual:
The setting of a key is always local to the current TeX group.
However, this is very annoying because it means ...
25
votes
3
answers
4k
views
What is the difference between local and global in a TeX meaning?
In tikz declare function and babel french option it came to the question about the difference between local and global in a TeX meaning.
In the linked question the babel shorthand ; should be ...
25
votes
3
answers
1k
views
What are the effects of an empty group, {}?
In order to have a syntactic space after a no-argument command, one is taught to delimit the command token with an empty group ({}), like this: \somecommand{} more LaTeX material.
However an empty ...
23
votes
1
answer
2k
views
Global scope or permanent length or savebox
I am trying to save a minipage width and height in one environment, and use these dimensions in a subsequent environment of mine, to make a picture environment.
The idea is to create a picture on the ...
20
votes
3
answers
1k
views
Should LaTeX counters always be modified globally?
In this answer, egreg states that "LaTeX counters should always be modified globally". However, the etoolbox package provides the \defcounter macro which will assign a value to a previously ...