Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
1answer
27 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
55 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
40 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
489 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
47 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
192 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*{\...
5
votes
1answer
197 views

Powerful pedagogic graph of lognormal distribution

I found this graph to explain the transformation from normal to lognormal distribution. enter link description here I am no latex expert and I was wondering if anyone knew how to reproduce it ? thank ...
4
votes
1answer
104 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
44 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
63 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 ...
2
votes
1answer
64 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
43 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
30 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
116 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 ...
4
votes
1answer
216 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 ...
4
votes
1answer
168 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
35 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
234 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
47 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
281 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 ...
0
votes
1answer
790 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
250 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. \...
4
votes
3answers
208 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
65 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
187 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
168 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
220 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 [>...
7
votes
1answer
446 views

Why the shift in tikz doesn't work?

I like the ring diagram, so I want to use a kind of ring diagram in my document. Thank Jack for the answer Ring Diagram(https://tex.stackexchange.com/users/2552/jake). However when I use the code in ...
0
votes
1answer
175 views

Context Defined Snippets

r-stein explained how you could define a keybinding in terms of a context specific to the document class (e.g. beamer or article). How could you do the same for a snippet? MWE: <snippet> &...
1
vote
1answer
66 views

Automatic inclusion of the following character, but with its subscripts and superscripts?

There are such commands as \vec which adds an arrow to the top of the immediate next non-space character. However, superscripts and subscripts are excluded from the scope. Now suppose I define a ...
5
votes
1answer
773 views

Fill color with tikzpicture

This code produce Fig. 2. Is there a way to get Fig. 1? \documentclass{minimal} \usepackage{tikz} \usetikzlibrary{shapes} \begin{document} \noindent\begin{tikzpicture}[fill opacity=0.5] \begin{...
6
votes
1answer
158 views

redefine ~ only within the scope of a \newcommand

I'd like to create a command (\newcommand) that does some decoration around a text (basically drawing a box around the text), for technical reports: Eg like: Use \pdobj{frob}{noz zle} for ...
1
vote
3answers
50 views

Putting extra brackets around equation adds whitespace to next line

As the title says, when I add an extra pair of {} brackets to the equation environment (on the outside), it adds a whitespace about the width of a space to the next line. Adding \noindent to the next ...
1
vote
1answer
39 views

Multiple vars fails in scope tikzpicture

Hello I have in my document a repeating figure of a bar like thing. So i want create a scope with 4 parameters. x and y from center point and dx dy displacements. (later on maybe color but that's ...
3
votes
1answer
205 views

Option `samples y` in scope doesn't work

Appearantly I don't understand how scope works. The following compiles fine: \begin{scope}[samples=20,domain=0:12] \addplot3[samples y=0] plot (x, x, -x*x); \end{scope} but the following gives the ...
3
votes
1answer
97 views

TikZ: Make “scopenode” compatible with matrix

Context: This question is a follow-up of Best practice for creating TikZ pictures with nested elements. Symbol 1 provided an answer to this question, where \scopenode is defined. \scopenode are ...
2
votes
1answer
117 views

How to define macros only for algorithm environment in my class file

I have a doc.tex and a myclass.cls file, and trying to keep the first as clean as possible. I need to define in myclass.cls some macros to use and be visible only inside the two environments: ...
3
votes
0answers
46 views

How can I isolate the scope of an object from the localized font settings at shipout?

I need to prevent my TikZ overlay's font settings from inheriting the font settings at ship out. I know this is a grouping issue because the closing } for the localized font changes has not yet been ...
1
vote
3answers
941 views

How to draw a graph in LATEX?

I need your help. I try to draw a graph in Tikz but i do not know how to do that. It seems to be like that. . Best regards
-1
votes
0answers
94 views

Customise Latex Scope/Operand

In the default(PLATFORM).sublime-keymap there is an "operand" for which a certain keymap is relevant. Likewise, there when making a snippet there is a "scope" for where the snippet is relevant. E.g. ...
2
votes
2answers
280 views

Avoid repetition of blocks of code for the same picture in TikZ

As a follow-up to my previous question (US Abilene Topology in Tikz: How can I further improve the picture), I want to optimise the code in the previous post (Segment 2). It contains a repetition of ...
5
votes
2answers
265 views

Why can't I use braces in an \if… \fi group?

I am starting to use \newif in a LaTeX class definition to finally stop carrying around all my definitions and imports from article to article. Since I am trying to define options, I am ending ...
2
votes
1answer
148 views

making \@namedef optionally global

I'd like to implement a global option on a package that I maintain, as per Mats's suggestion (here). The package is sepfootnotes, and the suggested modification will allow footnotes' content ...
4
votes
1answer
66 views

Use one axis' limit values in another axis

I'm working on a pgfplots source that plots a (dynamic) data file with different scale of the parallel axis. This is easy when you know the axis/data range in advance, but what if the range of axis/...
1
vote
1answer
210 views

What is the scope of the defined font family?

I experienced unexpected change of fonts at certain parts of my text. This was due to the fact that I did not realize that the \begin{center} and \end{center} environment has its own scope regarding ...
1
vote
1answer
44 views

How to make \@namedef within a tabular cell have wider scope?

How can I make \@namedef stated within a tabular cell define a name that can be reused outside that cell? For example: \documentclass{article} \begin{document} \makeatletter \begin{tabular}{ll} \...
6
votes
2answers
394 views

Why is text turning white (possible scope leak?) after page break and listings + tcolorbox + xelatex?

I had a very difficult time pinning this problem down, because it only exists when certain page-breaking conditions occur. Problem Text after environment mysteriously turns white under some ...
4
votes
2answers
86 views

Loading an array of fontfaces with fontspec and pgffor

I'm trying to produce a document to compare a bunch of fontfaces. I'd like to parse an array to load and try them all. This is what I have done: \documentclass{article} \usepackage{lipsum} \...
2
votes
0answers
249 views

problem when using scope and rotate with tikz

I wish to take this picture with tikz turning figure generally this type of scheme does not ask me problem and I wrote the following code \documentclass{article} \usepackage{tikz} \usetikzlibrary{...
1
vote
1answer
158 views

Close scope for global options in a tikz-pgf path

As an example, I wish to draw two segments, one in blue, one in red. \begin{tikzpicture} \draw [color=blue](0,0)--(1,1); \draw [color=red](1,0)--(0,1); \end{tikzpicture} I wish I could issue only ...