Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [scoping]

{scoping} defines the context within which a variable name or other identifier is valid and can be used, or within which a declaration has effect.

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

Changing text color \afterpage with page break in scoped blocks

I want to set the text and background color for a single page, to call it out from the rest of the document. This can be accomplished using \pagecolor and \color, then \afterpage is used to return to ...
user avatar
2 votes
3 answers
61 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.1k
1 vote
0 answers
48 views

What does "{%" mean? [duplicate]

What does "{%" (a brace followed by a percent) mean, and what is it called if I want to find the documentation for it? Here is an example. \newcommand{\atest} {% \includegraphics[width=1in]{...
user avatar
4 votes
2 answers
74 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
0 answers
32 views

Limiting the scope of a bibliography to an inputted file

I am in a bit of a pickle. I am compiling a big file with several contributions (over 100-200) by different people. For reasons I won't get into, I am constrained to the following: The different ...
user avatar
0 votes
1 answer
65 views

Scope of counters in paracol environment

I am trying to use longtables in MDPI article template but their numbering is incorrect (it always starts from 1). What have I tried so far? Below is minimal working example. I've stripped the ...
user avatar
  • 153
0 votes
1 answer
68 views

pgfkeys: Dynamic definition of keys

I want to define a list of keynames in a macro. Then I want to initialize multiple keys with this keynames. I've tried with \foreach, also with .list but the keys are never defined. But, nothing it's ...
user avatar
1 vote
1 answer
38 views

tikz: disperse images symmetrically in a bounding box

Consider this example: \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \begin{scope}[local bounding box=scope1] \node(a) at (0.0, 0.0){\includegraphics[width=1....
user avatar
  • 6,803
4 votes
1 answer
60 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
0 votes
0 answers
30 views

Dimensions don't match

I need to align the axis of the figures with the center of the circles, though I used the same values the the width of the horizontal lines, they don't match with the radiuses. How can all of that \...
user avatar
  • 973
1 vote
1 answer
87 views

Change properties of one table, but not for all tables

How can I change properties (like \arrayrulewidth and \arrayrulecolor) of one table, but leave the other tables unchanged?
user avatar
  • 11
1 vote
0 answers
14 views

wrapfigure doesn't work if there is a { in the beginning of a paragraph [duplicate]

I would like to have \addfontfeature scoped around one word in the beginning of a paragraph. However, it turns out it breaks wrapfigure, which does all kinds of weird stuff in this case. Consider the ...
user avatar
  • 743
1 vote
0 answers
110 views

Mapping between \xslant, \yslant in scope and degrees?

In order to project images or text in 2D, an elevation and rotation can be defined and the following scheme can be implemented \def\thexslant{-1} \def\theyslant{0.5} \begin{scope}[every node/.append ...
user avatar
1 vote
1 answer
170 views

LaTeX3: Function scope

If I get it right, a token list is declared globally but can be assigned locally. So all local variables with the same name are actually declared globally as the same one. Functions often need to use ...
user avatar
  • 597
1 vote
1 answer
162 views

Creating a semi ellipse in tikz

I'm trying to draw a depiction of a partial earth orbit using tikz. I want to draw the orbit such that it begins on one side of the globe and wraps around to the other side, nearly completing an ...
user avatar
  • 135
2 votes
2 answers
140 views

TikZ scope and xshift in a macro issues

I'm having a problem with using scope if the scope is embedded in a macro. There is an answer, but that relies on a local bounding box: Positioning a tikz scope relative to another tikz scope If the ...
user avatar
  • 7,683
1 vote
1 answer
96 views

Graph whit Tikz

I wanto to draw this graph whit Tikz: I have this code: \begin{tikzpicture}[scale=0.2] \begin{scope} ...
user avatar
2 votes
1 answer
104 views

private scope for long blocks

I understand that a privately-scoped block is created by squiggly-brace pairs ({, }). The following document has body text "bar baz": \documentclass{article} \begin{document} \newcommand{\...
user avatar
  • 261
2 votes
2 answers
184 views

How to turn a stickman into a pic object in Tikz?

I would like some help turning this code for a stickman into a Tikz pic. \documentclass[11pt]{scrartcl} \usepackage{tikz} \usetikzlibrary{shapes.callouts} %-------------------- \usepackage{amssymb} %...
user avatar
4 votes
1 answer
91 views

TikZ: rotating scope changes the shading, but not how you'd expect

It is my understanding that the shading in the following code is applied after the scope transformation. \documentclass[varwidth,margin=0.5cm]{standalone} \usepackage{tikz} \begin{document} \...
user avatar
5 votes
2 answers
140 views

TikZ: rotating scope changes shading

As a follow-up to this question, Saturn has a tilt of 26°. But when I tilt Saturn, the colors of the rings change. \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \...
user avatar
3 votes
1 answer
97 views

Scope inside TikZ axis environment shifted/x,y scaling broken

This is a further follow up to this question: When using a shifted scope within an axis environment, the (0,0) coordinate is not at the position where I shifted the scope to: \documentclass[tikz]{...
user avatar
  • 304
1 vote
1 answer
41 views

List arguments for a specific command within each section

How can I limit the scope of a command to a given section? I have adapted a macro found online which reads in the arguments from a command and lists them \newcommand{\printDefn}{} \newcommand\defn[...
user avatar
  • 113
2 votes
2 answers
222 views

Evolve content over beamer slides: using `scope` to group elements

I am applying https://tex.stackexchange.com/a/518585/114719 where I use scope to group elements while developing content over multiple beamer slides: \documentclass{beamer} \usepackage{tikz} \begin{...
user avatar
  • 6,803
5 votes
4 answers
394 views

Local bounding box doesn't work inside a scope

This code: \pic[rotate=40, local bounding box=microfono] at (4.5,-5) {microph}; \draw[black, line width=2pt] (microfono.-45) -- ++(-.2,+.2) ++(.2,-.2) -- ++(0,-2); works outside the scope but not ...
user avatar
  • 53.9k
4 votes
2 answers
189 views

How to extend background fill color scope for a tree?

I basically wished to extend the scope a little farther so that it doesn't touch the nodes or shadows. There is also a tiny "tick" between the parent node and the middle child, which I don't know ...
user avatar
2 votes
1 answer
90 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
13 votes
2 answers
373 views

How do I limit the scope of etoolbox environment patching?

I want to use the etoolbox package to patch a certain environment; but - I only want to do it for a certain stretch of my document. Enclosing in curly brances doesn't work: \documentclass{article} \...
user avatar
  • 11.3k
3 votes
1 answer
283 views

Use named paths inside a scope for intersections outside the scope?

I need to: draw an ellipse, name it so I can intersect it later, clip it. To accomplish 3, it seems most appropriate to use a scope, but this means that I cannot accomplish 2. Consider this MWE: \...
user avatar
  • 2,659
0 votes
2 answers
282 views

Use coordinates of bounding box

Consider the following MWE: \documentclass{standalone} \usepackage{tikz} \usepackage{latexcolors} \usetikzlibrary{patterns} \begin{document} \begin{tikzpicture} \begin{scope}[local bounding box =...
user avatar
  • 1,030
4 votes
2 answers
240 views

What is the difference between `put` and `gput` in `\tl_new:N` token lists?

Why is there one function to define (globally) e.g. a token list \tl_new:N, but there are two functions to put an element into it: \tl_put_left:Nn and \tl_gput_left:nN What does this g at the ...
user avatar
0 votes
1 answer
60 views

how to have a table close to scope plot?

I would like to have a table near by a plot. I know how to have a table but not know having a plot near by the table. I have attached my table code and figure that I want to have. Thanks in advance. ...
user avatar
  • 303
2 votes
1 answer
730 views

Local variable to a package

I am defining my own latex package mypackage.sty. How to define a local command such that: mycommand If mycommand is already defined elsewhere it will be locally redefined just inside the package If ...
user avatar
  • 4,263
2 votes
1 answer
211 views

Labeling points on a plane

I have two points in a plane, both depending on several parameters. The coordinates of them shall fall within the range [0,1], i.e. within the red square: I would like to draw these points for many ...
user avatar
  • 625
1 vote
1 answer
181 views

Scope Problem in a newcommand definition

I am a LaTeX beginner, I am having trouble trying to implement the following code \documentclass[a4,11pt]{article} \newcommand{\site}[1][http]{{\bfseries #1://}} \begin{document} \site{www.tug....
user avatar
6 votes
1 answer
1k views

Scope of LaTeX code

In C/C++ or other language, the code and variables have scope. Is this the same in LaTeX? I struggled to understand the behavior of below code-- \documentclass[doubleside]{article} \usepackage{...
user avatar
  • 195
1 vote
1 answer
200 views

scoping problem with newcommand, renewcommand and longtable

My problem to be solved is: I want to set and reset a value (like a summation value) per line in my longtable (whose content is generated from the outside of the document). \documentclass[12pt,...
user avatar
13 votes
1 answer
421 views

\savebox within tikzpicture results in an empty \savebox

Using \savebox within a tikzpicture environment seems wipe out the content of the \savebox. In the MWE below, the following macros define, measure and display the size of a \savebox: \newcommand*{\...
user avatar
4 votes
1 answer
204 views

xkeyval `boolkey` setting is persistent across macro calls: scope leak?

I thought that keyval arguments to macros were supposed to be confined in their macro scope, but the following code: \documentclass{report} \usepackage{xkeyval} % Define a custom command option ...
user avatar
  • 1,423
1 vote
1 answer
95 views

Change global tikz style from inside a tikz pic

OK, guys. I had a strange idea and wanted to check with you if there is a way to do it. I couldn't get any insight from the pgfmanual, and I couldn't find similar questions either. I wanted to use a ...
user avatar
  • 2,414
1 vote
2 answers
94 views

Contour around intersected (clipped) area

I would like to know how to draw a (visible) contour around a clipped figure in Latex. As a basic example, consider some basic Venn diagram like that: \begin{tikzpicture} \begin{scope} \clip ...
user avatar
  • 21
3 votes
1 answer
736 views

Printing all predefined variables and or values

So, whenever you begin a document by giving it some class (article, memoir, etc), there are many default lengths and heights being used. What I am looking for is a way to see these without explicitly ...
user avatar
2 votes
1 answer
67 views

Why coordinates are shifted but not scaled

I'm trying to draw on the spy'ed area \documentclass[multi={tikzpicture,wrapper}]{standalone} \usepackage{amsfonts} \usepackage{tikz} \usetikzlibrary{calc,spy} \begin{document} \begin{...
user avatar
  • 367
1 vote
1 answer
203 views

Swap many pair of command names in a row

I've learnt from this post how to swap two commands using the let primitive: \let\temp\first \let\first\second \let\second\temp \let\temp\undefined Now, in order not to flood my preamble with this ...
user avatar
  • 1,423
4 votes
1 answer
297 views

A question on pgfmath, variables, conditionals and scope

First, I would like to apologize for the vague title of my question, somehow I didn't manage to come up with something more precise. Based on an answer to this question, I wanted to create a function ...
user avatar
5 votes
1 answer
434 views

How can make scope for rotating one disc around an axis?

I have a rigid body formed by one disc (D) and one rod (T): I want to draw the rotation of the disc around the j_1 axis. I want the to make a scope for moving the disc on the stem and rotate it ...
user avatar
  • 387
5 votes
1 answer
439 views

fillbetween not working in scope

I want to display three plots each stacked vertically. As shown below in the figure. Generated by the following code. But fillbetween is not working. \documentclass{standalone} \usepackage{amsmath} \...
user avatar
  • 67
3 votes
0 answers
71 views

Colored right and left fences in mathmode [duplicate]

I have colored my fences \right( and \left( by grouping my fences into the same scope by following a comment here by @Bardaigorl. Is there a better way to accomplish my goal of getting the fences ...
user avatar
  • 367
4 votes
1 answer
451 views

TikZ: Better solution than nesting tikzpicture?

I created following example script to draw a TikZ that contains a nested tikz: \documentclass[tikz,border=2mm]{standalone} \usepackage{tikz} \usetikzlibrary{positioning, shapes.multipart, backgrounds,...
user avatar
0 votes
1 answer
112 views

TikZ: Box alignment not inline - wrong anchoring? [duplicate]

I came across the problem of correctly aligning a set of boxes in the following TikZ example: Code \documentclass[tikz,border=2mm]{standalone} \usepackage{tikz} \usetikzlibrary{positioning, shapes....
user avatar