8
votes
1answer
75 views

TeX-FAQ: Non-letters in macro names - special-command generator

I had a look at TeX-FAQ on Non-letters in macro names and tried to implement the approach #2. It looks like I'm missing something. When trying to refer later to the new commands the result is not what ...
5
votes
1answer
70 views

What's special about \: in the implementation of \pgfutil@ifnextchar

There is the following snippet of code in pgfutil-common.tex (with a very similar snippet in pgfmathutil.code.tex`): {% \def\:{\global\let\pgfutil@sptoken= } \: \def\:{\pgfutil@xifnch} ...
5
votes
1answer
74 views

How does \path, and the like, parse its argument?

I'm really curious whether someone would care to take the time to explain how to create macros which work similar to some of the macros in the pgf/TiKz bundle. What I'm particularly interested in is ...
2
votes
1answer
68 views

How do you define a command for use in a tikzpicture environment?

I want to define an environment for the tikzpicture environment which defines tikz specific commands. Here's an abbreviated example for a UML environment which defines a \Class command): ...
3
votes
1answer
61 views

\newcommands in the \standalone file not recognized in the main file

Few \newcommands defined in my standalone .tex file containing tikz figure is not recognized in the main beamer .tex file. Please point out what extra lines should I write to make it work. Here is ...
1
vote
1answer
103 views

fit tikzpicture to page width or height (using macros)

I have a new environment defined that fits tikzpicture to the page width, but when tikzpicture is long in height the bottom part of the tikzpicture is cut and extra blank page appears because of the ...
2
votes
0answers
62 views

Passing an array type argument for new command

I've looked around and can't seem to find anywhere, but I was wondering if there is somewhere you can do something like the following: \newcommand{\loopy}[1]{ \begin{tikzpicture} \foreach ...
12
votes
2answers
275 views

diagonal text in math mode w/ vertical equality

The goal is a code where one can label elements in math mode in the following way: without having to manually position each letter of each word as a node in tikz. Preferably, other than the stacks ...
5
votes
1answer
70 views

TikZ programming/macros, \list construct

TikZ 3.0 manual, on page 83, we have (not complete code): \list{--}{\topsep=2pt\itemsep=0pt\parsep=0pt \parskip=0pt\labelwidth=8pt\leftmargin=8pt \itemindent=0pt\labelsep=2pt} #5 ...
7
votes
2answers
172 views

How can I draw an arrowhead only at the end of a path drawn with \foreach?

I want to define a command for drawing some special polygonal lines with pgf/tikz. In these polygonal lines, the line styles are of alternating change. The following is my latex code: ...
2
votes
1answer
83 views

Slanted grids in TikZ as a macro?

I'm trying to draw a diagram with slanted grids in it, sort of like the 3D effect given at http://www.texample.net/tikz/examples/3d-graph-model/ Ideally, I'd like a macro slantedgrid so that for ...
5
votes
1answer
106 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
165 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
56 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 ...
2
votes
1answer
123 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
95 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 ...
6
votes
1answer
141 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
227 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
144 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 ...
5
votes
2answers
187 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
41 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
160 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
56 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
50 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 ...
3
votes
1answer
87 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
119 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
124 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
100 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
64 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
87 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
238 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} ...
5
votes
1answer
333 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
183 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
358 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
149 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
123 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
368 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
86 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
460 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
117 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 ...
24
votes
2answers
744 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
123 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]{ ...
14
votes
3answers
1k 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
303 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
297 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} ...
9
votes
1answer
1k 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
175 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
258 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
295 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
757 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 ...