• Can anyone help me adjusting a tikz picture?
    by Joao Paulo Guardieiro on July 4, 2026 at 1:59 pm

    I want to draw the graph of z = x^2 + y^2, and I am using tikz for that. I used the following command: \begin{tikzpicture}[ x={(1cm,0cm)}, y={(-0.6cm,-0.35cm)}, z={(0cm,1cm)}, line join=round, line cap=round, scale=1, ] % Axes \draw[->] (0,0,0) -- (2,0,0); \draw[->] (0,0,0) -- (0,2.5,0); \draw[->] (0,0,0) -- (0,0,4); % Graph \draw[thick,smooth,variable=\t,domain=-1.8:1.8] plot ({\t},{0},{\t*\t}); % Circle that gives a 3d impression \draw[thick,smooth,variable=\t,domain=0:360] plot ({1.8*sin(\t)},{1.8*cos(\t)},{3.24}); \end{tikzpicture} However, the circle does not "fit" the graph: Can anyone guide me on how to adjust this?

  • Is that possible to declare harpoon arrow with two directions more compact without defining twice?
    by Explorer on July 1, 2026 at 2:09 pm

    I have the following code partly comes from here: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{arrows.meta,bending,nfold} \makeatletter \tikzset{ shrink/.style={thick,shorten >=5pt,shorten <=5pt}, offset/.code= \tikz@addoption{% \pgfgetpath\tikz@temp \pgfsetpath\pgfutil@empty \pgfoffsetpath\tikz@temp{#1}% }, foo/.tip={Straight Barb[harpoon,length=5pt]}, foo'/.tip={Straight Barb[harpoon,swap,length=5pt]}, dualharpoon/.style={ draw=none, postaction={path only,draw,foo'-,shrink,offset=+#1ex}, postaction={path only,draw,-foo',shrink,offset=-#1ex}, }, dualharpoon/.default=1, dualharpoon'/.style={ draw=none, postaction={path only,draw,-foo,shrink,offset=+#1ex}, postaction={path only,draw,foo-,shrink,offset=-#1ex}, }, dualharpoon'/.default=1, relarrow/.style={ dualharpoon,orange,thick,#1 }, relarrow'/.style={ dualharpoon',orange,thick,#1 }, } \makeatother %%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} \begin{tikzpicture} \node[fill=cyan,circle] (A) at (-2,-1) {A}; \node[fill=magenta,circle] (B) at (2,-1) {B}; \node[fill=cyan,circle] (C) at (-2,1) {C}; \node[fill=magenta,circle] (D) at (2,1) {D}; \draw[relarrow=teal] (A) -- (B); \draw[relarrow'] (C) -- (D); \end{tikzpicture} \end{document} which declare two arrow style, relarrow and relarrow': However, I did the similar things twice here! Which I was not quite comfortable with dupliacted syntax: foo/.tip={Straight Barb[harpoon,length=5pt]}, foo'/.tip={Straight Barb[harpoon,swap,length=5pt]}, dualharpoon/.style={ draw=none, postaction={path only,draw,foo'-,shrink,offset=+#1ex}, postaction={path only,draw,-foo',shrink,offset=-#1ex}, }, dualharpoon/.default=1, dualharpoon'/.style={ draw=none, postaction={path only,draw,-foo,shrink,offset=+#1ex}, postaction={path only,draw,foo-,shrink,offset=-#1ex}, }, dualharpoon'/.default=1, relarrow/.style={ dualharpoon,orange,thick,#1 }, relarrow'/.style={ dualharpoon',orange,thick,#1 }, I wonder I could simplify the code to define the '-version in a reverse dualharpoon direction?

  • How to apply the `decorate`-friendly patched `offset` version correctly?
    by Explorer on July 1, 2026 at 9:57 am

    The question was originated from the previous question and the comment: The offset implementation of A763043 would shift the path before decorations which means yshifting in the markings wouldn't be necessary, they would however be moved towards the postactions of the offsetting. However, when I just copied the following patched-offset-trick: % https://tex.stackexchange.com/a/763043 \makeatletter % see Code B in https://tex.stackexchange.com/a/728379 \let\nfold@orig@tikz@finish\tikz@finish \def\tikz@finish{\tikz@nfold@do\nfold@orig@tikz@finish} \let\tikz@nfold@do\relax \tikzset{offset/.code=% \edef\tikz@temp{#1}\ifx\tikz@temp\tikz@nonetext \let\tikz@nfold@do\relax \else\def\tikz@nfold@do{\pgfgetpath\tikz@temp\pgfsetpath\pgfutil@empty\pgfoffsetpath\tikz@temp{#1}}% \fi} \makeatother and the complete code: % https://tex.stackexchange.com/a/96970 % https://tex.stackexchange.com/a/762399 \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{arrows.meta,bending,nfold,ext.nodes,decorations.markings} % https://tex.stackexchange.com/a/763043 % https://tex.stackexchange.com/questions/764317/how-to-better-design-the-binary-switch-option-in-tikz-case#comment1907525_764317 \makeatletter % see Code B in https://tex.stackexchange.com/a/728379 \let\nfold@orig@tikz@finish\tikz@finish \def\tikz@finish{\tikz@nfold@do\nfold@orig@tikz@finish} \let\tikz@nfold@do\relax \tikzset{offset/.code=% \edef\tikz@temp{#1}\ifx\tikz@temp\tikz@nonetext \let\tikz@nfold@do\relax \else\def\tikz@nfold@do{\pgfgetpath\tikz@temp\pgfsetpath\pgfutil@empty\pgfoffsetpath\tikz@temp{#1}}% \fi} \makeatother %%%%%%%%%%%%%%%%%%%%%%%%%% \tikzset{ foo/.tip={Straight Barb[harpoon,swap,length=5pt]}, shrink/.style={thick,shorten >=2pt,shorten <=2pt}, dualharpoon/.style={% draw=none, postaction={path only,draw,-foo,shrink,offset=-#1ex}, postaction={path only,draw,foo-,shrink,offset=+#1ex, decorate, decoration={markings, mark=at position 0.5 with { \draw[-,line cap=round,thick] ++ (-.15cm,-.15cm) -- (+.15cm,+.15cm); }}, }, }, dualharpoon/.default=.75, } \begin{document} \begin{tikzpicture}[ Qstyle/.style={ dualharpoon, % ext/auto with offset, % default true ext/auto offset=1ex, auto, }] \node[draw,circle,fill=teal] (A) at (0,1) {A}; \node[draw,circle,fill=magenta] (B) at (0,-1) {B}; \node[draw,circle,fill=cyan] (C) at (2.5,.5) {C}; \draw[magenta,Qstyle] (A) to[bend right] node {$\Delta$} node[swap]{$\nabla$} (B); \draw[teal,Qstyle] (B) to[bend right] node {$f(x)$} node[swap]{$g(x)$} (C); \draw[orange,Qstyle] (A) -- node {$x$} node[swap]{$y$} (C); \end{tikzpicture} \end{document} gives not the ideal result(?) Possibly I missed some important...

  • How to better design the binary switch option in tikz case?
    by Explorer on July 1, 2026 at 7:31 am

    I have the following code modified from my previous question: % https://tex.stackexchange.com/a/96970 % https://tex.stackexchange.com/a/762399 \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{arrows.meta,bending,nfold,ext.nodes,decorations.markings} \makeatletter \tikzset{ foo/.tip={Straight Barb[harpoon,swap,length=5pt]}, mystyle/.style={thick,shorten >=2pt,shorten <=2pt}, offset/.code= \tikz@addoption{% \pgfgetpath\tikz@temp \pgfsetpath\pgfutil@empty \pgfoffsetpath\tikz@temp{#1} }, dualharpoon/.style={ draw=none, postaction={path only,draw,foo-,mystyle,offset=+#1ex}, postaction={path only,draw,-foo,mystyle,offset=-#1ex}, postaction={decorate, decoration={markings, mark=at position 0.5 with { \begin{scope}[yshift=+#1ex] \draw[-,line cap=round,thick] ++ (-.15cm,-.15cm) -- (+.15cm,+.15cm); % \draw[-,line cap=round,thick] ++ (-.15cm,+.15cm) -- (+.15cm,-.15cm); \end{scope} \begin{scope}[yshift=-#1ex] \draw[-,line cap=round,thick] ++ (-.15cm,-.15cm) -- (+.15cm,+.15cm); % \draw[-,line cap=round,thick] ++ (-.15cm,+.15cm) -- (+.15cm,-.15cm); \end{scope} }}, }, }, dualharpoon/.default=.75, } \makeatother \begin{document} \begin{tikzpicture}[ Qstyle/.style={ dualharpoon, ext/auto with offset, % default true ext/auto offset=1ex, auto, }] \node[draw,circle,fill=teal] (A) at (0,1) {A}; \node[draw,circle,fill=magenta] (B) at (0,-1) {B}; \node[draw,circle,fill=cyan] (C) at (2.5,.5) {C}; \draw[magenta,Qstyle] (A) to[bend right] node {$\Delta$} node[swap]{$\nabla$} (B); \draw[teal,Qstyle] (B) to[bend right] node {$f(x)$} node[swap]{$g(x)$} (C); \draw[orange,Qstyle] (A) -- node {$x$} node[swap]{$y$} (C); \end{tikzpicture} \end{document} Now I want two control switches: which one to place slash: positive offset one? negetive one? or both? or none? which direction to put slash? forward: \draw[-,line cap=round,thick] ++ (-.15cm,-.15cm) -- (+.15cm,+.15cm); and \draw[-,line cap=round,thick] ++ (-.15cm,-.15cm) -- (+.15cm,+.15cm); backward: \draw[-,line cap=round,thick] ++ (-.15cm,+.15cm) -- (+.15cm,-.15cm); or \draw[-,line cap=round,thick] ++ (-.15cm,+.15cm) -- (+.15cm,-.15cm);? Or in other word, I want the syntax for example: \draw[magenta,Qstyle,slash side=both,slash direction=backward] (A) to[bend right] node {$\Delta$} node[swap]{$\nabla$} (B); \draw[teal,Qstyle,slash side=positive,slash direction=forward] (B) to[bend right] node {$f(x)$} node[swap]{$g(x)$} (C); \draw[orange,Qstyle,slash side=none] (A) -- node {$x$} node[swap]{$y$} (C); I was after a neat option syntax to encapsulate the logic above. Any suggestions?

  • how to align axis-coordinate system with tikzpicture-coordinate system
    by flawr on June 30, 2026 at 3:13 pm

    I'd like to use a pgfplots axis environment to render some plots. I'd like them to be aligned with the surrounding TiKz graphics. However, I have not yet managed to find the correct options. I'm also only interested in the plotted line itself, so no ticks or axes need to be drawn in addition. So far I have this (failed) example. My goal would be aligning the coordinate system the axis environment such that the two curves are right on top of each other. With the width/height I assumed I could set the exact dimensions, but that already seems to be off. Is there a way to modify this axis-environment to match the coordinate system of the tikzpicture-environment? \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \draw[lightgray] (-2, -3) grid (4, 4); \fill[lightgray] (0,0) circle (0.2); % origin \draw[green] plot [red, domain=-2:4, samples=200] (\x, {exp(-abs(\x)^2)}); \begin{axis}[ xtick=\empty, ytick=\empty, hide axis, xmin=-2, xmax=4, axis equal, width=6cm, height=7cm, anchor=south west, at={(-2cm,-2cm)}, ] \addplot [red, domain=-2:5, samples=200] (\x, {exp(-abs(\x)^2)}); \end{axis} \end{tikzpicture} \end{document}

  • How to have multiple hyperlinks in a TikZ picture with alt text and valid tagging?
    by Senex on June 30, 2026 at 10:02 am

    In the MWE below, the TikZ picture is a ‘roadmap’ showing how various lemmas combine in a proof (vastly simplified from my original), and I would like to have the hyperlinked \refs to the lemmas (which are spread over multiple pages in my original). But with alt={...}, VeraPDF complains that Link annotations that target different locations shall be in separate Link or Reference structure elements If I remove alt={...}, the PDF passes validation. If I change \ref to \ref* to remove the hyperlinks, the PDF passes validation. If there is only one hyperlink in the TikZ picture, the PDF passes validation. The same problem occurs replacing on alt={...} with artifact. I understand that tagging is in development, but is there any quick fix or workaround that allows multiple hyperlinks in a TikZ picture with alt text? (Or is there perhaps some fundamental incompatibility with tagging multiple hyperlinks inside a TikZ picture?) MWE: \DocumentMetadata{ pdfversion=2.0, pdfstandard=UA-2, lang=en-GB, tagging=on, } \documentclass{article} \usepackage{unicode-math} \usepackage{hyperref} \usepackage{tikz} \newtheorem{lemma}{Lemma} \title{Test} \begin{document} Roadmap of proving the theorem: \begin{tikzpicture}[alt={Roadmap}] \node (A) at (0,0) {$A$}; \node (B) at (2,0) {$B$}; \node (C) at (4,0) {$C$}; \draw[->] (A) edge node[auto] {Lem.~\ref{lem:ab}} (B); \draw[->] (B) edge node[auto] {Lem.~\ref{lem:bc}} (C); \end{tikzpicture} \begin{lemma} \label{lem:ab} If $A$, then $B$. \end{lemma} \begin{lemma} \label{lem:bc} If $B$, then $C$. \end{lemma} \end{document}

  • Water molecule in tikz [duplicate]
    by Andy Fletcher on June 29, 2026 at 3:26 pm

    How can I draw a water molecule using tikz like the ones in the image below with "H" in hydrogen atoms and "O" in oxygen atom?

  • Straight lines in a matrix
    by Andy Fletcher on June 28, 2026 at 12:14 pm

    I'm trying to draw straight lines in a matrix using nicematrix, and I achived the code: \documentclass{article} \usepackage{nicematrix,tikz} \begin{document} \begin{equation*} \begin{bNiceMatrix} \CodeBefore[create-cell-nodes] \begin{tikzpicture} %\draw[blue,-] (3-1) -- (4-2) ; %\draw[blue,-] (4-2) -- (3-4) ; \draw[blue,-] (3-1.north west) -- (4-2.south east) ; \draw[blue,-] (4-2.south east) -- (3-4.north east) ; \end{tikzpicture} \Body a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ a_{41} & a_{42} & a_{43} & a_{44} \end{bNiceMatrix} \end{equation*} \end{document} My problem is the straight lines are not centered in the entries of the matrix (see image below); I considered also \draw[blue,-] (3-1) -- (4-2) ; \draw[blue,-] (4-2) -- (3-4) ; instead of \draw[blue,-] (3-1.north west) -- (4-2.south east) ; \draw[blue,-] (4-2.south east) -- (3-4.north east) ; but in this case the two line are not linked. Any hint (desirably keeping the matrix created by nicematrix)? Thanks.

  • How to draw a diagram in math-mode or in-line LaTeX?, for example, the following kind of diagram? What packages do I require? [closed]
    by Sagnik Roy on June 28, 2026 at 7:04 am

    I need to draw the following and similar kind of diagrams with labels inside an LaTeX article.

  • Spacing TikZ pictures with \hspace and \vspace
    by LMPogoda on June 26, 2026 at 8:42 pm

    I have several TikZ pictures. These are a set of rectangles with some nodes inside, creating a grid on a page. These are spaced by \hspace horizontally and \vspace vertically. It mostly works unless \hspace is just after the \vspace. When I want to push a TikZ picture toward right margin after \vspace, \hspace doesn't work. I think it is related to a switch from vertical to horizontal mode, but I haven't mastered it yet. I removed the nodes from TikZ code, but what matters (and does not work) is left intact. \documentclass[a4paper]{article} \usepackage{geometry} \geometry{a4paper,top=10mm,bottom=27mm,hmargin=10.0mm} \usepackage{tikz} \usepackage{graphicx} \pagestyle{empty} \setlength\parindent{0pt} \begin{document} \begin{tikzpicture} \draw[rounded corners=2pt] (0,0) rectangle (60.00mm,60.00mm); \end{tikzpicture}\hspace{5mm} \begin{tikzpicture} \draw[rounded corners=2pt] (0,0) rectangle (60.00mm,60.00mm); \end{tikzpicture}\hspace{5mm} \begin{tikzpicture} \draw[rounded corners=2pt] (0,0) rectangle (60.00mm,60.00mm); \end{tikzpicture}\vspace{5mm} \hspace{65mm}\begin{tikzpicture} \draw[rounded corners=2pt] (0,0) rectangle (60.00mm,60.00mm); \end{tikzpicture}\hspace{5mm} \begin{tikzpicture} \draw[rounded corners=2pt] (0,0) rectangle (60.00mm,60.00mm); \end{tikzpicture}\vspace{5mm} \end{document} Edit: I replaced code snippet with complete document for better clarity.

  • How can I list or visualize all available anchors of a CircuitTikZ component?
    by internet on May 8, 2026 at 9:31 am

    I am using CircuitTikZ and often need to connect wires or labels to component anchors. However, it is not always easy to know which anchors are available for a specific component. For example, different components may provide anchors such as north, south, in, out, gate, collector, emitter, etc., and the available anchors vary depending on the component type. When building more complicated schematics, I frequently need to stop and search through the documentation to check anchor names. I was wondering whether there is a way to programmatically: List all available anchors of a given CircuitTikZ/TikZ shape/components, and/or Visualize those anchors directly on the rendered component. For example, something conceptually like: \showanchors{a component/shape} that would either print all anchor names and draw markers/labels on the component itself. So my question is: Is there a practical way to list all anchors associated with a TikZ/CircuitTikZ shape? My motivation is mainly usability and workflow efficiency. A tool like this would make it much easier to explore unfamiliar components and reduce the need to constantly check the manual, especially for beginners or occasional CircuitTikZ users. This is an example of visualizing the anchors to help wiring from CircuiTikz documentation. A possible MWE (clearly, the pin thing must be adjusted somehow to have a better distribution, and to take into account that labels can have spaces and strange characters, but well...). The task it to substitute the \allanchors definition with something automatic, see the comment above it. \documentclass[border=10pt]{standalone} \usepackage[T1]{fontenc} \usepackage[siunitx, RPvoltages]{circuitikz} \begin{document} \begin{tikzpicture}[every pin/.append style={text=red, inner sep=1pt, font=\tiny\ttfamily}] \node [npn](myshape) at (0,0) {}; % Example: this should be autofilled % Basically, for every shape named, say, "gizmo", the anchor "spot" % is a macro named pgf@anchor@gizmo@spot % --- so to do what you want, you should be able to find all % the macros with that pattern that exist % (and I do not know if this is possible in TeX in general, % maybe in LuaTeX...). \newcommand{\allanchors}{center,E,B,south} \foreach \anc in \allanchors { \node[circ, pin=45:\anc] at (myshape.\anc) {}; } \end{tikzpicture} \end{document}

  • TiKZ: possibility of "average" blend mode?
    by putianyi888 on February 4, 2026 at 8:40 am

    I get that the screen mode basically adds the RGB values. Is it possible to take the average of the values instead, so that colors don't get lighter? Opacity trick doesn't seem to work because I want full opacity where the images don't overlap.

  • TikZ: make a nice pattern at a small area if using \usetikzlibrary{patterns}
    by cis on April 9, 2024 at 2:39 pm

    How can I make a nice pattern if I use \usetikzlibrary{patterns} (if possible not \usetikzlibrary{patterns.meta})? E.g. pattern lines not so thick and no overlap and smaler line distances. I don't find the keys in the file tikzlibrarypatterns.code.tex If I set \pgfmathsetlengthmacro\cardwidth{0.61em} and then line width=0.025*\cardwidth this has no effect. \documentclass[]{article} \usepackage{tikz} \usetikzlibrary{patterns} \pgfmathsetlengthmacro\cardwidth{0.61em}% card width \pgfmathsetlengthmacro\cardheight{9*\cardwidth/6}% card height \begin{document} text \begin{tikzpicture}[ mypattern/.style={% fill=violet!22, postaction={ pattern=crosshatch, %pattern=north east lines, % alternativ pattern color=violet, draw=none, line width=0.025*\cardwidth, % <---- no effect.......... }, },% ] \node[minimum width=\cardwidth, minimum height=\cardheight, draw, rounded corners=0.075*\cardwidth, line width=0.025*\cardwidth,% <---- line width of node frame mypattern, ]{}; \end{tikzpicture} text \end{document}

  • Prevent connection of ends of a partial circle in a 3D tikz picture
    by Melissa on April 3, 2024 at 5:00 pm

    I want to draw a 3-dimensional parabola (i.e. plot $z=x^2 + y^2$) with maximal value of z=1 and then mark the part of the parabola where $x^2 + y^2 =1$, $x\leq 0$ and $y \leq 0$, which is part of a circle. I have the following code: \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture}[radius=1] \begin{axis}[ xlabel=$l_1$, ylabel=$l_2$, zlabel=$u$, xmin=-1, xmax=1, ymin=-1, ymax=1, zmin=-0.1, zmax=1.05, % x={(-0.125cm,-0.05cm)}, % y={(0.125cm,-0.05cm)}, % z={(0cm,0.05cm)}, axis lines=middle, every axis x label/.style={ at={(ticklabel* cs:1.05)}, }, every axis y label/.style={ at={(ticklabel* cs:1.05)}, }, every axis z label/.style={ at={(ticklabel* cs:1.05)}, }, colormap/blackwhite,] % Paraboloid \addplot3[ surf, samples=50, shader=interp, draw=lightgray, ultra thin, opacity=0.5, fill opacity=0.5, data cs=polar, domain=0:360, y domain=0:1, restrict z to domain=0:1, ](x, y, y^2); % Part of parabola \addplot3[ surf, samples=50, shader=interp, draw=lightgray, fill=green, ultra thin, left color=green, right color=green, middle color=green!25, data cs=polar, domain=180:270, y domain=0:1, restrict z to domain=0:1, ](x, y, y^2); %partial circle \addplot3[ domain=180:270, samples=20, variable=\t, color=red, untra thin, ] ({cos(\t)}, {sin(\t)}, {1}); \end{axis} \end{tikzpicture} \end{document} I do not want to connect the end points of the partial circle. How do I prevent this from happening?

  • Drawing 3D dice
    by Ole Christian on March 5, 2024 at 10:49 am

    I want to create 3D dice in LaTeX. I am familiar with the excellent package "customdice", but it unfortunately only produces 2D images. I am also inspired by the answer from hpekristiansen to this question. It creates beautiful dice, but I am uanble to change from colored circles to the familiar circle symbols for the numbers 1 to 6. One idea I had was to try to put the images from customdice on each of the surfaces, but I am unable to make it work. I believe the package customdice doesn't agree well to the packages required in the question linked above. Could anyone help me create "normal" dice faces on the surfaces on the answer linked above?

  • Question about a TikZ template
    by Hicham on October 26, 2022 at 11:07 pm

    I want to create something like this image below, but I didn't know how to start because I'm a beginner in TikZ

  • Self loop in LaTeX
    by JSN on June 22, 2022 at 11:39 am

    \documentclass[12pt,a4paper]{article} \usepackage{tikz} \tikzset{mynode/.style={inner sep=2pt,fill,outer sep=0,circle}} \begin{document} \begin{tikzpicture}[scale=.60, thick, acteur/.style={ circle, fill=black, thick, inner sep=1.2pt, minimum size=0.01cm } ] % \tikzstyle{every loop}=[] \node (a1) at (0,0) [acteur,label=left:\scriptsize{$1$}]{}; \node (a2) at (1.5,0)[acteur,label=left:\scriptsize{$2$}]{}; \node (a3) at (0,-1.5) [acteur,label=above left:\scriptsize{$3$}]{}; \node (a4) at (1.5,-1.5) [acteur,label=above right:\scriptsize{$4$}]{}; \draw (a1) -- (a2); \draw (a2) -- (a4); \draw (a3) -- (a4); \draw (a1) -- (a3); \draw (a2) -- (a3); \draw (a1) -- (a1); %\node at (2.25,-1) {\textit{$U^{+}$}}; \end{tikzpicture} \end{document} Here I am trying to draw a self loop at vertexes 1 and 2. How to draw it? I need this type of loop without arrows:

  • node labels: inherit node color
    by pschulz on May 31, 2022 at 7:02 am

    Is it possible for node labels to "inherit" their parent's color? More specifically, I'm doing this: \node[red, label = {[red]above:label}] {node}; but I want to be able to do this: \node[red, label = above:label] {node}; Here is an MWE: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node[red, label = above:label] at (-2, 0) {node}; \node[red, label = {[red]above:label}] at (2, 0) {node}; \end{tikzpicture} \end{document} which produces

  • How to wrap the label of a node into two in a tikzpicture?
    by Sechkin on February 16, 2022 at 3:53 pm

    I want to get the following figure, but somehow I could not divide the labels of the nodes. The code I'm using is below. Code: \documentclass[12pt,english]{article} \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{patterns, arrows.meta} \usetikzlibrary{patterns,math} \usetikzlibrary{arrows} \usetikzlibrary{shapes.geometric} \usetikzlibrary{arrows,decorations.markings} \begin{document} \begin{figure}[H] \begin{center} \begin{tikzpicture} \begin{scope}[every node/.style={draw, circle, inner sep=0pt, minimum size=.15cm, fill=black}] \node[label=right:\text{$v_{1}=i=w_{1}$}] (A) at (0,0) {}; \node[label=above:\text{$a=w_{2}$}] (B) at (1.5,1.5) {}; \node[label=above:\text{$w_{3}$}] (C) at (3,1.5) {}; \node[label=below:\text{$k=w_{p}$}] (D) at (1.5,-1.5) {}; \node[label=below:\text{$w_{p-1}$}] (E) at (3,-1.5) {}; \node[label=above:\text{$b=v_{2}$}] (F) at (-1.5,1.5) {}; \node[label=above:\text{$v_{3}$}] (G) at (-3,1.5) {}; \node[label=below:\text{$j=v_{m}$}] (H) at (-1.5,-1.5) {}; \node[label=below:\text{$v_{m-1}$}] (I) at (-3,-1.5) {}; \node[fill,circle,inner sep=0pt,minimum size=1pt] (J) at (4.5,-0.5) {}; \node[fill,circle,inner sep=0pt,minimum size=1pt] (K) at (-4.5,-0.5) {}; \node[fill,circle,inner sep=0pt,minimum size=1pt] (L) at (-4.5,0.5) {}; \node[fill,circle,inner sep=0pt,minimum size=1pt] (M) at (4.5,0.5) {}; \draw[-{Stealth[scale=2]}] (A) edge[bend left=15] (B); \draw[-{Stealth[scale=2]}] (B) edge[bend left=15] (C); \draw[-{Stealth[scale=2]}] (C) edge[bend left=15] (M); \draw[-{Stealth[scale=2]}] (E) edge[bend left=15] (D); \draw[-{Stealth[scale=2]}] (D) edge[bend left=15] (A); \draw[-{Stealth[scale=2]}] (J) edge[bend left=15] (E); \draw[-{Stealth[scale=2]}] (A) edge[bend right=15] (F); \draw[-{Stealth[scale=2]}] (F) edge[bend right=15] (G); \draw[-{Stealth[scale=2]}] (G) edge[bend right=15] (L); \draw[-{Stealth[scale=2]}] (I) edge[bend right=15] (H); \draw[-{Stealth[scale=2]}] (H) edge[bend right=15] (A); \draw[-{Stealth[scale=2]}] (K) edge[bend right=15] (I); \draw[thick,dashed] (-4.5,0.5) edge[bend right=15] (-4.5,-0.5); \draw[thick,dashed] (4.5,0.5) edge[bend left=15] (4.5,-0.5); \end{scope} \end{tikzpicture} \end{center} \end{figure} \end{document}

  • TikZ: Is there concept of layouts in tikz (which I could use in composite pic's)?
    by DimanNe on November 28, 2021 at 12:25 pm

    In Qt there is concept of layouts (for example, vertical layout arranges all objects vertically and possibly aligns them, horizontal - arranges horizontally, etc...). I am trying to solve a problem where layouts would help a lot. Namely, I would like to specify (1) nodes on the left ({n1}, {n2}, {n3}, {n4}, ...), (2) text for the center node, (3) nodes on the right. And expect the code to generate multiple nodes that have the following properties: nodes on the left are aligned to the right, and center of the group of the nodes is aligned with the center of the center node. the same with right nodes, but mirrored. each node has to be referenc-able outside there should be bounding box with anchors for the entire "thing" to be able to arrange them. Here is an example of how it could look in latex: \pic (a) [anchor=north] at(0, 0) { % `a` is the name of entire "thing" lcrpic={{n1}, {n2}, {n3}, {n4}, {n5}, {n6}, {n7}} % List of nodes on the left {Center1:\\many nodes on the left} % Center node {{n1}} % Nodes on the right }; I did manage to make the code below produce the picture below: \pic (a) [anchor=north] at(0, 0) { lcrpic={{n1}, {n2}, {n3}, {n4}, {n5}, {n6}, {n7}} {Center1:\\many nodes on the left} {{n1}} }; \pic (b) [anchor=north] at ({$(a-bb.south) - (0cm, 0.4cm)$} -| {$(a-center.south)$}) { lcrpic={{111111111111111111111111}} {Center2:\\Long nodes on the left} {{11}, {22}, {33}, {44}} }; \node (f) [nodefx_default] at (-6, -3) {Nodes must be reference-able outside:}; \draw[line width=1pt, draw=red!20] (f) -- (a-leftnodes-node-6); \draw[line width=1pt, draw=red!20] (f) -- (b-leftnodes-node-1); BUT The code is cumbersome, inefficient and ugly. My question is: what is the right approach in tikz to achieve this? (Maybe there is something that is similar to layouts in Qt?) MWE \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc, positioning} \makeatletter \newcommand{\gettikzxy}[3]{% \tikz@scan@one@point\pgfutil@firstofone#1\relax \edef#2{\the\pgf@x}% \edef#3{\the\pgf@y}% } \begin{document} \begin{tikzpicture} \tikzstyle{noders_default} = [rectangle, rounded corners=8pt, minimum height=17pt, font=\footnotesize, text centered, draw=black!20, thick, fill=white] \tikzstyle{nodefx_default} = [noders_default, text width=60pt] % ============================== left ============================== % the only useful "output" of the pic is "-bb" (invisible) node - it stores geometry of the left part and is used in pics/leftnodes \tikzset{ pics/leftnodeslayout/.style n args = {1}{ code={ \begin{scope}[local bounding box = layoutBoundingBox] \foreach [count=\ei, remember=\ei as \prevei (initially 0)] \elem in {#1} { \ifnum \prevei=0 \node (-node-\ei) [noders_default, draw=none, opacity=0, text opacity=0] {\elem}; \else \node (-node-\ei) [noders_default, anchor=north east, draw=none, opacity=0, text opacity=0] at (-node-\prevei.south east) {\elem}; \fi } \end{scope} \gettikzxy{(layoutBoundingBox.north west)}{\xLeft}{\yTop}; \gettikzxy{(layoutBoundingBox.south east)}{\xRight}{\yBottom}; \node[draw=none, green, dashed, minimum height=\yTop - \yBottom, minimum width=\xRight - \xLeft] (-bb) at (0,0) {}; } } } % Draw leftnodeslayout => get its "-bb" draw real nodes using "-bb" as reference: \tikzset{ pics/leftnodes/.style n args = {1}{ code={ \pic (layout) {leftnodeslayout={#1}}; \gettikzxy{(layout-bb.north west)}{\xLeft}{\yTop}; \gettikzxy{(layout-bb.south east)}{\xRight}{\yBottom}; \node[draw, green, dashed, minimum height=\yTop - \yBottom, minimum width=\xRight - \xLeft] (-bb) at (0,0) {}; \begin{scope} \foreach [count=\ei, remember=\ei as \prevei (initially 0)] \elem in {#1} { \ifnum \prevei=0 \node (-node-\ei) [noders_default, anchor=north east] at (-bb.north east) {\elem}; \else \node (-node-\ei) [noders_default, anchor=north east] at (-node-\prevei.south east) {\elem}; \fi } \end{scope} } } } % ============================== right ============================== % the only useful "output" of the pic is "-bb" (invisible) node - it stores geometry of the right part and is used in pics/righttnodes \tikzset{ pics/rightnodeslayout/.style n args = {1}{ code={ \begin{scope}[local bounding box = layoutBoundingBox] \foreach [count=\ei, remember=\ei as \prevei (initially 0)] \elem in {#1} { \ifnum \prevei=0 \node (-node-\ei) [noders_default, draw=none, opacity=0, text opacity=0] {\elem}; \else \node (-node-\ei) [noders_default, anchor=north east, draw=none, opacity=0, text opacity=0] at (-node-\prevei.south east) {\elem}; \fi } \end{scope} \gettikzxy{(layoutBoundingBox.north west)}{\xLeft}{\yTop}; \gettikzxy{(layoutBoundingBox.south east)}{\xRight}{\yBottom}; \node[draw=none, green, dashed, minimum height=\yTop - \yBottom, minimum width=\xRight - \xLeft] (-bb) at (0,0) {}; } } } % Draw rightnodeslayout => get its "-bb" draw real nodes using "-bb" as reference: \tikzset{ pics/rightnodes/.style n args = {1}{ code={ \pic (layout) {rightnodeslayout={#1}}; \gettikzxy{(layout-bb.north west)}{\xLeft}{\yTop}; \gettikzxy{(layout-bb.south east)}{\xRight}{\yBottom}; \node[draw, green, dashed, minimum height=\yTop - \yBottom, minimum width=\xRight - \xLeft] (-bb) at (0,0) {}; \begin{scope} \foreach [count=\ei, remember=\ei as \prevei (initially 0)] \elem in {#1} { \ifnum \prevei=0 \node (-node-\ei) [noders_default, anchor=north west] at (-bb.north west) {\elem}; \else \node (-node-\ei) [noders_default, anchor=north west] at (-node-\prevei.south west) {\elem}; \fi } \end{scope} } } } % ============================== LeftCenterRight (lcr) ============================== % The same approach here, but for the entire leftnodes-center-rigthnodes: \tikzset{ pics/lcrlayout/.style n args = {3}{ code={ \pic (leftnodes) {leftnodeslayout={#1}}; \gettikzxy{(leftnodes-bb.north west)}{\xLeftL}{\yTopL}; \gettikzxy{(leftnodes-bb.south east)}{\xRightL}{\yBottomL}; \pic (rightnodes) {rightnodeslayout={#3}}; \gettikzxy{(rightnodes-bb.north west)}{\xLeftR}{\yTopR}; \gettikzxy{(rightnodes-bb.south east)}{\xRightR}{\yBottomR}; \begin{scope}[local bounding box = layoutBoundingBoxForLCR] \node (-center) [nodefx_default, draw=none, opacity=0, text opacity=0] {#2}; \node (fakeleftbbrect) [draw=none, anchor=east, left=20pt of -center.west, minimum height=\yTopL - \yBottomL, minimum width=\xRightL - \xLeftL] {}; \node (fakerightbbrect) [draw=none, anchor=west, right=20pt of -center.east, minimum height=\yTopR - \yBottomR, minimum width=\xRightR - \xLeftR] {}; \end{scope} \gettikzxy{(layoutBoundingBoxForLCR.north west)}{\xLeft}{\yTop}; \gettikzxy{(layoutBoundingBoxForLCR.south east)}{\xRight}{\yBottom}; \node[draw=none, green, dashed, anchor=south west, minimum height=\yTop - \yBottom, minimum width=\xRight - \xLeft] (-bb) at (\xLeft, \yBottom) {}; } } } \tikzset{ pics/lcrpic/.style n args = {3}{ code={ \pic (-layout) {lcrlayout={{#1}}{#2}{{#3}}}; \gettikzxy{(-layout-bb.north west)}{\xLeft}{\yTop}; \gettikzxy{(-layout-bb.south east)}{\xRight}{\yBottom}; \gettikzxy{(-layout-bb.south)}{\xBbC}{\yBbC}; \gettikzxy{(-layout-center.south)}{\xC}{\yC}; \begin{scope}[xshift=\xBbC - \xC] \node[draw, blue, dashed, minimum height=\yTop - \yBottom, minimum width=\xRight - \xLeft] (-bb) {}; \pic (-leftnodes) [anchor=west] at (-bb.west) {leftnodes={#1}}; \node (-center) [nodefx_default, anchor=west, right=20pt of -leftnodes-bb.east] {#2}; \pic (rightnodes) [anchor=west, right=20pt of -center.east] {rightnodes={#3}}; \foreach [count=\ei, remember=\ei as \prevei (initially 0)] \elem in {#1} { \draw[line width=1pt, draw=black!20] (-center) -- (-leftnodes-node-\ei.east); } \foreach [count=\ei, remember=\ei as \prevei (initially 0)] \elem in {#3} { \draw[line width=1pt, draw=black!20] (-center) -- (rightnodes-node-\ei.west); } \end{scope} } } } % % The interface I want and tests: % \pic (a) [anchor=north] at(0, 0) { lcrpic={{n1}, {n2}, {n3}, {n4}, {n5}, {n6}, {n7}} {Center1:\\many nodes on the left} {{n1}} }; \pic (b) [anchor=north] at ({$(a-bb.south) - (0cm, 0.4cm)$} -| {$(a-center.south)$}) { lcrpic={{111111111111111111111111}} {Center2:\\Long nodes on the left} {{11}, {22}, {33}, {44}} }; \node (f) [nodefx_default] at (-6, -3) {Nodes must be reference-able outside:}; \draw[line width=1pt, draw=red!20] (f) -- (a-leftnodes-node-6); \draw[line width=1pt, draw=red!20] (f) -- (b-leftnodes-node-1); \end{tikzpicture} \end{document}

  • Subheadings for Pie charts
    by Waseem on June 15, 2021 at 8:03 am

    Can anyone help me for writing subheading on top each Pi chart with the following code. Please see the example picture \documentclass[border=5mm]{standalone} \usepackage{pgf-pie} % version: https://github.com/pgf-tikz/pgf-pie Dec 26, 2020 \usepackage{etoolbox} \makeatletter \pretocmd{\pgfpie@slice}{% define label text with percentages for small values \pgfmathparse{#3 > 5}% \ifnum\pgfmathresult=1 % \def\txtlabel{#4}% original label for large values \else% \def\txtlabel{#4 (#3\%)}% label with percentage for small values \fi% }{\message{define label patch ok}}{\message{define label patch failed}} \patchcmd{\pgfpie@slice}% use label text instead of original argument #4 {\pgfpie@text={\pgfpie@midangle:#4}}% {\pgfpie@text={\pgfpie@midangle:\txtlabel}}% {\message{add pct patch ok}}% {\message{add pct patch failed}}% \def\pgfpie@numbertext#1{% don't print percentage in slice for small values \pgfpie@ifhidenumber{}{% \pgfmathparse{#1 > 5}% \ifnum\pgfmathresult=1 % \pgfpie@beforenumber#1\pgfpie@afternumber% \fi }% } \makeatother \begin{document} \begin{subfigure} \footnotesize \begin{tikzpicture} %\begin{scope}[scale=0.7] \pie[before number =, after number = {\%},text=pin, ]{ 18.9/1-20 Employees, 29.2/21-100 Employees, 22.6/101-500 Employees, 7.5/501-1000 Employees, 21.7/Over 1000 Employees } %\end{scope} \end{tikzpicture} \end{subfigure} %\begin{tikzpicture} %\pie[before number =, after number = {\%},text=pin, ]{ %42.3/ Combination of DDD and business capability, %29.8/ Only business capability, %27.9/ only DDD %} %\end{tikzpicture} \begin{subfigure} \footnotesize \begin{tikzpicture} %\begin{scope}[scale=0.7] \pie[before number =, after number = {\%},text=pin, ]{ 5.7/1 Practitioners, 43.4/2-3 Practitioners, 27.4/4-5 Practitioners, 9.4/6-7 Practitioners, 6/8-10 Practitioners, 8.5/Over 10 Practitioners } %\end{scope} \end{tikzpicture} \end{subfigure} \end{document}

  • Circuitikz with wrapfig problem
    by aure4 on February 15, 2021 at 9:49 am

    I have a problem with circuitikz. I can't manage to display my circuits as I want to. More specifically, I can't change where the text next to the image begin, I've already tried things like \hspace, \\, \break, \newline but nothing works and circuitikz doesn't have much documentation as I see. Here is my code : \documentclass{article} \usepackage[english]{babel} \usepackage[utf8]{inputenc} \usepackage[siunitx]{circuitikz} \usepackage{fancyhdr} \usepackage{enumitem} \usepackage{wrapfig} \usepackage{geometry} \geometry{ a4paper, total={170mm,257mm}, left=20mm, top=20mm, } \pagestyle{fancy} \fancyhf{} \rhead{Equipe 11.97} \lhead{Labo S3} \rfoot{\thepage} \title{LEPL1502 : Rapport de Laboratoire \\ Diode Zener et Circuits RC} \date{} \begin{document} \maketitle\thispagestyle{fancy} \textbf{\large \hspace{15pt} 1. Objectif(s) :} \\ %hspace = écart du titre \begin{itemize} \item Compréhension du fonctionnement et des caractéristiques d’une diode Zenner. Pour ce faire, nous mesurerons la tension aux bornes de celle-ci et nous étudierons l’influence du courant. \\ \item Compréhension du fonctionnement d’un circuit RC ainsi que de ses composantes. \\ \end{itemize} \textbf{\large \hspace{15pt} 2. Rappels théoriques :} \begin{description}[labelindent=2.5cm] %Ecart de chaque item par rapport à la marge \item %juste un espace %endroit où mettre les formules \item [\large Loi d'Ohm:] $V = R*I$ \item [\large Courant dans une capa:] $I = C * DV/Dt$ \item [\large Tension dans une capa:] $V = A + B*e^-t/\tau$ \item [\large Valeurs de A et B:] $A + B = V(O)$ \item [\large Valeur de A:] $A = V(\infty)$ \item [\large Valeur de tau:] $\tau = R_{eq} * C$ \item %juste un espace \end{description} \textbf{\large \hspace{15pt} 3. Méthodes de mesures :} \\ \\ \\ \\ \textbf{\large \hspace{15pt} a) Diode Zener :} \vspace{50pt} \begin{wrapfigure}{L}{0.47\textwidth} %réglage de textwidth suivant la grandeur du circuit \centering \begin{circuitikz}[american] \ctikzset{bipoles/length=1.5cm} %grandeur des composantes \draw (0,0)to [V, l_ = 5<\volt>, i = $I$](0,-4) to (6,-4) to [zzDo, i<= $I$, v<= VD](6,0) to [vR](3,0) to [short, -*](3,0) to [R, l_= 600<\ohm>](0,0); %ici circuit électrique \end{circuitikz} \caption{Circuit Diode Zener en Backward} \end{wrapfigure} Mesure de la tension de seuil et de breakdown : Nous allons faire varier le potentiomètre et ainsi calculer petit à petit à l'aide du multimètre, les tensions et courant en mode forward (premier dessin) et en backward (deuxième dessin) \newpage \vspace{50pt} \begin{wrapfigure}{L}[3]{0.47\textwidth} %réglage de textwidth suivant la grandeur du circuit \centering \begin{circuitikz}[american] \ctikzset{bipoles/length=1.5cm} %grandeur des composantes \draw (0,0) to [vR](-3,0) to [short, -*](-3,0) to [R, l_ = 600<\ohm>](-6,0); \draw (-6,0) to [V, l_ = 5<\volt>, i = $I$](-6,-4) to (0,-4); \draw (0,0) to [zzDo, v^ = $VD$, i_= $I$](0,-4); %ici circuit électrique \end{circuitikz} \caption{Circuit Diode Zener en Forward} \end{wrapfigure} \end{document} Deuxième circuit analysé comme décrit ci-dessus sauf que cette fois, la diode est dirigée dans l'autre sens ce qui change son mode en "forward" Here I can't manage to write below the circuit. Note that this is one of my circuit not the whole code. Also, text is in french but this is just what is displayed, that doesn't really matter Thanks for your kind help, Aurélien

  • How to draw the line containing the points origin and $(\sqrt{3},0)$ [closed]
    by Soham Chatterjee on May 2, 2020 at 5:12 pm

    How to draw a line whose coordinates contain irrational numbers like square root of non perfect square numbers $\sqrt{3}$, $\pi$, etc. In TikZ environment.

  • How to draw orbital elements
    by Pier Paolo on August 12, 2017 at 11:32 am

    I'm trying to draw a diagram representing the orbital elements (only the angles) to obtain something like the following: At the moment I have only drawn the Line of Nodes and the right ascension of the ascending node $\Omega$. I'm having problems in drawing the actual orbit (the circle in solid line) because I can't figure out how to set tikz-3dplot's rotated coordinate system. Any suggestion on how to go about that? Here is my code and the result so far: \documentclass[border=5pt]{standalone} \usepackage{tikz,tikz-3dplot} \begin{document} \tdplotsetmaincoords{70}{110} \begin{tikzpicture}[tdplot_main_coords,scale=4] \pgfmathsetmacro{\r}{.8} \pgfmathsetmacro{\O}{45} % right ascension of ascending node [deg] \pgfmathsetmacro{\i}{30} % inclination [deg] \draw[->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; \draw[->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; \draw[->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; \tdplotdrawarc[dashed]{(0,0,0)}{\r}{0}{360}{}{} \tdplotsetrotatedcoords{\O}{0}{0} \draw [tdplot_rotated_coords] (-1,0,0) -- (1,0,0) node [below] {Line of Nodes}; \tdplotdrawarc[->]{(0,0,0)}{.5*\r}{0}{\O}{anchor=north}{$\Omega$} \end{tikzpicture} \end{document}

  • How to join two TikZ figures together?
    by JP Janet on August 8, 2017 at 5:26 pm

    I have two TikZ figures that are identically sized images saved as separate tex files. The images have vertical symmetry. I would like to plot one image of the same size, with the left half from the first image and the right half from the second image to compare them. The files are long and automatically generated and hence I don't want to modify the source TikZ files. I don't want to compile the source files and join rendered images as they will be updated.

  • Pie chart size from Bordaigorl
    by Laura K on April 27, 2017 at 7:10 pm

    I have been using this great pie chart code: How to draw Bar & Pie Chart The code is from Bordaigorl. I was wondering if anyone can see how it is possible to have two pie charts in the same environment with different sizes. The part of the code that is responsible for this is "scale" when you call the function pie chart: \begin{tikzpicture} [ pie chart, slice type={g}{giallo}, slice type={A}{rosso}, slice type={B}{blu}, pie values/.style={font={\small}}, scale=2 ] \pie{t=1, A in power}{66/g,34/A} \pie[xshift=2.2cm]% {t=2, B in power}{33/g,33/B} \end{tikzpicture} My question is: does anyone see how to create two "types" of pies, one with scale=2 and another with scale=2.5, for example? For the purpose of understanding, I will post an MWE based on the whole code created by Bordaigorl here. What I would like is to have the left pie chart in one scale and the pie chart on the right in another scale. Please note that I am not the one who designed this code and credit must be given to Bordaigorl: \documentclass[border=10pt,multi,tikz]{standalone} \definecolor{rosso}{RGB}{220,57,18} \definecolor{giallo}{RGB}{255,153,0} \definecolor{blu}{RGB}{102,140,217} \definecolor{verde}{RGB}{16,150,24} \definecolor{viola}{RGB}{153,0,153} \makeatletter \tikzstyle{chart}=[ legend label/.style={font={\scriptsize},anchor=west,align=left}, legend box/.style={rectangle, draw, minimum size=5pt}, axis/.style={black,semithick,->}, axis label/.style={anchor=east,font={\tiny}}, ] \tikzstyle{bar chart}=[ chart, bar width/.code={ \pgfmathparse{##1/2} \global\let\bar@w\pgfmathresult }, bar/.style={very thick, draw=white}, bar label/.style={font={\bf\small},anchor=north}, bar value/.style={font={\footnotesize}}, bar width=.75, ] \tikzstyle{pie chart}=[ chart, slice/.style={line cap=round, line join=round, very thick,draw=white}, pie title/.style={font={\bf}}, slice type/.style 2 args={ ##1/.style={fill=##2}, values of ##1/.style={} } ] \pgfdeclarelayer{background} \pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground} \newcommand{\pie}[3][]{ \begin{scope}[#1] \pgfmathsetmacro{\curA}{90} \pgfmathsetmacro{\r}{1} \def\c{(0,0)} \node[pie title] at (90:1.3) {#2}; \foreach \v/\s in{#3}{ \pgfmathsetmacro{\deltaA}{\v/100*360} \pgfmathsetmacro{\nextA}{\curA + \deltaA} \pgfmathsetmacro{\midA}{(\curA+\nextA)/2} \path[slice,\s] \c -- +(\curA:\r) arc (\curA:\nextA:\r) -- cycle; \pgfmathsetmacro{\d}{max((\deltaA * -(.5/50) + 1) , .5)} \begin{pgfonlayer}{foreground} \path \c -- node[pos=\d,pie values,values of \s]{$\v\%$} +(\midA:\r); \end{pgfonlayer} \global\let\curA\nextA } \end{scope} } \newcommand{\legend}[2][]{ \begin{scope}[#1] \path \foreach \n/\s in {#2} { ++(0,-10pt) node[\s,legend box] {} +(5pt,0) node[legend label] {\n} } ; \end{scope} } \begin{document} \begin{tikzpicture} [ pie chart, slice type={g}{giallo}, slice type={A}{rosso}, slice type={B}{blu}, pie values/.style={font={\small}}, scale=2 ] \pie{1}{66/g,34/A} \pie[xshift=2.2cm]% {2}{33.3/g,33.3/B,33.3/A} \end{tikzpicture} \end{document} I apologize if that is an obvious question. I've tried in 2 differents ways and they were all not succesful: I've tried to remove the scale from the preamble on tikz and added scale=2 when was calling pie function: \pie[xshift=2.2cm, scale=2]{2}{33.3/g,33.3/B,33.3/A} I've also tried to create two functions in the preamble of the document, one pie1 and another pie2. The code doesn't compile Thank you!

  • Draw a colored sphere in Tikz
    by Salvatore Baldino on October 1, 2016 at 6:14 pm

    first post here, I'm a Tikz starter. I'm currently preparing a presentation, and I'd like to be able to draw colored spheres, like in page 5 of this article. Basically, I have to color a sphere by dividing it into three equal pieces (along the meridians), except for two antipodal tips of the sphere (see figure for a better explanation), that I draw differently. Understanding how to describe this coloration through a function of polar angles is straightforward enough, just some basic algebra. Basically, I'd define a function of the polar angles that is defined piecewise (no smooth fading of a color into another, let's keep it simple) and use it to color the sphere. I've searched in the documentation about how to implement this, but so far no luck, so I've come to ask you. Next, I'd like to draw graphics like in page 15 of this other article, by drawing many balls with different orientations. It would be very useful to then have a function that draws a colored sphere at a given center, that also takes some angles as input for rotating it.

  • Is it possible to make such an image with TikZ? How?
    by ThePunisher on March 17, 2016 at 10:34 am

    I'm wondering what's the best way to render this image width the dashed line and with angles between normal lines and dashed lines. And also is there a way to quickly rotate the TikZ resulting image 90 degrees without rotating the letters?

  • Anchoring TiKZ pics
    by Ignasi on June 17, 2014 at 12:35 pm

    Is it possible to anchor a TiKZ-pic on an internal anchor? I know (more or less) how to use TiKZ pics and know that they are draw arround their origin. What I would like to be sure is that it's not possible to use another internal coordinate as origin. As an example consider next code. \tikzset{ mytest/.pic = { \node (-A) at (0,0) {A}; \node (-B) at (0,1) {B}; \node[fit=(-A) (-B),draw] (-C) {}; } } It defines a pic with three nodes: A, B and C being A.center the pic origin. A command like \draw pic (T) at (2,1) {mytest}; draws the pic with A.center at (2,1). Now, I would like to draw this pic but selecting B.center (or any other internal anchor like C.120) as anchoring (pic-origin) point. Is it possible? In case you needed, there is some complete code: \documentclass[tikz,border=2mm]{standalone} \usetikzlibrary{fit} \tikzset{ mytest/.pic = { \node (-A) at (0,0) {A}; \node (-B) at (0,1) {B}; \node[fit=(-A) (-B),draw] (-C) {}; } } \begin{document} \begin{tikzpicture} \draw[blue!20] (0,0) grid (3,3); \draw pic (S) at (0,0) {mytest}; \draw pic (T) at (2,1) {mytest}; \draw (S-A.north) to [out=90,in=-90] (T-B.south); \end{tikzpicture} \end{document} Question updates: I would like a general solution. For this particular case I know that node B.center is 1cm above A.center and it's easy to shift the whole picture, but it's more difficult to shitf it if the origin must be at C.120 or C.100-|B.35. Consider also some pic with variable size nodes. The example is just an example. I'm not trying to solve a particular problem. The question is more ... conceptual(?). The answer could be no, it's not possible. But, please, with some explanation as I always ask to my students 😉

  • How can I strike-out arrows in tikz?
    by Ellie on February 6, 2013 at 2:22 am

    I am using the following code to draw a Directed Acyclic Graph (DAG) using tikz: \usepackage{tikz} \small{\begin{tikzpicture}[% ->, shorten >=2pt, >=stealth, node distance=1cm, pil/.style={ ->, thick, shorten =2pt,} ] \node (1) {A}; \node[left=of 1] (2) {L}; \node[right=of 1] (3) {Y}; \draw [->] (2.east) -- (1.west); \draw [->] (1.east) -- (3.west); \draw [->] (2) to [out=15, in=165] (3); \end{tikzpicture}} I would like to be able draw a slash or strike-out through the arrow from L to A (the first arrow in the code) to indicate that the analysis method removes this association completely. How can I modify the code to do this?