Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [grouping]

{grouping} is about the grouping mechanism in TeX, and about local and global assignments.

13
votes
4answers
2k 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 ...
10
votes
2answers
1k views

How can I change the text color in such a way that the effect transcends groups?

I'd like to have a command \globalred that makes all subsequent text red, even if the command is issued inside a group. For example, the output of the TeX file \documentclass{article} \begin{document}...
8
votes
1answer
161 views

Why does the `&` reset grouping?

In this answer, I used \tikzmark to mark the extent of a typeset piece of text, so I could draw changebars next to it. But it initially seemed that the changebars "disappear" with math-mode content. ...
8
votes
3answers
1k views

Macro to close all open environments, groups and argument delimiters

Initial Request I am in search for a macro that would close all curly brackets and all open environments. Ideally, I could write something of the following sort: \Open\begin{minipage}\begin{quote}\...
6
votes
1answer
1k views

Can a \newcommand Definition Contain Braces as Substitution Text?

The following example is completely counter-intuitive, but I need this in a bigger definition I'm not including here. \newcommand{\openbrace}{{} I need this to start a nested scope. Is this ...
6
votes
1answer
686 views

How to display some text based on a condition inside a tabular environment?

I defined a variable \@afwezig that holds people that were not present at a certain meeting. \long\def\@afwezig{} \def\afwezig#1{\def\@afwezig{#1}} Now I want to make the header of the meeting ...
6
votes
2answers
193 views

why aren't the \left and \right before my parentheses changing their size?

I am working on a document, and in only one case have the \left and \right before my parentheses seemed to do anything. For example, I have this equation: \begin{equation} \mathbb{E}(RS_{nd}) = (1-F(...
5
votes
3answers
206 views

How to perform a \global\renewenvironment

I need to execute a \renewenvironment within a group. Using \global\renewenvironment is not sufficient. What changes do I need to make to the \DisableMyEnvironment macro in the MWE below so as to ...
5
votes
1answer
143 views

How to generate a xy diagram with multiple grouped data sets?

Based on the answer of Stefan Pinnow in 'How to group several charts into one chart?', I tried to generate a diagram with multiple grouped data. Therefore, I modified the diagram but I have some ...
5
votes
1answer
108 views

Should additional groups be avoided?

Should additional groups like \begin{algorithm} ... \end{algorithm} be generally avoided and the use of \algorithm...\endalgorithm be preferred? By additional is meant, that there is at least one ...
4
votes
2answers
378 views

Defining macro \gsetlength as global setlength, reliable?

As is noted in other questions, such as Global scope or permanent length or savebox, the \setlength command does not always have global effect. In many cases, that is desirable. But when the effect ...
4
votes
1answer
290 views

Measure and retain lengths between tabular rows

I need elements in a tabular environment to set some lengths and be able to access these lengths in another row of this same table. But it appears that adding \global in front of \settoheight and \...
4
votes
2answers
759 views

Variable persist outside environment

I am using the ifthen package for some conditional formatting. I am storing state in some booleans, but it seems that there is an issue with lexical scope. In particular, when a boolean is set within ...
3
votes
1answer
551 views

How to create groups of table rows with alternating colors?

Problem. When coloring a table, using different colors for even / odd rows is quite usual and can be accomplished with the xcolor package. I, however, don't want to have alternating colors per row, ...
3
votes
1answer
66 views

Lost global definition after \ifthenelse using package xifthen

I created my MWE with the help of this Q&A. MWE: \documentclass{article} \usepackage{xifthen}% provides \isempty test \newcommand{\GlobalDef}[1][]{ % \ifthenelse{\isempty{#1}} % {} % ...
3
votes
2answers
464 views

Adding \comment or \begin{comment} to \AtBeginDocument?

For Partial compilation commands/environment?, I would like to add \begin{comment} or \comment at the start of the document (so I could turn it off elsewhere in the code). So, even if in the larger ...
2
votes
1answer
238 views

Group figures in LOF by chapter (with chapter number, but w/o page number)

I have a problem which I can't seem to solve: My list of figures is grouped by chapters with a space between the figures of each chapter. What I would like to have though is not only space, but also ...
2
votes
1answer
215 views

Chess: Problem with notation style

This is a follow-up question to the one here. Using Ulrike's code from here, \documentclass{article} \usepackage{xskak} \usepackage{expl3} \makeatletter \ExplSyntaxOn \clist_const:Nn \...
1
vote
1answer
369 views

Grouping and undefined control sequence error

I was trying to figure out an answer to another question, which required a change of font and size in the middle of a sentence. So I tried to use a \begingroup and \endgroup to isolate the change of ...
1
vote
1answer
74 views

Keep sorting local to groups for symbols in glossaries-extra with bib2gls

Consider this example: \documentclass{article} \usepackage[record,style=alttreegroup,nomain,symbols]{glossaries-extra} \begin{filecontents}{symbols.bib} @symbol{alpha, name = {\ensuremath{\alpha}}, ...
1
vote
1answer
55 views

How to disable grouping for \includestandalone

I redefine the default macros for real and imaginary part according to \let\Re\relax \DeclareMathOperator{\Re}{Re} \let\Im\relax \DeclareMathOperator{\Im}{Im} Besides the main document, I'd also ...
1
vote
1answer
80 views

Span figure across margin and textbody in twoside: Assigning savebox locally

For twosidedocuments, I'd like my wide images and tables to span both the margin and the text. In my approach, I have created a command, which takes the input and stores in in a save box, measures its ...