Questions tagged [grouping]
{grouping} is about the grouping mechanism in TeX, and about local and global assignments.
281
questions
2
votes
1
answer
60
views
How to group elements in order to use them like one character
I want to create commands that will show some data and will be used as a single character in different places (paragraphs, tables etc.).
Here is an example of how it should be looking:
I achieved it ...
0
votes
1
answer
17
views
How to ignore ExPex code in texcount
I'm wondering if it is possible to exclude ExPex code from being counted by texcount? At the moment I'm writing a thesis with lots of linguistic examples, but I need to exclude these from the total ...
1
vote
2
answers
43
views
Is it possible to fully `\restoregeometry` inside a group?
For the geometry package, is it possible to \newgeometry{…} and fully \restoregeometry inside a group?
Minimal Example
In the following, the \restoregeometry inside the {…} restores frames, but still ...
1
vote
2
answers
60
views
How to add vertical braces to a matrix showing different groupings of the elements?
So, I am currently trying to do this:
And this is what I tried so far,
\[
\left[
\begin{array}{c}
\left.\begin{matrix}
x_k \\
y_k \\
v_k \\
\psi_k \\
\end{matrix}\right\} s_k^p \\
\...
2
votes
1
answer
59
views
Locally redefine figure environment as figure* for automated export
I'm using a workflow based on pandoc and Latex to produce papers with my companies layout. Part of the formatting are captions set inside the margin and sometimes using images that span text and ...
5
votes
1
answer
107
views
How to avoid resetting macro definitions within a group/environment
Here's the question: why does the following code reset the meaning of the \pgPtList control sequence when the group ends?
\documentclass[12pt]{article}
\begin{document}
\begingroup
\gdef\...
0
votes
1
answer
55
views
Saving a math style in beamer
I am trying to build a version of beamer's alt that occupies the space of its larger argument. I do this with some saveboxes and measuring. Because I also want to use it in math, I need to save the ...
4
votes
2
answers
490
views
"\uppercase{a\lowercase{bC}}" produces "Abc" in TeX?
In TeX, \uppercase{a\lowercase{bC}} produces Abc not ABC, why? As far as I know, TeX will run the inner group before run the outer group, so I think it should be ABC and even \uppercase{a\expandafter{\...
0
votes
2
answers
73
views
Need add a space before character in changing category of character?
At the bottom of page 307 of The TeXbook, it says
TEX always reads the token following a constant before evaluating that constant.
So,
{\catcode‘\>=2 >
is different from
{\catcode\`>=2>
...
0
votes
2
answers
60
views
If one of TEX’s internal parameters is changed within a group, the previous contents of that parameter will be restored when the group ends in TeX?
I see this sentence on page 21 of the book The TeXbook, but I can't understand it. May you show me an example and explain it to me?
If one of TEX’s internal parameters is changed within a group, the ...
0
votes
2
answers
76
views
Without "\global", we can still change "\count0"?
As on page 21 of the book The TeXbook, if we need to change the page number to add 1, we need to use \global\advance\count0 by 1, as \advance\count0 by 1 couldn't change \count0 in other groups. ...
-1
votes
1
answer
98
views
Ignore Text between \bgroup and \egroup from printing in PDF during runtime [closed]
I would like to exclude the text between \bgroup and \egroup from appearing in the final PDF, i.e. mark it as a comment during runtime. However, the problem here is that the text is not static and \...
0
votes
0
answers
39
views
`\endgroup` error with {dinbrief} and XeLaTeX [duplicate]
First, let's consider this minimal working example:
\documentclass{dinbrief}
\begin{document}
\begin{letter}
test
\end{letter}
\end{document}
This document compiles sortof fine with PDFlatex and ...
2
votes
1
answer
64
views
Why does loading `newenviron` cause compilation to fail?
To avoid unnecessary effort, please note that I'm asking specifically about the error's cause, as opposed to how to avoid it. Furthermore, I'm aware that \NewDocumentEnvironment now offers the b ...
0
votes
0
answers
63
views
How to set background image on every page using group elements
I need to put a background image on full page and I have several group elements, sometimes two groups on one page
I only get one Image on half of the page and on the next page the group elements start
...
0
votes
1
answer
43
views
Locally adjust a dimension written into aux
I am writing some code that makes use of a dimension (termed \shape below) that gets adjusted several times over the course of the code. The value \shape has by the time the code is finished is what ...
2
votes
1
answer
65
views
Put \item into a group so that typesetting effects are limited for the list entry
I want to have an implicit grouping for each \item in an itemize or enumerate environment to limit typesetting effects (coloring, emphasizing) to the respective \item.
E.g.,
\begin{itemize}
\item\...
0
votes
1
answer
106
views
Issue with Hyperlinks in PDF using Hyperref Package
I am currently facing an issue with the placement of hyperlinks in a PDF document that I am typesetting using LaTeX and the hyperref package. I have tried various approaches, but I haven't been able ...
0
votes
1
answer
82
views
Exercise 5.7 in TeX - define control sequences with grouping
I want to solve Exercise 5.7 in the TeXBook by Donald E. Knuth.
Define control sequences **\beginthe**<block name> and **\endthe**<block name>
that provide a “named” block structure.
In ...
0
votes
1
answer
22
views
Variables set within tables and reused later in the document
I am writing a document that involves a table of information for many sections, something like:
\textbf{Details:}
\begin{table}[H]
\begin{center}
\begin{tabularx}{\linewidth}{|X|c|c|c|c|c|}
...
10
votes
3
answers
496
views
Latex3: elegant way to forward a variable outside of the group
I want to define a macro in a group in LaTeX3 so that it stays defined after the group, but without using global variables. For now I do:
\documentclass{article}
\ExplSyntaxOn
\NewDocumentEnvironment{...
2
votes
2
answers
98
views
Pgf foreach ungrouped displays list twice
While trying to give a foreach loop a macro to loop into, I found on Macro not working in foreach loop that I can use \pgfplotsforeachungrouped and it was indeed able to loop through my macro.
However,...
0
votes
1
answer
68
views
Grouping mismatch if loop is dissolved
I am sure that I overlooked something very obvious. Still, why does the example in this nice answer work, but if I remove the loop, I get an error about a grouping mismatch?
Consider the following ...
3
votes
4
answers
255
views
Table decleration
In my document, I have a table, I want to use \setlength{\tabcolsep}{18pt} but since there is one more table, this also affects the other, which I don't want to change. Therefore I thought of creating ...
1
vote
0
answers
25
views
Add content in a global table located in the beginning of the document
I would like to generate a global table with entries that can be added with a command. I based myself on this post. The issue I have is that I can only display the table after I added all its entries. ...
0
votes
0
answers
20
views
Grouping problem in figure vertical alignment of text
I had the same problem as in LINK. The question is about using \endgroup somewhere. If I use the following code
\usepackage[a4paper,hmargin=1in,top=1.2in,bottom=1in]{geometry}
\usepackage{lipsum}
\...
13
votes
2
answers
1k
views
Is this the right way to understand \let \def \edef \gdef \xdef \newcommand \renewcommand \providecommand?
I've already looked at at least ten different q&as explaining the differences of a subset of the commands listed above. While experimenting with them and trying to understand the subtle ...
3
votes
1
answer
117
views
`\global\NewCommandCopy` instead of `\GlobalLetLtxMacro`?
The new LATEX2ε kernel provides \NewCommandCopy (and \Renew... and \Declare... variants) which functions almost like \LetLtxMacro from the letltxmacro package.
Instead of \GlobalLetLtxMacro from ...
0
votes
0
answers
34
views
How to make calling of xeCJK work in a group
From the following example, you can see that calling a package in a group does work (xcolor in this example), except the package xeCJK.
Does that mean this is a bug of xeCJK, or is there other way to ...
0
votes
1
answer
71
views
How to define a macro globally with a name containing a number?
I'm trying to define multiple macros in a \foreach loop. The name of each macro contains a different integer. To do that I use \csname ... \endcsname.
The issue is I would like to be able to call ...
1
vote
3
answers
152
views
Subgroups inside of a table
I'm trying to create the following table so that the parts marked in red are listed as subgroups with indent while the others are unindented.
I have tried multicolumn. However, it worked only ...
0
votes
1
answer
321
views
Add further grouping to nomenclature using {nomencl} + {etoolbox}
To add a nomenclature to my master thesis I follow overleaf's recommendation and use below code.
Grouping is quite important for me. Unfortunately, I cannot figure out how to create subgroups by using ...
2
votes
1
answer
164
views
Construct new environment with \bgroup...\egroup
The following code is just for experiment It would result in a framed box(seem like \fbox{\parbox{2in}{...}}). But it fails. What's wrong with my code?
Yet framed box in this example is not my root ...
1
vote
0
answers
69
views
What is the cost of TeX grouping?
While developing some package I end up with a dilemma:
either a small number of TeX groups but many scratch variables
or a small number of scratch variables but many TeX groups
I have the impression ...
1
vote
2
answers
135
views
Reduce font size for all tables in my document : inside these tables, there are \begingroup and \begin{tabular}
I would like to reduce the font size into of all my tables.
The ideal would be to put new macro at the top of my Latex source.
I show you for the moment the current formatting :
we have 4 bins and not ...
2
votes
1
answer
107
views
What is correct? `(-1)^a` or `{(-1)}^a`? [duplicate]
Essentially the title says it all.
The TeX linter ChkTeX recommends to group parentheses if sub-/superscripting. It makes the grouped content into an atom (my TeX knowledge is minimal), so it is ...
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{\...
3
votes
1
answer
556
views
What's the cleanest way to set \emergencystretch only for one list item?
Feeding pdflatex with
\documentclass{article}
\pagestyle{empty}
\usepackage[USenglish,latin]{babel}
\babelprovide[hyphenrules=nohyphenation]{latin}
\usepackage{enumitem}%%% the same problem occurrs ...
0
votes
2
answers
66
views
text underscore groups with caption
I am trying to achieve what I have called the underscore groups with caption. I don't know the exact name and I have tried to search on the internet for this, without any success.
Here is an image ...
0
votes
4
answers
485
views
Define global function within \begingroup ... \endgroup
I have a command that accepts optional arguments as key-value pairs, handled by the l3keys package. I use \begingroup and \endgroup to \keys_set:nn the keys in order to process set options only for ...
1
vote
0
answers
107
views
I'm working with MiKTeX, TeXstudio and writing letters with KOMA-Script and get the following warning "Unused global option(s): [dieter]."
My dieter.lco file includes besides personal information the following lines
\ProvidesFile{dieter.lco}[2022/01/08 scrlttr2 options]
\RequirePackage{ngerman}
\RequirePackage{fix-cm}
\...
2
votes
3
answers
79
views
How to detect if a command, which is undefined in the current scope, also is undefined in all superordinate scopes?
Theoretical question/moot point:
Scenario: You wish to have defined a command globally. But you wish to have it defined only if it is undefined both in the current scope and in all superordinate ...
0
votes
0
answers
78
views
How to execute TeX only for side effects
I need to execute a part of my TEX code without printing the text it produces while making \global macros defined by it available.
For example, when I have this group:
{
foo\global\def\bar{baz}
}
I ...
2
votes
1
answer
77
views
Grouping mainmatter prevents chapter count
When I group my mainmatter to prevent it of inserting a blank page, my chapter numbering dissapears as well.
I can't seem to find any work-around or even why this is happening.
\documentclass[a4paper,...
3
votes
2
answers
398
views
How can I save and restore fontdimen parameters?
I am using the fontdimen code in this answer to make spaces stretch in inline code samples (credit to Stefan Kottwitz):
\documentclass{minimal}
\usepackage{lipsum}
\newcommand*\justify{%
\...
0
votes
0
answers
51
views
One to one function, how to draw in LaTeX? [duplicate]
Here are both set of one to one function. How to make LaTeX coding in figure type:
(x)=0,2,3
(y)=a,b,c
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\...
0
votes
1
answer
404
views
Change the word “Table” in only one table caption
I'm using the xltabular with the group, because of the table is large and it occupies more than one page.
My document which is a thesis, I have two types of tables, the tables and the frames.
By ...
0
votes
2
answers
116
views
Why do headers and footers inherit the current value of \spaceskip, and how can I prevent it?
Problem:
I'm using a listings-like package to display source code in a paper. The environment that the package defines uses \spaceskip=\fontdimen2 to ensure that spaces all have the same width.
When ...
3
votes
1
answer
161
views
"extract" package causes unfinished group
I've noticed errors like this when using the extract package:
(\end occurred inside a group at level 1)
### semi simple group (level 1) entered at line 5 (\begingroup)
This seems to happen even with ...