Questions tagged [grouping]

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

Filter by
Sorted by
Tagged with
2 votes
1 answer
51 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 ...
user avatar
  • 2,355
1 vote
0 answers
63 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 ...
user avatar
1 vote
2 answers
50 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
58 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 ...
user avatar
3 votes
1 answer
60 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{\...
user avatar
  • 2,335
2 votes
1 answer
71 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
37 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 ...
user avatar
0 votes
4 answers
113 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 ...
user avatar
1 vote
0 answers
41 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} \...
user avatar
  • 11
2 votes
3 answers
62 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 ...
user avatar
  • 23.5k
0 votes
0 answers
67 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 ...
user avatar
  • 169
2 votes
1 answer
33 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,...
user avatar
  • 35
2 votes
2 answers
106 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{% \...
user avatar
  • 3,914
0 votes
0 answers
39 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
user avatar
4 votes
2 answers
76 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\...
user avatar
0 votes
1 answer
139 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 ...
user avatar
0 votes
2 answers
56 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 ...
user avatar
  • 3,914
1 vote
1 answer
74 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 ...
user avatar
  • 833
0 votes
1 answer
41 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 ...
user avatar
1 vote
1 answer
79 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
25 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\...
user avatar
  • 1
1 vote
1 answer
30 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}} \...
user avatar
  • 49k
4 votes
1 answer
61 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 ...
user avatar
  • 830
1 vote
1 answer
117 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 ...
user avatar
1 vote
0 answers
23 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 ...
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
user avatar
3 votes
1 answer
78 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: \...
user avatar
  • 31
0 votes
2 answers
110 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: ...
user avatar
2 votes
1 answer
160 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 ...
user avatar
  • 795
4 votes
1 answer
76 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 ...
user avatar
2 votes
1 answer
247 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 ...
user avatar
1 vote
4 answers
95 views

Suppress all typesetting within a group

I have a macro that is purely functional (e.g. only defines other macros), and I want to be able to invoke this inline without any new paragraphs or blank spaces being typeset. \documentclass{article} ...
user avatar
  • 145
1 vote
1 answer
78 views

Why does \endgroup not work inside \uline?

I want underlined text (or math) where the color of the underline is different from the color of the text (e.g. black text underlined by a red line). Therefore I tried the following code using the \...
user avatar
  • 721
5 votes
2 answers
470 views

Why do I have to put braces around my macro for subscripts / indices?

I want to define a macro \ind which let's me set in math mode a subscript in upright letters and when starred (\ind*) in italic letters. Additionally, an optional argument allows me to adjust the ...
user avatar
0 votes
0 answers
59 views

How to make brackets work like group separators?

I know that the following is not something you are usually supposed to do, but I ask anyway: I am getting quite tired of the fact that TeX does not treat the content of brackets [...] as groups like {....
user avatar
  • 11.1k
0 votes
1 answer
554 views

How to change the global font size of align?

I'd like to change the font size of align blocks. I've tried to change it by using \large, but this also changes the equation numbering. The second approach was to use \declaremathsizes in combination ...
user avatar
  • 11
4 votes
1 answer
127 views

Declaration commands of setspace have no effect inside groups

According to this answer of the question change space to only a part of the document (about 8 years ago), the effect of setspace' declaration commands (\singlespacing, \onehalfspacing, \doublespacing) ...
user avatar
4 votes
0 answers
151 views

SIUnitx Unit Grouping

Is there any siunitx options to manage grouping of units when per-mode=symbol is active? Or, is there a better way to handle this? Manually inserting parenthesis works fine (second line). But, when I ...
user avatar
3 votes
3 answers
238 views

How to define an environment that defines a macro, maybe a brace-parenthesis issue?

I know how to define a macro as follows \newcommand{\mycommand}{ here my macro commands } But I would like to create an environment that defines macro, as follows \begin{definemycommand}{\...
user avatar
6 votes
4 answers
454 views

What LaTeX macros cannot accept a group as an argument?

I am working on a LaTeX pretty printer that parses a LaTeX document and then re-renders the source. (I know that this is not possible in all cases, but it should be possible a lot of the time.) In ...
user avatar
5 votes
1 answer
760 views

Formating Maxwell's Equations

Hey y'all I am trying to format Maxwell's equations like the image below but without the box. I also want to be able to reference the labels, thanks!
user avatar
4 votes
2 answers
161 views

Text variant vs font switch - bfseries

I stumbled into the following sample \documentclass[a4paper,11pt]{article} \usepackage[english, ngerman]{babel} \begin{document} Quick test - not yet bold "\textbf{Bold text for test - part 2} ...
user avatar
  • 1,215
2 votes
1 answer
58 views

When do curly braces disappear in macro definitions? (e.g. \documentclass expansion)

I've been looking into how \documentclass and friends are actually defined, and I noticed something peculiar which I'd like to understand. Let's say I have \documentclass[11pt, titlepage]{article}. ...
user avatar
1 vote
1 answer
58 views

Background image on frame not in slide navigation

I try to achieve the following: have a background image on a frame and disable the frame to appear in the navigation bullets at the same time. I can do both but not at the same time. If commenting out ...
user avatar
  • 3,443
0 votes
0 answers
60 views

Error: Missing \endgroup inserted (dmath)

I have the problem with the error shown in the following screenshot. I cannot figure out what the problem is as this identical syntax has worked in other files... Thanks in advance for your help!
user avatar
0 votes
0 answers
55 views

How can I create Local commands definitions in equations?

I would like to use small local macro expansion similar to how \newcommand works but on a per environment basis. Something that would expand \[ \begin{local} \local{\poly}[2][x]{#1^2 - #1^#2} \...
user avatar
  • 445
1 vote
0 answers
142 views

How can I use a minted listing inside a tcolorbox's top half *and* bottom half?

I'm creating reference documentation for a intro-to-programming class. As part of this, I'm going to have syntax definitions and examples of the syntax. To write this, I'd like to have LaTeX syntax ...
user avatar
  • 26.7k
2 votes
1 answer
87 views

How to make a simple macro from this grouping?

I'm frequently using the following group code to reduce vertical space between some equations (with the equation, align, gather and other maths environment) and the text above it: \begingroup\...
user avatar
  • 2,034
1 vote
1 answer
114 views

Writing expanded macro with space to file

I'm trying to write an expanded macro to a file without the expansion eating the space after it. I could replace the {} empty group with an explicit \space, but I want this to be fairly robust. Is ...
user avatar
2 votes
1 answer
95 views

Why does the \centering command affect prior text?

Usually commands of the form: {\command <text>} affect only <text> and nothing else. In other words, the scope of such commands is limited to the group they are nested in. In the case of ...
user avatar

1
2 3 4 5