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

learn more… | top users | synonyms (2)

5
votes
1answer
50 views

How can I write a command that defines another macro which may optionally be prefixed by \global?

In various contexts I define a macro such as \makeatletter \newcommand\aedosomething{\ae@do@something} \def\ae@do@something#1#2#3{%% %% do something with arguments #2 and #3 \def#1{<result ...
8
votes
3answers
207 views

Arguments possibly delimited by \bgroup and \egroup

I still don't see (and haven't thought about) pros and cons of making available the arguments as \foo{…} or \foo\bgroup …\egroup (or even unbalanced, \bgroup …} and {…\egroup). But I'm curious about ...
8
votes
3answers
325 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: ...
3
votes
1answer
198 views

pgfplots: “group” legend entries?

Actually, I'm working on a study where I've to plot a lot of temperature data etc. Therefore, I use "pgfplots". Everything works pretty well, so that I get the result as shown in the attached picture ...
4
votes
1answer
46 views

How do you define a command to select nested groups?

Assuming a pair structure (2-tuple) is defined using groups {{<tokens1>}{<tokens2>}} is it possible to define a command \first#1{...} (and \last#1{...}) taking the surrounding group as ...
3
votes
2answers
84 views

grouping enumerated list

I am trying to generate a numbered list with a bracket to the right of the list to group the list items into additional categories. I am trying to get something like: I have fiddled around with ...
4
votes
1answer
86 views

Convert a latex command with parameter into a two begin end commands without parameter

I have defined a command \newcommand{\CV}[1]{\parbox[c]{0.2\textwidth}{\begin{flushleft}#1\end{flushleft}}} which I obviously have to call like \CV{My text} However I rather would like to use ...
9
votes
2answers
117 views

Error when using defs inside a macro to write a row in a table

For the following MWE \documentclass{article} \newcommand{\cmd}[5]{% \def\tA{#1}% \def\tB{#2}% \def\tC{#3}% \def\tD{#4}% \def\tE{#5}% \tA & \tB & \tC & \tD & \tE \\ } ...
10
votes
1answer
270 views

Restore kerning across empty groups

Context In my document, I attach a tooltip to the middle part of a word. To demonstrate this behavior, try mousing over just the letter V in the word AVA. Here is the implementation and usage of my ...
4
votes
1answer
116 views

\AfterGroup sorcery and choking tex/pgf

In the following code, the line \AfterGroup* (from theetextools package) causes the pdfLatex compiler to 'choke', i.e it produces only this output and the process is stuck forever, consuming 13% of ...
4
votes
0answers
287 views

Multiple ternary plots and pie charts in pgfplots

I'm trying to plot lots of ternary plots and pie charts. Ideally it should look smth like this: The pie-chart (ternary plot) on the left-hand side serves as an explanation of what is happening, ...
8
votes
1answer
61 views

Missing bullet when itemize \item content is empty and buried within a group

When writing my question about various approaches to creating loops, I stumbled across the following anomaly \documentclass{article} \usepackage{pgffor} \begin{document} \begin{itemize} \foreach \x ...
2
votes
0answers
22 views

Behavior of \global when used with xifthen package [duplicate]

I'm trying to calculate the sum of some numbers in my document. I want to allow non-integer values, so I'm using lengths, which works just fine. In my document it's often necessary to specify the ...
3
votes
1answer
119 views

mdframed: setting up a global environment

How do I set up a global mdframed environment? Would I add something like this in the preamble: \newtheorem{laws} \mdfsetup{% background = blue!30,% roundcorner = 5pt } } but then I want to be ...
5
votes
2answers
157 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 ...
5
votes
1answer
504 views

Splitting a command syntax across a \newenvironment definition

This question is a direct follow-up to the question Can a \newcommand Definition Contain Braces as Substitution Text? I asked yesterday. The following example is once again a counter-intuitive one, ...
5
votes
1answer
264 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 ...
13
votes
1answer
332 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 ...
4
votes
2answers
293 views

How to redefine \label, \ref and \pageref in a way compatible with varioref?

In order to prevent conflicts with labels when gathering exercices from a database, I need to redefine the commands \label, \ref and \pageref to add a local prefix to labels. Unfortunately, the ...
2
votes
1answer
122 views

Modifying section, subsection based on scope?

Using MS Word 2013 I mocked up what I would like to create using LaTeX: I tried exporting it in LibreOffice using its writer2latex; but that didn't work. So starting from the sectionbox LaTeX ...
7
votes
2answers
172 views

Coordinate system along line

I would like to draw a coordinate system along some lines in a framework for a structural course. This little coordinate system is called local coordinate system. At the moment the framework looks ...
3
votes
2answers
152 views

Using before as a Global setting in enumitem

I am working on a small project and am using the enumitem package reasons for beyond this example. I read the docs and managed to produce this example. Currently, I am using the before argument on the ...
7
votes
1answer
147 views

Grouping items onto the same line to avoid wrapping

I am authoring a poker-related document and am using the following commands to allow me to display cards: % Suit image adjustments: \newcommand{\suit}[1]{\includegraphics[width=8pt, height=8pt]{#1}} ...
8
votes
2answers
1k 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 ...
8
votes
2answers
174 views

Defining TeX count in a group

I thought that TeX counts were local definitions, but that is not what I am seeing. I was expecting that if I used \newcount within a group, that the etoolbox \ifdefcounter would say that the counter ...
12
votes
2answers
325 views

Is there a way to limit the scope of \usepackage?

When I tried to use the breqn package suggested by an answer to the question How do I break a long equation over lines It managed to break a whole bunch of unrelated equations (equations that did ...
14
votes
1answer
458 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 ...
21
votes
1answer
687 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} ...
4
votes
2answers
161 views

Disable chapter separation in \listoffigures and \listoftables

I use \listoffigures and \listoftables. Both commands create line breaks for items from different chapters. How can you stop that? Screenshot:
2
votes
1answer
241 views

How do I set group headings for an index in Lyx?

I want to set group headings, in form of a corresponding letter, for an index in lyx. I have one main lyx file, containing links (with include) to other lyx files, placed in a subfolder. I tried ...
4
votes
0answers
1k views

Attempts to manually change \linewidth ignored by LaTeX [closed]

I was going to try to answer the question: How can I change the geometry of a page on the chapter header page only, and return to normal on the next page? It didn't seem like it should be too ...
19
votes
3answers
362 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 ...
7
votes
3answers
220 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 ...
15
votes
3answers
379 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 liked question the babel shorthand ; should be ...
2
votes
2answers
146 views

Why does defining a new command inside a framed block not work?

Why does the following 'minimal working example' work \documentclass[a4,german]{book} \usepackage{framed} \begin{document} \newcommand{\myText}{Bliblibli!} \begin{framed} Blabla \end{framed} ...
4
votes
1answer
120 views

Grouping Negates Effect of \centering

Why does the use of \begingroup, \endgroup negate the effect of centering in the MWE? The MWE below yields a left aligned figure (not desired), with subsequent text on the left (desired): But if ...
2
votes
1answer
106 views

Add a brace on the left side of a group [duplicate]

I can't figure out how to place the brace on the opposite side, that is on the left of the group of equations, when following the answer in this link: How to put a brace on the right, not left, to ...
0
votes
1answer
125 views

A way of handling \left and \right brackets [duplicate]

I'm looking a way of making something like this: \underbrace{ \left[\nabla\times \left[\nabla\times \left[\ldots\nabla\times }_{ \infty\text{-times taking curl operator} } ...
4
votes
1answer
691 views

How to reset \renewcommand\l{\lambda} locally

I have a large document with a lot of equation, the author overwritten the original \l (used to get polish letter ł) with \renewcommand\l{{\lambda}}. It would be to much work to find all the \l in all ...
1
vote
1answer
826 views

Single paragraph with styling and larger \parskip

I'd like to use something like this: {\bfseries\small Some text here...\setlength{\parskip}{1em}} More text here in the next paragraph... In order to increase the spacing after a single paragraph, ...
2
votes
1answer
230 views

Paragraph and subparagraph titles inherit color settings from TeX group *after* them

I'm getting some strange behaviour when using the color package at paragraph and subparagraph level. See the code snippet below: \usepackage[usenames,dvips]{color} \section{A} {\color{Green} ...
2
votes
1answer
94 views

Why can't I set hyperref's pdfinfo from within a group? (Is it a bug?) [closed]

When I run the following code (using hyperref version 2012/09/27 v6.83g), I do not get any errors or warnings, but the metadata I set using pdfinfo doesn't appear. If I uncomment the \@firstofone ...
8
votes
1answer
282 views

Creating temporary definitions for commands

In the context of writing something like homework solutions for a math class, I often face an awkward situation. Each problem will have some idiomatic functions that are cumbersome and error prone to ...
12
votes
2answers
422 views

How to create *local* labels/refs in LaTeX?

Concise question: Is there any way to limit the scope in which a \label is visible to a \ref? Motivation: My current goal is to create a rather large document, containing many exercises and their ...
10
votes
2answers
579 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} ...
2
votes
1answer
166 views

Strange chapter influence on quotation environment

The code below give a strange result when I comment out the \begingroup end \endgroup: the quotation environment has different vertical space to the text before ("Some text"). What is it that chapter ...
4
votes
1answer
1k views

Grouping nodes in tikz

For the MWE below: \documentclass[a4paper,11pt,twoside]{report} \usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry} \usepackage[T1]{fontenc} \usepackage{amsmath, graphicx, tikz, enumerate, ...
5
votes
1answer
86 views

Problem setting lengths in an environment (spilling outside of the environment)

I am having with spacing between paragraphs in my document, and I think I have been able to trace back to a custom environment I have defined. \makeatletter \def\remarkname{Remark} ...
13
votes
1answer
124 views

Difference between “hbox group” and “adjusted hbox group”?

eTeX's \currentgrouptype distinguishes two types of \hbox group types \hbox{\showthe\currentgrouptype} % 3 "adjusted hbox group" \noindent \hbox{\showthe\currentgrouptype} % 2 "hbox group" Looking ...
3
votes
2answers
485 views

How to make a recursive macro in (La)TeX?

The following MWE is the code of my attempt translating my working algorithm in C# to (La)TeX. I don't understand why it does not work. Can you probe the source of problem? Remarks: #1 is a list of ...