4
votes
1answer
63 views

Resize tikzfigure in tcolorbox depending on height of tcolorbox

in my book I got many different type of boxes so I made some macros placing the boxes automatically according to their arguments. That's one of them. So far I made some boxes that have big "+" and ...
6
votes
2answers
124 views

How to rewrite this command using \newenvironment?

I once defined a customized latex command, which works well. And now I would like to convert it into a latex environment using \newenvironment command. However, I failed after trying several ways. ...
2
votes
0answers
50 views

tikz command fails after .cls file change

The following tex content is a part a tex file which is added to main file with command input. With a new .cls and some other unrelated changes, tex isn't compiling with error message of ! Package ...
1
vote
1answer
70 views

Defining a custom symbol by path in TikZ

I want to define a 2-to-1 multiplexer symbol, defined by this path: (0,0) -- (1,-0.5) -- (1,-1.25) -- (1.3,-1.25) -- (1,-1.25)-- (1,-2) -- (0,-2.5) -- (0,-1.75) -- (-0.3,-1.75) -- (0,-1.75) -- ...
2
votes
1answer
63 views

Macro for pgfplot cycle list entry

I'm trying to define multiple cycle lists based on macro variables. The reason for this is that I need more than one list and I want to be able to change the appearance quickly while keeping the ...
5
votes
1answer
106 views

Key value options in combination with TikZ

I'm trying to create some TikZ commands that use key value options. Using the following link: How to create a command with key values? I was able to declare some commands, but now I'm stuck. As a MWE ...
7
votes
2answers
157 views

Expanding a sequence inside a TikZ path

I am trying to draw a simple path using TikZ, with a custom syntax to specify it. This works: \documentclass{article} \usepackage{tikz} \begin{document} \newcommand{\latticepath}[1]{ ...
1
vote
1answer
95 views

Using variables to draw a tikz diagram

I am defind my own command to plat a diagram with tikz. Instead of constant values I rather want to pass numbers to my command which determine the height of the bars in my diagram. Problem: I am ...
4
votes
2answers
158 views

Bouncing ball over time

I have this clumsy code to plot the height of a bouncing ball over time. Is there a possibility for optimization? Perhaps writing the functions directly with the tikz math library? Also at the moment ...
3
votes
0answers
39 views

Preserving the value of a macro outside the local scope [duplicate]

I'm writing a (supposedly) simple financial tracking program using tikz and the fp package. Within a tabular environment I compute a value using \pgfmathparse{adding some numbers}\pgfmathresult. ...
4
votes
1answer
140 views

Is it possible to define abbreviations for coding?

I am using the tikz-timing package to create a timeline since chronosys and chronology wouldn't cooperate and were too limited and archaic-looking to suit my purposes, and moderntimeline unfortunately ...
3
votes
1answer
54 views

Use of \Tree with a macro

I am using the qtree to produce some trees, for example with this syntax \Tree [.foo bar ]. Now, I have automated some part of the tree and get troubles. When I place [.foo bar ] inside of a macro, ...
4
votes
1answer
44 views

Strange behaviour of \iftoggle inside tikzpicture

I want to set flag from inside of decoration which I want to check outside of the decoration. I set the flag (call \toggletrue{} or \togglefalse{}) but when I check this flag it always false. For MWE ...
2
votes
1answer
66 views

How to save a list as a macro for pgfplots

I want to create and store a list then use that list in a pgfplots scatterplot. My attempt is \documentclass{standalone} \usepackage{pgfplots} \begin{document} \newcommand{\listA}{ (1,2) (2,3) ...
11
votes
1answer
116 views

PGF's `foreach` recognises when there are no list items and doesn't run the code. Is this guaranteed?

The PGF \foreach macro behaves differently when the item list is totally empty than it does when a single item happens to be empty. \documentclass{article} \usepackage{pgffor} \begin{document} ...
5
votes
1answer
96 views

Tikz Procedure/Function like abstraction? [closed]

I am pretty new to tikz but, so I do understand the basics, however, I am truly confused on what's the best way to create a procedure like constructs: there seems to be so many mechanism, and I cannot ...
4
votes
1answer
75 views

How to reference the arguments defined in a “newcommand”?

What I am doing: I want to draw a picture (as shown below) to illustrate the contraction of some intervals to nodes in a line. First, I define a newcommand for interval (i.e., \op) with three ...
4
votes
2answers
62 views

Why is \color moving the relative position of an entire \picture environment?

I've been writing a set of simple line drawing macros for some piecewise functions. For some reason, when I attempt to add color to the lines, each segment is translated to the right. I've verified ...
6
votes
1answer
84 views

\alph without counters

When I iterate numbers with TikZ \foreach, they are stored in a macro. Now, when I need the letter corresponding to this macro, I can only convert it by saving it to a counter and then receiving it ...
3
votes
1answer
145 views

Settting PGFplots axis environment options by means of \newcommand and {\newlength,\setlength}

Because I often use the same options for multiple axes in my LaTeX documents, I use the following code to simplify my life. \documentclass{article} \usepackage{pgfplots} ...
4
votes
1answer
186 views

(x)ifthen in TikZ

I am searching for a way to conditionally handle some items in a TikZ \foreach specially using an \ifthenelse condition. However, the compiler responds ! Undefined control sequence. <argument> ...
6
votes
1answer
155 views

evaluate a string like `sin(x)+3` with `x` given

I defined a macro that gets as input a string like sin(x)+3, a starting x and an ending x, which is plotted using \addplot from PGFplots. Now I want to evaluate this function for x equal to the ...
7
votes
1answer
302 views

Separating a decimal number into whole and fractional parts with only the digits using pgfmath

Note: Firstly my apologies for making this confusing to start with. I have finally clarified matters I hope. This particular question is asking for macros that will split pgfmath results. The ones ...
6
votes
1answer
144 views

Problems with passing values through nested levels

Inspired by a comment to another question, I'm trying to generalise some code to draw coloured in rectangles upon the graph of a function. The routine \findmax, given an x-value and a function, ...
4
votes
1answer
104 views

tikz def node name (or reference) for nodes create using the def

I have the following definition in order to create a node with cylinder shape \def\dnc[#1,#2,#3,#4]#5{ \node[draw, cylinder, alias=cyl, shape border rotate=90, aspect=1.6, % minimum height=25, ...
4
votes
4answers
323 views

Recursive drawing, command flow

I am trying to recursively draw Ck x Ck, where Ck is the k-th iteration of a Cantor set. I have a command which recursively calls itself four times. If I pass N as parameter #6, the output ...
4
votes
1answer
83 views

Drawing anomaly — do macros nest properly?

The following code draws edges with arrows to two squares. It seems to me the effect should be identical, but no. The arrow at the "node[alive]" child just touches the child, while the arrow at the ...
4
votes
2answers
264 views

Using macro vs length to set TikZ coordinate affects placement of tikzpicture

I'm a bit baffled why the results of these two MWE should result in different output at all. Example 1 (desired output) In this example, I set the y-coordinate value using a length: ...
7
votes
1answer
100 views

Use brackets in a \def macro doesn't work

I am using TikZ to draw some graph drawings (with nodes and directed edges/paths). I have two nodes and an arrow pointing from one node to another. I have made a macro called \pathedge so I can use ...
23
votes
2answers
616 views

Arguments for TikZ style

Motivation To put arrows inside of a TikZ path I have defined myself a TikZ style arrow inside. To make it even more portable I want it to take arguments like this \draw[arrow inside={pos = 0.1, end ...
2
votes
2answers
113 views

New operators inside tikzpicture

I am trying to declare a new operator (only using horizontal and vertical lines and labels). By now I used tikzpicture for that with the following code: \newcommand{\newtypeline}[3]{ ...
13
votes
3answers
879 views

How to draw a irregular circle(shape)?

I want to draw some irregular circle(shape) in my wireless scenario. with a basestation in the center. around is some irregular circle(shape). I find something(could be used) in this web(but I feel ...
5
votes
2answers
273 views

TikZ: Using optional arguments in after part of \newenvironment*

How can I pass the optional arguments to a node being drawn in the after part of a \newenvironment*? In the before part this is easy since I can simply use #1. I tried using \edef, but that ended up ...
7
votes
2answers
250 views

TikZ: \foreach in macro with argument as list

The code below generates: What I expect is: Why does the \foreach seem to treat the entire list as one value? How do I fix it? \documentclass{article} \usepackage{xparse} \usepackage{xstring} ...
7
votes
1answer
742 views

TikZ: \newcommand with optional TikZ options

I want to create a new command with some default TikZ options that you can override using an optional argument. If working as intended the code below would generate a red line between A and B, and a ...
4
votes
1answer
152 views

lstlistings in defined Tikz box

I have created a box using \newcommand, based on TikZ named "mybox". The equation easily insertable in it. But I want to insert a \lstlisting environment in it. But it doesn't work. How can I do it? ...
4
votes
1answer
214 views

pgfplots: using macro for tick label

I would like to use a macro to define the label of an extra tick in a pgfplots picture. When the macro uses a greek character it generates an error: ! Missing \endcsname inserted. Here is my MWE: ...
10
votes
2answers
280 views

How to create commands for automating the commenting process on some zones of a picture

I have a lot of comments to make on different pictures, I can do it with the following command for ex: \begin{tikzpicture} \node[anchor=south west,inner sep=0] (image) at (0,0) ...
8
votes
0answers
731 views

How to automatically generate Venn diagrams given the inclusion relations? [closed]

I'm writing a paper about classes of formal languages, and I'd like to have a diagram showing their heirarchy. Something similar to this (from Wikipedia:) Is there a LaTeX package which, I can give ...
9
votes
2answers
209 views

Expansion problems with pgfkeys

I'm using pgfkeys, and a fairly adventurous syntax in which the values for some keys contain additional key/value pairs. (For instance, the value of the nodes key is a list of pairs, and the second ...
4
votes
1answer
101 views

Exposing a new command for each element of a list

I have a macro lVars, defined using foreach from the pgffor package (part of PGF) as: \newcommand{\lVars}[1]{\foreach \x [count=\ii] in {#1}{ \ifnum\ii=1{} \else {,} \fi \lVar[\x]} } The intended ...
4
votes
3answers
133 views

TikZ - bad positioning of images drawn by macro

Probably a lame question about how positioning in TikZ works. I'm trying to draw some electrical stuff (starting on the level of single gates) and because many of them repeat over and over, I want to ...
4
votes
2answers
211 views

Graphical vertical rule in tikz

I would like to make design (class), where I would like to have special type of paragraph that will have { character on left and will have height exactly same as height of whole paragraph. Also, I ...
2
votes
1answer
211 views

Need help making a data table from \plot function in Tikz

I want to be able to generate a list of points from a plot in Tikz, with an adjustable interval and range for the x-values. So basically something like this: ++++++++++++++ + + + ^ ...
14
votes
2answers
698 views

TikZ coordinate calculations

I have very simple problem, and I also have a solution to the problem. But I am hoping for a better solution:) Consider the following code: \documentclass{article} \usepackage{tikz} ...
6
votes
3answers
245 views

Aligning image and text in new command in TikZ

As a Teaching Assistant for a class, I am trying to draw a seating chart for the professor. The seating chart will have a photo of each student, the student's name, and where the student is sitting in ...
6
votes
1answer
275 views

How to define macro containing TikZ \coordinate

I am trying to create a macro to calculate the center of a shape. Consider the following code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \newcommand{\getcellcent}[4]{ ...
7
votes
1answer
1k views

Difference between \newcommand and \pgfmathsetmacro used in TikZ \coordinate

Consider the following code: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \newcommand{\MA}{4} \pgfmathsetmacro{\MB}{4}; \coordinate (V11) at (0,0); ...
3
votes
1answer
214 views

tikz - Multiple nodes with same content

I would like to know how to place multiple nodes with same content in TikZ. I've made a macro for it, but I think that it could have a different approach. \usepackage{tikz} \usepackage{bm} ...
10
votes
2answers
1k views

TikZ: Defining and reusing complex objects?

(How) Is it possible to save some complex TikZ objects for reusing them (in the same and in different pictures)? I know it's possible to define own styles, but I'm not sure if it's the right thing ...