• TikZ forest: how to add vertical dots to the 'top' or bottom of a directory tree?
    by Grass on November 16, 2025 at 9:51 am

    cfr provides us with a nice starting MWE to create directory trees: \documentclass[border=10pt,multi,tikz]{standalone} \usepackage[edges]{forest} \definecolor{folderbg}{RGB}{124,166,198} \definecolor{folderborder}{RGB}{110,144,169} \newlength\Size \setlength\Size{4pt} \tikzset{% folder/.pic={% \filldraw [draw=folderborder, top color=folderbg!50, bottom color=folderbg] (-1.05*\Size,0.2\Size+5pt) rectangle ++(.75*\Size,-0.2\Size-5pt); \filldraw [draw=folderborder, top color=folderbg!50, bottom color=folderbg] (-1.15*\Size,-\Size) rectangle (1.15*\Size,\Size); }, file/.pic={% \filldraw [draw=folderborder, 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, 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}, } \begin{document} \begin{forest} pic dir tree, pic root, for tree={% folder icons by default; override using file for file icons directory, }, [system [config ] [lib [Access ] [Plugin ] [file.txt, file ] ] ] \end{forest} \end{document} But how do I add vdots at the top of the directory tree --- more precisely, right below [system] --- and at the bottom of the directory tree? Here are the respective illustrations of the results I wish to achieve: I tried looking at edge path, the names of the forest nodes, and forest anchors in forest's documentation, but I couldn't get anywhere close to the results I want.

  • How to draw a rectangle in tikz at scale 0.9 without broken line joins
    by msrd0 on November 15, 2025 at 10:28 am

    I have a tikz picture that I apply scale=0.9 to that \draws a rectangle, like this: \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=0.9] \draw[draw=red, fill=red, fill opacity=0.3, thick] (0.24999999999999997, 5.8) -| (0.44999999999999996, 6.2) -| cycle; \end{tikzpicture} \end{document} This results in one corner not having the correct line join: If I would remove the scale argument, the line joint would be correct, but the whole picture no longer fits on my page. I also would like to avoid having to manually multiply all coordinates with 0.9. As a workaround, I could draw a second rectangle over it, with the "missing" corner in a different location. Is there a better solution?

  • Artifacts with externalize and geometry
    by Sak on November 14, 2025 at 11:36 pm

    I'm using TikZ externalization in my main LaTeX document, but when I include a PDF that was generated with different geometry and layout settings, it corrupts all subsequent TikZ externalizations. Project Structure: . ├── figures/ # Externalized tikz outputs ├── tikzfigure/ │ ├── figures -> ../figures # symbolic link │ ├── otd.pdf # to be included PDF │ └── otd.tex └── Poster_Presentation_outline.tex # Main document Main Document (Poster_Presentation_outline.tex): \documentclass[9pt]{extarticle} \usepackage{tikz} \usetikzlibrary{arrows.meta,external} \tikzexternalize[prefix=figures/] \usepackage{pdfpages} \begin{document} \pagestyle{plain} \tikzexternaldisable \newpage \includepdf[pages=-,landscape,fitpaper=true]{tikzfigure/otd.pdf} \newpage \tikzexternalenable \begin{tikzpicture}[scale=1.2] \draw[thick] (0,0) circle (2); \draw[thick] (-1.2,-1.2) rectangle (1.2,1.2); \coordinate (O) at (0,0); \coordinate (A) at (1.2,1.2); \coordinate (B) at (0,1.2); \coordinate (C) at (0,2); \coordinate (D) at (1.414,1.414); \draw[{Stealth[length=1.5mm]}-{Stealth[length=1.5mm]}, gray] (O) -- (-2,0) node[midway, below] {$R_I$}; \draw[{Stealth[length=1.5mm]}-{Stealth[length=1.5mm]}, gray] (1.3,0) -- (1.3,1.2) node[midway, right] {$\frac{L}{2}$}; \draw[{Stealth[length=1.5mm]}-{Stealth[length=1.5mm]}, gray] (0,0) -- (1.2,0) node[midway, below] {$\frac{L}{2}$}; \draw[{Stealth[length=1.5mm]}-{Stealth[length=1.5mm]}, gray] (-1.2,-1.4) -- (1.2,-1.4) node[midway, below] {$L$}; \draw[{Stealth[length=1.5mm]}-{Stealth[length=1.5mm]}, red!50!black] (A) -- (D) node[midway, above right=0.1] {$\phi_{\text{min}}$}; \draw[{Stealth[length=1.5mm]}-{Stealth[length=1.5mm]}, blue!50!black] (B) -- (C) node[midway, right] {$\phi_{\text{max}}$}; \draw[-{Stealth[length=1.5mm]}, dashed, gray] (O) -- (A) node[midway, above left=-0.2] {$\frac{L\sqrt{2}}{2}$}; \end{tikzpicture} \end{document} PDF Source (otd.tex): \documentclass{article} \usepackage{pdflscape} \usepackage{afterpage} \usepackage{tikz} \usepackage[landscape]{geometry} \geometry{papersize={297mm,330mm}, margin=20mm} \usetikzlibrary{external} \tikzexternalize[prefix=figures/] \usepackage{fancyhdr} \pagestyle{fancy} \fancypagestyle{plain}{ \fancyhf{} \renewcommand{\headrulewidth}{0pt} \fancyhead[L]{\textit{S. name1, F. name2, A. name3 et al.}} \fancyhead[R]{\textit{EG5416C - Exploring Engineering Project Management}} \fancyfoot[C]{\footnotesize6} } \setlength{\headsep}{0.2in} \setcounter{section}{2} \setcounter{subsection}{3} \begin{document} \pagestyle{plain} \centering \vspace*{2em} \subsection{OTD} \vspace*{\fill} \begin{tikzpicture}[ scale=0.7,every node/.append style={transform shape},myarrow/.style={-{Stealth[length=1.5mm,width=2mm]}}, mynode/.style={draw,fill=green!20!white,rectangle,inner xsep=5pt,inner ysep=20pt,text width=3cm,align=center,rounded corners=2mm,scale=0.8}, mynode2/.style={draw=white,fill=green!10!white,rectangle,inner xsep=5pt,inner ysep=20pt,text width=5cm,align=center,rounded corners=2mm,scale=0.8}] \def\opa{0} \def\posA{3} \def\posB{12} \def\firstx{-abs(\posA)} \def\firsty{abs(\posB)} \pgfmathsetmacro{\r}{sqrt(abs(\posA)^2 + abs(\posB)^2)} \pgfmathsetmacro{\angleLeft}{atan2(-\posA,-\posB)} \pgfmathsetmacro{\angleRight}{atan2(-\posA,\posB)} \pgfmathsetmacro{\span}{\angleRight - \angleLeft} \pgfmathsetmacro{\step}{\span/3} \pgfmathsetmacro{\angleOne}{\angleLeft + \step} \pgfmathsetmacro{\angleTwo}{\angleLeft + 2*\step} \pgfmathsetmacro{\xOne}{\r*cos(\angleOne)-0.1} \pgfmathsetmacro{\yOne}{\r*sin(\angleOne)+0.1} \pgfmathsetmacro{\xTwo}{\r*cos(\angleTwo)+0.1} \pgfmathsetmacro{\yTwo}{\r*sin(\angleTwo)+0.1} \def\cr{5} \def\opa{0.2} \node[mynode, rounded corners=0mm, inner sep=1cm, text width=5cm,fill=green!30!white] (main) at (0,0) {\LARGE Main Objective}; \node[mynode] (structural) at (-\posB,-\posA) {Structural Integrity}; \node[mynode] (efficiency) at (\xOne,\yOne) {Achieve operational efficiency}; \node[mynode] (safety) at (\xTwo,\yTwo) {Maintain safety compliance}; \node[mynode] (sustainability) at (\posB,-\posA) {Meet sustainability standards}; \node[mynode2, anchor=center] (LBC) at ($(-\posB,-\posA) + (150:\cr cm)$) {\textbf{Load-Bearing Capacity:} Support combined 5 t load (lid + internals) during lifting and assembly.}; \node[mynode2, anchor=center] (LSI) at ($(-\posB,-\posA) + (188:\cr cm)$) {\textbf{Lifting \& Support Interfaces:} Include lifting eyes, collars, or guided mounts for safe vessel handling.}; \node[mynode2, anchor=center] (AS) at ($(-\posB,-\posA) + (230:\cr cm)$) {\textbf{Anchoring \& Stability:} Maintain rigidity and resist tipping or lateral loads during operation.}; \draw[myarrow] (structural) .. controls (-\posB-0.5,-\posA+2) and ($(-\posB+3,-\posA) + (150:\cr cm)$) .. (LBC); \draw[myarrow] (structural) -- (LSI); \draw[myarrow] (structural) .. controls (-\posB,-\posA-1.5) and ($(-\posB+2.85,-\posA+1.2) + (230:\cr cm)$) .. (AS); \node[mynode2, anchor=center] (MR) at ($(\posB,-\posA) + (180-150:\cr cm)$) {\textbf{Material Recyclability:} Select frame materials that can be recycled at the end of the lifecycle.}; \node[mynode2, anchor=center] (EEF) at ($(\posB,-\posA) + (180-188:\cr cm)$) {\textbf{Energy-Efficient Fabrication:} Choose manufacturing methods that minimize energy consumption and waste.}; \node[mynode2, anchor=center] (WM) at ($(\posB,-\posA) + (180-230:\cr cm)$) {\textbf{Waste Minimization:} Reduce offcuts and scrap during production; design for easy disassembly and reuse.}; \draw[myarrow] (sustainability) .. controls (\posB+0.5,-\posA+2) and ($(\posB-3,-\posA) + (180-150:\cr cm)$) .. (MR); \draw[myarrow] (sustainability) -- (EEF); \draw[myarrow] (sustainability) .. controls (\posB,-\posA-1.5) and ($(\posB-2.85,-\posA+1.2) + (180-230:\cr cm)$) .. (WM); \node[mynode2, anchor=center] (AWO) at ($(\xOne,\yOne) + (190:\cr cm)$) {\textbf{Assembly Workflow Optimization:} Develop a clear, efficient method for assembling and disassembling the frame with minimal downtime.}; \node[mynode2, anchor=center] (OMA) at ($(\xOne,\yOne) + (235:\cr cm)$) {\textbf{On-Site Maintenance Access:} Provide clearance and lifting features for module removal and replacement without external workshops.}; \node[mynode2, anchor=center] (OR) at ($(\xOne,\yOne) + (300:\cr cm)$) {\textbf{Operational Reliability:} Maintain alignment and structural stability during repeated maintenance cycles.}; \draw[myarrow] (efficiency) .. controls (\xOne-1.5,\yOne-0.5) and ($(\xOne+3,\yOne+0.1) + (190:\cr cm)$) .. (AWO); \draw[myarrow] (efficiency) .. controls (\xOne-0.5,\yOne-1.5) and ($(\xOne+2,\yOne+2) + (235:\cr cm)$) .. (OMA); \draw[myarrow] (efficiency) .. controls (\xOne+0.5,\yOne-1.5) and ($(\xOne-1.6,\yOne+2.2) + (300:\cr cm)$) .. (OR); \node[mynode2, anchor=center] (LS) at ($(\xTwo,\yTwo) + (180-300:\cr cm)$) {\textbf{Lifting Stability:} Ensure the frame and lifting features maintain structural stability during lid and internal component handling.}; \node[mynode2, anchor=center] (LPI) at ($(\xTwo,\yTwo) + (180-235:\cr cm)$) {\textbf{Load Path Integrity:} Verify safe load transfer through the frame under both static and dynamic lifting conditions.}; \node[mynode2, anchor=center] (OSC) at ($(\xTwo,\yTwo) + (180-190:\cr cm)$) {\textbf{Operator Safety Clearances:} Maintain adequate access and spacing to prevent collision or pinch hazards during assembly and maintenance.}; \draw[myarrow] (safety) .. controls (\xTwo+1.5,\yTwo-0.5) and ($(\xTwo-3,\yTwo+0.1) + (180-190:\cr cm)$) .. (OSC); \draw[myarrow] (safety) .. controls (\xTwo+0.5,\yTwo-1.5) and ($(\xTwo-2,\yTwo+2) + (180-235:\cr cm)$) .. (LPI); \draw[myarrow] (safety) .. controls (\xTwo-0.5,\yTwo-1.5) and ($(\xTwo+1.6,\yTwo+2.2) + (180-300:\cr cm)$) .. (LS); \draw[myarrow] (main) .. controls (0,-7) and (-\posB+2,-\posA) .. (structural); \draw[myarrow] (main) .. controls (0,-7) and (\xOne,\yOne+2) .. (efficiency); \draw[myarrow] (main) .. controls (0,-7) and (-\xOne,\yOne+2) .. (safety); \draw[myarrow] (main) .. controls (0,-7) and (\posB-2,-\posA) .. (sustainability); \end{tikzpicture} \vspace*{\fill} \end{document} \includepdf doesnt isolate the PDF’s geometry i presume, so TikZ externalization is “inherits” them, corrupting figure output. here is the otd.pdf that is included and this is what it does to other tikz Am willing to give code for these if needed i provided one in the current main tex I Tried wrapping \includepdf with \tikzexternaldisable / \tikzexternalenable and using landscape, fitpaper=true options in \includepdf, ive been playing arround alot but cant seem to understand why the artifact form and how to fix them. None of my approaches prevent TikZ externalization from being affected. How can I safely include this PDF otd.pdf without its contents leaking into the TikZ externalization process?

  • How to draw disconnected nodes in a forest?
    by John Doe on November 14, 2025 at 4:05 pm

    Suppose I have the following forest: \documentclass{article} \usepackage{forest} \begin{document} \begin{forest} for tree={ grow=east, parent anchor=east, child anchor=west, align=center, inner sep=2pt, l=1em, l sep+=0em, s sep=5pt, anchor=base west, outer sep=0pt, edge path={ \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(5pt,0) |- (.child anchor)\forestoption{edge label}; }, for root={ parent anchor=east, text width=3cm, }, } [{My Cool Taxonomy},child anchor=north, parent anchor=east, anchor=center [ First Child, [Charlie [Test9, draw=black, no edge], [Test8, draw=black, no edge], [Test7, draw=black, no edge], [Test6, draw=black, no edge], ] [Bravo, [Test5, draw=black, no edge], [Test4, draw=black, no edge], [Test3, draw=black, no edge], ], [Alpha,, [Test2, draw=black, no edge], [Test1, draw=black, no edge], ] ] ] \end{forest} \end{document} which produces the following output: How can I draw the third-level nodes (Test1, ..., Test9) next to each other without an edge while considering their respective level? These nodes should grow from east to west. My desired output would be:

  • How to color the circle line of Tikz nodes with radial gradient using the node definition \node[...] with the built-in option "color"?
    by user2379123 on November 14, 2025 at 12:44 pm

    This is my code: \documentclass[margin=1mm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[C/.style = {circle, draw, inner sep=5pt, node contents={}}] \node[shading = axis, circle, left color=blue, right color=red, shading angle=135] (a) [C]; \end{tikzpicture} \end{document} This is the output: I want to color the black circle line with the filled radial gradient. Normally, I would use the node definition \node[color=...] with the predefined option "color" to obtain the result. But it just seems to be working for single colors. How can I use this option for color gradients? Do you have any idea?

  • How can I draw a filled plane using tikz/closedcycle
    by katang on November 13, 2025 at 11:26 pm

    I want to make a 3-D figure with a spatial diagram line and draw its projections onto the three axes planes. For better visibility, I want to mark the projections' positions with shaded planes. The MWE and the result are shown below. It looks like that \closedcycle wants to close anyhow in the plane containing the z-axis. Is there any option to draw a plane perpendicular to the z-axis (i.e., to the other two planes)? (I also tried \addplot3 [surf, fill] and fill between, but to no avail.) \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis} %XZ plane \addplot3 [fill=red!20,opacity=30,draw=none,fill opacity=0.5,] coordinates {(0,120,3900)(3,120,3900)} \closedcycle; %YZ plane \addplot3 [fill=green!20,opacity=30,draw=none,fill opacity=0.5,] coordinates {(3,-40,3900)(3,120,3900)} \closedcycle; %XY plane \addplot3 [fill=blue!20,opacity=30,draw=none,fill opacity=0.5,] coordinates {(0,-40,3900)(3,120,3900)} \closedcycle; \end{axis} \end{tikzpicture} \end{document} As a reply to @Jasper, I attach the figure here I need one more plane, for the blue diagram line. The thick spatial curve is projected to the axial planes. Thanks to all for your helpfulness and the useful hints.

  • How to add stripes/layers to a Tikz cube
    by Lucas on November 13, 2025 at 1:40 pm

    I have the following cube and I would like to add stratified layers/stripes vertically, i.e. travelling in the x_1 direction I come across a red layer, then blue layer, then red, then blue etc. How can I do this? \documentclass[tikz,border=5pt]{standalone} \usepackage{tikz} \begin{document} \begin{center} \begin{tikzpicture} \pgfmathsetmacro{\cubeSize}{3} \pgfmathsetmacro{\axisLength}{1.2} \draw[black,fill=gray!50] (0,0,0) -- ++(-\cubeSize,0,0) -- ++(0,-\cubeSize,0) -- ++(\cubeSize,0,0) -- cycle; \draw[black,fill=gray!60] (0,0,0) -- ++(0,0,-\cubeSize) -- ++(0,-\cubeSize,0) -- ++(0,0,\cubeSize) -- cycle; \draw[black,fill=gray!40] (0,0,0) -- ++(-\cubeSize,0,0) -- ++(0,0,-\cubeSize) -- ++(\cubeSize,0,0) -- cycle; \draw[->,thick] (-6,0,0) -- ({-6+\axisLength},0,0) node[right] {$x_1$}; \draw[->,thick] (-6,0,0) -- (-6,-\axisLength,0) node[below] {$x_2$}; \draw[->,thick] (-6,0,0) -- (-6,0,-\axisLength) node[above left] {$x_3$}; \end{tikzpicture} \end{center} \end{document}

  • \tikzmath defined functions sometimes won't parse in \addplot, producing spurious errors
    by Francis Cook on November 13, 2025 at 12:38 pm

    This is my first post so the graph may not appear and/or the format may look weird. Apologies if that is so. The graph is produced when the line \addplot[red, thick] {myexp(x,4)}; is commented out When included, numerous errors result, seemingly spurious because it is not being parsed as expected, for example "! Illegal unit of measure (pt inserted)." Unfortunately, I cannot see my mistake. I have tried everything I can think of, including spaces before and/or after pretty much every reference and even trying to use "declare function" (but I couldn't make that work the with complex, iterative logic). I am puzzled by the fact that a simple, two argument function (myfunc) can be called successfully, one with more complex logic (expterm) can be called successfully, but a complex one, with a loop and calls (myexp) fails. Any help/suggestions gratefully received. I am hoping to fix this with \tikzmath rather than use the equivalent pgfplots function definitions etc The code is as follows \documentclass{article} \usepackage{pgfplots} \usetikzlibrary{math} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} % Define the function using tikzmath - scope is within the tikzpicture % note that the \tikzmath block is sensitive to blank lines % so don't leave any lines blank % inclde non math lines like drawing commands within double curly braces {{ }} \tikzmath{ function myfunc(\x,\a) { return sin(\x r) + \a*\x; }; function expterm(\x,\n) { if \n == 0 then { return 1; } else { if \n == 1 then { return \x; } else { return \x ^ \n / factorial(\n); }; }; }; function myexp(\x,\n) { \s=0; for \i in {0,1,...,\n-1}{ \s=\s+expterm(\x,\i); }; return \s; }; } \begin{axis}[ domain=-2*pi:2*pi, xmin=-2*pi, xmax=2*pi, ymin=-3, ymax=3, restrict y to domain=-3:3, samples=100, axis lines=middle, xtick={ -2*pi, -3*pi/2, -pi, -pi/2, pi/2, pi, 3*pi/2, 2*pi }, xticklabels={ $-2\pi$, $-\frac{3\pi}{2}$, $-\pi$, $-\frac{\pi}{2}$, $\frac{\pi}{2}$, $\pi$, $\frac{3\pi}{2}$, $2\pi$ }, width=14cm, height=14cm, xlabel=$x$, ylabel={$y = f(x)$}, title={Function defined in \texttt{\textbackslash tikzmath}} ] % Use the tikzmath function in an addplot \addplot[blue, thick] {myfunc(x,0.3)}; \addplot[green, thick] {expterm(x,3)}; % \addplot[red, thick] {myexp(x,4)}; \end{axis} \end{tikzpicture} \end{document}

  • dvipsnames colours changing between tikz and tcolorbox [duplicate]
    by Craig on November 13, 2025 at 10:53 am

    Why is the colour RedViolet (or any colour) appearing differently in the tikzpicture and the tcolorbox, when the color is defined by its dvips name? \documentclass{standalone} \usepackage[dvipsnames]{xcolor} \usepackage{tikz,tcolorbox} \begin{document} \begin{tikzpicture} \shade[rounded corners=22pt, left color=RedViolet, right color=RedViolet] (0,0) rectangle ++(5,1.5); \end{tikzpicture} \begin{tcolorbox}[ title=Hello World, colframe=RedViolet, width=3cm ] \end{tcolorbox} \end{document}

  • match tikz \node placement with beamer's natural input
    by user1850133 on November 13, 2025 at 10:00 am

    I have a beamer document in which I placed text (first input on that slide) without using any special command or environment. Now on the next slide. I was expecting that tikz places \node at (0,0) { ... } exactly where beamer placed that first input on the previous slide. Actually there is a slight gap. So here I'd like to know if there's a way to make tikz place text exactly at the same place as the natural input of beamer. I also want to know if there is a way to get the coordinates of the last node placed by tikz. \documentclass[aspectratio=169,t]{beamer} \mode<presentation> \usetheme{moloch} \usepackage{tabularray,blindtext,tikz} \usetikzlibrary {fadings,patterns} \UseTblrLibrary{tikz,booktabs} \SetTblrInner{rowsep={2pt}} \newcommand{\titles}[1]{{\bfseries #1\vspace{.5em}}} \tikzfading[name=fade top,bottom color=transparent!100, top color=transparent!0] \begin{document} \begin{frame}{première} \end{frame} \begin{frame}{pgf input}% \begin{tikzpicture}% \node at (0,0) [font=\bfseries] {titre}; \end{tikzpicture}% % \titles{\centering titre}% \end{frame} \begin{frame}{basic input}% \titles{\centering titre}% \end{frame} \end{document} EDIT: based on the answer of the user who answered to my post I have written this code but the text input using the tikzmark set on the second slide of the document, is not at the right position. So, if anyone could debug it... \documentclass[aspectratio=169,t]{beamer} \usetheme{moloch} \usepackage{tikz,tabularray} \newcommand{\titles}[1]{{\bfseries #1\vspace{.5em}}} \usetikzlibrary{tikzmark} \NewDocumentCommand{\titremaker}{m}{% \begin{tikzpicture} \node at (0,0) [font=\bfseries,red,inner sep=0pt] {#1}; \end{tikzpicture}\vskip.5em} \NewDocumentCommand{\titreoverlay}{m m}{% \begin{tikzpicture}[remember picture,overlay,inner sep=0pt] \node at (pic cs:#2) [font=\bfseries,purple] {#1}; \end{tikzpicture}\vskip.5em} \begin{document} \begin{frame}{super prems} this frame only to avoid the slight positional shift of okular on the first page of pdf documents \end{frame} \begin{frame} \frametitle{pgf input}% \tikzmark{titrepos}% \titremaker{titre}% \only<2->{\vspace{-1cm}}% {% \only<2>{\SetTblrInner{cell{1}{1}={fg=brown}}} \only<3>{\SetTblrInner{cell{1}{2}={fg=brown}}} \begin{tblr}{colspec={lll},cells={yellow!20}} un & deux & trois\\ quatre & cinq & six\\ \end{tblr}} \only<3->{% \titreoverlay{titre}{titrepos}}% \end{frame} \end{document}

  • Strange node naming scope issues across two tikzpictures environment?
    by Explorer on November 13, 2025 at 1:27 am

    This post raised from my previous answer, and pascal974's comment: Consider the following two codes: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture} \foreach[remember=\n as \lastn] \n in {0,...,5}{ \node (\n) [right = of \lastn] {\n}; } \end{tikzpicture} \end{document} It would complain that as expected: ! Package pgf Error: No shape named `0' is known. See the pgf package documentation for explanation. Type H <return> for immediate help. ... l.10 } ? However, if I add \tikz \node (0) {}; in another tikzpicture, the definition of node's namespace looks like "penetrated" the tikzpicture, which affect the next node named 0 as below: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{positioning} \begin{document} \tikz \node (0) {}; \begin{tikzpicture} \foreach[remember=\n as \lastn] \n in {0,...,5}{ \node (\n) [right = of \lastn] {\n}; } \end{tikzpicture} \end{document} My question is: Why the namespace of \node is shared across different tikzpictures? It looks like some information leak happened here? I believe that this case is different with cfr's this excellent solution.

  • How come when filling in TikZ, there is a visible gap between adjacent fills?
    by Jasper on November 12, 2025 at 1:00 am

    How come when filling in TikZ, there is a visible gap between adjacent fills? \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \fill (0,0) -- (1,1) -- (1,0) -- cycle; \fill (0,0) -- (1,1) -- (0,1) -- cycle; \end{tikzpicture} \end{document}

  • How to distribute TikZ pics along entire path consisting of multiple subpaths?
    by dsacre on November 11, 2025 at 7:25 pm

    Assume the following: One wants to distribute (ideally: equally by length) TikZ pics along a path consisting of multiple subpaths. MWE \documentclass[border=5pt]{standalone} \usepackage{tikz} % DESCRIPTION: Definition of picture for positioning along the path \tikzset{ mypic/.pic={ \path[fill=cyan](0,0)circle(5pt); } } \begin{document} \begin{tikzpicture} \path[draw=black] (0,0)--++(0,2.5) arc(0:180:5) --++(0,-2.5) arc(180:360:5) % DESCRIPTION: Distributes pictures only on last part of path foreach \t in {0, 0.125, ..., 1}{ pic[pos=\t]{mypic} } ; \end{tikzpicture} \end{document} Result Goals Distribute pics along complete path (without copy pasting the foreach construct to each subpath) Achieve equal distribution by length over the whole path Question Is there a way to achieve this with plain TikZ or a TikZ library? Ideally, the solution should be as programmatically as possible, since it is intended to be used in an animation later on.

  • Aligning arrows along a path at fixed steps on a rectangular grid
    by PatrickT on November 11, 2025 at 5:42 pm

    The objective is to have arrows along a path for every 1-unit step we take horizontally or vertically. The arrows would be aligned midway between major grid tick marks, e.g. midway along (0,0)--(0,1). To give context, these arrows could be used to show east-west and north-west movement along a rectangular grid. I have managed to handle the case where the x and y units are the same. Below I have tweaked the parameters to have the blue arrows aligned at the midpoint (grid minor line colored in cyan). But I failed with the red arrows. The problem is that the x-scale and y-scale are quite different. If the step is tweaked to match horizontal distances (parallel to the x-axis), then it will not match the vertical distances. How to fix this? To clarify, if I give a path like (0,0)--(10,0), I would like an arrow midway along (0,0)--(1,0), then midway along (1,0)--(2,0), and so on. Otherwise I would just use something like [midway](0,0)--(10,0) or [pos=0.5](0,0)--(10,0). In my code I have to tweak the "starting value" as well as the "step". It would obviously be much nicer to have a solution where I could set a starting value at 0.5 (meaning at the midway point between two major grid tick lines) and a step equal to 1 (meaning moving by 1 unit of image scale --- not units of the axis --- along both x and y directions). \documentclass[border=3pt,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{calc} % Required for coordinate calculations \usetikzlibrary{decorations.markings} % Required for decorations along path % Define a TikZ style for arrows on path: color as optional argument % \usetikzlibrary{decorations.markings, arrows.meta} \tikzset{ arrows along path/.style args={#1/#2/#3}{% >=latex, decoration={ markings, mark=between positions #1 and #2 step #3 with { \arrow{latex} } }, postaction={decorate} }, arrows along path/.default={0/1/0.5} } % x has range 5 % y has range 3000 % 3000/5 = 600 % 5/3000 = 0.00166666666 \begin{document} \begin{tikzpicture} \begin{axis}[ x = 2cm, y = 0.0033cm,% tweaked to match y/x=5/3000 ratio xmin=0, xmax=5, ymin=500, ymax=3500, xtick = {0,1,...,5}, ytick = {500,1000,...,3500}, tick align=outside, minor tick num=1, minor tick length=4pt, minor tick style={color=cyan,thick}, minor grid style={color=cyan,thick}, grid = both, clip = false, ] \coordinate (A) at (0,2000); \coordinate (B) at (5,2000); \coordinate (C) at (0,1000); \coordinate (D) at (1,1000); \coordinate (E) at (1,3000); \coordinate (F) at (4,3000); \coordinate (G) at (4,1000); \coordinate (H) at (5,1000); % Blue line \draw [blue, thick, arrows along path={0.118/1/0.20}] (A) -- (B); % Red line \draw [red, thick, arrows along path={0.051/1/0.079}] (C) -- (D) -- (E) -- (F) -- (G) -- (H); \end{axis} \end{tikzpicture} \end{document} Second implementation, also fails to get the correct output: \documentclass[border=3pt,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{calc} % Required for coordinate calculations \usetikzlibrary{decorations.markings} % Required for decorations along path % Define a TikZ style for arrows on path: color as optional argument % \usetikzlibrary{decorations.markings, arrows.meta} \tikzset{ arrows along path/.style args={#1/#2/#3}{% >=latex, decoration={ markings, mark=between positions #1 and #2 step #3 with { \arrow{latex} } }, postaction={decorate} }, arrows along path/.default={0/1/0.5} } \begin{document} \begin{tikzpicture} \begin{axis}[ x=2cm, y=0.0033cm, xmin=0, xmax=5, ymin=500, ymax=3500, xtick = {0,1,...,5}, ytick = {500,1000,...,3500}, tick align=outside, minor tick num=1, minor tick length=4pt, minor tick style={color=cyan,thick}, minor grid style={color=cyan,thick}, grid = both, clip = false, ] \coordinate (A) at (0,2000); \coordinate (B) at (5,2000); \coordinate (C) at (0,1000); \coordinate (D) at (1,1000); \coordinate (E) at (1,3000); \coordinate (F) at (4,3000); \coordinate (G) at (4,1000); \coordinate (H) at (5,1000); % Blue line \draw [blue, thick, arrows along path={0.12/1/0.20}] (A) -- (B); % Red line \pgfplotsextra{ \foreach \P/\Q in {C/D, D/E, E/F, F/G, G/H}{ \draw [red, thick, arrows along path={0.6/1/0.40}] (\P) -- (\Q); } } \end{axis} \end{tikzpicture} \end{document} A variant with a node and a dot, that sort of look like the ideal implementation for its simplicity, but fails just the same. \documentclass[border=3pt,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{calc} % Required for coordinate calculations \usetikzlibrary{decorations.markings} % Required for decorations along path % set up all axes \pgfplotsset{% every axis/.append style={% axis styles %ticks = none, grid = both, clip = false,% remove clip }% }% % Define a TikZ style for arrows \tikzset{ marks along path/.style args={#1/#2/#3/#4}{% decoration={ markings, mark=between positions #1 and #2 step #3 with { \node[#4] at (0,0) {}; } }, postaction={decorate} }, marks along path/.default={0/1/0.5/shape=circle,fill=black,draw=black,inner sep=0pt,minimum size=4mm,line width=2pt} } \begin{document} \begin{tikzpicture} \begin{axis}[ x = 2cm, y = 0.0033cm,% tweaked to match y/x=5/3000 ratio xmin=0, xmax=5, ymin=500, ymax=3500, xtick = {0,1,...,5}, ytick = {500,1000,...,3500}, tick align=outside, minor tick num=1, minor tick length=4pt, minor tick style={color=cyan,thick}, minor grid style={color=cyan,thick}, grid = both, clip = false, ] \coordinate (A) at (0,2000); \coordinate (B) at (5,2000); \coordinate (C) at (0,1000); \coordinate (D) at (1,1000); \coordinate (E) at (1,3000); \coordinate (F) at (4,3000); \coordinate (G) at (4,1000); \coordinate (H) at (5,1000); % Blue line \draw[blue, line width=2pt, marks along path={0/1/0.5/shape=circle,fill=blue,draw=black}] (A) -- (B); \draw[red, line width=2pt, marks along path={0/1/0.5/shape=circle,fill=red,draw=black}] (C) -- (D) -- (E) -- (F) -- (G) -- (H); \end{axis} \end{tikzpicture} \end{document}

  • TikZ externalization does not respect dependency definition
    by Christian Wolf on November 10, 2025 at 3:02 pm

    I want to configure my setup for externalizing TikZ images. I ran into an issue and created the following MWE: \documentclass{article} \usepackage{tikz} \usetikzlibrary{external} \tikzexternalize[mode=list and make] \begin{document} \tikzpicturedependsonfile{mwe1.tex} \begin{tikzpicture} \tikzpicturedependsonfile{mwe.tex} \draw (0,0) circle (1cm); \end{tikzpicture} \end{document} This works in general to create a document and create the images as well. So, theoretically this works (almost). I want to handle the dependencies as part of a macro definition in the document header. Thus, I would like to define a \ImportTikz macro to read an external file (using \input) and set the dependency on the file for externalization. I found (see MWE) that the dependency is only working within the tikzpicture environment. The documentation states: 52.4.3 Remaking Figures or Skipping Figures \tikzpicturedependsonfile{⟨file name⟩} Adds a dependency for the next picture which is about to be externalized. If the command is invoked within a picture environment, it adds a dependency for the surrounding picture. Comparing this with e.g. the export next key, it implies for me that I could also put the \tikzpicturedependsonfile just before the tikzpicture in question. The problem is that the generated .dep file only contains the mwe.tex and not the (non-existent) mwe1.tex. Am I misinterpreting the documentation or is this a bug?

  • what is the best AI tool to write fancy latex code [closed]
    by Abderrahim Hadder on November 10, 2025 at 11:17 am

    by your experience ,i want some suggestion about the best AI tool to write latex ( long code, fancy design, good with tikz).... I have tried chatgpt 4, gemini, and claude ( previous version) and i didnt find what i looked for. Thanks

  • Plot any real sequence of real variables as in Geogebra and Desmos
    by Sebastiano on November 8, 2025 at 11:25 pm

    Several years ago, I created a GeoGebra script to plot any real sequence of real variables. As you can see from the screenshot, there is a command on the left: Sequence({(n, 1/n)}, n, 1, M) which putting every sequence, give me a graph of this. Usually, I use GeoGebra and then quickly export to TikZ with the option Save as. Here an example: \documentclass[10pt]{article} \usepackage{pgfplots} \pgfplotsset{compat=1.15} \usepackage{mathrsfs} \usetikzlibrary{arrows} \pagestyle{empty} \begin{document} \definecolor{qqweqq}{rgb}{0,0.43137254901960786,0} \definecolor{aqaqaq}{rgb}{0.6274509803921569,0.6274509803921569,0.6274509803921569} \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm] \begin{axis}[ x=1cm,y=1cm, axis lines=middle, grid style=dashed, xmin=-0.41753528626111724, xmax=22.657576260984815, ymin=-1.2286763992422356, ymax=7.280825323814707, xtick={0,1,...,22}, ytick={-1.2000000000000002,-1.1,...,7.200000000000001},] \clip(-0.41753528626111724,-1.2286763992422356) rectangle (22.657576260984815,7.280825323814707); \draw[line width=5.2pt,color=aqaqaq] (5.616473767760089,4.363281875909468) -- (10.036993221255479,4.363281875909468); \draw (11.053712695559419,5.777848396105947) node[anchor=north west] {$a_n= \frac{1}{n} \quad \quad n \in [1,14]$}; \begin{scriptsize} \draw [fill=aqaqaq] (7.598085936568367,4.363281875909468) circle (3pt); \draw[color=aqaqaq] (8.158272453519938,5.114770339763847) node {$M = 14$}; \draw [fill=qqweqq] (1,1) circle (1.5pt); \draw [fill=qqweqq] (2,0.5) circle (1.5pt); \draw [fill=qqweqq] (3,0.3333333333333333) circle (1.5pt); \draw [fill=qqweqq] (4,0.25) circle (1.5pt); \draw [fill=qqweqq] (5,0.2) circle (1.5pt); \draw [fill=qqweqq] (6,0.16666666666666666) circle (1.5pt); \draw [fill=qqweqq] (7,0.14285714285714285) circle (1.5pt); \draw [fill=qqweqq] (8,0.125) circle (1.5pt); \draw [fill=qqweqq] (9,0.1111111111111111) circle (1.5pt); \draw [fill=qqweqq] (10,0.1) circle (1.5pt); \draw [fill=qqweqq] (11,0.09090909090909091) circle (1.5pt); \draw [fill=qqweqq] (12,0.08333333333333333) circle (1.5pt); \draw [fill=qqweqq] (13,0.07692307692307693) circle (1.5pt); \draw [fill=qqweqq] (14,0.07142857142857142) circle (1.5pt); \end{scriptsize} \end{axis} \end{tikzpicture} \end{document} With Desmos, for example, there is a page where https://www.desmos.com/calculator/4wwz1emgyd?lang=it I have given an arbitrary sequence a(x)= sin ( (π/2) ⋅ x⁴/(x⁴+1)) it gives a graph. Is it possible to have the same thing of Geogebra and Desmos in TikZ/Metapost/Lua that allow me to plot any sequence directly to save time without to write a long code?

  • TikZ: How to draw a 3D shape by defining its 2D cross-section and 3D path?
    by Diaa on November 8, 2025 at 12:24 pm

    For the following, I would like to draw a 3D shape by sweeping the cross-section (i.e., rectangle or circle) along the 3D path from its start to end coordinates, while having, if possible, the option to draw the hidden edges as dashed lines based on the 3d view view angles control the smoothness of connectivity at vertices (getting right-angled bends or curved ones). \documentclass[tikz,border=10pt]{standalone} \usepackage{tikz} \usetikzlibrary{3d,calc,perspective} \begin{document} \begin{tikzpicture}[3d view={140}{40}] \begin{scope}[->, black, thin] \draw (0,0,0)-- (3,0,0) node[anchor=north east]{$x$}; \draw (0,0,0) -- (0,3,0) node[anchor=north west]{$y$}; \draw (0,0,0) -- (0,0,3) node[anchor=south]{$z$}; \end{scope} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \coordinate (start1) at (3,1,2); \coordinate (end1) at (3,1,-2); \draw[canvas is xy plane at z=2, fill=blue!10] ($(start1) - (0.25,0.5)$) rectangle ($(start1) + (0.25,0.5)$); \coordinate (v1) at ($(start1)+(0,0,1)$); \coordinate (v2) at ($(v1)+(-2,0,0)$); \coordinate (v3) at ($(v2)+(0,0,-6)$); \coordinate (v4) at ($(v3)+(2,0,0)$); \draw[blue] (start1) -- (v1) -- (v2) -- (v3) -- (v4) -- (end1); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \coordinate (start2) at (-3,1,2); \coordinate (end2) at (-3,1,-2); \draw[canvas is xy plane at z=2, fill=red!10] (start2) circle (0.25); \coordinate (v11) at ($(start2)+(0,0,1)$); \coordinate (v22) at ($(v11)+(2,0,0)$); \coordinate (v33) at ($(v22)+(0,0,-6)$); \coordinate (v44) at ($(v33)+(-2,0,0)$); \draw[red] (start2) -- (v11) -- (v22) -- (v33) -- (v44) -- (end2); \end{tikzpicture} \end{document}

  • "Hanging" corners on Tikz diagram
    by pwesterbaan on November 6, 2025 at 7:23 pm

    I'm creating a diagram of an open box using Tikz: \documentclass[margin=5pt, convert={density=1000, size=10000}]{standalone} \usepackage{tikz} \usetikzlibrary{calc} \pagecolor[RGB]{255,255,255} \begin{document} % H-------G % /| /| % / | / | % / E----/--F % / / / / % D-------C / % | / | / % |/ |/ % A-------B \begin{tikzpicture}[ declare function={ wdth=4.35; hgt=2; x_offset=2.75; y_offset=2.75;} ] \coordinate (A) at (0,0); \coordinate (B) at (wdth,0); \coordinate (C) at (wdth,hgt); \coordinate (D) at (0,hgt); \coordinate (E) at ($(A)+(x_offset, y_offset)$); \coordinate (F) at ($(B)+(x_offset, y_offset)$); \coordinate (G) at ($(C)+(x_offset, y_offset)$); \coordinate (H) at ($(D)+(x_offset, y_offset)$); \draw[fill=black!15, line width=1pt] (A) -- (B) -- (F) -- (E) -- cycle; \draw[line width=1pt] (E) -- (F) -- (G) -- (H) -- cycle; \draw[fill=white, line width=1pt] (A) -- (E) -- (H) -- (D) -- cycle; \draw[fill=white, line width=1pt] (B) -- (F) -- (G) -- (C) -- cycle; \draw[fill=white, line width=1pt] (A) -- (B) -- (C) -- (D) -- cycle; \draw[dotted] (A) -- (E) -- (F); \end{tikzpicture} \end{document} The problem I'm having is that the lines protrude where the corners meet (likely because my line width=1pt). How do I draw this diagram without the "hanging" bits at the corners?

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

  • TikZ arrow difference in different PDF-viewer(PDF-XChange-Editor v10.5.2)?
    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? Edit to mizimizhi Z's comments(@muzimuzhiZ): The test code: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{arrows.meta} \begin{document} \tikz \draw[line join=round, {-Latex}] (0,0) -- (1,0); \begin{tikzpicture}[ line width=5pt, line join=round ] \draw (0,0) -- (1,1) -- (1,0); \draw[line join=miter, xshift=2cm] (0,0) -- (1,1) -- (1,0); \end{tikzpicture} \end{document} While in contrast, I compared it with another PDF-viewer: foxit-PDF-editor-pro, it gives the correct result:

  • 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: (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!

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

  • Parsing command arguments with xstring within tikzpicture block
    by UnderscorePoY on October 26, 2025 at 10:26 pm

    I'm trying to write a custom command to automatically adapt the shape of intervals in Tikz. I'm currently trying to pass an orientation argument to the command \intervalle to parse it via another command \intervalleParseOrientation. Here's a MWE: \documentclass[crop,tikz]{standalone} \usepackage{xstring} \newcommand{\intervalleParseOrientation}[2]{ \IfStrEqCase{#1}{ {h}{{#2}, 0} {v}{0, {#2}} }[\GenericError{}{}{}{h (horizontal) or v (vertical)}] } \newcommand{\intervalle}[1]{ \draw[|-|] (0, 0) -- (\intervalleParseOrientation{h}{1}); } \begin{document} \begin{tikzpicture} \intervalle{1}; \end{tikzpicture} \end{document} This gives the error Illegal parameter number in definition of \tikz@scan@point@coordinate., pointing at the argument within the call to \intervalle. Anyone happens to have encountered such error ? I'd really appreciate some help on that one. Thanks in advance!

  • Non-linear transformation of text
    by David Purton on August 16, 2025 at 2:20 pm

    My end goal is to apply a specific wave warp to a short block of text in line with a style guide. Below is my attempt. I've applied the transform to a 4 by 4 grid and it behaves as I want with the sine wave having maximum height in the middle of the grid and reducing until the top and bottom of the grid remain horizontal. The second transform uses the text converted to a path in Inkscape and exported as TikZ code (sorry it's long). This also does what I want. The third example shows what I wish I could do in just putting the text in a node. I know that this is not possible to do this way as the TikZ documentation states: When /tikz/transform shape nonlinear is set to true, TikZ will try to apply any current nonlinear transformation also to nodes. Typically, for the text in nodes this is not possible in general, in such cases a linear approximation of the nonlinear transformation is used. But converting to curves in Inkscape and then applying the transform is a little too manual. I would like a more automated option, so that I can easily change the text and have a new wave output. Question: Is there a way I can do this? It does not have to be using TikZ (but I do want LaTeX). It can use l3draw or lua code. \documentclass{article} \usepackage{tikz} \usepgfmodule{nonlineartransformations} \pagestyle{empty} \makeatletter \def\wavewarp{% \pgf@ya=\pgf@y% \pgfmathsetmacro{\warped@y}{% \pgf@ya+% 0.01*\pgfkeysvalueof{/tikz/wave warp/bend}*% \pgfkeysvalueof{/tikz/wave warp/height}*% sin(\pgf@x/\pgfkeysvalueof{/tikz/wave warp/width}*360)*% sin(\pgf@ya/\pgfkeysvalueof{/tikz/wave warp/height}*180)% }% \pgf@y=\warped@y pt% } \makeatother \newsavebox{\warpbox} \newlength{\warpboxwd} \newlength{\warpboxht} \begin{document} \tikzset{ wave warp/width/.initial=\warpboxwd, wave warp/height/.initial=\warpboxht, wave warp/bend/.initial=10 } \newcommand*{\grid}{\draw (0,0) grid (4,4);} \sbox\warpbox{\tikz{\grid}} \setlength{\warpboxwd}{\wd\warpbox} \setlength{\warpboxht}{\ht\warpbox} \begin{tikzpicture} \begin{scope} \pgftransformnonlinear{\wavewarp} \grid \end{scope} \end{tikzpicture} \vspace{1cm} \tikzset{x=1pt,y=1pt} \newcommand*{\textaspath}{% \fill[shift={(6.6, 8.6)}] (11.8, -8.6) -- (6.0, -8.6) -- (6.0, 8.1) -- (0.8, 8.1) -- (0.8, 12.8) -- (17.0, 12.8) -- (17.0, 8.1) -- (11.8, 8.1) -- cycle(32.8, -8.6) -- (20.1, -8.6) -- (20.1, 12.8) -- (32.8, 12.8) -- (32.8, 8.2) -- (25.9, 8.2) -- (25.9, 4.8) -- (32.3, 4.8) -- (32.3, 0.2) -- (25.9, 0.2) -- (25.9, -3.9) -- (32.8, -3.9) -- cycle(55.9, -8.6) -- (49.2, -8.6) -- (45.0, -1.9) -- (40.9, -8.6) -- (34.3, -8.6) -- (41.4, 2.4) -- (34.7, 12.8) -- (41.2, 12.8) -- (45.0, 6.2) -- (48.7, 12.8) -- (55.3, 12.8) -- (48.6, 1.9) -- cycle(67.7, -8.6) -- (61.9, -8.6) -- (61.9, 8.1) -- (56.7, 8.1) -- (56.7, 12.8) -- (72.9, 12.8) -- (72.9, 8.1) -- (67.7, 8.1) -- cycle(23.7, 44.3) -- (18.4, 22.9) -- (11.5, 22.9) -- (9.5, 32.2) .. controls (9.5, 32.4) and (9.4, 32.7) .. (9.3, 33.1) .. controls (9.2, 33.5) and (9.1, 34.0) .. (9.0, 34.6) .. controls (8.9, 35.1) and (8.8, 35.6) .. (8.8, 36.1) .. controls (8.7, 36.7) and (8.6, 37.1) .. (8.6, 37.5) .. controls (8.5, 37.1) and (8.5, 36.7) .. (8.4, 36.1) .. controls (8.3, 35.6) and (8.2, 35.1) .. (8.1, 34.6) .. controls (8.0, 34.0) and (7.9, 33.5) .. (7.8, 33.1) .. controls (7.7, 32.7) and (7.7, 32.4) .. (7.6, 32.2) -- (5.5, 22.9) -- (-1.3, 22.9) -- (-6.6, 44.3) -- (-1.0, 44.3) -- (1.3, 33.6) .. controls (1.4, 33.3) and (1.5, 32.9) .. (1.6, 32.4) .. controls (1.7, 31.9) and (1.8, 31.4) .. (1.9, 30.9) .. controls (2.0, 30.3) and (2.1, 29.8) .. (2.2, 29.2) .. controls (2.3, 28.7) and (2.4, 28.3) .. (2.4, 27.9) .. controls (2.5, 28.5) and (2.6, 29.2) .. (2.7, 30.0) .. controls (2.8, 30.7) and (3.0, 31.5) .. (3.1, 32.3) .. controls (3.3, 33.1) and (3.5, 33.8) .. (3.6, 34.5) .. controls (3.8, 35.2) and (3.9, 35.8) .. (4.0, 36.2) -- (5.9, 44.3) -- (11.2, 44.3) -- (13.1, 36.2) .. controls (13.2, 35.8) and (13.3, 35.2) .. (13.4, 34.5) .. controls (13.6, 33.8) and (13.8, 33.1) .. (13.9, 32.3) .. controls (14.1, 31.5) and (14.2, 30.7) .. (14.4, 29.9) .. controls (14.5, 29.2) and (14.6, 28.5) .. (14.7, 27.9) .. controls (14.7, 28.4) and (14.8, 29.0) .. (15.0, 29.8) .. controls (15.1, 30.5) and (15.2, 31.2) .. (15.4, 31.9) .. controls (15.5, 32.6) and (15.6, 33.2) .. (15.7, 33.5) -- (18.1, 44.3) -- cycle(38.4, 22.9) -- (37.3, 26.9) -- (30.4, 26.9) -- (29.3, 22.9) -- (22.9, 22.9) -- (29.9, 44.4) -- (37.6, 44.4) -- (44.7, 22.9) -- cycle(35.2, 35.2) .. controls (35.1, 35.5) and (34.9, 36.1) .. (34.8, 36.8) .. controls (34.6, 37.5) and (34.4, 38.2) .. (34.2, 39.0) .. controls (34.0, 39.8) and (33.9, 40.4) .. (33.8, 40.9) .. controls (33.7, 40.4) and (33.6, 39.8) .. (33.4, 39.1) .. controls (33.3, 38.3) and (33.1, 37.6) .. (32.9, 36.9) .. controls (32.7, 36.2) and (32.6, 35.6) .. (32.5, 35.2) -- (31.6, 31.6) -- (36.1, 31.6) -- cycle(64.3, 44.3) -- (57.3, 22.9) -- (50.5, 22.9) -- (43.5, 44.3) -- (50.0, 44.3) -- (52.9, 33.4) .. controls (53.0, 33.0) and (53.1, 32.5) .. (53.3, 31.9) .. controls (53.4, 31.2) and (53.5, 30.6) .. (53.7, 30.0) .. controls (53.8, 29.3) and (53.9, 28.8) .. (53.9, 28.4) .. controls (53.9, 28.8) and (54.0, 29.3) .. (54.1, 29.9) .. controls (54.2, 30.6) and (54.4, 31.2) .. (54.5, 31.8) .. controls (54.6, 32.5) and (54.7, 33.0) .. (54.9, 33.4) -- (57.8, 44.3) -- cycle(79.3, 22.9) -- (66.6, 22.9) -- (66.6, 44.3) -- (79.3, 44.3) -- (79.3, 39.7) -- (72.4, 39.7) -- (72.4, 36.3) -- (78.8, 36.3) -- (78.8, 31.6) -- (72.4, 31.6) -- (72.4, 27.6) -- (79.3, 27.6) -- cycle(9.8, 60.8) .. controls (9.8, 59.7) and (9.5, 58.6) .. (8.9, 57.5) .. controls (8.4, 56.5) and (7.4, 55.7) .. (6.2, 55.0) .. controls (5.0, 54.4) and (3.4, 54.0) .. (1.4, 54.0) .. controls (0.5, 54.0) and (-0.4, 54.1) .. (-1.1, 54.2) .. controls (-1.9, 54.3) and (-2.5, 54.4) .. (-3.2, 54.6) .. controls (-3.8, 54.8) and (-4.5, 55.1) .. (-5.2, 55.4) -- (-5.2, 60.5) .. controls (-4.0, 60.0) and (-2.8, 59.5) .. (-1.7, 59.2) .. controls (-0.5, 58.9) and (0.6, 58.7) .. (1.6, 58.7) .. controls (2.4, 58.7) and (3.0, 58.9) .. (3.4, 59.2) .. controls (3.8, 59.5) and (4.0, 59.9) .. (4.0, 60.3) .. controls (4.0, 60.9) and (3.7, 61.3) .. (3.1, 61.7) .. controls (2.6, 62.0) and (1.6, 62.5) .. (0.2, 63.2) .. controls (-0.9, 63.7) and (-1.8, 64.2) .. (-2.6, 64.7) .. controls (-3.4, 65.3) and (-4.0, 66.0) .. (-4.4, 66.8) .. controls (-4.8, 67.6) and (-5.0, 68.6) .. (-5.0, 69.8) .. controls (-5.0, 71.2) and (-4.7, 72.3) .. (-4.0, 73.2) .. controls (-3.3, 74.2) and (-2.4, 74.9) .. (-1.2, 75.3) .. controls (0.0, 75.8) and (1.5, 76.1) .. (3.1, 76.1) .. controls (4.5, 76.1) and (5.7, 75.9) .. (6.8, 75.6) .. controls (8.0, 75.3) and (9.0, 74.9) .. (9.8, 74.5) -- (8.1, 70.1) .. controls (7.1, 70.5) and (6.2, 70.8) .. (5.3, 71.0) .. controls (4.5, 71.3) and (3.6, 71.4) .. (2.9, 71.4) .. controls (2.1, 71.4) and (1.6, 71.3) .. (1.2, 71.0) .. controls (0.9, 70.8) and (0.7, 70.5) .. (0.7, 70.1) .. controls (0.7, 69.7) and (0.8, 69.4) .. (1.1, 69.2) .. controls (1.4, 68.9) and (1.8, 68.6) .. (2.4, 68.3) .. controls (3.0, 68.0) and (3.9, 67.6) .. (4.9, 67.1) .. controls (6.0, 66.7) and (6.8, 66.1) .. (7.6, 65.6) .. controls (8.3, 65.0) and (8.9, 64.4) .. (9.2, 63.6) .. controls (9.6, 62.9) and (9.8, 62.0) .. (9.8, 60.8) -- cycle(33.2, 65.1) .. controls (33.2, 62.9) and (32.8, 60.9) .. (32.1, 59.3) .. controls (31.4, 57.6) and (30.3, 56.3) .. (28.7, 55.4) .. controls (27.2, 54.5) and (25.2, 54.0) .. (22.8, 54.0) .. controls (20.4, 54.0) and (18.4, 54.5) .. (16.9, 55.4) .. controls (15.3, 56.3) and (14.2, 57.6) .. (13.4, 59.3) .. controls (12.7, 60.9) and (12.4, 62.9) .. (12.4, 65.1) .. controls (12.4, 67.3) and (12.7, 69.3) .. (13.5, 70.9) .. controls (14.2, 72.6) and (15.3, 73.8) .. (16.9, 74.7) .. controls (18.4, 75.6) and (20.4, 76.1) .. (22.8, 76.1) .. controls (25.2, 76.1) and (27.2, 75.6) .. (28.7, 74.7) .. controls (30.3, 73.8) and (31.4, 72.5) .. (32.1, 70.9) .. controls (32.8, 69.2) and (33.2, 67.3) .. (33.2, 65.1) -- cycle(18.4, 65.1) .. controls (18.4, 63.1) and (18.8, 61.6) .. (19.4, 60.5) .. controls (20.1, 59.4) and (21.2, 58.9) .. (22.8, 58.9) .. controls (24.4, 58.9) and (25.5, 59.4) .. (26.1, 60.5) .. controls (26.8, 61.6) and (27.1, 63.1) .. (27.1, 65.1) .. controls (27.1, 67.0) and (26.8, 68.5) .. (26.1, 69.7) .. controls (25.5, 70.8) and (24.4, 71.3) .. (22.8, 71.3) .. controls (21.2, 71.3) and (20.1, 70.8) .. (19.4, 69.7) .. controls (18.8, 68.5) and (18.4, 67.0) .. (18.4, 65.1) -- cycle(46.4, 54.3) -- (42.0, 69.8) -- (41.9, 69.8) .. controls (41.9, 69.4) and (42.0, 68.8) .. (42.0, 68.1) .. controls (42.0, 67.5) and (42.1, 66.7) .. (42.1, 65.9) .. controls (42.2, 65.1) and (42.2, 64.4) .. (42.2, 63.6) -- (42.2, 54.3) -- (37.0, 54.3) -- (37.0, 75.8) -- (44.8, 75.8) -- (49.2, 60.5) -- (49.3, 60.5) -- (53.7, 75.8) -- (61.4, 75.8) -- (61.4, 54.3) -- (56.1, 54.3) -- (56.1, 63.7) .. controls (56.1, 64.4) and (56.1, 65.1) .. (56.2, 65.9) .. controls (56.2, 66.7) and (56.2, 67.4) .. (56.2, 68.1) .. controls (56.3, 68.8) and (56.3, 69.3) .. (56.3, 69.7) -- (56.2, 69.7) -- (51.9, 54.3) -- cycle(78.8, 54.3) -- (66.1, 54.3) -- (66.1, 75.8) -- (78.8, 75.8) -- (78.8, 71.1) -- (71.8, 71.1) -- (71.8, 67.7) -- (78.3, 67.7) -- (78.3, 63.1) -- (71.8, 63.1) -- (71.8, 59.0) -- (78.8, 59.0) -- cycle;} \sbox\warpbox{\tikz{\textaspath}} \setlength{\warpboxwd}{\wd\warpbox} \setlength{\warpboxht}{\ht\warpbox} \begin{tikzpicture} \begin{scope} \pgftransformnonlinear{\wavewarp} \textaspath \end{scope} \end{tikzpicture} \vspace{2cm} \newcommand*{\textastext}{% \node[transform shape, transform shape nonlinear, inner sep=0pt, outer sep=0pt, align=center, font=\sffamily\Huge\bfseries] {% SOME\\ WAVE\\ TEXT};} \sbox\warpbox{\tikz{\textastext}} \setlength{\warpboxwd}{\wd\warpbox} \setlength{\warpboxht}{\ht\warpbox} \begin{tikzpicture} \begin{scope} \pgftransformnonlinear{\wavewarp} \textastext \end{scope} \end{tikzpicture} \end{document}

  • Prevent quantikz from altering tikz behaviour?
    by mavzolej on March 21, 2024 at 2:18 am

    This code \documentclass{article} \usepackage{tikz-cd} % \usetikzlibrary{quantikz2} \begin{document} \begin{tikzcd}[ampersand replacement=\&] A \arrow[rrrr, ""] \& \& \& \& B \arrow[rd, ""] \\ \& \& \& \& \& C \\ D \arrow[rrrr, ""] \& \& \& \& E \arrow[ru] \end{tikzcd} \end{document} produces this: This code \documentclass{article} \usepackage{tikz-cd} \usetikzlibrary{quantikz2} \begin{document} \begin{tikzcd}[ampersand replacement=\&] A \arrow[rrrr, ""] \& \& \& \& B \arrow[rd, ""] \\ \& \& \& \& \& C \\ D \arrow[rrrr, ""] \& \& \& \& E \arrow[ru] \end{tikzcd} \end{document} produces this: How do I get the first result if I need to use quantikz in my document? Loading quantikz locally for each diagram seems painful.

  • How to uncover underbraces without unwanted text moves? [duplicate]
    by natsirt on October 30, 2019 at 12:02 pm

    I'm trying to uncover underbraces, and I do not want distracting and annoying text moves, like in this example : \documentclass[12pt,a4paper]{beamer} \usepackage{tikz} \usetikzlibrary{arrows, arrows.meta, bending, calc, fadings, hobby, positioning, shadows, shadows.blur, shapes, shapes.misc, tikzmark} \usetikzlibrary{matrix, overlay-beamer-styles} \begin{document} \begin{frame} $(2k+1)^2=(2k+1)(2k+1)=2k\!\times\!2k+2k\!\times\!1+1\!\times\!2k+1\!\times\!1$\\ \pause $\hphantom{(2k+1)^2}=4k^2+2k+2k+1 = \alt<2>{4k^2+4k+1}{{\underbrace{4k^2\onslide<3->}_{\text{pair}}+\underbrace{4k\onslide<3->}_{\text{pair}}+1}}$ \pause so $(2k+1)^2$ is also odd \end{frame} \end{document} This renders to : I can imagine tricks with box saving, measurement and \rule, or \hphantom, or opacity and \rlap, but this seems to be tricky and ungly solutions. Do you have some ideas to get an elegant solution ? Many thanks in advance.

  • Custom numbering of figures
    by Gennaro Arguzzi on December 19, 2017 at 8:53 pm

    I'd like to number figures in a custom way. For example: fig. 1, fig. 2a, fig. 2b, fig. 3 (among figures there is text). \documentclass[10pt,a4paper]{report} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{pgfplots} \begin{document} Bla bla bla \begin{figure}[h] \centering \begin{center} \begin{tikzpicture} \draw (0,0) circle (1cm); \end{tikzpicture} \end{center} \caption{Es.} \end{figure} Bla bla bla \begin{figure}[h] \centering \begin{center} \begin{tikzpicture} \draw (0,0) circle (1cm); \end{tikzpicture} \end{center} \caption{Es.} \end{figure} bla bla \begin{figure}[h] \centering \begin{center} \begin{tikzpicture} \draw (0,0) circle (1cm); \end{tikzpicture} \end{center} \caption{Es.} \end{figure} bla \begin{figure}[h] \centering \begin{center} \begin{tikzpicture} \draw (0,0) circle (1cm); \end{tikzpicture} \end{center} \caption{Es.} \end{figure} \end{document} Thank you so much for your time.

  • Are the TikZ libraries cd and external incompatible with one another?
    by Marco Varisco on April 16, 2014 at 10:51 pm

    Is there a way to use the TikZ libraries cd and external together? This does not work: \documentclass{article} \usepackage{tikz} \usetikzlibrary{cd, external} \tikzexternalize \begin{document} \begin{tikzcd} A \arrow[rd] \arrow[r, "\varphi"] & B \\ & C \end{tikzcd} \end{document} Error: Runaway argument? ! File ended while scanning use of \tikzexternal@laTeX@collect@until@end@tikzpicture. I’m using TikZ/PGF version 3.0.0 and tikz-cd version 0.9b.

  • Draw a longitudinal wave in TikZ
    by Ale on June 11, 2011 at 1:20 pm

    I'm trying to obtain this longitudinal wave with TikZ: Here's my code \documentclass{article} \usepackage{tikz} \begin{document} \usetikzlibrary{decorations.pathmorphing} \begin{tikzpicture}[decoration={coil}] \draw[decorate, decoration={aspect=0.3, segment length=3mm, amplitude=3mm}] (0,0) --(3,0); \draw[decorate, decoration={aspect=0.3, segment length=0.5mm, amplitude=3mm}] (3,0) -- (3.5,0); \draw[decorate, decoration={aspect=0.3, segment length=3mm, amplitude=3mm}] (3.5,0) -- (5,0); \end{tikzpicture} \end{document} but so there are the junctions between one line and the others that interrupt the continuity of the coil. How can improve it?