Questions tagged [grouping]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

Table of contents is not fully appearing inside \begin\clearpage\relax \endgroup [closed]

I have my main.tex as \documentclass{article} \begin{document} \tableofcontents \pagebreak \begingroup \let\clearpage\relax \include{lec1} \include{lec2} \include{lec3} \endgroup \end{...
Soham Chatterjee's user avatar
0 votes
1 answer
41 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 ...
Noah J's user avatar
  • 443
2 votes
1 answer
57 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\...
Benno's user avatar
  • 31
0 votes
1 answer
56 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 ...
oierpa's user avatar
  • 1
0 votes
1 answer
69 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 ...
GarretW's user avatar
0 votes
1 answer
17 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|} ...
BugInACode's user avatar
10 votes
3 answers
472 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{...
tobiasBora's user avatar
  • 7,417
2 votes
2 answers
84 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,...
Balansoire's user avatar
0 votes
1 answer
60 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 ...
Jasper Habicht's user avatar
3 votes
4 answers
122 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 ...
4DescarTes's user avatar
1 vote
0 answers
22 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. ...
Pa Dalton's user avatar
0 votes
0 answers
23 views

Adding contour outline to whole document?

My document has background pictures on every page. Thus, in some cases the text is quite hard or unpleasent to read due to similarity of font color and background color. I´d like to know if there is ...
Benjamin's user avatar
0 votes
0 answers
17 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} \...
UnknownW's user avatar
  • 389
11 votes
2 answers
588 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 ...
mbly82553's user avatar
  • 111
3 votes
1 answer
88 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 ...
Stephen's user avatar
  • 14.7k
0 votes
0 answers
32 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 ...
lyl's user avatar
  • 2,677
0 votes
1 answer
66 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 ...
FunkiePhil's user avatar
1 vote
3 answers
98 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 ...
Alina Krichevsky's user avatar
0 votes
1 answer
170 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 ...
Pax's user avatar
  • 103
2 votes
1 answer
126 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 ...
lyl's user avatar
  • 2,677
1 vote
0 answers
66 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 ...
Jérôme LAURENS's user avatar
1 vote
2 answers
91 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 ...
user avatar
2 votes
1 answer
89 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 ...
Gargantuar's user avatar
3 votes
1 answer
68 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,610
2 votes
1 answer
303 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 ...
user avatar
0 votes
2 answers
60 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 ...
alexandre1985's user avatar
0 votes
4 answers
323 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 ...
Maximilian Keßler's user avatar
1 vote
0 answers
79 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} \...
dkraft's user avatar
  • 11
2 votes
3 answers
76 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 ...
Ulrich Diez's user avatar
  • 26.9k
0 votes
0 answers
71 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 ...
jiwopene's user avatar
  • 179
2 votes
1 answer
65 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,...
Mathieu's user avatar
  • 35
2 votes
2 answers
266 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{% \...
Clément's user avatar
  • 3,984
0 votes
0 answers
42 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
Muhammad WASEEM FAROOQ's user avatar
4 votes
2 answers
83 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
0 votes
1 answer
323 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 ...
user2535338's user avatar
0 votes
2 answers
95 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 ...
Clément's user avatar
  • 3,984
3 votes
1 answer
141 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 ...
Kerrek SB's user avatar
  • 1,055
0 votes
1 answer
77 views

Locally change the scale of the chosen (mono) font without specifying its name?

Suppose a custom class which, thanks to package titlesec, prints the sections titles in uppercase. Suppose now the user of this class wants the mono font to be Scale = MatchLowercase. If a section ...
Denis Bitouzé's user avatar
1 vote
1 answer
161 views

How to globally apply all texts as the argument of a command?

I'm trying to make an entire document to look like handwrote. For that I tried both the Cthulhu and handlatex. Both of them require the following usage: \command{here the text to be applied.} Which ...
user avatar
0 votes
2 answers
26 views

Global change applied only to lists inside definition and theorem environments

For editing my lecture notes and worksheets, I am using the enumitem package. I regularly make global changes, for example using the following code in the preamble: \setenumerate[1]{label={\bfseries\...
Tonn's user avatar
  • 1
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.1k
4 votes
1 answer
102 views

Can I change a \def inside a \foreach loop without making it visible to the whole document?

I understand that a \foreach loop creates a group and local definitions are, of course, local. Is there a way to skip just one level of the scoping? I mean I wish to make a local change inside the ...
Jander's user avatar
  • 1,029
1 vote
1 answer
245 views

A group macro from a command

Goal: create a command that works within a group (a scope) I am using polyglossia package to write bilingual texts. I want to create \eng declaration or switch to behave just like \textenglish: {\eng ...
AvidSeeker's user avatar
1 vote
0 answers
24 views

Creating matrix newenvironment with arraystretch [duplicate]

I want to create a new matrix environment with different spacing for a matrix instead of manually typing arraystretch locally for each matrix. I am new to more advanced LaTeX coding, and have not ...
CyCeez's user avatar
  • 11
0 votes
0 answers
25 views

How to add table in between two \item commands [duplicate]

I insert a table command between two itemized items, but the table appears at the top of the page. please help me locate this at the right place it means to be. thank you. Ardalan
Ardalan Marandi's user avatar
3 votes
1 answer
169 views

Local vs. global variables in pgf, interaction with foreach

I am trying to write a macro with variable number of inputs (this is important to me) that should return the maximum of the lengths of the different inputs. It uses the foreach macro from pgffor: \...
HowieR's user avatar
  • 31
0 votes
2 answers
156 views

LaTex macro not properly executed in tabular environment

I want to use a macro to set the separators (&,\\) in a tabular environment. The macro should thereby act as a Boolean switch with three states. Unfortunately I keep getting a result like this: ...
Gedlex's user avatar
  • 3
2 votes
1 answer
286 views

How to make `\cref` after expansion stand at the same group of surrounding text?

I would like to make \cref after expansion stand at the same group of surrounding text. With \crefname{figure}{图}{图}, I need to use 如\cref{...} 所示 to make typesetting correct, if the counter of figure ...
Eli4ph's user avatar
  • 815
4 votes
1 answer
83 views

Can this code be more compact?

I have a number of commands with the same structure as this one and I'm wondering whether or not the code can be compacted to avoid having to type the E_{K and K_{\symup{trans} twice each. I don't see ...
LaTeXereXeTaL's user avatar
2 votes
1 answer
1k views

"Paragraph ended before ..." error in TeX

While playing around with TeX, I came across a strange error. This is my input file: \def\twice#1{#1#1} \def\hello{Hello World.\par} \twice{\hello} % works \twice{Hello World. } % works \twice{Hello ...
Eklavya Sharma's user avatar

1
2 3 4 5 6