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
4
votes
1answer
36 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 ...
0
votes
0answers
29 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 \...
1
vote
1answer
42 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?
1
vote
0answers
13 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 ...
1
vote
0answers
67 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 ...
0
votes
0answers
68 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 ...
1
vote
1answer
95 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 ...
2
votes
2answers
76 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 ...
1
vote
1answer
92 views

Graph whit Tikz

I wanto to draw this graph whit Tikz: I have this code: \begin{tikzpicture}[scale=0.2] \begin{scope} ...
2
votes
1answer
73 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{\...
2
votes
2answers
139 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} %...
4
votes
1answer
59 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} \...
5
votes
2answers
83 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} \...
3
votes
1answer
50 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]{...
1
vote
1answer
39 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[...
2
votes
2answers
99 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{...
5
votes
4answers
274 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 ...
4
votes
2answers
140 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 ...
2
votes
1answer
63 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 ...
13
votes
2answers
317 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} \...
3
votes
1answer
182 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: \...
0
votes
2answers
180 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 =...
4
votes
2answers
188 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 ...
0
votes
1answer
51 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. ...
2
votes
1answer
424 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 ...
2
votes
1answer
156 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 ...
1
vote
1answer
137 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....
6
votes
1answer
847 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{...
1
vote
1answer
148 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,...
13
votes
1answer
365 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*{\...
4
votes
1answer
160 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 ...
1
vote
1answer
69 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 ...
1
vote
2answers
80 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 ...
3
votes
1answer
565 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 ...
2
votes
1answer
64 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{...
1
vote
1answer
119 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 ...
4
votes
1answer
231 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 ...
5
votes
1answer
345 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 ...
5
votes
1answer
358 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} \...
3
votes
0answers
58 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 ...
4
votes
1answer
391 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,...
0
votes
1answer
82 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....
2
votes
1answer
660 views

What are the drawbacks to scope environment in TikZ?

The answer by Marmot to How can I use rotate inside a defined TikZ command? calls one use of scope in TikZ a quick and dirty fix. The fix works. But the answer suggests to avoid this use of scope in ...
1
vote
1answer
3k views

How to add options to \Begin {Scope}

How to add options to \Begin {Scope} like [fill=..., shading angle, top color, bottom color]? \begin {scope}[color=OrangeD] \draw [-] plot[smooth, tension=.7] coordinates {(-5.25,1) (-5.15,1.15) (-4....
2
votes
2answers
467 views

How to control the scope for setting variables

Why am I not getting |col. 1|col. 2| ... etc? Obviously I am not controlling the scope for setting the \l_rn_i_int variable correctly, but am unable to determine where I am going wrong. \...
5
votes
3answers
399 views

tikz node distance not measured by border but center

I have a pic element draw headphone, it works perfect but node distance is measured from center but not border as other nodes. \documentclass[border=2pt,convert={outfile=\jobname.png}]{standalone} \...
2
votes
0answers
80 views

Grouping trees and graphs with nodes

I would like to draw a tree as in the picture: Could you help me please? What I have so far: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[frenchb]{babel} \usepackage{tikz} \...
1
vote
1answer
271 views

How to create a local token list variable in LaTeX3?

The \tl_new:(Nc) functions create a new token list variable globally. Is there a way to create a new token list variable locally?
2
votes
1answer
261 views

Nodes within scope

I have the following code: \documentclass[a4paper]{report} \usepackage[T1]{fontenc} \usepackage[french]{babel} \usepackage{float} \usepackage[justification=centering]{caption} \usepackage{mathtools} \...
2
votes
1answer
399 views

How to prefix node names inside tikz graph environment

I have a graph with two chains like this: \begin{document} \tikz [] \graph [layered layout, components go right top aligned, nodes=draw] { {[nodes={name prefix=cat1}] cat1 -> {100, 200 [>...