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

learn more… | top users | synonyms (2)

5
votes
1answer
87 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
126 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
494 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 ...
12
votes
2answers
263 views

necessity of braces for accent commands

Many resources on LaTeX teach that "é" and "ä" are typeset with (respectively) \'{e} and \"{a}; and it is similar for other accent symbols. Are the braces really needed? Aren't \'e and \"a shorter but ...
19
votes
2answers
253 views

global confusion

Simply put, when should I care if something is global or not? What does this really mean? If my package, for example, provides \newcommand*{\setfooter}[1]{\def\mypackage@footer{#1}} And I later ...
8
votes
3answers
608 views

Using execute at begin node with \phantom and \pgfuseimage in TikZ?

Problem I would like to create several nodes whose text is a placeholder for an image, i.e., \phantom{\pgfuseimage{mypicture}}. This is easily done as, for example: \matrix { \node ...
15
votes
1answer
201 views

First occurrence of a command

I'm writing some macros that need to behave differently after first occurrence. I decided to use the etoolbox package's toggle. My MWE is as follows: \documentclass{article} \usepackage{etoolbox} ...
17
votes
1answer
598 views

Why is \global\let not always global?

As an LaTeX environment opens a local group, it is normally necessary to use a global definition if changes in the environment should be available after the environment: \documentclass{minimal} ...
11
votes
1answer
325 views

What is the scope of elements of TikZ pictures?

I understand that named elements of a tikzpicture cannot be referenced before they are defined; but I'm confused about how "long" a named element persists. It appears that once named, an element ...
18
votes
4answers
537 views

How do I get a value out of a group?

I've just recovered from my first real foray into LaTeX3 programming. It was ... an experience. Not a completely unpleasant one and once I'd gotten used to the syntax then I found it a lot easier ...
1
vote
1answer
210 views

Unexpected scoping issue using \XeTeXinterchartoks

Minimal example (compile with xetex): \XeTeXinterchartokenstate = 1 \newXeTeXintercharclass \classa \XeTeXcharclass `\a \classa \XeTeXinterchartoks 255 \classa = {\begingroup} \XeTeXinterchartoks ...
13
votes
3answers
2k views

\global\renewcommand equivalent of \global\def

The following MWE works just fine, but I had to resort to using \global\def (not that there's anything wrong with it). The intent of the MWE is to provide access to the value of macro as set in an ...
13
votes
2answers
12k views

Temporarily increase line spacing

How do I temporarily increase line spacing? I have some text on my title page: \begin{center} { \Large \textbf{The Great Thesis About Some Very Great Things Indeed With a Pretty Long Title That Will ...
5
votes
1answer
2k views

How to globally tikzset styles

I would like to set a tikzstyle from within a tabular environment, and use it after the table. Adding the usual \global seems to have no effect. The MWE below produces: but I want the last line ...
13
votes
2answers
492 views

\expandafter within a \begingroup … \endgroup [duplicate]

Possible Duplicate: What does \begingroup\expandafter…\endgroup do? In many of Heiko Oberdiek's packages one sees this type of construction: ...
9
votes
2answers
708 views

\newtoks token seems to have local scope

I want to collect the first line of a quotation to use later. I have used \newtoks for a similar purpose so tried it here, this way: \documentclass[12pt] {article} \newtoks{\qfirstlineinternal} ...
15
votes
3answers
830 views

Use \bgroup and \egroup to set some pre and post code to a macro

Why isn’t it possible to use \bgroup and \egroup in this way? \documentclass{article} \def\precode{\fbox\bgroup} \def\postcode{\egroup} \newcommand{\mymacro}[1]{\precode#1\postcode} ...
3
votes
1answer
358 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, ...
4
votes
1answer
227 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 ...
10
votes
3answers
1k views

Drawing a proper shadow for overlapping objects

I draw images that are composed of several overlapping nodes. If I add a drop shadow to each node, the shadow of the second node is drawn over the first node, as seen in the picture below (which ...
9
votes
2answers
598 views

Beamer: content in box register does not survive \end{frame}

Consider the following example (I edited the example to include LaTeX lrbox environment): \documentclass{beamer} \newsavebox\mybox \newsavebox\myboxb \begin{document} \frame{ \sbox\mybox{Hello ...
7
votes
2answers
173 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}) = ...
10
votes
1answer
133 views

Emulate TeX's grouping

In TeX, various kinds of groups must match properly, for instance, the following is wrong: $ \begingroup $ \endgroup I would like macros which allow such mismatched grouping. They would keep ...
6
votes
2answers
472 views

Is there a way to control scope of fontspec font change?

I would like to limit the scope of \fontspec to just one or a couple of words in my paragraph, for example: Vivamus gravida lacus a sapien \fontspec{The Font Name}{interdum} eget interdum mi ...
2
votes
1answer
301 views

A simple implementation of comment/verbatim: drawbacks?

While considering how to exclude \items in Yossi Farjoun's recently active question onlyitems? How to select specific items from an item list, I thought I would do what I proposed in my first answer: ...
17
votes
2answers
361 views

Why do I have to put the center environment in a group for \@afterindentfalse\@afterheading to suppress indentation?

Consider the following two macros, the only difference being that one has the environment inside a group: \documentclass{article} \makeatletter \newcommand\thisworks{% {\begin{center} $\ast$ ...
3
votes
2answers
564 views

Linewidth resets when using input files

I'm trying to set some figure files in standalone .tex files, and then input them in the main file. Those files looks something like this \ifx \plotwidth \undefined \newlength{\plotwidth} ...
24
votes
4answers
984 views

Kerning between bold and non-bold text

I'd like to write a word in bold followed by a comma and a non-bold word, like this: \textbf{why}, blah If I just write why, TeX inserts a kern to shift the comma a little closer to the "y". But ...
10
votes
2answers
890 views

siunitx: How do I unset options previously set with \sisetup?

In the siunitx package (v1.3), I know that I can set various options with the \sisetup command. But what if I want a particular option to apply to only a small section of my document, with default ...
7
votes
4answers
946 views

Is there a way of limiting the scope of \newlength?

Is there a way of limiting the scope of \newlength? I'm using the same name in many TikZ picture but each with different value, and I don't want it to live on between the pictures as it's not intended ...
4
votes
2answers
2k views

\bgroup and \egroup?

So I've been looking to expand on the following bit of code (a hack to not screw up the margins when using oversized figures): \noindent\makebox[\textwidth]{% \begin{tabularx}{1.5\textwidth}{XX} ...
26
votes
3answers
7k views

When to use @ in an \if statement

I am new to LaTeX and so this question might come across as rather basic. It might also reflect my biases/assumptions from my C/C++ programming days. I was seeing the code of the 'exam' class and ...
11
votes
1answer
860 views

Why do \setcounter and \addtocounter commands have global effect, while \setlength and \addtolength commands obey the normal scoping rules?

The \setcounter and \addtocounter commands have global effect, while the \setlength and \addtolength commands obey the normal scoping rules. Why were they designed like this? Why are ...
2
votes
1answer
181 views

Use a tikz variable outside tikz environment… or something that could do that whatsoever?

I want to use a variable that could be used in TikZ code to get an external data file, and outside this code to define a legend associated. TikZ won't let me use \caption inside its environment, and ...
11
votes
2answers
188 views

What combinations of mode and \currentgrouptype exist?

I am trying to predict in any given situation what TeX does if a closing brace reaches its stomach (apart from reverting local assignments). For instance, \vbox{\tracingall H} shows that if it is in ...
20
votes
2answers
3k views

What does \begingroup\expandafter…\endgroup do?

I often see code of the following form in package implementations (this example is from the LaTeX3 sources): \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname ...
2
votes
3answers
902 views

TeX Nested Loops With \iftoggle

This forum has helped me understand how to use nested loops in TeX, but now I am having trouble using \iftoggle (from the etoolbox package) with loops. My goal is to have a toggle that can keep track ...
8
votes
1answer
142 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
1answer
1k views

How to escape “]” in a description's item tag?

In a description like \begin{description} \item[\texttt{DoSomething(items[])}:] ... \end{description} , how do I escape the "]" character?
18
votes
3answers
681 views

Should LaTeX counters always be modified globally?

In this answer, egreg states that "LaTeX counters should always be modified globally". However, the etoolbox package provides the \defcounter macro which will assign a value to a previously ...
6
votes
2answers
752 views

Tikz: How to move a footnote in a node out of that group?

Apologies for the slightly strange title, I struggled to come up with something else. I have defined my own quote environment with brackets around the quote. In order to do that I use tikz and the ...
2
votes
2answers
275 views

Macro behaviour different inside tabular environment

I have a lot of problems lately with macros expanding (or not expanding) at unexpected times, so thought I was having a related problem here. But, in this case, things are working as I want outside of ...
11
votes
2answers
408 views

Restrict macro to an environment

I am quite a noob when it comes to customising LaTeX/XeLaTeX. I would like to know if there's a way to limit the usage of a macro to a specific environment. Consider the following macro and ...
14
votes
2answers
623 views

Is there a way to set a *global* key value using `pgfkeys`?

The simple answer to this question appears to be "No"; quoting from the pgf manual: The setting of a key is always local to the current TeX group. However, this is very annoying because it means ...
6
votes
3answers
550 views

Is there a way for a command to have a scope within item?

I defined a command \newcommand{\done}{\color[RGB]{124, 124, 255}} Is there a way to use it as \item \done la-la instead of \item {\done la-la} It bothers me to put brackets all the time. ...
7
votes
3answers
2k views

LaTeX3: how to define a variable locally

I am trying to learn the LaTeX3 syntax. One of the questions I have come up with is how to define a variable, i. e. a macro without arguments in TeX parlance, with local scope within a group. In TeX ...
6
votes
2answers
324 views

Name scoping issue (probably)

I'm trying to solve what is clearly a name scoping problem and don't know how to do it. (This discussion is extracted from a poorly-formed question about the same code that I posted yesterday; I've ...
3
votes
1answer
1k views

How to make a local variable in Plain TeX?

I want to simplify my code below by creating a local variable as a temporary container to save the value of \numexpr#1+#2+#3+#4+#5}. \documentclass[dvips,dvipsnames,rgb,table]{book} ...
9
votes
3answers
437 views

Making register declarations local, Undefining a register (count, toks, etc.)

Is it possible to make \newcount, \newtoks, etc. respect grouping, so that, e.g., \newcount\temp\temp=2{\newcount\temp\temp=1}\showthe\temp gives 2 (instead of 0)? Relatedly, is it possible to ...
4
votes
1answer
464 views

Booleans fail in tabular environment

I've got a workaround for this problem, but maybe someone knows a cleaner way to fix it. I'm using the standard packages in TexLive 2009. Here's the code that doesn't work: \documentclass{article} ...