• TikZ forest: custom vdots keys overrides custom l sep and s sep keyvals
    by Grass on February 15, 2026 at 3:12 am

    The Problem From cfr's answer to my previous question, I managed to draw nice vdots in my forest tree. But now for tree={ s sep=1cm, % example of 1cm for illustrative purposes; you probably wouldn't want it to be so big l sep=1cm }, fails to be applied across the entire tree: Attempt(s) To Fix Said Problem I tried messing with before computing xy={% l'=0pt, s'=-15pt, % length of vdots }, but it didn't really work. What Help I need I've only had very modest experience with forest so I'm having trouble deducing how to modifiy cfr's code, such that the keyvals s sep and l sep work correctly. Thus, it would be nice if someone was able to help me out with this. MWE: % Source - https://tex.stackexchange.com/a/755401 % Posted by cfr, modified by community. See post 'Timeline' for change history % Retrieved 2026-02-14, License - CC BY-SA 4.0 \documentclass[border=10pt,multi,tikz]{standalone} % ateb: https://tex.stackexchange.com/a/754955/ % ateb: https://tex.stackexchange.com/a/755401/ \usepackage[edges]{forest} \usetikzlibrary{calc} \definecolor{folderbg}{RGB}{124,166,198} \definecolor{folderborder}{RGB}{110,144,169} \newlength\Size \setlength\Size{4pt} \tikzset{% folder/.pic={% \draw [draw=folderborder, sharp corners, top color=folderbg!50, bottom color=folderbg ] (-1.05*\Size,0.2\Size+5pt) rectangle ++(.75*\Size,-0.2\Size-5pt); \draw [draw=folderborder, sharp corners, top color=folderbg!50, bottom color=folderbg ] (-1.15*\Size,-\Size) rectangle (1.15*\Size,\Size); }, file/.pic={% \filldraw [draw=folderborder, sharp corners, top color=folderbg!5, bottom color=folderbg!10] (-\Size,.4*\Size+5pt) coordinate (a) |- (\Size,-1.2*\Size) coordinate (b) -- ++(0,1.6*\Size) coordinate (c) -- ++(-5pt,5pt) coordinate (d) -- cycle (d) |- (c) ; }, } \forestset{% declare autowrapped toks={pic me}{}, declare boolean register={pic root}, pic root=0, declare keylist={additional edge options}{}, pic dir tree/.style={% for tree={% folder, font=\ttfamily, grow'=0, }, before typesetting nodes={% for tree={% edge label+/.option={pic me}, }, if pic root={ tikz+={ \pic at ([xshift=\Size].west) {folder}; }, align={l} }{}, }, }, pic me set/.code n args=2{% \forestset{% #1/.style={% inner xsep=2\Size, pic me={pic {#2}}, } } }, pic me set={directory}{folder}, pic me set={file}{file}, } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %===========================================% \makeatletter \def\dirtree@dot@radius{0.5pt} \def\dirtree@vdots@length{5pt} \forestset{% declare toks={real siblings}{}, continue/.style={% delay={% if n children=0{% before computing xy={% for current and following siblings={% s'+=-10pt, }, }, if n=1{% edge path'={% (!u.parent anchor) ++(\foresteregister{folder indent},0pt) coordinate (a) -- ($(!u.parent anchor -| a)!1/3!(.child anchor -| a)$) edge [dotted] ($(!u.parent anchor -| a)!2/3!(.child anchor -| a)$) ($(!u.parent anchor -| a)!2/3!(.child anchor -| a)$) |- (.child anchor) }, }{% edge path'={% (!u.parent anchor |- !p.child anchor) ++(\foresteregister{folder indent},0pt) coordinate (a) -- ($(!p.child anchor -| a)!1/3!(.child anchor -| a)$) edge [dotted] ($(!p.child anchor -| a)!2/3!(.child anchor -| a)$) ($(!p.child anchor -| a)!2/3!(.child anchor -| a)$) |- (.child anchor) }, }, for following siblings={% edge path'={% (!u.parent anchor |- !p.child anchor) ++(\foresteregister{folder indent},0pt) |- (.child anchor) }, }, }{% prepend={[\strut, delay={% do dynamics, temptoksa=, for following siblings={% if temptoksa={}{}{% temptoksa+={,}, }, temptoksa+/.option=name, }, real siblings/.register=temptoksa, folder, grow'=0, before computing xy={% l'=0pt, s'=-\dirtree@vdots@length, % length of vdots }, delay n=2{% split option={real siblings}{,}{append}, }, before typesetting nodes={% temptoksa/.option=name, delay={ do dynamics, for children={ if n=1{ edge path'={% (!uu.parent anchor) ++(\foresteregister{folder indent},0pt) coordinate (a) -- ($($(a)!1/2!(.child anchor -| a)$)+0.5*(0,\dirtree@vdots@length)$) coordinate (A\foresteoption{id}) % ($($(a)!1/2!(.child anchor -| a)$)-0.5*(0,\dirtree@vdots@length)$) coordinate (B\foresteoption{id}) |- (.child anchor)% }, tikz+={ \coordinate (A') at ($(A\foresteoption{id})+(0,\dirtree@dot@radius)$); \coordinate (B') at ($(B\foresteoption{id})-(0,\dirtree@dot@radius)$); \coordinate (C) at ($0.25*($(B')-(A')$)$); \fill ($(A')+(C)$) circle (\dirtree@dot@radius); \fill ($(A')+2*(C)$) circle (\dirtree@dot@radius); \fill ($(A')+3*(C)$) circle (\dirtree@dot@radius); }, }{ edge path'={% (!uu.parent anchor) ++(\foresteregister{folder indent},0pt) coordinate (a) (a |- !p.child anchor) |- (.child anchor) }, }, }, }, }, }, no edge, ]}, }, }, }, to be continued/.style={% delay={% append={[\strut, folder, grow'=0, before computing xy={% l'=0pt, s'=0pt, }, if n children=0{% before drawing tree={% delay={% y/.min={>O{y}}{parent,descendants}, }, }, }{}, edge path'={% (!uu.parent anchor |- !u.child anchor) ++(\foresteregister{folder indent},0pt) coordinate (a) -- (.parent anchor -| a) coordinate (A\foresteoption{id}) % ([yshift=-\dirtree@vdots@length]% length of vdots A\foresteoption{id}) coordinate (B\foresteoption{id}) }, tikz+={ \coordinate (A') at ($(A\foresteoption{id})+(0,\dirtree@dot@radius)$); \coordinate (B') at ($(B\foresteoption{id})-(0,\dirtree@dot@radius)$); \coordinate (C) at ($0.25*($(B')-(A')$)$); \fill ($(A')+(C)$) circle (\dirtree@dot@radius); \fill ($(A')+2*(C)$) circle (\dirtree@dot@radius); \fill ($(A')+3*(C)$) circle (\dirtree@dot@radius); }, ]}, }, }, } \makeatother %===========================================% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} \begin{forest} pic dir tree, pic root, for tree={% folder icons by default; override using file for file icons directory, s sep=1cm, l sep=1cm }, [system [config ] [lib [file.txt, file ] ] ] \end{forest} \begin{forest} pic dir tree, pic root, for tree={% folder icons by default; override using file for file icons directory, s sep=1cm, l sep=1cm }, [system, continue [config ] [lib, to be continued [file.txt, file, to be continued ] ] ] \end{forest} \end{document}

  • TikZ forest: evenly spaced vertical dots in directory tree
    by Grass on February 14, 2026 at 3:10 pm

    I modified cfr's previous answer to draw three evenly spaced vertical dots. A sketch of the desired look is as follows, where the blue line is imaginary (only there for illustrative purposes) and should not be actually drawn by TikZ. But, only one set of my custom vdots are drawn by TikZ. Any idea how to fix this? I tried appending the node names (e.g. (A)) with a counter ((A \the<counter_name>)) that is incremented with each invocation of vdots. But that didn't seem to work at all. MWE: % Source - https://tex.stackexchange.com/a/755401 % Posted by cfr, modified by community. See post 'Timeline' for change history % Retrieved 2026-02-14, License - CC BY-SA 4.0 \documentclass[border=10pt,multi,tikz]{standalone} % ateb: https://tex.stackexchange.com/a/754955/ % ateb: https://tex.stackexchange.com/a/755401/ \usepackage[edges]{forest} \usetikzlibrary{calc} \definecolor{folderbg}{RGB}{124,166,198} \definecolor{folderborder}{RGB}{110,144,169} \newlength\Size \setlength\Size{4pt} \tikzset{% folder/.pic={% \draw [draw=folderborder, sharp corners, top color=folderbg!50, bottom color=folderbg ] (-1.05*\Size,0.2\Size+5pt) rectangle ++(.75*\Size,-0.2\Size-5pt); \draw [draw=folderborder, sharp corners, top color=folderbg!50, bottom color=folderbg ] (-1.15*\Size,-\Size) rectangle (1.15*\Size,\Size); }, file/.pic={% \filldraw [draw=folderborder, sharp corners, top color=folderbg!5, bottom color=folderbg!10] (-\Size,.4*\Size+5pt) coordinate (a) |- (\Size,-1.2*\Size) coordinate (b) -- ++(0,1.6*\Size) coordinate (c) -- ++(-5pt,5pt) coordinate (d) -- cycle (d) |- (c) ; }, } \forestset{% declare autowrapped toks={pic me}{}, declare boolean register={pic root}, pic root=0, declare keylist={additional edge options}{}, pic dir tree/.style={% for tree={% folder, font=\ttfamily, grow'=0, }, before typesetting nodes={% for tree={% edge label+/.option={pic me}, }, if pic root={ tikz+={ \pic at ([xshift=\Size].west) {folder}; }, align={l} }{}, }, }, pic me set/.code n args=2{% \forestset{% #1/.style={% inner xsep=2\Size, pic me={pic {#2}}, } } }, pic me set={directory}{folder}, pic me set={file}{file}, } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %===========================================% \makeatletter \def\dirtree@dot@radius{1pt} \forestset{% declare toks={real siblings}{}, vdots@root/.style={% delay={% if n children=0{% before computing xy={% for current and following siblings={% s'+=-10pt, }, }, if n=1{% edge path'={% (!u.parent anchor) ++(\foresteregister{folder indent},0pt) coordinate (a) -- ($(!u.parent anchor -| a)!1/3!(.child anchor -| a)$) edge [dotted] ($(!u.parent anchor -| a)!2/3!(.child anchor -| a)$) ($(!u.parent anchor -| a)!2/3!(.child anchor -| a)$) |- (.child anchor) }, }{% edge path'={% (!u.parent anchor |- !p.child anchor) ++(\foresteregister{folder indent},0pt) coordinate (a) -- ($(!p.child anchor -| a)!1/3!(.child anchor -| a)$) edge [dotted] ($(!p.child anchor -| a)!2/3!(.child anchor -| a)$) ($(!p.child anchor -| a)!2/3!(.child anchor -| a)$) |- (.child anchor) }, }, for following siblings={% edge path'={% (!u.parent anchor |- !p.child anchor) ++(\foresteregister{folder indent},0pt) |- (.child anchor) }, }, }{% prepend={[\strut, delay={% do dynamics, temptoksa=, for following siblings={% if temptoksa={}{}{% temptoksa+={,}, }, temptoksa+/.option=name, }, real siblings/.register=temptoksa, folder, grow'=0, before computing xy={% l'=0pt, s'=-15pt, }, delay n=2{% split option={real siblings}{,}{append}, }, before typesetting nodes={% temptoksa/.option=name, delay={ do dynamics, for children={ if n=1{ edge path'={% (!uu.parent anchor) ++(\foresteregister{folder indent},0pt) coordinate (a) -- ($(a)!1/3!(.child anchor -| a)$) coordinate (A) % ($(a)!2/3!(.child anchor -| a)$) coordinate (B) % ($(a)!2/3!(.child anchor -| a)$) |- (.child anchor)% }, tikz+={ \coordinate (A') at ($(A)+(0,\dirtree@dot@radius)$); \coordinate (B') at ($(B)-(0,\dirtree@dot@radius)$); \coordinate (C) at ($0.25*($(B')-(A')$)$); % Debugging % \draw[blue] ($(A')-(5pt,0)$) -- ($(A')+(5pt,0)$); % \draw[red] ($(A')+(C)-(5pt,0)$) -- ($(A')+(C)+(5pt,0)$); % \draw[red] ($(A')+2*(C)-(5pt,0)$) -- ($(A')+2*(C)+(5pt,0)$); % \draw[red] ($(A')+3*(C)-(5pt,0)$) -- ($(A')+3*(C)+(5pt,0)$); % \draw[red] ($(A')+4*(C)-(5pt,0)$) -- ($(A')+4*(C)+(5pt,0)$); % \draw[blue] ($(B')-(5pt,0)$) -- ($(B')+(5pt,0)$); \fill ($(A')+(C)$) circle (\dirtree@dot@radius); \fill ($(A')+2*(C)$) circle (\dirtree@dot@radius); \fill ($(A')+3*(C)$) circle (\dirtree@dot@radius); }, }{ edge path'={% (!uu.parent anchor) ++(\foresteregister{folder indent},0pt) coordinate (a) (a |- !p.child anchor) |- (.child anchor) }, }, }, }, }, }, no edge, ]}, }, }, }, vdots@others/.style={% delay={% append={[\strut, folder, grow'=0, before computing xy={% l'=0pt, s'=-15pt, }, if n children=0{% before drawing tree={% delay={% y/.min={>O{y}}{parent,descendants}, }, }, }{}, edge path'={% ([xshift=\forestregister{folder indent}]!uu.parent anchor) coordinate (a) -- ([yshift=9pt].parent anchor -| a) coordinate (A) % (.parent anchor -| a) coordinate (B) }, tikz+={ \coordinate (A') at ($(A)+(0,\dirtree@dot@radius)$); \coordinate (B') at ($(B)-(0,\dirtree@dot@radius)$); \coordinate (C) at ($0.25*($(B')-(A')$)$); \fill ($(A')+(C)$) circle (\dirtree@dot@radius); \fill ($(A')+2*(C)$) circle (\dirtree@dot@radius); \fill ($(A')+3*(C)$) circle (\dirtree@dot@radius); }, ]}, }, }, vdots/.style={ if level = 0{vdots@root}{vdots@others} } } \makeatother %===========================================% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} \begin{forest} pic dir tree, pic root, for tree={% folder icons by default; override using file for file icons directory, }, [system,vdots [config ] [lib,vdots [Access, vdots ] [Plugin, vdots ] [file.txt, file,vdots ] ] ] \end{forest} \end{document}

  • Strange geometric calculation error of ellipse with `arc` in tikz?
    by Explorer on February 14, 2026 at 7:33 am

    I want to plot something as below in an elegant appraoch, with a handy control of the angle and eccentricity: (the pattern is not important here) Here below, I make some calculations: \documentclass[tikz,border=5pt]{standalone} \begin{document} \begin{tikzpicture}[line join=round] \def\R{5} \def\ell{0.9} \def\startAngle{40} \def\endAngle{90-\startAngle} \def\rhoo{\fpeval{\R*sind(45-\startAngle)/cosd(\startAngle)}} \def\Rx{\fpeval{\rhoo*(sqrt(1-(\ell^2*cosd(\startAngle)^2)))/(sqrt(1-\ell^2))}} \def\Ry{\fpeval{\Rx*(sqrt(1-\ell^2))}} \def\ellstartAngle{\fpeval{atand(\Rx/\Ry*tand(\startAngle))}} \filldraw[ fill=cyan!30, draw=cyan, very thick ] (\R,0) arc[start angle=0, end angle=\startAngle, radius=\R] { [rotate=-\startAngle] arc[start angle=-\ellstartAngle,end angle=180+\ellstartAngle,x radius=\Rx,y radius=\Ry] } arc[start angle=\endAngle, end angle=90, radius=\R] -- (0,\R) -- (\R,\R) -- cycle; \end{tikzpicture} \end{document} But it gives some drawbacks of the ellipse's ending tip: With the following sketch: My calculation thoughts is as below: noted that \StartAngle is \theta, and \ell is the ellipse's eccentricity with \def\rhoo{\fpeval{\R*sind(45-\startAngle)/cosd(\startAngle)}}, I want to derive the radius from origin of the ellipse, that is the \rho's distance in the sketch with the formula of the radius length from origin of the ellipse, that is: I want to derive the x-radius of ellipse, that is a(\Rx) via \def\Rx{\fpeval{\rhoo*(sqrt(1-(\ell^2*cosd(\startAngle)^2)))/(sqrt(1-\ell^2))}} Then I calaulated the y-radius with \Rx and \ell via \def\Ry{\fpeval{\Rx*(sqrt(1-\ell^2))}} Finally, I calculate the geometric angle of sub-path rotation learning from this answer via \def\ellstartAngle{\fpeval{atand(\Rx/\Ry*tand(\startAngle))}} I really have no idea of any mathematical calculation issues or just my tikz's parameter misunderstandings. Could somebosy give me a hand? (Any approach with neat syntax are all welcome! My calculation above is just to draw this in one \path)

  • Any better suggestions with the pos of arrow on arc with tikz?
    by Explorer on February 13, 2026 at 12:25 pm

    This question is similar to this link, but not exactly the same focues. What I want, is something like: But I want a better looking and better syntax of the arrow: The figure above is produced by: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{bending,decorations.markings,arrows.meta,calc,spath3} \usepackage{amsmath} \begin{document} \begin{tikzpicture}[ >={Kite[inset=0pt,length=.32cm,bend]}, baz/.style={spath/save=curve}, foo/.style={ draw,tips=true,->, spath/remove empty components={curve}, spath/split at keep start={curve}{#1}, spath/use=curve }, foo/.default=0.5, ] \filldraw[thick,fill=gray!40] (4,0) node[below]{$R$} arc (0:180:4) node[below]{$-R$} -- (-3,0) arc(180:0:1) -- (1,0) arc(180:0:1) -- cycle; \path[baz] (4,0) arc (0:90:4);\path[foo=.4]; \path[baz] (0,4) arc (90:180:4);\path[foo]; \path[baz] (-3,0) arc (180:0:1);\path[foo=.55]; \path[baz] (1,0) arc (180:0:1);\path[foo=.55]; \draw[-Stealth] (-5,0) -- (5,0) node[below]{$\Re$}; \draw[-Stealth] (0,0) -- (0,5) node[right]{$\Im$}; \path node[below] {$O$} (60:4) node[above=3pt] {$C_{R}$}; \end{tikzpicture} \end{document} which learning from Andrew Stacey's elegant solution. However, the code above is manually seperated, my \foreach version didn't get expected result: \documentclass[tikz,border=5pt]{standalone} % https://tex.stackexchange.com/a/656167/322482 \usetikzlibrary{bending,decorations.markings,arrows.meta,calc,spath3} \usepackage{amsmath} \begin{document} \begin{tikzpicture}[>={Kite[inset=0pt,length=.32cm,bend]}] \filldraw[ thick,fill=gray!40, spath/save=curve, ] (4,0) node[below]{$R$} arc (0:180:4) node[below]{$-R$} -- (-3,0) arc(180:0:1) -- (1,0) arc(180:0:1) -- cycle; \foreach \pos in {.1,.4,.675,.9}{% \path[ draw=blue,tips=true,->, spath/clone={tmp}{curve}, spath/remove empty components={tmp}, spath/split at keep start={tmp}{\pos}, spath/use=tmp, ]; } \draw[-Stealth] (-5,0) -- (5,0) node[below]{$\Re$}; \draw[-Stealth] (0,0) -- (0,5) node[right]{$\Im$}; \path node[below] {$O$} (60:4) node[above=3pt] {$C_{R}$}; \end{tikzpicture} \end{document} Edited: (I seemed to find some out-of-my-intuition features with spath3 and also reported at here, but actually turn out to be my fault of understanding the pos parameter of curve).

  • Find the intersections of circles using pgfmath
    by Jasper on February 13, 2026 at 11:45 am

    Find the intersections of circles automatically using pgfmath: \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \pgfmathsetmacro{\circleonex}{0} \pgfmathsetmacro{\circleoney}{0} \pgfmathsetmacro{\circleoner}{2} \draw (\circleonex,\circleoney) circle[radius=\circleoner]; \pgfmathsetmacro{\circletwox}{1} \pgfmathsetmacro{\circletwoy}{1} \pgfmathsetmacro{\circletwor}{1.5} \draw (\circletwox,\circletwoy) circle[radius=\circletwor]; % Goal: use a sequence of \pgfmathsetmacro to find both % intersections automatically, if they exist. % It should cleanly degenerate when they no longer coincide. \end{tikzpicture} \end{document}

  • Table with pgfplots and title boxes across the entire textwidth
    by cis on February 13, 2026 at 10:16 am

    I want to use the entire \textwidth at a table, so I chose tabularx. The table contains plots (all the same size) and boxes with titles that contain varying amounts of text or lines. The "title boxes" should all be top-aligned, all have the same width and for each row (!) the same height. This means that the "title boxes" in row 1 have the same height, and those in row 3 also have the same height; but possibly a different height than in row 1. What's the best way to configure this? I've put the "title boxes" also into tabularx tables; but perhaps multirow would be more suitable here (?). I often have problems with overfull / underfull hbox warnings here. I don't know what the ideal solution for this. Note: I plan to disable the main table's rules later; I've set \setlength\arrayrulewidth{2pt} here to better visualize the dimensions. \documentclass[paper=a5]{scrarticle} \usepackage[margin=14mm, showframe]{geometry} \usepackage{tabularx} % \usepackage{multirow}% needed? \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage{lipsum}% dummy text \newcommand\mytitle[1]{% {\begin{tabularx}{\linewidth}{|X|} \hline #1 \\ \hline \end{tabularx}} } \newcommand\myplot[1]{% \begin{tikzpicture}[baseline] \begin{axis}[width=\linewidth, height=30mm] \addplot[#1, mark=*]{x^4}; \end{axis} \end{tikzpicture}} \newcolumntype{Y}{% hspaces should be as small as possible @{\hspace{1.5pt}}X@{\hspace{1.5pt}}} \setlength\arrayrulewidth{2pt}% to see the effects \begin{document} \noindent\begin{tabularx}{\textwidth}{| Y | Y |} % Title 1 (row 1, column 1) ================== \mytitle{Title 1: \lipsum[1][1-2]} % Title 2 (row 1, column 2) ================== & \mytitle{Title 2: \lipsum[1][1]} \\ % Plot 1 (row 2, column 1) ================== \myplot{brown} % Plot 2 (row 2, column 2) ================== & \myplot{red} \\ \hline % Title 3 (row 3, column 1) ================== \mytitle{Title 3: \lipsum[1][2]} % Title 4 (row 3, column 2) ================== & \mytitle{Title 4: \lipsum[1][1-4]} \\ % Plot 3 (row 4, column 1) ================== \myplot{blue} % Plot 4 (row 4, column 2) ================== & \myplot{orange} \\ \end{tabularx} \end{document}

  • Styled read out example for a value from a pgfplotstable (TikZ-spy?)
    by cis on February 12, 2026 at 4:04 pm

    I have a pgfplotstable: I would like to create a reading out example for a value, with the red lines and the framed cell. This could look like this then: How could I do that best way? My immediate idea would be a TikZ-spy. But maybe there's a completely different/easier way. %\documentclass[paper=a5]{scrarticle} %\usepackage[margin=14mm, showframe]{geometry} \documentclass[margin=5pt, varwidth]{standalone} \usepackage{diagbox} \usepackage{colortbl} \usepackage{pgfplotstable} \pgfplotsset{compat=1.18} \usetikzlibrary{spy} \pgfplotstableread[col sep=comma]{ n, k, 0.1, 0.2, 0.3, 0.4 1, 0, 1.1, 1.2, 1.3, 1.4 1, 1, 2.1, 2.2, 2.3, 2.4 2, 0, 2.1, 2.2, 2.3, 2.4 2, 1, 3.1, 3.2, 3.3, 3.4 2, 2, 4.1, 4.2, 4.3, 4.4 3, 0, 3.1, 3.2, 3.3, 3.4 3, 1, 4.1, 4.2, 4.3, 4.4 3, 2, 5.1, 5.2, 5.3, 5.4 3, 3, 6.1, 6.2, 6.3, 6.4 }{\mytable} \begin{document} \pgfplotstabletypeset[ every head row/.style={before row=\hline, after row=\hline}, columns/k/.style = {% k column column name={\diagbox{$k$}{$p$}}, column type={|>{\cellcolor{pink}}c|}, },% ]{\mytable} \begin{tikzpicture}[ spy using outlines={rectangle, magnification=1, connect spies} ] \spy [blue, width=2cm, height=1cm] on (0,1) in node [fill=white] at (3,0.5); \end{tikzpicture} \end{document}

  • Crossed branches in tikz [closed]
    by Uri Lifshitz on February 12, 2026 at 11:11 am

    I am having trouble figuring out how to have a drawed line crossed out and a dotted line in tikzpicture to have a desired result which will look something like thanks!

  • How can I geometrically translate a line segment on a line?
    by Jasper on February 12, 2026 at 4:17 am

    How can I geometrically translate a line segment on a line? I want to move the pink segment so that it starts at three and goes to four. I don't just want to teleport it. I want a geometric construction for this - Euclidean style. \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \draw[thick,->] (-1,0) -- (5,0) node[below left] {\(x\)}; \draw[ preaction = { draw = black, line width = 4pt }, postaction = { draw = pink, line width = 2pt } ] (0,0) -- (1,0); \fill (0,0) circle[radius = 3pt] node[below=3pt] {\(0\)}; \fill (1,0) circle[radius = 3pt] node[below=3pt] {\(1\)}; \fill (3,0) circle[radius = 3pt] node[below=3pt] {\(3\)}; \end{tikzpicture} \end{document}

  • pgfplots: Adjust groupplot to text width
    by cis on February 11, 2026 at 9:28 am

    I have a 2×2 groupplot (where the first plot should be replaced by a title "Supertitle") with titles in boxes. These "title boxes" should all have the same width, and boxes in the same row should have the same height. I achieved this using \vphantom{} because I didn't find a better method. How can I configure the settings such that the entire groupplot has a width of \textwidth? And a horizontal space between the columns like \tabcolsep (or something similar)? Is there a elegant way to do this by package keys? (resizebox etc. would certainly work, but that would be less elegant.) Ideally, it should stay a groupplot. PS: I'm using DIN A5 format here, but that shouldn't matter if the keys are set correctly. \documentclass[paper=a5]{scrartcl} \usepackage[margin=14mm, showframe]{geometry} \usepackage{pgfplots} \usepgfplotslibrary{groupplots} \pgfplotsset{compat=1.18} \begin{document} \section{Plots with Titles and Supertitle} \pgfmathsetlengthmacro\plotwidth{0.5*\textwidth-\the\arraycolsep} \begin{tikzpicture}[font=\footnotesize] \begin{groupplot}[ % Grouupplot settings ================== group style={ group size=2 by 2, % 2 columns, 2 rows vertical sep=25mm, horizontal sep=15mm, }, % Styles applied to all subplots ============== width=\plotwidth, height=30mm, % Title Styles ========================== title style={% at={(0,1)}, xshift=-3ex, align=left, anchor=south west, inner xsep=2pt, draw, fill=none, text width=0.925*\pgfkeysvalueof{/pgfplots/width}, },% ] % Title (Row 1, Col 1) \nextgroupplot[ % I don't know how to get this box to the same height without this trick: title={\vphantom{Plot 0} \\ \vphantom{000} \\ \vphantom{000}}, title style={name=super}, hide axis, ] \addplot[draw=none, samples={0}]{x}; % Plot 0 (Row 1, Col 2) \nextgroupplot[title={Title 0 \\ 000 \\ 000}] \addplot{x}; % Plot 1 (Row 2, Col 1) \nextgroupplot[title={Title 1 \\ 2-111 \\ 3-111 \\ 4-111}] \addplot{x^2}; % Plot 2 (Row 2, Col 2) \nextgroupplot[title={Title 2 \\ 2-222 \\ 3-222 \\ \vphantom{4-111}}] \addplot{x^3}; \end{groupplot} %% Supertitle \node[font=\bfseries\Large] at (super){Supertitle}; \node[anchor=north west, draw=none, align=left,] at (super.south west){ Some notes \\ below Supertitle}; \draw[cyan, very thick, |-|] (group c1r2.west) -- +(\plotwidth,0) node[midway, below, fill=yellow]{plotwidth =\plotwidth}; %% This gives a 'Overfull \hbox ' warning ================== \draw[red, thick, |-|, ] ([yshift=5mm]group c1r2.west) -- +(2*\plotwidth,0) node[midway, above, fill=yellow]{2*plotwidth =\plotwidth}; \end{tikzpicture} \end{document}

  • Creating Circular Domains with TikZ [closed]
    by Assuério Cavalcante on February 10, 2026 at 3:45 pm

    First, apologies if this question has been asked before. I'm trying to create an image of a particular circular domain, but my limited TikZ knowledge has made this quite challenging. I've searched for similar examples online without success. Any guidance would be greatly appreciated!

  • MetaPost, TikZ and their 3D libraries
    by Sebastiano on February 10, 2026 at 11:55 am

    I am referring to this Italian lecture notes by Prof. R. Tauraso, edited by a student/lecturer Massimiliano Pompegnani (link https://moodle2.units.it/pluginfile.php/767967/mod_resource/content/1/intdoppi.pdf) My question concerns which specific libraries are needed to draw in 3D (I’m not very familiar with 3D) what to me seems drawn in MetaPost and peraphs, for the their complexity, with IPE drawing https://ipe.otfried.org/ (?), WinFIG (?). From the axes arrows it appears to be MetaPost and also the fills. ecc. I’m not asking for any code but want to be informed. There are many 3D libraries for TikZ but I have never previously been interested in 3D. Are there any similar libraries that TikZ can use to reproduce Metapost drawings?

  • TikZ curved arrow bisecting text - how to increase arc height to clear obstacle?
    by Oregon Math Tutor on February 9, 2026 at 8:19 pm

    I'm annotating a fraction with TikZ arrows pointing to specific parts. The blue arrow works fine, but the red curved arrow is bisecting the "3" in the denominator instead of arcing over it. Current behavior: The red arrow cuts straight through the middle of "3" Desired behavior: The red arrow should arc upward and over the "3" with clear space. I initially tried adjusting the out angle from 160° to 120° to make it launch upward, but this still results in the arrow bisecting the number. How do I increase the arc height to make the curve clear the "3" completely as shown in the 2nd image? Note: I'm still learning TikZ best practices. If you spot any obvious improvements to the code structure, please mention them. MWE \usepackage{mathtools} \usetikzlibrary{calc, arrows.meta} \definecolor{textBlue}{RGB}{50, 50, 255} \definecolor{deepRed}{RGB}{200, 40, 40} \begin{document} \begin{tikzpicture} % Math fraction \node (fraction) at (0,0) { \scalebox{1.8}{% $\displaystyle \frac{2x^3 - 5x^2 - x + 3}{x + 3}$ } }; % Blue annotation (works fine) \node[ellipse, draw=textBlue, dashed, minimum width=0.3cm, minimum height=0.6cm, xshift=-0.4cm, yshift=0.4cm] (blueCircle) at ($(fraction.south) + (-0.65, 0.28)$) {}; \node[draw=textBlue, text=textBlue, align=center, anchor=north] (blueLabel) at ($(blueCircle.south) + (0, -0.6)$) {coefficient\\must be 1}; \draw[textBlue, ->, >=latex] (blueLabel.north) -- (blueCircle.south); % Red annotation (PROBLEM: arrow bisects the "3") \node[circle, draw=deepRed, dashed, minimum size=0.2cm, xshift=-0.2cm, yshift=0.3cm] (redCircle) at ($(fraction.south) + (-0.2, 0.55)$) {}; \node[draw=deepRed, text=deepRed, align=left, anchor=west] (redLabel) at ($(fraction.south) + (0.8, 0.3)$) {exponent\\must be 1}; % This arrow bisects "3" - how to make it arc higher? \draw[deepRed, ->, >=latex] (redLabel.west) to[out=120, in=0] (redCircle.east); \end{tikzpicture} \end{document}``` [1]: https://i.sstatic.net/zirlpD5n.png [2]: https://i.sstatic.net/BOIovYSz.png

  • Watermark misplacement with standalone class
    by Erwann on February 9, 2026 at 3:51 pm

    When using the standalone document class with a shipout hook to add a watermark, it fails to display. Output using article class is OK. \documentclass{standalone} %\documentclass{article} \usepackage{tikz} \AddToHook{shipout/background}{ \begin{tikzpicture}[remember picture, overlay, text=red] \node[ rotate=45, scale=1, opacity=0.5, anchor=center, font=\large] at (current page.center) {WATERMARK}; \end{tikzpicture} } \begin{document} % Uncomment for class article %\vspace*{\fill} %\begin{center} \begin{tikzpicture} \draw[thick] (0,0) rectangle (5,3); \node at (2.5,1.5) {Content}; \end{tikzpicture} %\end{center} % article %\vspace{\fill} % article \end{document} P.S. This requires two compilation passes.

  • pgfplots: align legend entries at a groupplot
    by cis on February 9, 2026 at 2:09 pm

    I have a groupplot where I want to use the legend as the title in the \nextgroupplots. And then I have a "Supertitel" that I would like to put in place of the first groupplot. How do I set it such that the text, like the small box, is aligned to the top edge? \documentclass[margin=5pt, varwidth]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepgfplotslibrary{groupplots} \usetikzlibrary{patterns} \begin{document} \begin{tikzpicture}[font=\footnotesize, mypattern/.style={% postaction={pattern=north east lines}, },% ] \begin{groupplot}[ group style={% group size=2 by 3, vertical sep=15mm, },% height=30mm,width=55mm, group/every plot/.style={%% ybar=0pt, bar width=1, bar shift=0pt, xmin=-0.5,% to see the bar at x=0 correctly ymin=0, xtick=data, },%% end of group/every plot/.style %% every axis plot/.style={ fill=lightgray, area legend,% legend as title 1/2 }, legend style={% legend as title 2/2 at={(0,1)}, yshift=6pt, anchor=south west, draw=none, fill=none, inner sep=0pt, cells={anchor=north, align=left},% PROBLEM HERE ..... },% ] \nextgroupplot[hide axis=true, title={Supertitle}, title style={at={(0.5,0.5)}, anchor=center, yshift=-6pt,% kill pgfplots's default draw=none, font=\bfseries\Large} ] \addplot[draw=none, fill=none]{x};% to avoid warning; don't know how to make this else \nextgroupplot[] \addplot[samples at={0,...,8}, forget plot]{x}; \addplot[mypattern, samples at={3,...,6}]{x}; \addlegendentry{plot 0: \\ plot good, \\ legend bad :(} \end{groupplot} \end{tikzpicture} \end{document}

  • Using xint in pgfplots (example: binomial distribution)
    by cis on February 9, 2026 at 9:26 am

    If I have a function with xint, say % \bdceval{<n>}{<p>}{<k>} \xintNewFloatExpr{\bdeval}[3]{% %B(n,p,k) = binomial(n,k)*p^k*(1-p)^(n-k) % formula binomial(#1,#3)*#2^#3*(1-#2)^(#1-#3)} this works well in text (e.g. \bdeval{13}{0.4}{5}); but how can I use that in pgfplots? In the following MWE I have drawn an example using pgfplots; the same curve should result with xint. \documentclass[margin=5pt, varwidth]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage{xintexpr} %\usepackage{xinttools}% needed? % \bdceval{<n>}{<p>}{<k>} \xintNewFloatExpr{\bdeval}[3]{% %B(n,p,k) = binomial(n,k)*p^k*(1-p)^(n-k) % formula binomial(#1,#3)*#2^#3*(1-#2)^(#1-#3)} % \bd[<digits, default: 4>]{<n>}{<p>}{<k>} \NewExpandableDocumentCommand{\bd}{O{4} mmm}{% %\xinteval{round(#2+#3+#4,2)}% for tests \xintRound{#1}{\bdeval{#2}{#3}{#4}}% rounded bd-values } \begin{document} \section{xint in Text (works)} $B(13,0.4,5) =\bdeval{13}{0.4}{5} \approx \bd{13}{0.4}{5}$ \par $B(1000,0.4,50) =\bdeval{1000}{0.4}{50} \approx \bd{1000}{0.4}{50}$ \section{xint in pgfplots (works not)} \begin{tikzpicture}[font=\footnotesize, declare function={ binom(\n,\p,\k)=\n!/(\k!*(\n-\k)!)*\p^\k*(1-\p)^(\n-\k);% works %xbinom(\n,\p,\k)=\bdeval{\n}{\p}{\k};% works not } ] \begin{axis}[ title={\texttt{xint} in pgfplots?}, title style={fill=blue!25}, xlabel={$k$}, ylabel={$P(X=k)$}, yticklabel style={ /pgf/number format/fixed, /pgf/number format/fixed zerofill, /pgf/number format/precision=2 }, xtick=data, variable=\k, only marks, ] \addplot+[samples at={0,...,13}] {binom(13, 0.4, k)}; % DOES NOT WORK %\addplot [samples at={0,...,13}] {\bd{13}{0.4}{\k} }; \end{axis} \end{tikzpicture} \end{document}

  • How can I horizontally align two math labels by their baseline in TikZ?
    by Jasper on February 9, 2026 at 2:27 am

    How can I horizontally align two math labels by their baseline in TikZ? \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \node[below] at (0,0) {\(\frac{1}{1}\)}; \node[below] at (1,0) {\(1\)}; \end{tikzpicture} \end{document}

  • Standard practices in label decluttering: overcoming overlapping label lines
    by Jasper on February 8, 2026 at 11:59 pm

    I have a situation where I want to lable the sample points of a line segment, and also label the smaller line segments connecting those sample points. My labels are really cluttered right now. How can I make this more proper? \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \draw[thick,->] (-1,0) -- (5,0) node[below left] {\(x\)}; \fill (0.5,0) circle[radius = 3pt] node[above] {point}; \fill[gray] (0.5,0) circle[radius = 1.5pt]; \draw[] (0.5,0) -- (0.5,-2) -- (5,-2) node[right] {individual sample point}; \draw[line width = 6pt] (2,0) -- (3.5,0) node[above,pos=0.5]{line segment}; \foreach[count = \c from 1] \x in {2,2.5,...,3.5} { \fill[gray] (\x,0) circle[radius = 1.5pt]; \draw[] (\x,0) -- (4,-1); \ifnum\c=4\else\draw[thick,gray] (\x,0) -- ++(0.5,0);\fi } \draw[](4,-1) -- (5,-1) node[right] {multiple sample points}; \foreach[count = \c from 1] \x in {2.25,2.75,...,3.25} { \draw[] (\x,0) -- (4,-1.5); } \draw[](4,-1.5) -- (5,-1.5) node[right] {one or more line segments}; \end{tikzpicture} \end{document}

  • pgfplots: axis-enlargement at a ybar plot (example: binomial distribution)
    by cis on February 8, 2026 at 4:34 pm

    I wanted to adapt this nice solution for my purposes. • I want to extend the x- and y-axes a bit. But, when I set enlarge y limits={upper, abs=0.125} it creates a strange gap (ymin=0 is no longer respected, and restrict y to domain=0:1 seems to have no effect). • Secondly, what's the best way to configure it so that bars with very small y-values ​​are also visible here? • Unfortunately, I saw this too late: I would also like to eliminate this x-gap between the first bar and the y-axis! \documentclass[margin=5pt]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture}[font=\footnotesize, declare function={ binom(\n,\p,\k)=\n!/(\k!*(\n-\k)!)*\p^\k*(1-\p)^(\n-\k); } ] \begin{axis}[%y=8mm, no effect ymin=0, xmin=0, axis lines=left, axis line style={-latex}, xlabel={$k$}, ylabel={$P(X=k)$}, x label style={at={(axis description cs:1,0)}, anchor=south east, inner xsep=0pt }, y label style={at={(axis description cs:0,1)}, rotate = -90, anchor=north west, inner ysep=0pt, }, yticklabel style={ /pgf/number format/fixed, /pgf/number format/fixed zerofill, /pgf/number format/precision=2 }, ybar=0pt, bar width=1, bar shift=0pt, samples at={0,...,13}, variable=\k, enlarge x limits={upper, abs=0.785}, enlarge y limits={upper, abs=0.125}, %restrict y to domain=0:1,% no effect.... ] \addplot [fill=gray!25] {binom(13, 0.4, k)}; %\addplot [fill=orange, samples at={0,...,4}] {binom(12,0.4,k)}; %\addplot [fill=cyan, samples at={7}] {binom(12,0.4,k)}; \end{axis} \end{tikzpicture} \end{document}

  • How can I draw a coloured factorization diagram?
    by Bayaraa Surenjav on February 8, 2026 at 4:11 pm

    My code is: \documentclass[tikz,border=10pt]{standalone} \usepackage[utf8]{inputenc} \usepackage[mongolian]{babel} \usepackage{amsmath} \usetikzlibrary{calc, positioning, arrows.meta, backgrounds, shapes.geometric} \begin{document} \begin{tikzpicture}[ num node/.style={ font=\Large\bfseries\rmfamily, % Serif font, Bold anchor=east, inner sep=3pt, minimum height=0.65cm }, div node/.style={ font=\Large\rmfamily, anchor=east, inner sep=3pt }, arrow style/.style={ ->, >=latex, draw=cyan!80!blue, line width=0.8pt }, label text/.style={ text=cyan!80!blue, font=\itshape, align=right }, % Үйлдлийн тэмдэг (div 2) op label/.style={ text=cyan!80!blue, font=\large, anchor=west, xshift=2pt } ] \def\rowh{0.9} \node[div node] (d1) at (0,0) {2)}; \node[num node] (n1) at (1.8,0) {120}; \draw[thick] (d1.south east) -- (n1.south east); \node[div node] (d2) at (0,-\rowh) {2)}; \node[num node] (n2) at (1.8,-\rowh) {60}; \draw[thick] (d2.south east) -- (n2.south east); \node[div node] (d3) at (0,-2*\rowh) {2)}; \node[fill=cyan!25, inner sep=2pt, minimum height=0.6cm, minimum width=0.8cm, anchor=east] at (1.85,-2*\rowh) {}; \node[num node, text=magenta] (n3) at (1.8,-2*\rowh) {30}; \draw[thick] (d3.south east) -- (n3.south east); \node[div node] (d4) at (0,-3*\rowh) {3)}; \node[num node] (n4) at (1.8,-3*\rowh) {15}; \draw[thick] (d4.south east) -- (n4.south east); \node[num node] (n5) at (1.8,-4*\rowh) {5}; \begin{scope}[on background layer] % Зүүн талын босоо багана (Хуваагчдыг хамарсан) \fill[cyan!15] (-0.8, 0.4) rectangle (0.2, -4.5*\rowh); \fill[cyan!15] (-0.8, -3.65*\rowh) rectangle (2.2, -4.5*\rowh); \end{scope} \def\arm{0.5} \draw[arrow style] (n1.east) -- ++(\arm,0) |- node[pos=0.25, op label] {$\div 2$} (n2.east); \draw[arrow style] (n2.east) -- ++(\arm,0) |- node[pos=0.25, op label] {$\div 2$} (n3.east); \draw[arrow style] (n3.east) -- ++(\arm,0) |- node[pos=0.25, op label] {$\div 2$} (n4.east); \draw[arrow style] (n4.east) -- ++(\arm,0) |- node[pos=0.25, op label] {$\div 3$} (n5.east); \node[label text] (txt1) at (-3.5, 0) {анхны тоогоор хуваах}; \draw[arrow style] (txt1) -- (d1.west); \node[label text] (txt2) at (-4, -4*\rowh) {анхны тоо гартал үргэлжлүүлнэ}; \draw[arrow style] (txt2) -- (n5.west); \end{tikzpicture} \end{document} Current: Intended:

  • tikz euclides draw circle hung
    by Vuvi Numa on February 8, 2026 at 1:49 pm

    The MWE below freezes on the commented out line, until it is killed with Ctrl-C. This is a part of an old manuscript that was published, several years in the past, so at some point it did work. \documentclass{standalone} \usepackage{tikz} \usepackage{tkz-euclide} \begin{document} \begin{tikzpicture} \draw(-1,-1) rectangle(1,1); \tkzDefPoint(3,-1){A}; \tkzDefPoint(6,-1){B}; \tkzDefPoint(3,1){C}; %\tkzDrawCircle[in](A,B,C); \end{tikzpicture} \end{document} The last few lines of pdflatex output are: (/usr/share/texlive/texmf-dist/tex/latex/tkz-euclide/tkz-draw-eu-protractor.tex 2023/02/03 5.02c tkz-obj-eu-protractor.tex )) No file test.aux. (/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii [Loading MPS to PDF converter (version 2006.09.02).] ) (/usr/share/texlive/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty (/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)) Missing character: There is no ; in font nullfont! Missing character: There is no ; in font nullfont! Missing character: There is no ; in font nullfont! ^C! Interruption. \pgfkeys@parse ...uturelet \pgfkeys@possiblerelax \pgfkeys@parse@main l.12 \tkzDrawCircle[in](A,B,C) ; How can I fix the freeze and allow the arch to be drawn?

  • Tikzcd's "crossing over" option and transparent backgrounds
    by Ben Steffan on February 5, 2026 at 8:55 pm

    I currently have the following simple setup for producing commutative diagrams using tikzcd and exporting them to .svg's, following the two most popular answers on this question: Put the code for the diagram in a standalone tex file. Compile. Convert to .svg using dvisvgm. This... works, mostly (better ideas are warmly welcome), but I'm running into one issue in particular that is slightly annoying. Consider the following example: \documentclass[crop,tikz]{standalone} \usetikzlibrary{cd} \begin{document} \begin{tikzcd} & & & \{1\} \ar[dd] \ar[dl] \\ \{0\} \ar[rr] \ar[dd] & & \{0, 1\} \\ & \{2\} \ar[dl] \ar[rr] & & \{1, 2\} \ar[dl] \\ \{0, 2\} \ar[rr] & & \{0, 1, 2\} \ar[from=uu, crossing over] \end{tikzcd} \end{document} If you compile this, the resulting pdf looks like this: Great, that looks fantastic. But if you now go and run dvisvgm yourfilenamehere.dvi and drop the resulting svg into something with a non-white background, you get this: This is bad for two obvious reasons: Text and background color are way too similar, and the crossing over arrow now lives on top of a white box. This box is an artifact of the way crossing over works, which simply adds a preaction to the arrow path that draws a background color colored rectangle. Consequently, both problems can be avoided by setting color and background color to something that works, see e.g. this answer. Suppose now, however, that I don't know what color the background of the document/website/etc. the svg will be embedded in has. Perhaps I know that it's going to be a dark background, so that setting the text color to white will take care of the first issue, but unless I know the precise shade of the background I can't set the crossing over box' color to perfectly match. My question, thus, is whether there is a (nice) way to solve this second issue when the final background color is not precisely known (if you have a way to dynamically alter the text color, I'd be happy to hear about it as well). (By "nice" here I mean that e.g. it's obviously possible to draw the two "pieces" of the arrow being crossed over separately and avoid crossing over entirely, but this seems to annoying to do in general unless there is some way to package it up into a flexible macro/tikz key).

  • Issue: Unable to Display Text Below TikZ Code in LyX"
    by Evya1 on January 20, 2024 at 10:35 am

    I am currently facing a challenge in LyX where, after typing several lines of text, I insert TikZ code either inside a TeX box or directly into the apex preamble. However, I have observed that the text following the TikZ code is not visible. In the case of placing the code in the preamble, none of the text I have written in the document is visible. I am seeking assistance in resolving this issue and understanding how to ensure the proper display of text below inserted TikZ code in LyX. Any guidance or solutions would be greatly appreciated. LyX file: #LyX 2.3 created this file. For more info see http://www.lyx.org/ \lyxformat 544 \begin_document \begin_header ... \end_header \begin_body \begin_layout Standard Text here. 1 Algorithms - question 1 1 . ~~~Trying to show the figure here ~~~ ~~~ Text of the solution that isn't shown in rendered pdf~~~ \end_layout \end_body \end_document LaTeX preamble: \usepackage{autobreak} \usepackage{fontspec} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{autobreak} \usepackage{xcolor} \usepackage{amssymb} \usepackage{polyglossia} \usepackage{tikz} \setmainlanguage{hebrew} \setotherlanguage{english} \spaceskip=1\fontdimen2\font plus 1\fontdimen3\font minus 1.5\fontdimen4\font \everymath{\, } \usepackage{xcolor} \definecolor{blue}{RGB}{14,107,217} \definecolor{green}{RGB}{0,158,40} \definecolor{red}{RGB}{235,16,16} \definecolor{brown}{RGB}{164,66,0} \definecolor{orange}{RGB}{231,135,26} \definecolor{purple}{RGB}{94,53,177} \usepackage{amssymb} \renewcommand{\qedsymbol}{$\blacksquare$} \pagestyle{empty} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \begin{document} \begin{tikzpicture}[->,>=stealth',auto,node distance=2.5cm, thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries, minimum size=1cm}, align=center] \node[main node] (s) {$s$}; \node[main node] (v1) [below right=0.8cm and 1.8cm of s] {$v_1$}; \node[main node] (v2) [above right=0.8cm and 1.8cm of s] {$v_2$}; \node[main node] (vn-3) [right=1.2cm of v1] {$v_{n-3}$}; \node[main node] (vn-2) [right=1.2cm of v2] {$v_{n-2}$}; \node[main node] (t) [below right=0.8cm and 1.8cm of vn-2] {$t$}; \draw [->] (s) -- (v1); \draw [->] (s) -- (v2); \draw [->] (vn-3) -- (t); \draw [->] (vn-2) -- (t); \draw [dashed] [->,blue] (v1) -- (vn-2); \draw [dashed] [->,blue] (v2) -- (vn-3); \draw [dashed, ->, bend right] (v1.north) to (v2.south); \draw [dashed, ->, bend] (v2.south) to (v1.north); \draw [dashed, ->, bend right] (vn-3.north) to (vn-2.south); \draw [dashed, ->, bend] (vn-2.south) to (vn-3.north); % Add dashed lines to represent the cutted paths \draw [dashed] (s) -- (v1); \draw [dashed] (s) -- (v2); \draw [dashed] (v1) -- (vn-3); \draw [dashed] (v2) -- (vn-2); \draw [dashed] (vn-3) -- (t); \draw [dashed] (vn-2) -- (t); \end{tikzpicture} \end{document}

  • Improve Tikz code of the complex conjugate
    by Hibou on July 23, 2020 at 1:23 pm

    I needed to draw a graph on LaTex, I'm quite new to Tikz environment so I used the following code. My question is how to improve my code because I'm sure I can have a better result with fewer lines. PS : is it possible to add a legend for s1 and z1 ? \documentclass[12pt,a4paper]{report} \usepackage[utf8]{inputenc} \usepackage[margin=1in]{geometry} \usepackage{graphicx} \usepackage{tikz} \usepackage{xcolor} \begin{document} \begin{center} \begin{tikzpicture}[thick, >=stealth] %axe des x \draw [->] (-2.5,0) -- (1,0); \node at (1.5,0) {\small \textbf{Re(s)}}; %axe des y \draw [->] (0,-2.5) -- (0,2.5); \node at (0.5,2.6) {\small \textbf{Im(s)}}; %demi cerle \draw (0,1.5) arc (90:270:1.5cm); %partie réelle omega n \draw [ultra thick] (-1.5,-0.1) -- (-1.5,0.1); \node at (-1.8,-0.2) {\small \textbf{$\omega_n$}}; %moins alpha \draw [ultra thick] (-0.85,-0.1) -- (-0.85,0.1); \node at (-1.2,-0.2) {\small \textbf{-$\alpha$}}; %dots \draw [dotted, thick] (0,-1.25) -- (-0.85,-1.25) -- (-0.85,1.25) -- (0,1.25); %s1 \node at (-0.85,1.25) {\tiny \textbf{+}}; \node at (-1.1,1.3) {\scriptsize \textbf{$s_1$}}; %s2 \node at (-0.85,-1.25) {\tiny \textbf{+}}; \node at (-1.1,-1.3) {\scriptsize \textbf{$s_2$}}; % omega d \draw [very thick] (-0.1,1.25) -- (0.1,1.25); \node at (0.4,1.26) {\scriptsize \textbf{$\omega_d$}}; %-omega d \draw [very thick] (-0.1,-1.25) -- (0.1,-1.25); \node at (0.4,-1.26) {\scriptsize \textbf{-$\omega_d$}}; %segment \draw [thick] (-0.85,1.25) -- (0,0) -- (-0.85,-1.25); %Phi \draw [ultra thin, ->] (-0.298,0.4) arc (140:90:0.4cm); \node at (-0.2,0.65) {\scriptsize $\phi$}; %zéro 1 \draw (-.7,0.625) circle (0.7mm); \node at (-.7,0.4) {\scriptsize $z_1$}; %zéro 2 \draw (-.7,-0.625) circle (0.7mm); \node at (-.7,-0.4) {\scriptsize $z_2$}; \end{tikzpicture} \end{center} \end{document}

  • How to shift default x=0 for tikzpicture graphs
    by Will Kim on May 31, 2019 at 1:58 pm

    I am trying to produce a probability distribution graph for a discrete random variable. What I want to know is how to shift x=0 to the right so that it is positioned where x=1 is. As you can see, this is not being done for my graph above, using the code below. \documentclass[]{article} \usepackage[margin=0.5in]{geometry} \usepackage{pgfplots} \renewcommand{\thesection}{\arabic{section}} \usepackage{mathtools} \usepackage{cancel} \usepackage{pgfplots} \usepackage{amsmath} \newtheorem{theorem}{THEOREM} \newtheorem{proof}{PROOF} \usepackage{tikz} \usepackage{amssymb} \usetikzlibrary{patterns} \usepackage{fancyhdr} \usepackage{bigints} \usepackage{color} \usepackage{tcolorbox} \usepackage{color,xcolor} \usepackage{booktabs,array} \usepackage{hyperref} \usepackage{graphicx} \usetikzlibrary{arrows} \usepackage{polynom} \usepackage{wallpaper} \usetikzlibrary{shapes.geometric} \usepgfplotslibrary{fillbetween} \newenvironment{tightcenter}{ \setlength\topsep{0pt} \setlength\parskip{0pt} \begin{center}}{\end{center}} \begin{document} \begin{tikzpicture} \begin{axis}[ %axis lines=middle, grid=major, %ticks=none, xmin=0, xmax=4.2, ymin=0, ymax=0.55, clip=false, xtick={0,1,2,3,4}, xticklabels={$0$,$1$,$2$,$3$,$4$}, ytick={0,0.1,0.2,0.3,0.4,0.5}, height=10cm, width=14cm, %axis line style={shorten >=-10pt, shorten <=-10pt}, yticklabel style={ fill=white, %yshift=10pt, }, ylabel=\text{proportion}, xticklabel style={ %xshift=10pt, fill=white }, xlabel=\text{Number of accidents per week}, ylabel near ticks, xlabel near ticks %ylabel style={rotate=-90} ] %\node[below] at (axis cs:-1.5,0) {$O$}; %\draw[fill=black](axis cs:30,35) circle (3pt); %\draw[fill=black](axis cs:15,20) circle (3pt); %\draw[fill=black](axis cs:25,20) circle (3pt); %\draw[fill=black](axis cs:12,10) circle (3pt); %\draw[fill=black](axis cs:25,22) circle (3pt); %\draw[fill=black](axis cs:32,40) circle (3pt); %\draw[fill=black](axis cs:50,30) circle (3pt); %\draw[fill=black](axis cs:45,40) circle (3pt); %\draw[fill=black](axis cs:60,50) circle (3pt); %\draw[fill=black](axis cs:20,15) circle (3pt); %\draw[fill=black](axis cs:15,10) circle (3pt); %\draw[fill=black](axis cs:19,20) circle (3pt); %\draw[fill=black](axis cs:25,20) circle (3pt); %\draw[fill=black](axis cs:45,40) circle (3pt); %\draw[fill=black](axis cs:50,45) circle (3pt); % \draw[thick,fill=gray,opacity=0.5] (axis cs: 0-0.2,0) rectangle (axis cs: 0+0.2,0.45); \draw[thick,fill=gray,opacity=0.5] (axis cs: 1-0.2,0) rectangle (axis cs: 1+0.2,0.3); \draw[thick,fill=gray,opacity=0.5] (axis cs: 2-0.2,0) rectangle (axis cs: 2+0.2,0.15); \draw[thick,fill=gray,opacity=0.5] (axis cs: 3-0.2,0) rectangle (axis cs: 3+0.2,0.1); \end{axis} \end{tikzpicture} \end{document} The following graph is what I am trying to replicate: Thank you in advance.

  • Effectively, how to do "Underbrace" under two "Underbraces"?
    by wonderich on December 20, 2018 at 5:36 pm

    Goal: I am trying to find a way to write an equation for: However, I fail, or at least so far could not find a way, to add the last layer in the bottom for "magnetic flux" using \underbrace. Here is what I have so far, $$ \overbrace{ \underbrace{S^1_A \times S^1_B}_{E} \times \underbrace{S^1_C \times \mathbb{R}}_{\mathbb{CP}^{N-1}} }^{\text{ABCDEFG}} $$ and my output is this: Could you find a better way to do it? Effectively, how to do "Underbrace" under two "Underbraces"? Or maybe we can also try to use TikZ instead? (i.e. I don't mind to try other methods) p.s. Another thing is that, in my case, the size of ABCDEFG is smaller than the S^1_A \times S^1_B \times S^1_C \times \mathbb{R} — is there a way to adjust the size of ABCDEFG and others? Thank you for your help!!!

  • Drawing an irregular shape for hypothesis space representation
    by Metamatics on November 13, 2016 at 1:35 pm

    Is there any way to reproduce the picture below with tikz? I am relatively unfamiliar with tikz and failed to reproduce anything that looks at least partly like the following representation. This is were I've got until now: \documentclass{article} \usepackage{tikz} \usetikzlibrary{hobby} \begin{document} \begin{tikzpicture}[use Hobby shortcut,closed=true] \draw (-3.5,0.5) .. (-3,2.5) .. (-1,3.5).. (1.5,3).. (4,3.5); \draw (-1,1.5) ellipse (57pt and 33pt); \draw [fill=black] (-0.5,1.5) circle (1.5pt); \draw[color=black] (-0.5,1.2) node {$f$}; \draw [fill=gray] (0,1.2) circle (1.5pt); \draw[color=gray] (0,0.9) node {$h_1$}; \draw [fill=gray] (-1.2,2) circle (1.5pt); \draw[color=gray] (-1.2,2.3) node {$h_2$}; \draw [fill=gray] (-1,1.35) circle (1.5pt); \draw[color=gray] (-1.3,1.35) node {$h_3$}; \end{tikzpicture} \end{document} The two most challenging tasks are to reproduce this irregular shape in the same form and to draw these irregular arrows.

  • improvement of a complex contour
    by user5590 on April 30, 2016 at 12:26 am

    By adapting the codes in an answer to the question How to draw these (closed contours) diagrams using TikZ or PSTricks?, I get the following picture. Would anybody help me to make the following improvement? How can I have arrows in the line segment (-R,0) and also the smaller arc? (And only one arrow in the bigger arc.) How can I make the sizes of 1-\epsilon, 1+\epsilon smaller? \documentclass{article} \usepackage{tikz} \usetikzlibrary{decorations.markings} \begin{document} \begin{tikzpicture}[decoration={markings, mark=at position 0.5cm with {\arrow[line width=1pt]{>}}, mark=at position 2cm with {\arrow[line width=1pt]{>}}, mark=at position 7.85cm with {\arrow[line width=1pt]{>}}, mark=at position 9cm with {\arrow[line width=1pt]{>}} } ] % The axes \draw[help lines,->] (-4,0) -- (4,0) coordinate (xaxis); \draw[help lines,->] (0,-1) -- (0,4) coordinate (yaxis); \node at (0,2) {$\times$}; \node at (-.5,2) {$2i$}; \node at (1,0) {$\times$}; % The path %\path[draw,line width=0.8pt,postaction=decorate] (1,0) node[below] {$\epsilon$} -- (2,0) node[below] {$r$} arc (0:180:2) -- (-1,0) arc (180:0:1); \path[draw,line width=0.8pt,postaction=decorate] (1.5,0) node[below] {$1+\epsilon$} -- (3,0) node[below] {$R$} arc (0:180:3) node[below] {$-R$} -- (.5,0) node[below]{$1-\epsilon$} arc (180:0:.5); % The labels \node[below] at (xaxis) {$x$}; \node[left] at (yaxis) {$y$}; \node[below left] {$O$}; \node at (1,.8) {$C_{\varepsilon}$}; \node at (2,3) {$\Gamma_{R}$}; \end{tikzpicture} \end{document}

  • Vertical strikethrough in table is too long
    by Labbiqa on March 7, 2015 at 5:45 pm

    So I just started using LateX yesterday and ran into a problem. I'm making a table where a number is circled and the whole row is crossed out. I found different codes on the internet and tried applying them to the table. Here's the code: \documentclass[12pt,a4paper]{article} \usepackage{amsmath,amssymb,amsthm, amsfonts} \usepackage{tikz-inet} \usepackage{graphicx} \usetikzlibrary{matrix} \usepackage{tikz} Command to make circle: \usetikzlibrary{fit,shapes.geometric} \newcounter{nodemarkers} \newcommand\circletext[1]{% \tikz[overlay,remember picture] \node (marker-\arabic{nodemarkers}-a) at (0,1.5ex) {};% #1% \tikz[overlay,remember picture] \node (marker-\arabic{nodemarkers}-b) at (0,0){};% \tikz[overlay,remember picture,inner sep=2pt] \node[draw,ellipse,fit=(marker-\arabic{nodemarkers}-a.center) (marker-\arabic{nodemarkers}-b.center)] {};% \stepcounter{nodemarkers}% } Command to make lines in the table: \newcommand{\tikzmark}[2]{\tikz[overlay,remember picture,baseline] \node [anchor=base] (#1) {$#2$};} \newcommand{\DrawVLine}[3][]{% \begin{tikzpicture}[overlay,remember picture] \draw[shorten <=0.3ex, #1] (#2.north) -- (#3.south); \end{tikzpicture} } \newcommand{\DrawHLine}[3][]{% \begin{tikzpicture}[overlay,remember picture] \draw[shorten <=0.2em, #1] (#2.west) -- (#3.east); \end{tikzpicture} } The table: \begin{document} \begin{center} \renewcommand{\arraystretch}{1.3} \begin{tabular}{c|cccc} \multicolumn {1}{c|}{} & 60 & 110 & 80 & 110 \\ \hline 80 & \tikzmark{topA}{3} & \tikzmark{topB}{10} & \tikzmark{topC}{20} & \tikzmark{topD}{ \circletext{0} } \\ 20 & 2 & 1 & 3 & \tikzmark{rightB}{0} \\ 50 & 2,5 & 3,5 & 4 & \tikzmark{rightC}{0} \\ 210 & 4 & 5 & 9 & \tikzmark{rightD}{0} \\ \DrawVLine[blue, thick, opacity=0.8]{topD}{rightD} \end{tabular} \end{center} \end{document} As you can see the vertical line is too long. Can anyone tell me where the code went wrong? If I try to remove \DrawVLine[blue, thick, opacity=0.8]{topD}{rightD} it looks fine though.

  • How to draw slope fields with all the possible solution curves in latex
    by MaoYiyi on October 16, 2013 at 3:17 am

    Sorry, I have no code to submit, mostly because I have no idea how to do this. I want to type up my homework (I can do the homework by hand) and I am looking for a simple method that I can use repetitively on different equations; without having to code each equation; to make/produce/draw the slope field of that equation. Currently, I have typed up the rest of my homework with latex, but have no good example from the internet to follow. I want to put the slope fields for both $\frac{\mathrm{d}y}{\mathrm{d}x}=2x$ and $\frac{\mathrm{d}y}{\mathrm{d}x}=x\sqrt{x}$ into my homework. My system is Fedora 19. Any suggestions? ps. sorry if this is a poor quality question. I just used the suggested tags.