• `subfiles` package and sharing exported TikZ pictures
    by UnderscorePoY on November 5, 2025 at 10:34 pm

    I have a main.tex file that includes content with the \subfile command, let's call one of these subfiles sub.tex. All these subfiles generate many Tikz pictures, that i store in external files via the \tikzexternalize command. The goal is to store them to avoid re-compiling them every time when compiling chapters independantly or when compiling the whole project. My issue is the following: when compiling the subfiles independantly, the pictures have a prefix equal to the subfiles' filenames, for example sub for sub.tex. But when compiling main.tex, the compiler tries to load pictures with a prefix of main, which aren't found, thus recreates each picture from each subfile with a prefix of main. I found some posts on this forum to help the main file to retrieve the name of the subfiles (for example with having the subfiles call \tikzsetexternalprefix with a prefix of \jobname or \currfilename), but in my case they all are equal to the main filename. Is there a way to dynamically retrieve the proper name of the subfiles when compiling from the main file, such that these pictures can be loaded properly ?

  • Accounting Scheme with TikZ
    by Fractal on November 5, 2025 at 6:08 pm

    I'm trying to reproduce this scheme : What I did : \documentclass[tikz,border=6pt]{standalone} \usepackage{tikz} \definecolor{docBlue}{RGB}{20,60,170} \begin{document} \begin{tikzpicture}[x=1cm,y=1cm] %================ Réglages ================= \definecolor{docBlue}{RGB}{20,60,170} \def\Wleft{8.80} % longueur des 2 traits bleus à gauche \def\Gap{1.05} % écart gauche -> cartouche \def\Wbox{6.90} % largeur cartouche (ouvert vers la gauche) \def\Hrow{1.12} % hauteur d'une ligne \def\Stub{0.70} % débordement (cassure) des traits du cartouche vers la gauche \def\VEgap{0.35} % cartouche -> 1er trait vertical \def\VEsep{1.90} % 1er -> 2e trait vertical (plus éloigné) % Abscisses communes \def\xCode{-1.45} % x des codes \def\xL{0} % début des traits bleus à gauche \pgfmathsetmacro{\xB}{\xL+\Wleft+\Gap} % début cartouche \pgfmathsetmacro{\xVone}{\xB+\Wbox+\VEgap} % 1er trait \pgfmathsetmacro{\xVtwo}{\xVone+\VEsep} % 2e trait % Styles \tikzset{ code/.style = {anchor=west,font=\bfseries\footnotesize}, labA/.style = {anchor=west,font=\itshape\footnotesize}, labB/.style = {anchor=west,font=\bfseries\itshape\footnotesize}, ve/.style = {anchor=west,font=\bfseries\footnotesize}, } %========== Bloc gauche (traits + textes) ========== \newcommand{\Gauche}[5]{% yTop, codeH, codeB, lab1, lab2 \pgfmathsetmacro{\yT}{#1} \pgfmathsetmacro{\yB}{\yT-\Hrow} \draw[very thick] (-0.20,\yT) -- (-0.20,\yB); \node[code] at (\xCode,\yT-0.27) {#2}; \node[code] at (\xCode,\yB+0.27) {#3}; \draw[docBlue, line width=1.1pt] (\xL,\yT) -- ++(\Wleft,0); \draw[docBlue, line width=1.1pt] (\xL,\yB) -- ++(\Wleft,0); \node[labA] at (\xL+0.15,\yT-0.40) {#4}; \node[labB] at (\xL+0.15,\yB+0.15) {#5}; } %========== Cartouche simple (1 ligne) ========== \newcommand{\CartoucheUn}[2]{% yTop, texte \pgfmathsetmacro{\yT}{#1} \pgfmathsetmacro{\yB}{\yT-\Hrow} \pgfmathsetmacro{\yM}{(\yT+\yB)/2} % ouvert vers la gauche avec cassure \draw[docBlue, line width=1.1pt] (\xB-\Stub,\yT) -- ++(\Wbox+\Stub,0); \draw[docBlue, line width=1.1pt] (\xB-\Stub,\yB) -- ++(\Wbox+\Stub,0); \draw[docBlue, line width=1.1pt] (\xB+\Wbox,\yB) -- ++(0,\Hrow); \node[anchor=west] at (\xB+0.30,\yM) {#2}; % VE + traits verticaux \node[ve] at (\xB+\Wbox+0.12,\yM) {VE}; \draw[docBlue, line width=1.1pt] (\xVone,\yB+0.08) -- ++(0,\Hrow-0.16); \node[ve] at (\xVtwo-0.40,\yM) {VE}; \draw[docBlue, line width=1.1pt] (\xVtwo,\yB+0.08) -- ++(0,\Hrow-0.16); } %========== Cartouche double (2 lignes superposées) ========== \newcommand{\CartoucheDeux}[4]{% yTop, txt1, txt2, avec trait médian \pgfmathsetmacro{\yT}{#1} \pgfmathsetmacro{\yM}{\yT-\Hrow} % niveau médian \pgfmathsetmacro{\yB}{\yT-2*\Hrow} % cadre ouvert vers la gauche (une seule verticale à droite) \draw[docBlue, line width=1.1pt] (\xB-\Stub,\yT) -- ++(\Wbox+\Stub,0); \draw[docBlue, line width=1.1pt] (\xB-\Stub,\yB) -- ++(\Wbox+\Stub,0); \draw[docBlue, line width=1.1pt] (\xB+\Wbox,\yB) -- ++(0,2*\Hrow); % trait horizontal médian \draw[docBlue, line width=1.1pt] (\xB,\yM) -- ++(\Wbox,0); % textes \node[anchor=west] at (\xB+0.30,(\yT+\yM)/2) {#2}; \node[anchor=west] at (\xB+0.30,(\yM+\yB)/2) {#3}; % VE + traits verticaux (continus sur 2 lignes) \node[ve] at (\xB+\Wbox+0.12,(\yT+\yM)/2) {VE}; \node[ve] at (\xB+\Wbox+0.12,(\yM+\yB)/2) {VE}; \draw[docBlue, line width=1.1pt] (\xVone,\yB+0.08) -- ++(0,2*\Hrow-0.16); \node[ve] at (\xVtwo-0.40,(\yT+\yB)/2) {VE}; \draw[docBlue, line width=1.1pt] (\xVtwo,\yB+0.08) -- ++(0,2*\Hrow-0.16); } %================ 1) Bloc haut ================= \Gauche{1.70}{6512}{2230} {VNA des immob. Incorporelles cédées} {Sortie du fonds commercial cédé} \CartoucheUn{1.70}{Fonds commercial} %================ 2) Deux blocs bas (gauche) ================= \Gauche{-0.35}{6513}{2310} {VNA des immob. Corporelles cédées} {Sortie des terrains nus cédés} \Gauche{-1.60}{6514}{2510} {VNA des immob. Financières} {Sortie des TP cédés} %================ Cartouche droit commun aux 2 lignes ================= \CartoucheDeux{-0.35}{Terrains nus}{Titres de participation}{} \end{tikzpicture} \end{document} The result :

  • TikZ - Define the line style of multiple pens with different colors and widths
    by myhsia on November 5, 2025 at 5:33 pm

    I would like to define the TikZ line style like the following to draw the line within one \draw command, i.e, \draw [mystyle] (A) -- (B); The MWE \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture} \draw (0,0) rectangle (6,3); \draw [orange!25, line width = 12pt] (1,1) -- (2,2) -- (4.5,1.5); \draw [orange, line width = 6pt] (1,1) -- (2,2) -- (4.5,1.5); \draw (1,1) -- (2,2) -- (4.5,1.5); \end{tikzpicture} \end{document}

  • Iterated plot with TikZ, PGFPlots and foreach loop
    by Dominique on November 5, 2025 at 4:31 pm

    I'm trying to plot an illustration of the fixed point method in which a function is evaluated repeatedly in a loop. The result should be a staircase or spiral plot on top of the plot of the function itself. I've read here about the use of \edef inside a foreach loop. The following MWE should show what I'm trying to do, but it seems to only perform a single iteration. Notes: the loop variable isn't used inside the loop. perhaps it's an illusion that only single iteration is performed and the real issue is that \xprev and \xnext aren not updated at each pass through the loop. I tried placing the updates inside the \edef, but that gives an undefined control sequence error. I also tried \pgfplotsinvokeforeach instead of \foreach, but only obtained other errors. \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \pgfmathdeclarefunction{g}{1}{\pgfmathparse{#1^2 - 2}} \begin{tikzpicture} \begin{axis} [ xmin = -2.5, xmax = 2.5, ymin = -3, ymax = 3, axis x line = center, axis y line = center, domain=-2.5:2.5, samples=300, ] \addplot[ultra thick] {g(x)}; % graph of g \addplot[thin] {x}; % diagonal \def\xstart{-0.75} \pgfmathsetmacro{\xprev}{\xstart}; \pgfmathsetmacro{\xnext}{g(\xprev)}; \draw[thick, blue] (\xstart, 0) -- (\xstart, \xnext) -- (\xnext, \xnext); \foreach \i in {1, 2, 3}{ \pgfmathsetmacro{\xprev}{\xnext} \pgfmathsetmacro{\xnext}{g(\xprev)} % x <- g(x) \edef\plotoneiter{% \noexpand% \draw[thick, blue] ({\xprev}, {\xprev}) -- ({\xprev}, {\xnext}) -- ({\xnext}, {\xnext}); }\plotoneiter% } \end{axis} \end{tikzpicture} \end{document} Thanks in advance for any hints! EDIT: Here is a quick sketch of what I'm trying to achieve:

  • Two non-miscible liquids: U-tube
    by Sebastiano on November 3, 2025 at 12:46 pm

    In this website https://tikz.net/fluid_dynamics_barometer/ there is an illustration with this code: % Author: Izaak Neutelings (November 2020) \documentclass[border=3pt,tikz]{standalone} \usepackage{siunitx} \usepackage{physics} \usepackage{tikz} \usepackage[outline]{contour} % glow around text \usetikzlibrary{patterns,decorations.pathmorphing} \usetikzlibrary{arrows.meta} \tikzset{>=latex} \contourlength{1.1pt} \colorlet{mydarkblue}{blue!50!black} \colorlet{myred}{red!65!black} \colorlet{watercol}{blue!80!cyan!10!white} \colorlet{darkwatercol}{blue!80!cyan!20!white} \tikzstyle{piston}=[blue!50!black,top color=blue!30,bottom color=blue!50,middle color=blue!20,shading angle=0] \tikzstyle{water}=[draw=mydarkblue,top color=watercol!90,bottom color=watercol!90!black,shading angle=5] \tikzstyle{vertical water}=[water, top color=watercol!90!black!90,bottom color=watercol!90!black!90,middle color=watercol!80,shading angle=90] \def\tick#1#2{\draw[thick] (#1)++(#2:0.1) --++ (#2-180:0.2)} \begin{document} % OPEN MANOMETER \begin{tikzpicture} \def\W{0.8} % pressure box height \def\H{0.7} % pressure box height \def\Rx{0.55} % tube bend radius horizontal \def\Ry{0.2*\Rx} % tube bend radius vertical \def\rx{0.28*\Rx} % tube radius horizontal \def\ry{0.28*\Ry} % tube radius vertical \def\HL{1.3} % tube height left \def\HR{2.2} % stube height right \def\hL{0.40*\HL} % water level height left \def\hR{0.95*\HR} % water level height right %\def\th{2.7*\H} % tube height %\def\ty{0.93*\th} % tube level \def\N{14} % WATER + CONTAINER \draw[water] (-\Rx,\hL) --++ (0,-\hL) arc(180:360:\Rx) --++ (0,\hR) --++ (2*\rx,0) --++ (0,-\hR) arc(360:180:\Rx+2*\rx) --++ (0,\hL); \draw[water] (-\Rx-\rx,\hL) ellipse({\rx} and {\ry}) (\Rx+\rx,\hR) ellipse({\rx} and {\ry}); \draw[thick] (-\Rx,\HL) --++ (0,-\HL) arc(180:360:\Rx) --++ (0,\HR) coordinate (T) arc(180:0:\rx) --++ (0,-\HR) arc(360:180:\Rx+2*\rx) --++ (0,\HL); \draw[thick] (-\Rx-\rx,\HL) ellipse({\rx} and {\ry}); \foreach \i [evaluate={\y=(\hL+\hR)/2+0.8*\HR*(\i-\N/2)/\N;}] in {0,...,\N}{ \draw[line cap=round] (\Rx+2*\rx+0.007,\y) arc(0:-50:{\rx} and \ry); } %\draw[line cap=round,myred] (\Rx+2*\rx+0.007,{(\hL+\hR)/2}) arc(0:-70:{\rx} and \ry); \draw[line cap=round,myred] (-\Rx+0.007,\hL+\hR-\HR-\rx) arc(0:-70:{\rx} and \ry); \node at (-\W/2-4*\rx-\Rx,\HL+1.7*\rx) {$P_\mathrm{atm}$}; \draw[very thin,line cap=round] (T)++(130:\rx) node[anchor=-19,inner sep=1] {$P=0$} to[out=-50,in=170]++ (-30:1.5*\rx); \draw[dashed] (-\Rx,\hL) --++ (1.3*\Rx,0) (\Rx,\hR) --++ (-1.3*\Rx,0); \draw[<->] (0,\hL) -- (0,\hR) node[midway,fill=white,inner sep=1] {$h$}; \end{tikzpicture} \end{document} How is it possible to adapted to have this, giving a different level for fixed heights? The last image is taken here: https://www.iistelese.it/wp-content/uploads/2020/03/L-equilibrio-dei-fluidi-p1-p2.pdf

  • I want a command which can take two arbitrary ellipses, and shade the region between them, bounded by their mutual tangents
    by Jasper on November 2, 2025 at 9:31 pm

    I want a command which can take two arbitrary ellipses, and shade the region between them, bounded by their mutual tangents. \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \fill (-5,0) ellipse[x radius = 1, y radius = pi]; \fill ({sqrt(2)},e) ellipse[x radius = {sqrt(pi)}, y radius = {sqrt(e^sqrt(pi))}]; \end{tikzpicture} \end{document}

  • Problem trying to set color in dynamic in pgfplot [duplicate]
    by Liam Seddio on November 2, 2025 at 6:12 pm

    I'm trying to draw 10 functions of ten different colors (actually starting from red and ending with yellow) inside a tikzpicture environment. Problem is that the code reads only the first color (red) and then plot all 10 functions in green Here's the code: \documentclass{amsart} \usepackage[english]{babel} \usepackage{amsmath} \usepackage{hyperref} \usepackage[a4paper, margin=2.5cm]{geometry} \usepackage{pgfplots} \usepackage{xcolor} \pgfplotsset{compat=1.18} \usepackage{mdframed} \usepackage{subcaption} \begin{document} \begin{figure}[htb] \begin{mdframed} % un solo riquadro esterno per coerenza visiva \centering % --- PRIMA SUBFIGURE --- \begin{subfigure}[t]{0.45\textwidth} \centering \begin{tikzpicture} \begin{axis}[ axis lines=none, grid=none, width=\linewidth, height=0.8\linewidth, % stessa altezza per entrambi xmin=-1, xmax=4, ymin=-2, ymax=3, samples=200, domain=0:3.1416 ] \addplot[thick,smooth]{2*sin(deg(x))}; \addplot[only marks, mark=*] coordinates {(0,0)}; \addplot[only marks, mark=*] coordinates {(3.1416,0)}; \node[below left] at (axis cs:0,0) {$x_0$}; \node[below right] at (axis cs:3.1416,0) {$x_1$}; \node[below] at (axis cs:1.5,1.9) {$\gamma(t)$}; \end{axis} \end{tikzpicture} \end{subfigure}% \hfill % --- SECONDA SUBFIGURE --- \begin{subfigure}[t]{0.45\textwidth} \centering \begin{tikzpicture} \begin{axis}[ axis lines=none, grid=none, width=\linewidth, height=0.8\linewidth, xmin=-1.5, xmax=1.5, ymin=-1.5, ymax=1.5, samples=200, domain=0:360 ] \addplot[thick, parametric] ({-0.5+0.5*cos(x)}, {0.5*sin(x)}); \addplot[only marks, mark=*] coordinates {(0,0)}; \node[right] at (axis cs:0,0) {$x_0$}; \node[left] at (axis cs:-1,0) {$\mu(t)$}; \end{axis} \end{tikzpicture} \end{subfigure} \hfill \begin{subfigure}[t]{0.45\textwidth} \centering \begin{tikzpicture} \begin{axis}[ axis lines=none, grid=none, width=\linewidth, height=0.8\linewidth, xmin=-1, xmax=4, ymin=-3, ymax=3, samples=200, domain=0:3.1416 ] \addplot[thick,smooth]{2*sin(deg(x))}; \addplot[thick,smooth]{-sin(deg(x))}; \addplot[only marks, mark=*] coordinates {(0,0)}; \addplot[only marks, mark=*] coordinates {(3.1416,0)}; \foreach \n in {1,...,9} { \pgfmathsetmacro{\t}{\n/10} \pgfmathsetmacro{\coef}{2 - 3*\t} \pgfmathtruncatemacro{\perc}{100*\t} \addplot[ smooth, thick, red!\perc!black, % gradiente dal verde al blu domain=0:3.1416, samples=200 ] {\coef*sin(deg(x))}; } \node[below left] at (axis cs:0,0) {$x_0$}; \node[below right] at (axis cs:3.1416,0) {$x_1$}; \node[above] at (axis cs:1.5,1.9) {$\gamma_0(t)$}; \node[below right] at (axis cs:2.5,-0.4) {$\gamma_1(t)$}; \end{axis} \end{tikzpicture} \end{subfigure} \hfill \begin{subfigure}[t]{0.45\textwidth} %is here in this subfigure the problem \centering \begin{tikzpicture} \begin{axis}[ axis lines=none, grid=none, width=\linewidth, height=0.8\linewidth, xmin=-1.5, xmax=1.5, ymin=-1.5, ymax=1.5, samples=200, domain=0:360 ] \foreach \n in {1,...,9} { \pgfmathsetmacro{\t}{\n/10} \pgfmathsetmacro{\coefa}{-0.5 + 0.25*\t} \pgfmathsetmacro{\coefb}{-\coefa} \pgfmathtruncatemacro{\perc}{100*\t} \addplot[thick, parametric]({\coefa +\coefb*cos(x)},{\coefb*sin(x)}); }; \addplot[thick, parametric] ({-0.5+0.5*cos(x)}, {0.5*sin(x)}); \addplot[only marks, mark=*] coordinates {(0,0)}; \node[right] at (axis cs:0,0) {$x_0$}; \node[left] at (axis cs:-1,0) {$\mu_0(t)$}; \node[right] at (axis cs:-0.55,0) {$\mu_1(t)$}; \end{axis} \end{tikzpicture} \end{subfigure} \hfill \end{mdframed} \caption{Main Caption} \end{figure} \end{document} And the result is

  • Why outside `\centering` outside the `tikzpicture` affect the LR-mode in tikz's content?
    by Explorer on November 1, 2025 at 6:58 pm

    Description Here below are four examples: First. Without \centering and align=center: \documentclass[tikz]{standalone} \begin{document} % \centering% \begin{tikzpicture} \node [ % align=center ] {first\\second}; \end{tikzpicture} \end{document} Second. With \centering but not align=center: \documentclass[tikz]{standalone} \begin{document} \centering% \begin{tikzpicture} \node [ %align=center ] {first\\second}; \end{tikzpicture} \end{document} Third. With align=center but not \centering outsize: \documentclass[tikz]{standalone} \begin{document} % \centering% \begin{tikzpicture} \node [ align=center ] {first\\second}; \end{tikzpicture} \end{document} Fourth. With both \centering and align=center: \documentclass[tikz]{standalone} \begin{document} \centering \begin{tikzpicture} \node [ align=center ] {first\\second}; \end{tikzpicture} \end{document} Result case I: work. case II: failed. case III: work. case IV: work. The failed case, TeX complains that: ! LaTeX Error: Not allowed in LR mode. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.7 ] {first\\s econd}; Question: I was very surprised that \centering could even affect the node's content. IMO, the node's contents in deeply inside tikzpicture, which is safely protected by the group intuitively, and only control by tikz option align=<alignment>. My detailed questions are: In case I, without neigther align=center nor outside \centering, why the \\ didn't raise an error with LR-mode? In case II, why outside \centering would affect the node's contents mode?

  • Tikz arrow difference in difference PDF-viewer?
    by Explorer on November 1, 2025 at 6:03 pm

    I have the following mwe: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture}[% foo/.tip={Latex[width=0pt 5, length=5pt]}, line cap=round,line join=round,scale=1.3 ] \begin{scope} \coordinate (A) at (-1,0); \coordinate (B) at (1,0); \coordinate (C) at (0,{sqrt(3)}); \draw[foo-foo] (A) -- (B); \draw[foo-foo] (A) -- (C); \draw[foo-foo] (B) -- (C); \end{scope} \end{tikzpicture} \end{document} Then the output's arrow differs in different PDF-viewers: case1: PDF.js in LaTeXWorkshop case2: Edge browser case3: PDF-Xchange-Editor The abnormal arrow tip only shown with PDF-Xchange-Editor. Is this the PDF-viewer to be blamed, what caused this difference?

  • What package is being used to generate these 3d plots? and advice on how to efficiently produce similar figures without hand-drawing everything
    by userא0 on November 1, 2025 at 4:51 pm

    In the following 4800 pages long topology book one can see lots of images like this: At the moment I am writing a document (Using Lyx) in which I would like to include similar plots. Does anyone know what package is being used here? (ctrl+F -ing the documents makes my whole pc crash) Is this simply Tikz? From my experience (prior question of mine) generating such plots usually involves quite complicated calculations (to get the precise shape you want), so I would also love to get some advice on how to "make some shortcuts" if possible. In the linked book one can find (I would assume) hundreds of such (very complicated) figures, so I am very skeptical that the author "hand tailored" each and every one of them. Thank you!

  • pgfplots: declare function and parameters globally
    by PatrickT on November 1, 2025 at 12:11 am

    As I was intent on moving function declarations further up, so as to use them in multiple files, I noticed something unexpected. The first code plots a thin black line. The second code plots thick blue dots. I asked a well-known LLM and got a plausible explanation together with a hallucination. Do you have a suggestion to declare functions higher up while preserving the style? See a motivation further down. Example 1 \documentclass[border=3pt,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \tikzset{define functions/.style={% declare function={ A = 1.0; a = 0.5; f(\x) = A*\x^a; }, }, } \begin{document} \begin{tikzpicture} \begin{axis}[ domain=0:100, samples=100, ] \addplot[define functions] {f(x)}; \end{axis} \end{tikzpicture} \end{document} Example 2 \documentclass[border=3pt,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \tikzset{define functions/.style={% declare function={ A = 1.0; a = 0.5; f(\x) = A*\x^a; }, }, } \pgfplotsset{ every axis plot/.append style={define functions}, } \begin{document} \begin{tikzpicture} \begin{axis}[ domain=0:100, samples=100, ] % [define functions] not used here \addplot {f(x)}; \end{axis} \end{tikzpicture} \end{document} LLM talking now: Example 1 \addplot[define functions] {f(x)}; You explicitly attach the define functions style only to that plot. No other styles are affected. PGFPlots uses the default plot style, which is a thin black line (black, line width 0.4pt). Example 2 \pgfplotsset{every axis plot/.append style={define functions}} \addplot {f(x)}; You append the define functions style to every plot. But here’s the subtlety: every axis plot applies before the default plot style is applied, and declare function is a key that is not strictly separate from plotting keys. What happens internally: PGFPlots interprets your appended style as including both the function declaration and the style from the first plot in your style list. Because of key expansion order, the default line style is overridden. The plot falls back to the first "unknown" style PGFPlots sees for drawing, which is often the blue mark=* style (used for points), producing thick blue dots. Why this happens every axis plot is applied before \addplot options are merged. declare function is technically a "style key" in the PGFPlots system. PGFPlots sees a style (from every axis plot) that contains no explicit draw key, so it falls back to its default marker style (mark=*, thick, blue). When you attach [define functions] directly to \addplot, the default line style is preserved, so you get a thin black line. How to fix it You need to combine your define functions style with the standard line style: if you want to keep PGFPlots defaults but still append: \pgfplotsset{ every axis plot/.append style={define functions, /pgfplots/line} } Me speaking again: No this doesn't work and nor do the several other suggestions I received. Motivation: I would save different parameter values in distinct files and load them with, say \input{func1.tex}, so I can share code across multiple figures. The syntax used in declare function is natural, unlike an alternative like \pgfmathdeclarefunction{f}{1}{\pgfmathparse{1.0*#1^(0.5)}}. I'm not averse to trying something radically different from my current approach, including using LuaTeX or Python.

  • Including a Mathematica graphic within TikZ picture: aligning the origins
    by murray on October 30, 2025 at 8:13 pm

    I want to include a plot generated by Mathematica within a TikZ picture so that the origin (0,0) of the included plot is exactly at the TikZ origin (0,0). Here's how I create the Mathematica plot: SetOptions[$FrontEndSession, PrintingStyleEnvironment -> "Working"] cm = 72/2.54; parab = Plot[x^2/2, {x, 0, 3}, PlotRange -> {0, 4.5}, Ticks -> None, Axes -> True, AxesOrigin -> {0, 0}, AspectRatio -> Automatic, ImageSize -> 1 -> cm, Epilog -> {Purple, PointSize[Medium], Point[{1, 1/2}], Point[{2, 2}],Point[{3, 9/2}]}] Export["parabola.png", parab] Here is the exported .png (as was requested in a comment): And here is the LaTeX code where the Mathematica-generated graphic is imported and then the result of typesetting that LaTeX code: \documentclass{article} \usepackage{graphicx} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node[anchor= south west] at (0,0) {\includegraphics{parabola.png}}; \draw[dashed] (0,0) grid (4,5); \fill[red] (0,0) circle (0.1); % origin (0,0) from TikZ \end{tikzpicture} \end{document} The LaTeX output: Problem: The origin of the graphic inserted there does not match the origin in the TikZ picture. (This is the case even if I include in the Mathematica Plot command the options ImagePadding -> None, ImageMargins -> 0.) Rather, the graphic exported from Mathematica is shifted a bit upwards and rightwards so that its origin is no longer at the TikZ picture origin. So the question is whether there is some extra space to the left and bottom of the graphic being exported from Mathematica, on the one hand, or whether there is something I don't understand about placement of the import within the TikZ picture. Further information: Following a comment, I directly included the Mathematica-exported .png into a box with: \documentclass{article} \usepackage[top=0.1cm,left=0.1cm]{geometry} \usepackage{graphicx} \usepackage{tikz} \begin{document} \fboxsep=0pt \fbox{\includegraphics{parabola.png}} \end{document} And the result (ta-da!) as a .png (to allow import here) already shows the shifting of the origin (0,0) upwards and to the left of the lower-left corner: [![LaTeX boxed image from Mathematica export][3]][3] (I originally aksed about this in https://mathematica.stackexchange.com/questions/316827/make-graphics-units-exactly-1-cm but the answer proffered there does not resolve the issue.) The cure: in Mathematica! By changing the option Axes -> True to Axes -> None when generating the Mathematica graphic, I discovered that Mathematica is inserting extra space to the left of the y-axis and below the x-axis when those axes are actually drawn. For me, the solution, at least in this case, is to use Axes -> None; then the coordinate origin (0,0) is precisely at the lower-left corner of the graphic exported. Thank you to all those who suggested cures through TikZ or editing the exported graphic! [3]: https://i.sstatic.net/8MSy2nFT.png

  • Selectively Shift Axis Ticks in 3D Plot
    by Ludger on October 29, 2025 at 12:36 pm

    I am currently working on a 3D surface plot in which both x-, and y-axis are logarithmic. The issue I am facing and why I am posting is that the measurements are too close to each other, and I hence end up with overlapping axis ticks on the x-, and y-axis. Is there a good way to transform individual ticks, bet it an odd/even selection, or directly picking out individual ticks and then shifting them? Thank you for your help! \documentclass[crop,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.17} \usepgfplotslibrary{groupplots} \usepackage{xcolor} \begin{document} \begin{tikzpicture} % Ablation 1 (Linear System) \begin{axis}[ grid=major, tick align=outside, tick pos=left, view={210}{30}, xmin=0.0001, xmax=0.05, xmode=log, ymin=0.0001, ymax=0.0005, ymode=log, xtick={0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05}, xticklabels={$10^{-4}$, $5 \cdot 10^{-4}$, $10^{-3}$, $5 \cdot 10^{-3}$, $10^{-2}$, $5 \cdot 10^{-2}$}, ytick={0.0001, 0.0005}, yticklabels={$10^{-4}$, $5 \cdot 10^{-4}$}, ] \addplot3+ [mesh,scatter] table { 0.0001 0.0005 10 0.0001 0.0001 10 0.0005 0.0005 11 0.0005 0.0001 11 0.0010 0.0005 12 0.0010 0.0001 12 0.0050 0.0005 13 0.0050 0.0001 13 0.0100 0.0005 14 0.0100 0.0001 14 0.0500 0.0005 16 0.0500 0.0001 16 }; \end{axis} \end{tikzpicture} \end{document}

  • spath3: bridges at nodes (rather than intersections)
    by BGaraiko on October 29, 2025 at 8:51 am

    How can spath3 split a path at its coordinates? I have used spath3 to mark line intersections with an arc, but now I want the same arcs at the coordinates my line runs through. My understanding of the documentation is not sufficient to apply split at in a correct way. \documentclass[tikz]{standalone} \usetikzlibrary{spath3,intersections} \begin{document} \begin{tikzpicture} \path[nodes={circle,fill=red}] (-1.5,-.6) node(a) {a} (-.9, -.2) node(b) {b} (-1.5,1.5) node(c) {c} (-.3, .7) node(d) {d} (.5, 1.7) node(e) {e} (1.1, 1.1) node(f) {f} (.3, -.6) node(g) {g} (1.8, -.7) node(h) {h}; \path[spath/save=mainline] plot [smooth, tension=1] coordinates {(a) (b) (c) (d) (e) (f) (g) (h)}; \path[spath/save=arc] (0,0) arc[radius=1cm,start angle=180, delta angle=-180]; \tikzset{ % spath/split at intersections with={mainline}{???} spath/insert gaps after components={mainline}{5mm}, spath/join components with={mainline}{arc} } \draw[->,spath/use=mainline,line join=round]; \end{tikzpicture} \end{document}

  • Centering Loop in rectangle
    by Nick B on October 28, 2025 at 11:38 pm

    I am trying to create this image from Bryan Passwater. I can move my digits around, and would like the numbers to be centered (same distance from border on each side (see image). Is there a better way to make this? \documentclass{article} \usepackage{parskip,fullpage,hyperref} \usepackage{tikz} \usetikzlibrary{positioning,arrows.meta} \usetikzlibrary{backgrounds} %<- New Today \title{Drawing in the Background Using TiKZ} \author{\href{https://www.youtube.com/@UnlockingLaTeXGraphics}{@UnlockingLaTeXGraphics}} \date{} \begin{document} \begin{tikzpicture}[font=\Huge] % box (width 14, height 2) \draw (0,0) rectangle (14,2); % digits 0..9, evenly spaced from x=1 to x=13 at mid-height y=1.5 \foreach \n in {0,...,9} \node[align=center] at ({1 + 1.32*\n}, 1) {\n}; \end{tikzpicture} \end{document}

  • How do I make a quantum circuit with parititioned maximally entangled states?
    by jrobins on October 28, 2025 at 6:24 pm

    I want to make a quantum circuit (with possibly quantikz) that starts in a maximally entangled state for which each tensor factor is partitioned. That is, I want to replicate some of the quantum circuits as below (from https://arxiv.org/abs/1911.06314, p26): I know quantikz has the command \makeebit[s]{l} (p13), but it seems like it's only possible to use it for the lines connecting Br and Bl on the right hand side, not both and not either side. I am looking for a way to at least replicate the right side of the figure, preferably also the left side and preferably using a package. Is that possible? A satisfactory answer would be: some command like \eebit that generates the drawn line as in the 'desired outcome' some alternative tensor graphing package that does the job I'd greatly appreciate your considerations and thanks in advance. MWE \documentclass[border=2mm]{standalone} \usepackage{tikz} \usetikzlibrary{quantikz2} \input{preamble} \begin{document} \begin{quantikz} &\\ \makeebit[angle=-20]{$\ket{\text{epr}}$} &\\ &\\ & \end{quantikz} \end{document} outcome MWE vs desired outcome

  • Is it possile to make smaller half lefts in Feynman-Tikz?
    by DominikSz on October 20, 2025 at 5:52 pm

    I'm attempting to recreate the below diagrams using the feynman-tikz package. I've attempted the below code, \begin{subfigure}{0.4\textwidth} \centering \feynmandiagram[layered layout, horizontal = a to b]{ a -- [fermion] d -- [fermion, edge label =$e^-$] c -- [fermion] b, d -- [photon, half left, edge label =$\gamma$] c, }; \caption{An electron emits a photon which is then reabsorbed.} \end{subfigure} \begin{subfigure}{0.4\textwidth} \centering \feynmandiagram[horizontal = a to b]{ a -- [fermion] d -- [fermion, edge label=$e^-$] c -- [fermion] b, d -- [photon, quarter left, edge label=$\gamma$] e -- [fermion, half left=0.5cm, edge label=$e^-$] f -- [fermion, half left=0.1cm, edge label=$e^+$] e, f -- [photon, half left] c, }; \caption{Vacuum polarisation.} \label{fig:polarisation} \end{subfigure} however, my diagram (b) looks less than ideal, as shown below. Is there a way to make the latex diagram look more like the drawn one without having to resort to specifying vertices manually? Thanks.

  • TikZ ellipse with arrows
    by Aendie on October 15, 2025 at 6:58 pm

    What is the simplest solution to draw an ellipse with dashes, only each dash has an arrowhead (either clockwise or anticlockwise)? I struggled to create this solution with anti-clockwise arrows. I had to draw the ellipse backwards (clockwise) so that each "arrow" begins with the tip (arrowhead) followed by the stem. I note that the dashes are curved, correctly following the ellipse, however the arrowheads are incorrectly slanted at the left and right ends of the ellipse. This is a minor "deficiency" but I think TikZ is nigh to perfection when it comes to graphing. So I guess I am just doing it wrong. I found no question that answers this (although one was close). Here is the relevant MWE code: \documentclass[10pt, twoside, a4paper]{report} \usepackage[utf8x]{inputenc} \usepackage[ top=21mm, bottom=21mm, left=12mm, right=8mm]{geometry} \usepackage{tikz} \usetikzlibrary{decorations.markings} \begin{document} \thispagestyle{empty} % no page number \begin{tikzpicture}[decoration={markings,% switch on markings mark=% actually add a mark between positions 0 and 16cm step 30 pt with { \draw (4pt,-4pt) -- (0,0); \draw (4pt,4pt) -- (0,0); } } ] \draw[postaction=decorate,thick,dash pattern=on 20pt off 10pt,x radius=3.9cm,y radius=-0.975cm] (3.9cm,0) ellipse; \end{tikzpicture} \end{document} and it produces this diagram: Correction: I think the arrowheads are correctly slanted. But my solution is cumbersome to create ... is there an easier syntax? Reference: page 645 in pgfmanual version 3.1.10 Note: for clockwise arrows you only need to make y radius positive y radius=0.975cm

  • Strange brace positions in Tikz and adding texts at the bottom
    by user37891 on May 22, 2025 at 11:32 am

    I made this flow chart template in draw.io and would like to replicate this in Tikz to make it prettier. My current code (see below) can't seem to work right as the top brace keeps floating around, can't be put in the correct position. Will really appreciate if someone could point out the error and fix my code. \documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning, shapes, decorations.pathreplacing, calc} \begin{document} \begin{tikzpicture}[ every node/.style={font=\sffamily}, box/.style={draw, rounded corners, align=center, minimum width=3.3cm, minimum height=1cm, fill=gray!10}, level 1/.style={sibling distance=6cm}, level 2/.style={sibling distance=4cm}, level 3/.style={sibling distance=3.5cm}, edge from parent/.style={draw, thick}, edge from parent path={(\tikzparentnode.south) -- ++(0,-5pt) -| (\tikzchildnode.north)} ] % Tree structure \node[draw=none] {} child { node[box] (group1) {Group 1} child { node[box] (cme1) {A} child { node[box] {D} child { node[box] {C} } } } child { node[box] (group2) {group 2} child { node[box] (cme2) {A} child { node[box] {B} } } }; % Add a brace over Group 1 and Group 2 \path (group1.north west) ++(-0.3,0.4) coordinate (braceleft); \path (group2.north east) ++(0.3,0.4) coordinate (braceright); \draw [decorate, decoration={brace, amplitude=6pt}, thick] (braceleft) -- (braceright); \end{tikzpicture} \end{document}

  • Tikz 3D-Graphic; background, foreground, intersections
    by Mika on January 1, 2025 at 4:36 pm

    I need to draw something like this in Tikz. My problem is that the edges crossing in the back have to stop at every intersection... I already saw some examples using \usetikzlibrary{cd} \tikzcdset{3d cd/.style={/tikz/every odd row/.append style={xshift={#1}}}} But as I don´t want to draw a diagram, it seems to be the wrong way for me... This the code I used to draw the picture, but I´m very sure it´s way too complicated =) As I am realle new to Tikz, I´d be very thankful for any help =) \documentclass{article} \usepackage{tikz} \usetikzlibrary{patterns} \usetikzlibrary{calc} \usepackage[active,tightpage]{preview} \PreviewEnvironment{tikzpicture} \setlength\PreviewBorder{10pt}% \usetikzlibrary{intersections} \usepackage{tkz-euclide} \usetikzlibrary{3d} \usepackage{tikz-3dplot} \begin{document} \tdplotsetmaincoords{60}{120} % Radius intersection \def\radius{1.mm} \begin{tikzpicture}[tdplot_main_coords, scale=1.5] %XYZ \path[->] (0,0,0) -- (10,0,0) node[anchor=north east] {$x$}; \path[->] (0,0,0) -- (0,10,0) node[anchor=north west] {$y$}; \path[->] (0,0,0) -- (0,0,10) node[anchor=south] {$z$}; %Corners \coordinate (1) at (0,0,0); \coordinate (2) at (0,8,0); \coordinate (3) at (0,8,7); \coordinate (4) at (0,0,7); \coordinate (5) at (5,0,0); \coordinate (6) at (5,8,0); \coordinate (7) at (5,8,7); \coordinate (8) at (5,0,7); \coordinate (9) at (2.5,6,9); \coordinate (10) at (2.5,2,9); \draw [name path=front] (5) -- (6) -- (7) -- (8) -- cycle; \path[name path=back] (1) -- (2) -- (3) -- (4) -- cycle; \path[name path=uL] (1) -- (5); \path[name path=uR] (2) -- (6); \path[name path=oR] (3) -- (7); \path[name path=oL] (4) -- (8); \path[name path=DhL] (4) -- (10); \path[name path=DvL] (8) -- (10); \path[name path=DhR] (3) -- (9); \path[name path=DvR] (7) -- (9); \path[name path=Do] (9) -- (10); \path [name intersections={of = front and back}]; \coordinate (i) at (intersection-1); \coordinate (ii) at (intersection-2); \path [name intersections={of = DvL and back}]; \coordinate (iii) at (intersection-1); % circle around intersection \path[name path=circle1] (i) circle(\radius); \path [name intersections={of = circle1 and back}]; \coordinate (i1) at (intersection-1); \coordinate (i2) at (intersection-2); %bottom; y-axis; hidden \draw [dashed] (1) -- (i1); \draw [dashed](2) -- (i2); \path[name path=circle2] (ii) circle(\radius); \path [name intersections={of = circle2 and back}]; \coordinate (i3) at (intersection-1); \coordinate (i4) at (intersection-2); \path[name path=circle3] (iii) circle(\radius); \path [name intersections={of = circle3 and back}]; \coordinate (i5) at (intersection-1); \coordinate (i6) at (intersection-2); %roof \draw (4) -- (10); \draw(8) -- (10); \draw (3) -- (9); \draw (7) -- (9); \draw (9) -- (10); %front -> back; visible \draw (2) -- (6); %bottom right \draw (3) -- (7); %top right \draw (4) -- (8); %top left %back visible \draw (2) -- (3); %back hidden \path [name path = oH, dashed](3) -- (i6); \draw [dashed](4) -- (i5); \path [name path=Hl] (4) -- (i3); \path [name intersections={of = Hl and DvL}]; \coordinate (4i) at (intersection-1); \path[name path=circle4] (4i) circle(\radius); \path [name intersections={of = circle4 and Hl}]; \coordinate (i7) at (intersection-1); \coordinate (i8) at (intersection-2); \path [name intersections={of = oH and DvR}]; \coordinate (5i) at (intersection-1); \path[name path=circle5] (5i) circle(\radius); \path [name intersections={of = circle5 and oH}]; \coordinate (i9) at (intersection-1); \coordinate (i10) at (intersection-2); %back top \draw [dashed](3) -- (i10); \draw [dashed](i6) -- (i9); %left; z-axis; hidden \draw [dashed](4) -- (i7); \draw [dashed](i3) -- (i8); \draw [dashed](1) -- (i4); %left; x-axis; hidden \draw [dashed](1) -- (5); %draw visible parts XYZ \draw[->] (5,0,0) -- (10,0,0) node[anchor=north east] {$x$}; \draw[->] (2) -- (0,10,0) node[anchor=north west] {$y$}; \draw[->] (0,0,7) -- (0,0,10) node[anchor=south] {$z$}; \draw(0,0,0) node[anchor=east] {O}; \end{tikzpicture} \end{document}

  • Code Highlighting in tikzposter
    by ghxk on November 19, 2023 at 11:32 am

    I am doing a poster and I would like to show some programming code. With the package \begin{minted}{python}.....\end{minted} there is a beautiful code highlighting but it doesn't work in tikzposter. How could I highlight the code? \documentclass[25pt, a0paper, portrait]{tikzposter} \title{Mandelbrotmengen und Juliamengen} \author{Fachschaften Mathematik und Informatik} \usepackage{blindtext} \usepackage{comment} \usepackage{minted} \usetheme{Board} \begin{document} \maketitle \block{Mandelbrotmengen} { Die \textbf{Mandelbrotmenge}, benannt nach Benoit Mandelbrot, ist die Menge der komplexen Zahlen $c$, für welche die durch die iterative Vorschrift $z_{n+1} = z_{n}^2+c$ mit dem Anfangswert $z_0 = 0$ definierte Folge $z_0, z_1, z_2, z_3,...$ endlich bleibt, d.h. beschränkt ist. Interpretiert man die Mandelbrot-Menge (eine Teilmenge der Gaußschen Zahlenebenen) als geometrische Figur, so ergibt sie ein Fraktal, das im allgemeinen Sprachgebrauch oft Apfelmännchen genannt wird. Bilder berechnet man, indem man jedem Pixel $(x,y)$ eines Bildes eine komplexe Zahl zuordnet und beginnend mit $z_0 =0$ untersucht, ob und wann die Iterationen anfangen, zu „explodieren“. Bleiben die Werte klein, wird das Pixel häufig schwarz gefärbt, kommt es zu einer „Explosion“ der Zahlenwerte, wird die Anzahl der dafür notwendigen Iterationen als Farbe kodiert. \begin{tikzfigure} \includegraphics[width=0.5\textwidth]{pics/madelbrot.png} \end{tikzfigure} Die ersten mit einem Computer generierten Darstellungen wurden 1978 von Robert W. Brooks und Peter Matelski vorgestellt. 1980 veröffentlichte Benoît Mandelbrot eine Arbeit über das Thema. Später wurde sie von Adrien Douady und John Hamal Hubbard in einer Reihe grundlegender mathematischer Arbeiten systematisch untersucht. Die mathematischen Grundlagen dafür wurden bereits 1905 von dem französischen Mathematiker Pierre Fatou erarbeitet. } \block{Juliamengen} { Die \textbf{Julia-Mengen}, erstmals von Gaston Maurice Julia und Pierre Fatou beschrieben, sind Teilmengen der komplexen Zahlenebene, wobei zu jeder holomorphen oder meromorphen Funktion eine Julia-Menge gehört. Oft sind die Julia-Mengen fraktale Mengen. Das Komplement der Julia-Menge heißt Fatou-Menge.\\ Wendet man eine auf ganz $\mathbb{C}$ definierte Funktion $f$ immer wieder auf ihre Funktionswerte an, dann ergibt sich für jedes $z$ eine Folge komplexer Zahlen: \begin{center} $ z \mapsto f(z) \mapsto f(f(z)) \mapsto ...$ \end{center} \begin{tikzfigure} \includegraphics[width=0.4\textwidth, auto=left]{pics/Julia-Set_z2+c_-1_0.png} %\caption{Julia - Menge für $z \mapsto z^2-1$} \includegraphics[width=0.4\textwidth, auto=right]{pics/Julia-Set_z2+c_-0.6_0.6.png} %\caption{Julia - Menge für $z \mapsto z^2 -0.6 + 0.6i$} \end{tikzfigure} Die ersten mit einem Computer generierten Darstellungen wurden 1978 von Robert W. Brooks und Peter Matelski vorgestellt. 1980 veröffentlichte Benoît Mandelbrot eine Arbeit über das Thema. Später wurde sie von Adrien Douady und John Hamal Hubbard in einer Reihe grundlegender mathematischer Arbeiten systematisch untersucht. Die mathematischen Grundlagen dafür wurden bereits 1905 von dem französischen Mathematiker Pierre Fatou erarbeitet. } \end{document}

  • Same style for child as parent in tree
    by Junglemath on March 15, 2023 at 8:26 pm

    I am trying to create a tree in which the child nodes have the same appearance as their parent but I keep getting an unknown error when adding a child and attempting to use the same style: \PassOptionsToPackage{x11names}{xcolor} \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} [nonLeaf/.style n args={4}{minimum size=8mm, draw, line width=3pt, draw=MediumPurple3, fill=yellow, text=Blue4, rectangle, label={[align=left, xshift=-5pt]left:{$\alpha:#1$\\$\beta:#2$}}, label={[align=left]right:{$\alpha:#3$\\$\beta:#4$}}}, every child node/.style={nonLeaf}] \node[nonLeaf={1}{2}{3}{4}]{19}; %child{node[nonleaf={5}{6}{7}{8}]{25}} <----- problem \end{tikzpicture} \end{document}

  • level distance not working consistently
    by mk9y on July 28, 2021 at 6:22 pm

    The present question is a continuation of this one, and relies on answers given there. Here is the code that generates the image below. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary {calc, graphs, graphdrawing} \usegdlibrary {trees} \usegdlibrary{layered} \begin{document} \begin{tikzpicture}[ > = stealth, every node/.append style = {font = \sf\vphantom{gf}}, connect/.style = {to path = {(\tikztostart) -- ($(\tikztostart)!.5!(\tikztostart |- \tikztotarget)$) -| (\tikztotarget)}}, connectEffects/.style = {to path = {(\tikztostart) -- node[pos = 0.5, fill = white]{effects} ($(\tikztostart)!.65!(\tikztostart |- \tikztotarget)$) -| (\tikztotarget)}}, connectSubjects/.style = {to path = {(\tikztostart) -- node[pos = 0.5, fill = white]{subjects} ($(\tikztostart)!.65!(\tikztostart |- \tikztotarget)$) -| (\tikztotarget)}}, connectFactors/.style = {to path = {(\tikztostart) -- node[pos = 0.5, fill = white]{block factors} ($(\tikztostart)!.65!(\tikztostart |- \tikztotarget)$) -| (\tikztotarget)}}, connectSize/.style = {to path = {(\tikztostart) -- node[pos = 0.5, fill = white]{block size} ($(\tikztostart)!.65!(\tikztostart |- \tikztotarget)$) -| (\tikztotarget)}}, ] \graph [ layered layout, nodes = {draw, fill = white}, edge quotes = {fill = white}, level 1/.style = {level distance = 1.5 cm}, level 2/.style = {level distance = 1.5 cm}, level 3/.style = {level distance = 1.5 cm}, level 4/.style = {level distance = 1.5 cm}, level 5/.style = {level distance = 0.75 cm}, level 6/.style = {level distance = 0.75 cm}, level 7/.style = {level distance = 0.75 cm}, level 8/.style = {level distance = 0.75 cm}, sibling distance = 2 cm ]{ experiment ->[connectEffects] { fixed ->[connectSubjects] { homogeneous -> [minimum layers = 4] CRD -> CRFD -> CRSP, heterogeneous ->[connectFactors] { one ->[connectSize] { large -> { RCB -> GCB -> RCBF -> RBSP }, small -> PBIB or BTIB -> BIB }, two -> [minimum layers = 2] LSD } }, mixed } }; \end{tikzpicture} \end{document} I want to make the distance between levels 1.5 cm until level 5, and then switch to 0.75 cm. This seems to fail after level 6. A subsidiary question: I would like to make the code that defines the four connectors connectEffects/.style = ... more general and concise.

  • 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}

  • Making a tree where some nodes contain node objects
    by Akash Kumar on February 19, 2021 at 11:06 am

    I want to create a tree using tikz. However, I have a few constraints. Most of the nodes at all the levels are standard usual nodes. However, I want to have the following at some level (say level 3) in this tree: All nodes at this level should be drawn bigger (perhaps elliptical). Moreover, I also want each of these big nodes to contain some dots. In the picture below, I mark these dots in purple. There is a "home" node for these purple dots where most of them live. And a few of these purple dots appear in other nodes at this level. I can add the tikz code I obtained from online sources to create trees, but it is pretty bare-bones. Please let me know if that would be helpful in getting help with this question. EDIT (Added Later) Here are some variations that I tried so far on overleaf. Mostly, it revolves around attempts to define some new node objects. But then the picture I end up with is not particularly nice. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amsthm} \usepackage{algorithm} \usepackage{algorithmicx} \usepackage{subcaption} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing} \usetikzlibrary{decorations.markings} \usetikzlibrary{shapes.gates.logic.US,trees,positioning,arrows} \tikzset{ standard/.style = {circle, white, draw=black, inner sep = 1.5}, containerNode/.style={circle, draw=black, minimum size=1cm, node contents=\draw \Huge $\dots$ $\dots$ $\dots$}, } \begin{document} \begin{figure*}[t!] \centering \scalebox{.6}{ \begin{tikzpicture}[level/.style={sibling distance=60mm/#1,level distance = 2cm}] \node [standard] (z){} child {node [standard] {}edge from parent [draw=black, very thin] child {node [standard] {}edge from parent [draw=black,very thin] child {node [standard] {}edge from parent [draw=black,very thin]} child {node [standard] {}edge from parent [draw=black,very thin]} } child {node [standard] {}edge from parent [draw=black, very thin] child {node [containerNode] (a) {}edge from parent [draw=black, very thin] child {node [standard] (x) {}edge from parent[draw=black, very thin]} child {node [standard] (y) {}edge from parent[draw=black, very thin]} } child {node [standard] {}edge from parent [draw=black,very thin]} } } child { node [standard] {} edge from parent [draw=black, very thin] child {node [standard] {}edge from parent [draw=black, very thin] child {node [standard] {}edge from parent [draw=black,very thin] } child {node [standard] (b) {}edge from parent [draw=black, very thin]} } child {node [standard] {}edge from parent [draw=black, very thin] child {node [standard] (c){}edge from parent [draw=black, very thin]} child {node [standard] {} edge from parent [draw=black,very thin]} } }; \end{tikzpicture} } \end{figure*} \end{document} The image generated on overleaf is shown below. Apologies for the huge delay in adding the edits.

  • How to draw 3d matrix using tikz
    by Tgy Aldeen Abdo on November 12, 2019 at 4:16 am

    i want to draw a matrix like the pic below, i just don't know how to do it?

  • How to display a Tikz Flowcharts properly in a RTL Beamer document
    by Abdelhak Elfengour on March 26, 2019 at 4:37 pm

    \documentclass[hyperref=unicode]{beamer} \usepackage{hologo} \mode<presentation>{\usetheme{Warsaw}} \usepackage[nil,bidi=basic-r]{babel} \babelprovide[import=ar-DZ, main]{arabic} \babelprovide[import,language=Default]{english} \babelfont{rm}{Amiri} \babelfont{sf}{Amiri} \usepackage{beamer-rl} \usepackage{tikz}% \usetikzlibrary{shapes.geometric, arrows} \begin{document} \begin{frame} \tikzstyle{block} = [rectangle, draw, fill=blue!20, text width=4em, text centered, rounded corners, minimum height=3em] \tikzstyle{line} = [draw, -latex'] \begin{tikzpicture}[node distance = 2.6cm, auto] \node [block] (init) {start}; \node [block, left of=init] (Start2) {test}; \node [block, left of=Start2] (Start3) {test2}; \node [block, below of=init] (init3) {process}; \node [block, below of=init3] (End) {end}; \node [block, left of=init3] (End1) {end1}; \node [block, left of=End] (End2) {end2}; \path [line] (init) -- (Start2); \path [line] (init3) -- (End1); \path [line] (End) -- (End2); \end{tikzpicture} \end{frame} \end{document}

  • Is there a standard way to represent the file tree in a rather elaborate code?
    by Eugenio on February 11, 2017 at 8:19 am

    I've got a program which is split into some files located in two main folders, src and include, with the header .h files in the include folder while .cpp and .cu files in the other. Here is a little drawing for the whole routine Note#1 this is not exactly what I want to achieve but it may be a starting point. Note#2 here you can find the meaning of the word routine, but here I mean just a complex application split into multiple files. Is there a standard way to represent the tree of the files which a program is composed of? I mean the file tree, along with the folders tree. I'm looking for some solution to even add some of the relations within the files with some arrows. I'd like to use tikz if possible. Right now this is my poor, far-to-be-optimized tikz image I realized: \documentclass[]{standalone} \usepackage{tikz} \usetikzlibrary{arrows,positioning} \usetikzlibrary{calc} \tikzset{ %Define standard arrow tip >=stealth', pil/.style={ ->, thick, shorten <=2pt, shorten >=2pt,}, gpufile/.style={ rectangle, rounded corners, draw=red, very thick, minimum height=2em, minimum width=8em, text centered }, cpufile/.style={ rectangle, rounded corners, draw=black, thick, minimum height=2em, text centered }, header/.style={ rectangle, draw=gray, thin, minimum height=2em, minimum width=5em, text centered }, folder/.style={ rectangle, draw=yellow, thin, minimum height=3em, minimum width=5em, text centered } } \begin{document} \begin{tikzpicture}[node distance=1.5cm, auto,] \tikzstyle{every path}=[-latex,thick] \node[ folder, xshift=-2cm] (src) {src}; \node[ cpufile, right of=src, xshift=40pt] (main) {\texttt{main.cpp}}; \node[ gpufile, right of=main, xshift=40pt, yshift=0pt] (trbdf2) {\texttt{tr-bdf2.cu}} ; \node[ gpufile, right of=trbdf2, xshift=40pt, yshift=0cm ] (jacobian) {\texttt{jacobian.cu}}; \node[ gpufile, right of=jacobian, xshift=60pt ] (inversion) {\texttt{matrix\_inversion.cu}}; \node[ gpufile, right of=inversion, xshift=60pt] (tr) {\texttt{newton\char`_tr.cu}}; \node[ gpufile, right of=tr, xshift=60pt] (bdf2) {\texttt{newton\char`_bdf2.cu}}; \node[ folder, below of=src, yshift=-1cm] (include) {include}; \node[ header, right of=include, xshift=40pt] (libs) {\texttt{libs.h}}; \node[ header, right of=libs, xshift=40pt] (constants) {\texttt{constants.h}}; \node[ header, right of=constants, xshift=40pt] (fdefs) {\texttt{functions\char`_defs.h}}; \node[ header, right of=fdefs, xshift=40pt] (defs) {\texttt{defs.h}}; \node[ header, right of=defs, xshift=40pt] (linsolver) {\texttt{linear\char`_solver.h}}; ; \end{tikzpicture} \end{document} I need to highlight .cu files in the project, they have a different meaning from the clasic .cpp files. While sliding through the tikz library samples the closest I found to what I mean is this example, which is recommended just for a filesystem directory tree though.

  • How to make add tick to node in tikz
    by user2249626 on September 12, 2013 at 12:58 pm

    I'm trying to draw a simple timeline in tikz. Here's what I have: \documentclass[12pt,a4paper,bibtotoc]{scrartcl} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[ngerman]{babel} \usepackage{microtype} \usepackage{tikz} \begin{document} Ablauf der Schadenregulierung bei einem typischen Schadenfall \\ \\ % Zeitstrahl zur Schadenregulierung \begin{tikzpicture} \draw[black, ultra thick, ->] (0,0) -- (2,0) node [below]{Schadeneintritt} --(14,0); \end{tikzpicture} \end{document} What I would like is for there to be a tick on the line at node "Schadeneintritt". I've tried adding tick to the options of the node but that produces an error (apparently tickz doesn't know the tick option). I'm still new to tikz and so far I've only found solutions for full blown axes / coordinate systems. I know that I could do: \draw (2,0.2) -- (2,-0.2); but I wonder whether there's an easier solution (i.e. specifying this directly at the node). Cheers!

  • Work breakdown structure (WBS) TikZ
    by ABu on November 7, 2012 at 3:30 pm

    How can I draw WBS diagrams (Work breakdown structures) in LaTeX? I need to draw in LaTeX things like: I've searched on the Internet a lot but I've found nothing.