I have a TikZ picture  \begin{tikzpicture}[scale=0.5] \draw (-1,0) arc (180:360:1cm and 0.5cm); \draw[dashed] (-1,0) arc (180:0:1cm and 0.5cm); \draw (0,1) arc (90:270:0.5cm and 1cm); \draw[dashed] (0,1) arc (90:-90:0.5cm and 1cm); \draw (0,0) circle (1cm); \shade[ball color=blue!10!white,opacity=0.20] (0,0) circle (1cm); \end{tikzpicture}   which makes a small ball.  Is it possible to reuse this shape in another tikz picture?  I have another tikz picture in which I use  \draw[fill=yellow!30, fill opacity=0.5,text opacity=1] (B) circle (0.7cm) node[right] {$A$};   Instead of circle I want my small custom ball. How is that possible?
35423
If I have two tikzpictures drawn:  \documentclass{article} \usepackage[margin = 1in]{geometry} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing,calc,shapes,shapes.geometric,patterns} \begin{document}  \tikzset{treetop/.style = {decoration={random steps, segment length=0.4mm},decorate},trunk/.style = {decoration={random steps, segment length=2mm, amplitude=0.2mm},decorate}}  \begin{tikzpicture} \foreach \w/\f in {0.3/30,0.2/50,0.1/70} { \fill [brown!\f!black, trunk] (0,0) ++(-\w/2,0) rectangle +(\w,-3); } \foreach \n/\f in {1.4/40,1.2/50,1/60,0.8/70,0.6/80,0.4/90} {    \fill [green!\f!black, treetop] ellipse (\n/1.5 and \n); } \end{tikzpicture}  \begin{tikzpicture} \shade[bottom color=cyan!60!black, top color=blue!20!white] (0,0) rectangle (10,10); \end{tikzpicture}  \end{document}     How could I use the first tikz picture within the second? Can I define the first picture as some variable and then place this variable within the second picture and have the option of defining its exact location (x,y) and its size? For example, if I wanted to place the tree in the middle of the rectangle (5,5) but make the size of the tree half its current size. How would I do this
18722
I already have a code that draws a regular hexagon the following way   \begin{tikzpicture}[every node/.style={draw,shape=circle,fill=blue}] \path (0,0) node (p0) {} (-1.5,-1) node (p1) {} (-1.5,-2.5) node (p2) {} (1.5,-2.5) node (p3) {} (1.5,-1) node (p4) {} (0,-3.5) node (p5) { }; \draw (p0) -- (p1) (p0) -- (p1) (p0) -- (p2) (p0) -- (p3) (p0) -- (p4) (p0) -- (p5) (p1) -- (p2) (p1) -- (p3) (p1) -- (p4) (p1) -- (p5) (p2) -- (p3) (p2) -- (p4) (p2) -- (p5) (p3) -- (p4) (p3) -- (p5) (p4) -- (p5); \end{tikzpicture}   But Now I need to remove one of the points and to draw a regular pentagon the same way. So I need to remove (P5) and to recalibrate all other points (change their coordinates) But I don't need to change the code much.  Is there a way to do it by just slightly changing my code here. ?
102037
I can draw the black part in the picture, but  I cant rotate with angle alpha and draw the red part and fill it. Also, it is obvious, two side of figure rotate, and one side is fix, and the other one just shift in the z direction.  my code:   change to:   \documentclass{standalone} ‎\usepackage{tikz,tikz-3dplot}‎‎ \begin{document}‎‎ \begin{tikzpicture} \draw[-&gt;] (0,0,0)--++(5,0,0) node[right]{$x$}; \draw[-&gt;] (0,0,0)--++(0,5,0) node[above]{$y$}; \draw[-&gt;] (0,0,0)--++(0,0,8) node[below left]{$z$}; \draw[ultra thick] (4,0,0) arc[start angle=0, end angle=60, radius=4] --++(0,0,8.5) arc[start angle=60, end angle=0, radius=4]--cycle; ‎\filldraw[ fill=blue‎, ‎nearly transparent‎, ,‎looseness=.6](4,0,0) arc[start angle=0, end angle=60, radius=4] --++(0,0,8.5) arc[start angle=60, end angle=0, radius=4]--cycle; \end{tikzpicture} \end{document}
31716
I'm confused about tikz pics. I can freely define them without issue, and even add coordinates inside that will be available by name inheritance like (-A) as for example in \pic (S) at (0,0) {myPic}; \draw (S-A) -- ++(0,0);. This is all documented around p. 255 of the pgf manual.  However I don' understand why it is not possible to give a name to a pic like the one above if no coordinate is defined inside it. By default it would be great if it could behave like a normal node.  MWE:  \documentclass{minimal} \usepackage{tikz}  \tikzset{     myBlock/.pic = {         \node[draw,minimum width=1cm,minimum height=0.5cm] at (0,0) {};     },     myBlockNamed/.pic = {         \node[draw,minimum height=1cm,minimum width=0.5cm] (-m) at (0,0) {};     }, }  \begin{document} \begin{tikzpicture}     \pic () at (0,0) {myBock}; % can't give it a name     \pic (S) at (3,0) {myBlockNamed}; % can give it a name     \draw (S-A) -- ++(2,0); \end{tikzpicture} \end{document}   The underlying point is I'm working on a control blocs library (so that we can stop the chat below with @Alenanno). For example here is the definition of a math operator  \tikzset{     mySum background/.style = {         circle, minimum size=1.5em, fill=white,     },     mySum edge/.style = {         draw=black, circle, minimum size=1.5em, line width=.5pt,     },     pics/bOp/.style = {     code = {       \node [mySum background] {};       \foreach \t [count=\i] in {#1}{         \pgfmathsetmacro{\angle}{\i*90}         \node[anchor=center, font=\tiny] at (\angle:0.45em) {$\t$};       }       \node [mySum edge] {};     },   }, }
34978
I'm trying to draw a rounded rectangle with round "holes" using  but I need the rectangle borders to be thick and "holes" borders to be thin. Is there a better way to do so than:  \begin{tikzpicture}[x=1mm, y=1mm]     % Background         \fill[fill=black!10] (1.5, 1.5) rectangle (15, -15);      % Fill     \fill[fill=black!2, even odd rule, rounded corners=0.5mm]          (0, 0) rectangle (10, -10)          (2, -2) circle[radius=1.25mm]         (2, -5) circle[radius=1.25mm];     % Rectangle border     \draw[thick, rounded corners=0.5mm] (0, 0) rectangle (10, -10);     % Holes borders     \draw[thin] (2, -2) circle (1.25mm);     \draw[thin] (2, -5) circle (1.25mm); \end{tikzpicture}   The result image should look like this:
103348
I have an issue with the answer given in this .  As suggested in the comments to its answer, I modified the solution as follows:  \documentclass{article} \usepackage{tikz} \usetikzlibrary{shapes.geometric, arrows} \usetikzlibrary{calc,positioning}  \newcounter{image} \setcounter{image}{0}  \tikzstyle{square} = [draw, rectangle, draw=black, minimum width=1cm, minimum height=1cm, text centered]  \tikzset{drawinside/.code args={#1}{         \draw($(#1.west)!0.3!(#1.center)$)--($(#1.east)!0.3!(#1.center)$);         \draw($(#1.south)!0.3!(#1.center)$)--($(#1.north)!0.3!(#1.center)$);         \draw($(#1.south west)!0.4!(#1.west)!0.3!(#1.center)$)--($(#1.south west)!0.165!(#1.west)!0.5!(#1.center)$)--(#1.center);         \draw(#1.center)--($(#1.north east)!0.165!(#1.east)!0.65!(#1.center)$)--($(#1.north east)!0.45!(#1.east)!0.45!(#1.center)$);                } }  \tikzset{record/.style args={#1 and #2}{         rectangle,draw,minimum width=#1, minimum height=#2     } }  \newcommand{\drawrecord}[1] { \stepcounter{image} { \node [record=1 cm and 1 cm, name=a\theimage] at {#1}; } \node[drawinside={a\theimage}]{}; }  \begin{document} \begin{tikzpicture}  \drawrecord{0,0};  \node (sq) [square] {}; \drawrecord{sq};  \end{tikzpicture} \end{document}   but I keep receiving a ! Package tikz Error: Cannot parse this coordinate. error when I call \drawrecord  . how may I solve this issue?  . Is there a way to define \drawrecord as a \tikzstyle instead of a new command?  EDIT:  for the second question, I have been suggested to look into "append after command", but I cannot find documentation about it, anyone has a link?  EDIT2: actually, the second question is kind of redundant, I can simply call  \node [record=1 cm and 1 cm, name=newnode, right of=oldnode]; \node[drawinside={newnode}]{};   in my document. And  \tikzset{drawinside/.code args={#1}{     \draw($(#1.west)!0.3!(#1.center)$)--($(#1.east)!0.3!(#1.center)$);     \draw($(#1.south)!0.3!(#1.center)$)--($(#1.north)!0.3!(#1.center)$);     \draw($(#1.south west)!0.4!(#1.west)!0.3!(#1.center)$)--($(#1.south west)!0.165!(#1.west)!0.5!(#1.center)$)--(#1.center);     \draw(#1.center)--($(#1.north east)!0.165!(#1.east)!0.5!(#1.center)$)--($(#1.north east)!0.4!(#1.east)!0.3!(#1.center)$);             } }   is symmetrical (the previous one is slightly off)
62263
I am a tikz beginning. Here is a figure I am working on. I cannot avoid the "Dimension too large" error.  \documentclass{standalone} \usepackage{tikz} \usepackage{tkz-euclide} \usetkzobj{all} \begin{document}   \begin{tikzpicture}[x=2cm,y=2cm,scale=0.75]     \coordinate [label=below:$O$](O) at (0,0);      \coordinate [label=below:$A$](A) at (0,-1);      \coordinate [label=below:$D$](D) at (-1.1,-1);      \coordinate [label=below:$E$] (E) at (1,-1);      \coordinate [label=0:$B$](B) at (15:1);      \coordinate [label=180:$C$](C) at (140:1);     \draw (0,0) circle (1); \draw (C) -- (O) -- (B);     \draw (C) -- (A) -- (B);     \draw (D) -- (E);     \tkzMarkAngle[label=$124^{\circ}$,dist=0.35,arc=l,size=0.2,color=black,fill=none](B,O,C)     \tkzMarkAngle[arc=l,size=0.3,color=black](A,C,O)   \end{tikzpicture} \end{document}   I find it works if I change "scale=0.75" to "scale=1". But I want to keep the figure small.
120817
How can I create a cross product like the one in the picture.    \documentclass{article} \usepackage{tikz} \begin{document}  \begin{tikzpicture}[line width=.7pt] \draw [-&gt;] (-.2,0)node[below]{$o$}--(4.5,0)node[below]{$x$}; \draw [-&gt;] (0,-.2)--(0,2)node[left]{$y$};  \end{tikzpicture}  \end{document}
47078
How to fill the area under a function using the package tikz? Only tikz. Is it possible? This is what I have:  \begin{tikzpicture} \draw[very thin, gray!30, step=1 cm](-4.9,-3.9) grid (4.9,3.9);  \draw [thick] [-&gt;] (-5,0)--(5,0) node[right, below] {$x$};  \foreach \x in {-4,...,4}    \draw[xshift=\x cm, thick] (0pt,-1pt)--(0pt,1pt) node[below] {$\x$};  \draw [thick] [-&gt;] (0,-4)--(0,4) node[above, left] {$y$};  \foreach \y in {-3,...,3}    \draw[yshift=\y cm, thick] (-1pt,0pt)--(1pt,0pt) node[left] {$\y$};  \draw [domain=-2:2, variable=\x] plot ({\x}, {\x*\x}) node[right] at (1.5,2) {$f(x)=x^2$};   \end{tikzpicture}   Please tell me, how do I fill the area under the function I drew? I mean the area between x axis and the curve.
67322
's a picture example of what I want:     I'm able to make the type of arc that I want with this command:  \draw (-2,-2) [black,thick,dashed,domain=45:180] plot ({cos(\x)}, {sin(\x)}) ;   But it always creates the arc at the very top of the tree, even when I put the command inside the tree in the node where I want the arc. Here's the code I'm using:  begin{forest} [TP [T\textsuperscript{0}] [vP [DP\textsubscript{???},circle,draw] [v' [v\textsuperscript{0}] [VP,tikz={\draw[black,thick,dashed,domain=45:180] (2,2) plot ({cos(\x)}, {sin(\x)}) ;} [V\textsuperscript{0}] [DP\textsubscript{???},circle,draw] ]]]] \end{forest}
66008
I've created a path with a stroke and a fill of the same color, and I'd like to remove the stroke while preserving the size/shape of the object. Is there a simple way to do this?  In other words, I'm looking for something like a "Stroke-and-Fill to Path"  The best solution that I have come up with so far is to use "Stroke To Path" and then delete all of the inner nodes.
61523
How can I make a convex lens with TikZ?  I tried using arcs but this doesn't look right.  \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture}   \pgfmathsetmacro{\xr}{0.35}   \pgfmathsetmacro{\yr}{2}    \draw (0, 0) coordinate (O) arc[x radius = \xr cm, y radius = \yr cm,   start angle = 90, end angle = 270];   \draw (O) arc[x radius = \xr cm, y radius = \yr cm,   start angle = 90, end angle = -90]; \end{tikzpicture} \end{document}   I would like the arcs to meet at a sharp corner not rounded.
101003
I used the following code to draw a picture. I want to make the region insde (0,7), (0,11),(3,8),(3,4) to be red, and the region above it to be gray, but I don't know how to do this.   \documentclass{article} \usepackage{tikz} \begin{document} \pagestyle{empty} \begin{tikzpicture}[scale=0.5]  \draw (1.05cm,2pt) node[above];  %  {$\displaystyle\int_0^{3/2} \!\!x^2\mathrm{d}x$};  \draw[style=help lines] (0,0) grid (3.9,11.9);   % [step=0.25cm]      (1,2) grid +(1,1);  \draw[-&gt;] (-1,0) -- (4,0) node[right] {$i$}; \draw[-&gt;] (0,-1) -- (0,12) node[above] {$j$};  \foreach \x/\xtext in {1/1, 2/2, 3/3} \draw[shift={(\x,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$\xtext$};  \foreach \y/\ytext in {1/, 2/, 3/,4/,5/,6/,7/7,8/, 9/, 10/, 11/11} \draw[shift={(0,\y)}] (2pt,0pt) -- (-2pt,0pt) node[left] {$\ytext$};  \draw  {(0,11) -- (3,8)} node[below right] ; \draw  {(0,7) -- (3,4)} node[below right] ; \draw  {(3,8) -- (3,4)} node[below right] ; \end{tikzpicture}  \end{document}
59406
Suppose I have a complex figure made ​​with TikZ. How do I use it several times without having to repeat all the commands?  \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{tikz}  \begin{document}  Base figure  \begin{tikzpicture}   \draw[blue] circle (2);   \foreach \i in {0,10,...,350}     \draw[blue] (\i:1.9) -- (\i:2.1); \end{tikzpicture}  Using base figure.  \begin{tikzpicture}   \draw[blue] circle (2);   \foreach \i in {0,10,...,350}     \draw[blue] (\i:1.9) -- (\i:2.1);   \foreach \i in {0,10,...,350}     \node at (\i:2.7) {\tiny $\i^\circ$}; \end{tikzpicture}  Using base figure.  \begin{tikzpicture}   \draw[blue] circle (2);   \foreach \i in {0,10,...,350}     \draw[blue] (\i:1.9) -- (\i:2.1);   \foreach \i in {0,10,...,350}     \draw (0,0) -- (\i:2); \end{tikzpicture}  \end{document}
96687
I want to draw a cuboid in another transparent cuboid with TikZ. Therefore I've created a \newcommand to draw a cuboid.  \documentclass[11pt, halfparskip]{scrartcl} \usepackage{ucs} \usepackage[utf8x]{inputenc} \usepackage{tikz}  \begin{document} \newcommand{\cuboid}[7]{     % bottom     \draw[#7] (#1, #2, #3) -- ++(#4, 0, 0) -- ++(0, 0, #6) -- ++(-#4, 0, 0) -- cycle;     % back     \draw[#7] (#1, #2, #3) -- ++(#4, 0, 0) -- ++(0, #5, 0) -- ++(-#4, 0, 0) -- cycle;     % left     \draw[#7] (#1, #2, #3) -- ++(0, 0, #6) -- ++(0, #5, 0) -- ++(0, 0, -#6) -- cycle;     % right     \draw[#7] (#1+#4, #2, #3) -- ++(0, 0, #6) -- ++(0, #5, 0) -- ++(0, 0, -#6) -- cycle;     % front     \draw[#7] (#1, #2, #3+#6) -- ++(#4, 0, 0) -- ++(0, #5, 0) -- ++(-#4, 0, 0) -- cycle;     % top     \draw[#7] (#1, #2+#5, #3) -- ++(#4, 0, 0) -- ++(0, 0, #6) -- ++(-#4, 0, 0) -- cycle; } \begin{tikzpicture}   \tikzstyle{bottomfill} = [thick, fill=lightgray, fill opacity=.5] \tikzstyle{camerafill} = [thick, fill=blue!20]  \cuboid{0}{0}{0}{4}{4}{4}{bottomfill} \cuboid{1}{1}{1}{1}{1}{1}{camerafill}  \draw[-&gt;, thick] (2, 1.5, 1.5) -- ++(4, 0, 0);  \end{tikzpicture} \end{document}   But the result looks strange (The inner cuboid seems to be outside the transparent cuboid; compare the cuboid and and the arrow of the second image)    The result looks right if I'm adding the planes in the right z-order (but that's exhausting)  \documentclass[11pt, halfparskip]{scrartcl} \usepackage{ucs} \usepackage[utf8x]{inputenc} \usepackage{tikz}  \begin{document} \begin{tikzpicture} \tikzstyle{bottomfill} = [thick, fill=lightgray, fill opacity=.5] \tikzstyle{camerafill} = [thick, fill=blue!20]  % 1 bottom \draw[bottomfill] (0, 0, 0) -- ++(4, 0, 0) -- ++(0, 0, 4) -- ++(-4, 0, 0) -- cycle; % 1 back \draw[bottomfill] (0, 0, 0) -- ++(4, 0, 0) -- ++(0, 4, 0) -- ++(-4, 0, 0) -- cycle; % 1 left \draw[bottomfill] (0, 0, 0) -- ++(0, 0, 4) -- ++(0, 4, 0) -- ++(0, 0, -4) -- cycle;  % 2 bottom \draw[camerafill] (1, 1, 1) -- ++(1, 0, 0) -- ++(0, 0, 1) -- ++(-1, 0, 0) -- cycle; % 2 back \draw[camerafill] (1, 1, 1) -- ++(1, 0, 0) -- ++(0, 1, 0) -- ++(-1, 0, 0) -- cycle; % 2 left \draw[camerafill] (1, 1, 1) -- ++(0, 0, 1) -- ++(0, 1, 0) -- ++(0, 0, -1) -- cycle; % 2 right \draw[camerafill] (1+1, 1, 1) -- ++(0, 0, 1) -- ++(0, 1, 0) -- ++(0, 0, -1) -- cycle; % 2 front \draw[camerafill] (1, 1, 1+1) -- ++(1, 0, 0) -- ++(0, 1, 0) -- ++(-1, 0, 0) -- cycle; % 2 top \draw[camerafill] (1, 1+1, 1) -- ++(1, 0, 0) -- ++(0, 0, 1) -- ++(-1, 0, 0) -- cycle;  \draw[thick] (2, 1.5, 1.5) -- ++(2, 0, 0);  % 1 right \draw[bottomfill] (0+4, 0, 0) -- ++(0, 0, 4) -- ++(0, 4, 0) -- ++(0, 0, -4) -- cycle; % 1 front \draw[bottomfill] (0, 0, 0+4) -- ++(4, 0, 0) -- ++(0, 4, 0) -- ++(-4, 0, 0) -- cycle; % 1 top \draw[bottomfill] (0, 0+4, 0) -- ++(4, 0, 0) -- ++(0, 0, 4) -- ++(-4, 0, 0) -- cycle;  \draw[-&gt;, thick] (4, 1.5, 1.5) -- ++(2, 0, 0); \end{tikzpicture} \end{document}   With the result    My question: is there a possibility in TikZ to draw an object in a transparent object with without adding the shapes in the right z-order?
121355
I am trying to write the code to draw the picture below in TikZ. My code is necessarily long with lots of \foreach loops. Could you please give guidance on how to reproduce this picture in TikZ.
103395
I was quite impressed by the figures generated by TikZ and wanted to try TikZ to generate a few figures (please see the attached image drawn using an external WYSWYG program). When I tried to reproduce the figures myself using TikZ I found it very difficult to control the shapes in required positions. What is the simplest method to draw!these figures using TikZ?