• Interaction between drawing something in the background and a page of floats
    by Werner on June 26, 2026 at 3:59 am

    In the following setup, I have a couple of images that forms part of a very large figure. The float ends up on a page of floats (on its own), because of the size. I plan on drawing some elements in the background, simulated by the background fill being the example images via \AddToHookNext{shipout/background}{<background drawing>}: \documentclass{article} \usepackage{lipsum,tikz} \begin{document} \lipsum[1-2] \begin{figure} \centering \tikz [remember picture] \node [inner sep = 10pt] (image-a) {\includegraphics[width = 0.5\linewidth]{example-image-a}}; \bigskip \tikz [remember picture] \node [inner sep = 10pt] (image-b) {\includegraphics[width = 0.5\linewidth]{example-image-b}}; \bigskip \tikz [remember picture] \node [inner sep = 10pt] (image-c) {\includegraphics[width = 0.5\linewidth]{example-image-c}}; \caption{A large figure} \AddToHookNext{shipout/background}{% \begin{tikzpicture}[remember picture, overlay] \filldraw [draw = red, fill = red!10!white, thick] (image-a.south west) rectangle (image-a.north east); \filldraw [draw = blue, fill = blue!10!white, thick] (image-b.south west) rectangle (image-b.north east); \filldraw [draw = green, fill = green!10!white, thick] (image-c.south west) rectangle (image-c.north east); \end{tikzpicture}} \end{figure} \lipsum[3-10] \end{document} Using this approach, however, puts the background drawing on the page where the original figure is processed, rather than where the actual figure is placed. How can I adjust the code so that the background content is placed correctly on the page where the float ends up? Ideally I'd like to keep the code as part of the figure as it semantically belongs with the figure, rather than placing it at some other bizarre place in the document just to make sure it fits there.

  • How can I generate random numbers that are unique using pgftikz?
    by Matt on June 25, 2026 at 7:50 pm

    I am trying to generate worksheets where each time \A is called for in the document, a random number is generated. I use \NewNumbers to make sure each \A within a section is identical. How can I make it so that each \A after the \NewNumbers command is different? \documentclass[addpoints, 12pt, answers]{exam} \usepackage[margin=1in]{geometry} \usepackage{amsmath, amssymb, lmodern, pgfmath, tikz, tcolorbox, multicol} \renewcommand{\familydefault}{\sfdefault} \pointformat{} \renewcommand{\TheSolution}[1]{ \pgfmathparse{#1 <= 1 ? "Neither" : (isprime(#1) ? "Prime" : "Composite")} \pgfmathresult } \pgfmathsetseed{1} \newcommand{\NewNumbers}{ \pgfmathsetmacro{\A}{random(0,100)} } \begin{document} \printanswers \begin{questions} \begin{multicols}{3} \NewNumbers \question[1] $\A$ \fillin[\TheSolution{\A}] \NewNumbers \question[1] $\A$ \fillin[\TheSolution{\A}] \NewNumbers \question[1] $\A$ \fillin[\TheSolution{\A}] \end{multicols} \end{questions} \end{document}

  • tikz stops working when using a style in \tikzset
    by Harry on June 25, 2026 at 12:02 pm

    I have gotten a code (given below the question) which produces this: It is fine, but I want to modify the refracted ray by changing \draw[very thick, ray] (C) -- (b); to \draw[very thick, ray2] (C) -- (b); (to plot the red dots less in refracted ray). However, once I do this, my Texwoks throws out Runaway argument? ! Paragraph ended before \pgfkeys@addpath was complete. <to be read again> \par l.76 \draw[very thick, ray2] (C) -- (b); ? I checked my ray2/.style and it seems everything is fine. How can I solve this? The whole code is here \documentclass{beamer} % 4:3 \usetheme{Madrid} \usecolortheme{seahorse} \usepackage{amsmath} \usepackage{amssymb} \usepackage{physics} \usepackage{tikz} \usepackage{tikz-3dplot} \usetikzlibrary{calc, decorations.markings, arrows.meta, angles, quotes, decorations.pathreplacing, shapes.geometric, bending} \usetikzlibrary{patterns,decorations.pathmorphing, shapes.symbols, shadings, positioning} \usepackage{amsfonts} \usepackage[utf8]{inputenc} \usepackage{fontenc} \usepackage[safe]{tipa} \usepackage{xcolor} \usepackage{booktabs} % 用于绘制专业的表格线 \usepackage{setspace} %\setmainfont{Times New Roman} % 或者任意支持音标的字体 \usepackage{array} %% Rays \begin{document} \begin{frame}[fragile] \frametitle{Polarization in Reflection and Refraction} \begin{tikzpicture}[line cap=round, line join=round] % ====================== 所有定义都在这里 ====================== % TikZ Styles (integrated) \tikzset{ ray/.style = { postaction=decorate, decoration={ markings, mark=at position .52 with \arrow{stealth}, mark=between positions 0.1 and 1.2 step 0.5cm with { \draw[fill=red, draw=red] circle[radius=1pt]; \draw[red, {Latex[length=1.3mm, width=1.5mm]}-{Latex[length=1.3mm, width=1.5mm]}] (0,-7pt) -- (0,7pt); } } }, ray2/.style={ postaction=decorate, decoration={ markings, % 所有位置画箭头 draw arrow mark=between positions 0.1 and 1.4 step 0.5cm with { \draw[red, {Latex[length=1.3mm,width=1.5mm]}- {Latex[length=1.3mm,width=1.5mm]}] (0,-7pt)--(0,7pt); }, % 每隔一个位置画点 draw point mark=between positions 0.1 and 1.4 step 1.0cm with { \fill[red] (0,0) circle[radius=1pt]; } } }, polray/.style = { postaction=decorate, decoration={ markings, mark=at position .52 with \arrow{stealth}, mark=between positions 0.1 and 0.4 step 0.5cm with { \draw[fill=red, draw=red] circle[radius=1pt]; }, mark=between positions 0.6 and 0.9 step 0.5cm with { \draw[fill=red, draw=red] circle[radius=1pt]; } } } } % Right Angle Mark (local definition) \def\MarkRightAngle[size=#1](#2,#3,#4){ \draw[thick] ($(#3)!#1!(#2)$) -- ($($(#3)!#1!(#2)$)!#1!90:(#2)$) -- ($(#3)!#1!(#4)$) } % Coordinates \coordinate (A) at (4,5); \coordinate (B) at (4,0); \coordinate (a) at (1,4.6); \coordinate (C) at (4,3); \coordinate (a') at (7,4.6); \coordinate (b) at (5.5,0); % Second Material (interface) \node[rectangle, top color=black!30, bottom color=white, minimum width=7cm, minimum height=3cm] at (4,1.5) {}; % Incident ray \draw[dashed] (A) -- (B); \draw[very thick, ray] (a) -- (C); % Reflected ray (polarized) \draw[very thick, polray] (C) -- (a'); % Refracted ray \draw[very thick, ray] (C) -- (b); % Right angle mark \MarkRightAngle[size=6pt](b,C,a'); % Angle labels \pic[draw, thick, "\small$\theta_\text{b}$", angle radius=0.5cm, angle eccentricity=1.7] {angle = A--C--a}; \pic[draw, thick, "\small$\theta_\text{r}$", angle radius=0.7cm, angle eccentricity=1.5] {angle = a'--C--A}; \pic[draw, thick, "\small$\theta_\text{t}$", angle radius=0.7cm, angle eccentricity=1.6] {angle = B--C--b}; % Labels \node at (1,3.3) {$n_1$}; \node at (1,2.7) {$n_2$}; % Explanatory text \end{tikzpicture} \end{frame} \end{document}

  • Coloring a region of a sphere in 3D using TikZ
    by John on June 23, 2026 at 11:15 am

    I have just started using the 3d library in TikZ (and I'm quite new to the tikz package itself). I am modelling a physics problem; I want to draw a sphere that represents my system. The particularity of that sphere is to have regions delimited by parallel circles around the North and South poles; I would like to color these regions in a different shade than the rest of the sphere. I have been looking everywhere and I can't find how to do this (if it is possible); using \path and \fill doesn't seem to work. Sorry if it's a stupid question, thanks for your help! Here is my code (I'm also showing the θ,φ parametrization in my sketch; in commentary, my failed attempts for coloring the North Pole): \documentclass{article} \usepackage{tikz} \usepackage{tikz-3dplot} \usepackage{pgfplots} \begin{document} \begin{tikzpicture}[scale=3,tdplot_main_coords] \def\rvec{1.2} \def\thetavec{55} \def\phivec{35} \def\thetaRC{10} \shadedraw[tdplot_screen_coords,ball color = white] (0,0) circle (\rvec); \coordinate (O) at (0,0,0); \tdplotsetcoord{C}{\rvec}{\thetavec}{\phivec} \tdplotsetcoord{UD}{\rvec}{\thetaRC}{90} \tdplotsetcoord{UG}{\rvec}{\thetaRC}{-90} \draw[thick,->] (0,0,0) -- (1.7,0,0) node[anchor=north east]{$x$}; \draw[thick,->] (0,0,0) -- (0,1.7,0) node[anchor=north west]{$y$}; \draw[thick,->] (0,0,0) -- (0,0,1.7) node[anchor=south]{$z$}; \draw[-stealth,very thick,color=green!60!black] (O) -- (C) node[above right=-2] {P}; \draw[dashed, color=green!60!black] (O) -- (Cxy); \draw[dashed, color=green!60!black] (C) -- (Cxy); \tdplotdrawarc[color=green!40!black]{(O)}{0.4}{0}{\phivec}{anchor=north}{\(\varphi\)} \tdplotsetthetaplanecoords{\phivec} \tdplotdrawarc[color=green!40!black,tdplot_rotated_coords]{(0,0,0)}{0.7}{0}{\thetavec}{anchor=south west}{\(\theta\)} \draw[dashed] (\rvec,0,0) arc (0:360:\rvec); \draw[thick] (\rvec,0,0) arc (0:110:\rvec); \draw[thick] (\rvec,0,0) arc (0:-70:\rvec); %\tdplotdrawarc[fill=green!40!black]{(0,0,.995*\rvec)}{.0998}{0}{360}{anchor=south west}{\(\theta\)}; %\path[fill=red,fill opacity=0.5] (0,0,\rvec) -- plot[variable=\t,domain=0:360] (xyz spherical cs:radius=\rvec,longitude=\t,latitude=90-\thetaRC); \end{tikzpicture} \end{document}

  • Fraction bar crashes into superscript exponent in manually-drawn TikZ fraction
    by Oregon Math Tutor on June 22, 2026 at 9:38 pm

    I'm reproducing this educational graphic for my Algebra 1 students: I'm drawing fractions manually (separate nodes for numerator, bar, denominator) rather than \frac{}{} so I can control individual font sizes and colors. Two spacing problems I can't fix: 1. The fraction bar crashes into the 2 superscript on the denominator 5² 2. (where a ≠ 0) has no breathing room below the denominator aⁿ Both stem from the bar and note being placed at hardcoded absolute y-coordinates with no structural relationship to the surrounding nodes. MWE (problem area marked): % ── PROBLEM 1: bar hardcoded at y=1.88, unrelated to midfive.north ── \node[font=\bfseries\fontsize{38}{38}\selectfont] (midfive) at (11.70,1.03) {5}; \node[font=\bfseries\fontsize{22}{22}\selectfont] at ($(midfive.north east)+(0.08,0.10)$) {2}; \draw[line width=1.8mm] (11.18,1.88) -- (12.22,1.88); % bar too close to "2" % ── PROBLEM 2: note hardcoded at y=0.78, unrelated to aden.south ── \node[font=\bfseries\fontsize{41}{41}\selectfont] (aden) at (5.76,1.52) {a}; \node[font=\bfseries\fontsize{24}{24}\selectfont] at ($(aden.north east)+(0.10,0.12)$) {n}; \node[font=\bfseries\fontsize{15}{15}\selectfont] at (4.22,0.78) {(where a $\neq$ 0)}; Full MWE: \documentclass[tikz,border=0pt]{standalone} \usepackage{fix-cm} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage[scaled=0.98]{helvet} \renewcommand{\familydefault}{\sfdefault} \usepackage{xcolor} \usetikzlibrary{calc} \definecolor{bggray}{HTML}{ECECEC} \definecolor{purpleA}{HTML}{6B2FEA} \definecolor{purpleB}{HTML}{8B43F5} \definecolor{purpleText}{HTML}{7A34F0} \definecolor{greenText}{HTML}{43D400} \definecolor{redExample}{HTML}{FF2946} \definecolor{textMain}{HTML}{202020} \newcommand{\Avar}{\textcolor{purpleText}{\textbf{a}}} \newcommand{\Nvar}{\textcolor{greenText}{\textbf{n}}} \newcommand{\NegNvar}{\textcolor{greenText}{\textbf{-n}}} \begin{document} \begin{tikzpicture}[x=1cm,y=1cm] \path[use as bounding box] (0,0) rectangle (16,9); \fill[bggray] (0,0) rectangle (16,9); \shade[left color=purpleA,right color=purpleB] (0,6.82) rectangle (16,9); \node[text=white, font=\bfseries\fontsize{28}{30}\selectfont] at (8,8.18) {Negative Exponent Rule}; \node[anchor=north west, text=textMain, align=left, text width=15.0cm] at (0.56,6.47) {% {\bfseries\fontsize{12.6}{18}\selectfont Any nonzero number, \Avar, raised to a negative exponent, \NegNvar,\\[5pt] equals one over that number raised to the positive exponent, \Nvar.} }; \draw[black, line width=1.1mm, rounded corners=1.2mm] (1.02,0.35) rectangle (7.42,4.34); \node[text=purpleText, font=\bfseries\fontsize{53}{53}\selectfont] (abase) at (2.08,2.56) {a}; \node[text=greenText, font=\bfseries\fontsize{26}{26}\selectfont] at ($(abase.north east)+(0.18,0.16)$) {-n}; \node[text=textMain, font=\bfseries\fontsize{34}{34}\selectfont] at (4.18,2.62) {=}; \node[text=textMain, font=\bfseries\fontsize{36}{36}\selectfont] at (5.78,3.42) {1}; \draw[line width=2.0mm] (5.12,2.63) -- (6.44,2.63); \node[text=purpleText, font=\bfseries\fontsize{41}{41}\selectfont] (aden) at (5.76,1.52) {a}; \node[text=greenText, font=\bfseries\fontsize{24}{24}\selectfont] at ($(aden.north east)+(0.10,0.12)$) {n}; \node[text=textMain, font=\bfseries\fontsize{15}{15}\selectfont] at (4.22,0.78) {(where \Avar\ $\neq$ 0)}; % PROBLEM 2 \fill[redExample] (8.86,3.10) rectangle (14.78,4.20); \node[text=white, font=\bfseries\fontsize{21}{21}\selectfont] at (11.82,3.65) {Example}; \node[text=textMain, font=\bfseries\fontsize{44}{44}\selectfont] (fivebase) at (9.62,1.70) {5}; \node[text=textMain, font=\bfseries\fontsize{24}{24}\selectfont] at ($(fivebase.north east)+(0.08,0.12)$) {-2}; \node[text=textMain, font=\bfseries\fontsize{34}{34}\selectfont] at (10.58,1.85) {=}; \node[text=textMain, font=\bfseries\fontsize{34}{34}\selectfont] at (11.70,2.53) {1}; \draw[line width=1.8mm] (11.18,1.88) -- (12.22,1.88); % PROBLEM 1 \node[text=textMain, font=\bfseries\fontsize{38}{38}\selectfont] (midfive) at (11.70,1.03) {5}; \node[text=textMain, font=\bfseries\fontsize{22}{22}\selectfont] at ($(midfive.north east)+(0.08,0.10)$) {2}; \node[text=textMain, font=\bfseries\fontsize{34}{34}\selectfont] at (13.18,1.85) {=}; \node[text=textMain, font=\bfseries\fontsize{34}{34}\selectfont] at (14.35,2.53) {1}; \draw[line width=1.8mm] (13.86,1.88) -- (14.84,1.88); \node[text=textMain, font=\bfseries\fontsize{36}{36}\selectfont] at (14.35,1.00) {25}; \end{tikzpicture} \end{document} What is the canonical way to: Position a manually-drawn fraction bar so it reliably clears a denominator's superscript, using node anchors rather than hardcoded y-coordinates? Add vertical space above a text node relative to the node above it?

  • How to offset two bezier paths with specific ratio elegantly?
    by Explorer on June 22, 2026 at 8:44 am

    Description: I want to plot the following result: Now I have the following code with visual TikZ editor: \documentclass[tikz,border=2pt]{standalone} \begin{document} \begin{tikzpicture}[ line cap=round,line join=round, scale=3,line width=2pt, ] \clip circle[radius=1cm]; \draw[green] (-0.988,-0.155) .. controls (-0.689,0.093) and (-0.531,0.081) .. (-0.454,0.114) .. controls (-0.099,0.175) and (0.111,0.132) .. (0.402,0.132) .. controls (0.617,0.127) and (0.819,0.132) .. (0.98,0.252) ; \draw[teal] (-0.15,-0.349) .. controls (0.072,-0.109) and (0.231,-0.119) .. (0.274,-0.119) .. controls (0.607,-0.167) and (0.729,-0.431) .. (0.832,-0.53) ; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \draw[blue] (0.41,0.129) -- (0.343,-0.126); \draw[magenta] (-0.988,-0.174) .. controls (-0.732,0.048) and (-0.542,0.071) .. (-0.428,0.096) .. controls (-0.189,0.148) and (0.123,0.124) .. (0.385,0.11) .. controls (0.361,0.027) and (0.338,-0.056) .. (0.314,-0.139) .. controls (0.483,-0.182) and (0.563,-0.256) .. (0.61,-0.303) .. controls (0.666,-0.359) and (0.742,-0.454) .. (0.811,-0.54); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \draw[line width=4pt] circle [radius=1cm]; \end{tikzpicture} \end{document} However, the magenta line was not so perfect, in other word: \draw[magenta] (-0.988,-0.174) .. controls (-0.732,0.048) and (-0.542,0.071) .. (-0.428,0.096) .. controls (-0.189,0.148) and (0.123,0.124) .. (0.385,0.11) .. controls (0.361,0.027) and (0.338,-0.056) .. (0.314,-0.139) .. controls (0.483,-0.182) and (0.563,-0.256) .. (0.61,-0.303) .. controls (0.666,-0.359) and (0.742,-0.454) .. (0.811,-0.54); is no the best practice in my opinion(for example, green one and magenta one was partly overlepped). My question is, if I want the pos=0.7 of green one, and the pos=0.35 of teal one, how to offset(or yshift) the subpath in this case? See the below for pos details: References: https://tex.stackexchange.com/search?q=user%3A16595%20offset%20nfold How to thicken the subpath's segment with specific position? What is a better approach to plot the double path style as a subpath?

  • How to pass `\tikzgraphnodename` with `edge node` or `edge label` in `graph` with TikZ?
    by Explorer on June 21, 2026 at 8:31 pm

    I want replicated the following with the graphs trick in this post: Here below is my code: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{graphs.standard,arrows.meta} \tikzset{ polygon/.cd, dot/.style={shape=circle, color=black, fill, draw, inner sep=+0pt, minimum size=+5pt}, path/.style={draw,-latex,thick}, label/.style={shape=circle,inner sep=+.05em, minimum size=+2.5em,draw}} \newcommand*\tikzpolygon[4][]{ % #2 = phase, #3 = radius, #4 = number of vertices \tikz[polygon/.cd,#1] \graph[ edges = {polygon/path}, edge node = {node[ midway,auto,inner sep=+1pt,circle, % draw,anchor=...? ] {X}}, % edge node = {node[midway,auto] {\tikzgraphnodename}}, phase = {#2}, radius = {#3}, counterclockwise = {#4}, n = {#4}, nodes={ /tikz/polygon/dot, as=, /utils/exec=\pgfmathsetmacro\myangle{#2+360/(#4)*(\tikzgraphnodename-1)}, /utils/exec=\pgfmathtruncatemacro\mylabel{\tikzgraphnodename-1}, label/.expanded={[polygon/label, anchor=\myangle+180]\myangle:$a_{1,\mylabel}$} }, ]{subgraph C_n};% } \begin{document} \tikzpolygon{105}{80pt}{12} \end{document} However, I found it hard to pass \tikzgraphnodename with key edge label or edge node, I could only get: Any suggestion to tweak the label and the anchor of my code? Thx!

  • Efficiency and Size trade-off when customize symbols?
    by Explorer on June 19, 2026 at 12:28 pm

    This post originated wipet's comment here and here: The solution has one disadvantage and should not be used commonly with massive usage of these symbols. Each occurrence of this symbol saves to the PDF file a new code with all coordinates of all curves. This is not the same as if the font is used. Then the font is loaded only once to the PDF file (with curves of used characters) and then each occurence of the symbol in the document is realized as a reference to the font and its slot-code. The PDF is smaller. You can use \pdfxform or you can save the symbols to an external pdf and use \pdfximage primitives. I point out that saving a tikz picture into a box and usage of this box saves computation time needed by tikz which converts svg format to pdf format of curves specification, but it doesn't solve the problems mentioned in my comments above. Ad saving Tikz computation: we need not to use TikZ at all: Load svg image to inkscape and export it to eps format. Then cut the curves specification in the eps output and copy it to the \pdfliteral parameter. TikZ is not needed, the curves have native pdf format. In summary, I see four possible approaches to add custom symbol support: modify the LatinModernMath-Regular-Private.otf, add glyph slots to private area apply svg.path solution to define the symbol put svg.path symbol in a box to use for multiple times use primitive for example \pdfliteral to declare the symbols ... My question was: what is the trade-off here? Is there exists the best-practice? Feature Method1: patch font .otf file Method2: svg.path directly Method3: svg.path with box Method4: \pdfliteral primitive Depends on External Files Yes No No No Supports All Engines only unicode engines all engines all engines all engines(?) Runtime Efficiency High Low High Generated PDF File Size Small Big Big Supports Native Character Operations, e.g. \bm Yes (if coorresponding glyph was added) No (see for example) The same as left Edit Thr rows and columns of the table above could be extended freely, for example: "using a vector image (e.g. pdf)" or "use the xsavebox package or the pdfxform-commands in l3pdfxform to store the box, then it is an xobject and only stored once in the pdf" References: How to tweak the svg-symbol baseline and size to act exactly the same as `\ell`? Is that possible to get symbol-family like \ell for "k" and "h" with computer/latin modern math style? https://tex.stackexchange.com/a/763942/322482 https://tex.stackexchange.com/a/763984/322482 https://github.com/user-attachments/files/29108768/LatinModernMath-Regular-Private.zip

  • How to design station signs for Taiwan Railway in TeX?
    by mathrm alpha on June 16, 2026 at 4:08 am

    Although I wrote a LaTeX-like design for Taiwanese train station signs, the resemblance is still somewhat lacking. https://upload.wikimedia.org/wikipedia/commons/thumb/f/f1/ROC_Taiwan_Railways_Administration_Logo.svg/960px-ROC_Taiwan_Railways_Administration_Logo.svg.png \documentclass{article} \usepackage{xeCJK,amssymb} \usepackage[ paperwidth=5in, paperheight=3in, margin=0.2in ]{geometry} \usepackage{graphicx} \usepackage{tikz} \pagestyle{empty} \begin{document} \begin{tikzpicture}[remember picture,overlay] \node[anchor=north west, xshift=0in, yshift=0in] at (current page.north west) { \includegraphics[width=0.5in,height=0.5in]{960px-ROC_Taiwan_Railways_Administration_Logo.svg.png} }; \end{tikzpicture} \begin{tikzpicture}[remember picture,overlay] \node[align=center, text=black, yshift=0.25in] at (current page.center) { {\fontsize{28pt}{34pt}\selectfont Miaoli} \\[0.2em] {\fontsize{32pt}{38pt}\selectfont 苗栗} }; \end{tikzpicture} \begin{tikzpicture}[remember picture,overlay] \node[ draw, line width=0.8pt, minimum size=0.9in, inner sep=0pt, align=center, font=\fontsize{12pt}{12pt}\selectfont ] at ([xshift=1.25in, yshift=0.25in]current page.center) { 苗栗縣\\ 苗栗市 }; \end{tikzpicture} \begin{tikzpicture}[remember picture,overlay] \node[anchor=south west, xshift=0.2in, yshift=0.2in] at (current page.south west) { {\Large 豐富 Fengfu} }; \node[anchor=south east, xshift=-0.2in, yshift=0.2in] at (current page.south east) { {\Large 南勢 Nanshi} }; \end{tikzpicture} \begin{tikzpicture}[remember picture,overlay] \draw[green!60!black, line width=1.2pt] ([yshift=0.65in]current page.south west) -- ([yshift=0.65in]current page.south east); \node[anchor=west, text=green!60!black] at ([yshift=0.78in]current page.south west) {\large $\blacktriangleleft$ 3.9 公里 (km)}; \node[anchor=east, text=green!60!black] at ([yshift=0.78in]current page.south east) {\large 6.6 公里 (km) $\blacktriangleright$}; \end{tikzpicture} \end{document} A better version should be: Source: http://trstour.com/miao-li.htm

  • Draw simple figures: l3draw vs PGF performances
    by PHL on April 30, 2026 at 3:08 am

    I have some lua code that generates coordinates of many triangles/quadrilaterals I then want to draw/fill. See this answer about Penrose tilings for a concrete example. The drawing is actually done in TikZ via the luadraw package, but I am wondering if I can make the code faster by replacing TikZ with l3draw. Rewriting my actual code to remove TikZ and luadraw dependences (and use l3draw or any other drawing tool) is not a complex task, but will ask me some time due to my limited programming skills. So I would prefer to know in advance if this is a good idea or not. Apart possibly performance, is there any other reasons to use l3draw over pgf for this kind of task? Edit: I am not using TikZ/pgf for the rest of the document. Suggesting to use another environment (as picture) is a valid answer.

  • How to encapsulate this interface or make some recursion design in this Graph Theory figure generally?
    by Explorer on May 4, 2025 at 6:42 pm

    Description: My Target is to draw something like this: Notes that the quadrilateral's shape is a little arbitrary as the figure shown, and in Graph Theory, they are equivalent, so slight distortion is permitted. Now, I manually achieve that as below: \documentclass[tikz,border=8pt]{standalone} \usetikzlibrary{shapes.geometric,calc} \pgfmathsetseed{4321} \tikzset{line cap=round,line join=round} \begin{document} \begin{tikzpicture} \node[name=O1,regular polygon, regular polygon sides=5, draw,minimum size=5cm,inner sep=5pt] {}; \foreach \i in {1,...,5}{\fill (O1.corner \i) circle (1pt);} \node[name=O2,regular polygon, regular polygon sides=5, draw,minimum size=1cm,inner sep=5pt,rotate=30] {}; \foreach \i[evaluate = \i as \j using {int(mod(\i,5)+1)}] in {1,...,5}{% \fill (O2.corner \i) circle (1pt); \pgfmathsetmacro\rndlena{(rnd*30+85)/100} \pgfmathsetmacro\rndlenb{(rnd*30+85)/100} \pgfmathsetmacro\rndanga{-(15+rnd*20)} \pgfmathsetmacro\rndangb{(15+rnd*20)} % \node at (rand,rand) {(\rndlen,\rndanga,\rndangb)}; \coordinate (O2-corner \i\j) at ($(O2.corner \i)!\rndlena!\rndanga:(O2.corner \j)$); \fill (O2-corner \i\j) circle (1pt); \coordinate (O2-corner \j\i) at ($(O2.corner \j)!\rndlenb!\rndangb:(O2.corner \i)$); \fill (O2-corner \j\i) circle (1pt); \path (O2-corner \j\i) edge (O2-corner \i\j) (O2-corner \j\i) edge (O2.corner \i) (O2-corner \j\i) edge (O2.corner \j) (O2-corner \i\j) edge (O2.corner \i) (O2-corner \i\j) edge (O2.corner \j) (O1.corner \j) edge (O2-corner \j\i) edge (O2-corner \i\j) ; } \begin{scope} \node[name=O3,regular polygon, regular polygon sides=5, draw,minimum size=.5cm,inner sep=0pt,rotate=30] at (-.75,1.2) {}; \foreach \i/\p[evaluate = \i as \j using {int(mod(\i,5)+1)}] in% {% 1/{O1.corner 2}, 2/{O2-corner 21}, 3/{O2.corner 1}, 4/{O2-corner 51}, 5/{O1.corner 1}% } {% \pgfmathsetmacro\rndlena{(rnd*20+40)/100} \pgfmathsetmacro\rndlenb{(rnd*20+40)/100} \pgfmathsetmacro\rndanga{-(50+rnd*30)} \pgfmathsetmacro\rndangb{(50+rnd*30)} % \node at (rand,rand) {(\rndlen,\rndanga,\rndangb)}; \fill (O3.corner \i) circle (1pt); \coordinate (O3-corner \i\j) at ($(O3.corner \i)!\rndlena!\rndanga:(O3.corner \j)$); \fill (O3-corner \i\j) circle (1pt); \coordinate (O3-corner \j\i) at ($(O3.corner \j)!\rndlenb!\rndangb:(O3.corner \i)$); \fill (O3-corner \j\i) circle (1pt); \path (O3-corner \j\i) edge (O3-corner \i\j) (O3-corner \j\i) edge (O3.corner \i) (O3-corner \j\i) edge (O3.corner \j) (O3-corner \i\j) edge (O3.corner \i) (O3-corner \i\j) edge (O3.corner \j) %% a bit dummy here (\p) edge (O3-corner \j\i) edge (O3-corner \i\j) ; } \end{scope} \end{tikzpicture} \end{document} which yields: Difficulity: I mainly confrant with these predicament: Inconsisit Coordinate System to locate O2-corner 21(TikZ banned me to use dot here) and O2.corner 2 I want to encapsulate the code in scope to be reused, however, it seemed to need five parameters in last edge operation (\p) edge (O3-corner \j\i) edge (O3-corner \i\j), and I found it difficult to design the command, or may be some recursion design. I manually assign some location/rotation arguments of O3 to adjust, which also make it not so elegant,and I have no idea to prevent from this(maybe the bottom edge to be parelell with five polygon's edge?). Question: How to better design and tune my first attempt on these kind of graph, with better syntax, consist coordinate system, and more widely(or general) interfaces to these kinds of figure(say that if the O1 is larger enough, I want the third layers' plot inside O3)? Some Coordinate Illustration as below in my MWE that maybe help: Best Wishes!

  • Place (downscaled) pic vertically centered over TikZ-matrix node
    by cis on February 14, 2025 at 2:16 pm

    Is there an easy way to place the \pic vertically centered above the 1st matrix node? Hint: I use a \pic (instead of rectangle etc.) to be closer to my original code. \documentclass[margin=5mm, tikz]{standalone} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture}[font=\footnotesize, Pgram/.pic={ \draw[fill=green] (0,0) -- (2,0) -- ++(50:1) -- ++(-2,0) --cycle; }, ] \matrix[matrix of math nodes, anchor=north west, nodes={anchor=center, draw=none}, ](m) at (0,0) { \begin{vmatrix} a_x & b_x \\ a_y & b_y \end{vmatrix} &=&A &+&D \\ }; % Problem here: \begin{scope}[transform canvas={shift=(m-1-1.north), scale=0.35}] \pic[]{Pgram};% <-- shall be vertically centered %\draw[fill=orange] (0,0) rectangle (2,1);% Test \end{scope} \end{tikzpicture} \end{document}

  • How to automatically label through the dodecagon with TikZ elegantly?
    by Explorer on November 8, 2024 at 6:12 am

    My Final Propose is to draw a picture as below, but each dots lie in the circle, or says dodecagon. I tried with the wheels created by Qrrbrbirlbel: With miminum size and the outer sep option, something went wrong with the float calculation causing errors. \documentclass[border=20pt]{standalone} \usepackage{tikz} \usetikzlibrary{math} \usetikzlibrary{positioning} %https://tex.stackexchange.com/questions/729843/how-to-position-the-node-with-tikz-positioning-relative-to-specific-angle \makeatletter \tikzset{angle/.code 2 args=\pgfmathsincos{#1}\tikz@lib@place@handle@{#2}{180+#1}{\pgfmathresultx}{\pgfmathresulty}{#1}{1}} \makeatother \begin{document} \begin{tikzpicture} \node[ draw,fill,circle, %mininum size=3pt, inner sep=0pt,outer sep=3pt, label=above:{\scriptsize$a_{1,0}$}] (A0) {}; \foreach \ang[ count = \n, evaluate = \n as \prev using \n-1, evaluate = \ang as \labelang using {mod(450-30*\n,360)}, %evaluate = \ang as \edgeang using {mod(450-30*\n,360)}, ]in {330,300,...,60,30}{% \node[ draw,fill,circle, inner sep=0pt,outer sep=3pt, label=\labelang:{\scriptsize$ a_{1,\n}$} ] (A\n) [angle={\ang}{of A\prev}] {} edge[-latex] node[swap] {\scriptsize$\alpha_{\n}$} (A\prev); } \draw[-latex] (A0) -- (A11); \end{tikzpicture} \end{document} Then I temporarily reset the outer sep=0pt. I want to label the edge of the dodecagon outside each edge of the circle, but I couldn't find an option like pos provided by \node when using edge to set the label position $\alpha_{i,\n}$. In the below code, the label's position is not satisfactory. The code: \documentclass[border=20pt]{standalone} \usepackage{tikz} \usetikzlibrary{math} \usetikzlibrary{positioning} %https://tex.stackexchange.com/questions/729843/how-to-position-the-node-with-tikz-positioning-relative-to-specific-angle \makeatletter \tikzset{angle/.code 2 args=\pgfmathsincos{#1}\tikz@lib@place@handle@{#2}{180+#1}{\pgfmathresultx}{\pgfmathresulty}{#1}{1}} \makeatother \begin{document} \begin{tikzpicture} \node[ draw,fill,circle, %mininum size=3pt, inner sep=0pt,outer sep=0pt, label=above:{\scriptsize$a_{1,0}$}] (A0) {}; \foreach \ang[ count = \n, evaluate = \n as \prev using \n-1, evaluate = \ang as \labelang using {mod(450-30*\n,360)}, %evaluate = \ang as \edgeang using {mod(450-30*\n,360)}, ]in {330,300,...,60,30}{% \node[ draw,fill,circle, %mininum size=3pt, inner sep=0pt,outer sep=0pt, label=\labelang:{\scriptsize$ a_{1,\n}$} ] (A\n) [angle={\ang}{of A\prev}] {} edge[-latex] node[swap] {\scriptsize$\alpha_{\n}$} (A\prev); } \draw[-latex] (A0) -- (A11); \end{tikzpicture} \end{document} Is there a better solution to plot the figure as above(like shape=regular polygon)? And could my code be changed with less clumsy code (more elegantly)?

  • TikZ Tree Image
    by Theo Oseji on October 28, 2024 at 9:56 pm

    I recently figured out how to use tikz trees, so filling in a potential rectangle and the rest would not be an issue. Is there a way to somehow create a tree looking like the image provided that is not messy? \begin{tikzpicture} [ level 1/.style={level distance = 4cm, sibling distance = 3cm}, level 2/.style={level distance = 2cm, sibling distance = 3cm}, grow=left, edge from parent fork left % every node/.append style = {draw, anchor = west} ] \node[draw]{\footnotesize text here } child {node[draw] {\footnotesize text here}} child {node[draw]{ \footnotesize text here}}; \end{tikzpicture}

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

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

  • Getting pics to act like a chain
    by sgmoye on December 21, 2023 at 2:35 pm

    I am taking the code I put together in With TikZ, is it possible to split a node horizontally and vertically?, and make it into a pic. This is doable, but placing successive pics is problematic: pics, even if named cannot reference each other, though named nodes within a pic can be referenced. If the height of each pic is measured, it is possible, after the fact, to adjust the position of the pics using half of the pic height (in the optional argument to \step (see example code). I am having trouble wrapping my head around how to get this to happen with a minimum of manual intervention. The answers at Anchoring TiKZ pics seem to suggest that, under some circumstances, this is possible, but I have not found a way to use them so far... \documentclass{article} \usepackage{fontspec,tikz} \usetikzlibrary{calc,positioning,shapes.multipart,fit,backgrounds} \newcounter{stepnum} \newcounter{tmpnum} \newlength{\recwd} \setlength{\recwd}{2.5in} %% |=====8><-----| %% \makeatletter \newcommand{\dist}[3]{% #1 cs for result; #2 tikz coord. 1; #3 tikz coord. -- uses calc \tikz@scan@one@point\pgfutil@firstofone($(#2)-(#3)$)\relax \pgfmathsetlengthmacro{#1}{veclen(\the\pgf@x,\the\pgf@y)}% <<<--->>> }% \makeatother \tikzset{pics/hvmpnode/.style n args={3}{% The basic mechanism: #1=L; #2=UR; #3=LR code={% \node[name=L\thestepnum,rounded corners=1.5pt,fill=cyan!20] {% Left \hbox to 1.25em{\hss\textbf{#1}\hss} }; \node[rounded corners, rectangle split, rectangle split parts=2, rectangle split part fill={yellow!80!orange!20,none}, align=center, rounded corners=1.5pt, name=R, right= 0pt of L\thestepnum.east] {% \nodepart{one}\parbox{\recwd}{\centering\strut#2\strut}% UR \nodepart{two}\parbox{\recwd}{\parskip1ex\strut#3\strut} };% LR \draw[thick] (R.text split east) -- (R.text split west); \node[inner sep=0pt, draw, thick, rounded corners=1.5pt, name=W\thestepnum, anchor=south west, fit=(L\thestepnum)(R)] {};% W = enclosing box \draw[thick] (W\thestepnum.south west -| R.west) -- (W\thestepnum.north west -| R.west);% L/R rule \begin{scope}[on background layer] \fill[cyan!20,rounded corners=1.5pt] (W\thestepnum.north west) rectangle (R.south west); \end{scope} }% } } \NewDocumentEnvironment{example}{s O{} m o}{% \setcounter{stepnum}{0}% \parbox{\textwidth}{% \begingroup \bfseries \itshape \Large #3 \par \endgroup \IfNoValueF{#4}{% \par\small\itshape\rightskip=0.5\textwidth plus 3em#4\par }% }% \par \medskip \begin{tikzpicture}[] }{% \end{tikzpicture} \bigskip } \NewDocumentCommand{\step}{O{24pt} m +m}{% #1=materials; #2=technique \stepcounter{stepnum}% \setcounter{tmpnum}{\numexpr\thestepnum-1\relax} \ifnum\thestepnum=1 \path (0,0) pic{hvmpnode={\thestepnum}{#2}{#3}}; \else \path ([yshift=-#1]0,0 |- W\thetmpnum.south west)%% manually setting yshift as optional argument to \step is possible but icky; this aligns but is suspicious pic{hvmpnode={\thestepnum}{#2}{#3}};%% faulty \fi \dist{\mydist}{W\thestepnum.north}{W\thestepnum.south}\typeout{!!mydist=\mydist!!} } %% |=====8><-----| %% \parindent0pt \begin{document} \thispagestyle{empty} \begin{example}{Foobar}[This is a meaningless bunch of bla bla bla to see if this works in any way, shape, or form.] \step{1 2 3 4 5 6}{bla bla bla lkfjdlkj} \step[49.66pt]{z b c d e f 7 8 9}{Much more bla bla bla and this is so much more jejune nonsense and a lot more bubbishy stuff that makes no sense. Much more bla bla bla and this is so much more jejune nonsense and a lot more bubbishy stuff that makes no sense.} \step[49.66pt]{z b c d e f 7 8 9}{Much more bla bla bla, Much more bla bla bla and this is so much more jejune nonsense and a lot more bubbishy stuff that makes no sense. Much more bla bla bla and this is so much more jejune nonsense an} \step[19.66pt]{z b c d e f 7 8 9}{Much more bla bla bla} \end{example} For the height of each \texttt{pic}, \texttt{\string\typeout} says: \begin{tabular}{l} !!mydist=39.33188pt!!\\ !!mydist=99.33188pt!!\\ !!mydist=99.33188pt!!\\ !!mydist=39.33188pt!! \end{tabular} \end{document}

  • Connect two nodes from different figures with an arrow
    by bighero on May 1, 2023 at 10:22 pm

    I am trying to connect two nodes from two different figures; is there a solution? this is my attempt. \documentclass [conference] \usetikzlibrary{tikzmark, shadows.blur,arrows.meta,bending, shadings, intersections, calc, decorations.text,shapes,backgrounds, shapes.geometric, positioning, fit} \usepackage{tikz, pgfplots} \begin{figure*}[h!] \begin{tikzpicture} [auto, decision/.style={diamond, draw=blue, thick, fill=blue!20, text width=4.5em,align=flush center, inner sep=1pt}, block/.style ={rectangle, draw=blue, thick, fill=blue!20, text width=6em,align=center, rounded corners, minimum height=4em}, line/.style ={draw, thick, -latex,shorten >=2pt}, cloud/.style ={draw, cylinder, shape border rotate=90, aspect=0.4, % minimum height=40, minimum width=50, cylinder body fill = gray!10, cylinder end fill = gray!40}] \matrix [column sep=4mm,row sep=7mm] { % row 1 \node [cloud] (raw) {Raw Data}; & \node [block, fill=green!20] (prep) {Data Preprocessing}; & \node [block] (feature) {Feature Engineering}; & \node [block] (select) {Model Selection}; & % row 2 \node [block] (train) {Model Training};& \\ &&& \node [block ] (evaluate) {Model Evaluation}; \node [decision] (decide) [below = of select] {Is best candidate?}; \node [block, left] (stop) [left = of decide] {Model Deployment};\\ }; \begin{scope}[every path/.style=line] \path (raw) -- (prep); \path (prep) -- (feature); \path (feature) -- (select); \path (select) -- (train); \path (train.south) |- +(0,-40pt) --(evaluate.east); \path (evaluate) -- (decide); \path (decide) -- node [above] {Yes} (stop); \path [dashed] (decide.south) -- +(0,-10pt) -| node [pos=0.62, right] {No} (feature); \end{scope} \end{tikzpicture} \caption{Machine Learning Pipeline} \label{} \end{figure*}[h!] \begin{figure}[h!] \begin{tikzpicture} % cyclic flowchart % https://tex.stackexchange.com/questions/477310/cyclic-flowchart-in-tikz \node[draw, cylinder, shape border rotate=90, aspect=0.4, % minimum height=40, minimum width=50, cylinder body fill = gray!10, cylinder end fill = gray!40] (data) at (0,0) {Raw Data} ; \path[name path=circle] (0,0) circle[radius=3.2 cm]; \foreach \Angle/\Color/\Label/\Text in {90//DC/{Data \\ Cleaning},% 180//DI/{Data \\ Integration},% 270//DR/{Data \\ Reduction},% 360//DT/{Data \\ Transform- \\ ation}} { \node[draw=blue, rectangle, align=center, fill=blue!20, rounded corners, name path=\Label, align=center, text=black] (\Label) at (\Angle:3cm) {\Text}; % \node[draw, circle, name path=\Label, color=black, minimum width=1.5cm, align=center, text=black] (\Label) at (\Angle:3cm) {\Text}; \path[name intersections={of=circle and \Label,by={\Label-1,\Label-2}}]; \draw[{Latex}-] (\Label) -- (data); } \node[rectangle,draw=green, fit=(DC) (DR), minimum height=8cm, minimum width=8cm](fit) {}; \draw[{Latex}-{Latex}] let \p1=(DI-1),\p2=(DC-2),\n1={atan2(\y1,\x1)},\n2={atan2(\y2,\x2)} in (DC-2) arc(\n2:\n1:3.1cm); \draw[{Latex}-{Latex}] let \p1=(DR-1),\p2=(DI-2),\n1={atan2(\y1,\x1)},\n2={atan2(\y2,\x2)} in (DI-2) arc(\n2:\n1:3.1cm); \draw[{Latex}-{Latex}] let \p1=(DC-1),\p2=(DT-1),\n1={atan2(\y1,\x1)},\n2={atan2(\y2,\x2)} in (DT-1) arc(\n2:\n1:3.1cm); \draw[{Latex}-{Latex}] let \p1=(DT-2),\p2=(DR-2),\n1={atan2(\y1,\x1)},\n2={atan2(\y2,\x2)} in (DR-2) arc(\n2:\n1:3.1cm); \end{tikzpicture} \caption{Data Preprocessing Tasks} \label{} \end{figure} \end{document}

  • TikZ curved callout
    by user1850133 on May 1, 2023 at 6:11 am

    What is the easiest way to get a curved callout? It seems the callout library does not support it so it seems a custom callout must be done. Here's my MWE with a drawing of the desired result: \documentclass{beamer} \mode<presentation> { \usetheme{metropolis} } \usepackage{tikz} \usetikzlibrary{shapes.callouts} \tikzset{ bub/.style 2 args = { rectangle callout, rounded corners=2mm, anchor=#2, draw, callout absolute pointer={#1}, inner sep=5mm, outer sep=0pt, thick}, } \begin{document} \begin{frame}{curved callout} \begin{tikzpicture} \node at (0,0) [bub={(0,-4)}{north west}] { not curved callout }; \end{tikzpicture}\end{frame}\end{document}

  • How to create a half filled circle in tasks?
    by Azarang on October 12, 2022 at 8:45 pm

    I'm trying to make the last circle half filled like how \skill{Office}{4.5} work. Here's my try: \documentclass[12pt, a4paper]{resume} % Use the custom resume.cls style \usepackage[left=0.4 in,top=0.4in,right=0.4 in,bottom=0.4in]{geometry} % Document margins \usepackage{tasks} \usepackage{tikz} \begin{document} \begin{rSection}{Skills} \vspace{1em} \begin{tasks}[style=itemize, column-sep=-35mm, label-align=center, label-offset={2mm}, label-width={2mm}, item-indent={5mm}](3)% \task[] \textnormal{MATLAB} \tikz\draw[black,fill=black] (0,0) circle (.5ex); \tikz\draw[black,fill=black] (0,0) circle (.5ex); \tikz\draw[black,fill=black] (0,0) circle (.5ex); \tikz\draw[black,fill=black] (0,0) circle (.5ex); \tikz\draw[black,fill=black] (0,0) circle (.5ex); \end{tasks} \end{rSection} How can I do that here?

  • How to include `tikzpicture` in forest node?
    by Zarko on May 9, 2021 at 4:08 am

    How to include tizpicture, for example defined in ducks package, to a forest node? Edit: Simplified MWE with comparison result using duck in tikzpicture and in forest. \documentclass[border=3.141592]{standalone} \usepackage{forest} \usetikzlibrary{ducks} \begin{document} \tikz[baseline]{\duck[signpost=1]}\quad \begin{forest} [\tikz{\duck[signpost=1]}] \end{forest} \end{document} As you can see, the duck image in forest node is not complete, missed is result of option signpost=1. I guess, that image is included before its process of duck drawing is complete. So far I didn't find a way how to delay inclusion of image, or better, how to correct include such images in forest node.

  • Add a number foreach level of the Tikz tree
    by LukeTheWolf on April 3, 2021 at 10:08 am

    I'm trying to do a states tree as follows. My actual issue is that I don't know how to add the number placed on the left side of the tree (as in the picture). The numbers are placed at the level of the arrows and not at the same level as the nodes. In addition, can you tell me how I can make the marked arrows thicker? This is the snippet of code that I wrote: \documentclass[12pt]{article} \usepackage[english]{babel} \usepackage[utf8x]{inputenc} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{arrows,automata} \begin{document} \begin{tikzpicture}[nodes={draw, circle}, ->,accepting/.style={double distance=2pt, outer sep=0.75pt+\pgflinewidth}] \node{$q_0$} child { node {$q_0$} child { node {$q_0$} child { node {$q_0$} child{node {$q_0$}} } child { node {$q_1$} child{node [accepting]{$q_2$}} } } } child [missing] child { node {$q_1$} child { node {$q_2$} } }; \end{tikzpicture} \end{document}

  • Left-align TikZ pics and issue with TikZ graph
    by SommerEngineering on December 1, 2020 at 6:57 pm

    I'm trying to put together a more complex drawing from several TikZ pics. I have constructed a minimal example from which the challenges become visible (see below). After the styles, first the two pics are defined. Then both pics are drawn. Both blocks (the graph and the process) should be left aligned. I found some hints for this at StackExchange and implemented them already. Nevertheless, the two blocks and the corresponding headlines are not left-aligned. Could it be related to the fact that in the graph the outgoing arrow is drawn above node A? This is the second challenge. According to all instructions and tutorials for TikZ graphs, it should work like this. Can anyone help me with these two challenges? \documentclass{standalone} \usepackage[utf8]{inputenc} \usepackage[T1, OT1]{fontenc} \usepackage{tikz} \usetikzlibrary{arrows} \usetikzlibrary{arrows.meta} \usetikzlibrary{positioning} \usetikzlibrary{graphs} \usetikzlibrary{fit} \begin{document} \begin{tikzpicture} \tikzstyle{border} = [line width=0.6mm, gray, solid]; \tikzstyle{flow} = [line width=0.6mm, cyan, dashed]; \tikzstyle{sublineText} = [text width=2.5cm, align=center]; \tikzstyle{arrow} = [-Stealth, flow]; \tikzstyle{headerText} = [font=\large, align=center, rotate=90]; % Define the data structure block: \tikzset{dataStructure/.pic = { \graph[nodes={draw, circle}] { A[name=A] -> B[name=B]; }; % Draw the border: \node[name=-border, rectangle, draw, border, fit = (A) (B)] {}; }} % Define the process block: \tikzset{process/.pic = { \begin{scope}[node distance=32mm] \node[name=start] {A}; \node[name=startText, sublineText, below=-2mm of start] {{\tiny{subline}}}; \node[name=b, right=of start] {B}; \node[name=bText, sublineText, below=-2mm of b] {{\tiny{subline}}}; \node[name=c, right=of b] {C}; \node[name=cText, sublineText, below=-2mm of c] {{\tiny{subline}}}; \node[name=d, right=of c] {D}; \node[name=dText, sublineText, below=-2mm of d] {{\tiny{subline}}}; \node[name=e, below=10mm of d] {E}; \node[name=eText, sublineText, below=-2mm of e] {{\tiny{subline}}}; \node[name=f, below=10mm of b] {F}; \node[name=fText, sublineText, below=-2mm of f] {{\tiny{subline}}}; \node[name=restart, right=14mm of start] [fill=cyan,circle] {}; \end{scope} % Draw the path (flow): \draw[arrow] (start) -- (b); \draw[arrow] (f.west) to[bend left=40] (restart.south); \draw[flow] (b) -- (c) -- (d) (d.east) to[bend left=90] (e.east) (e) -- (f); % Draw the border: \node[name=-border, rectangle, draw, border, fit = (start) (startText) (eText)] {}; }} % Draw the data structure block: \pic[name=dataStructure, pic type=dataStructure, anchor=west]; \node[name=dataStructureHeader, headerText, left=of dataStructure-border.west, anchor=south] {Data}; % Draw the process block: \pic[name=process, pic type=process, below=of dataStructure-border, anchor=west]; \node[name=processHeader, headerText, left=of process-border.west, anchor=south] {Process}; \end{tikzpicture} \end{document}

  • Hurricane symbols
    by Sebastiano on June 23, 2020 at 3:06 pm

    There were hyperuragans mentioned on an Italian television channel. Does any of you know if there is a specific package in LaTeX, or fonts that reproduce hurricane symbols with numbers? The image is taken from https://image.shutterstock.com/image-vector/set-hurricane-scale-icons-symbolic-260nw-712052398.jpg.

  • Simulating paintbrush strokes in TikZ
    by bfootdav on February 16, 2019 at 3:26 am

    I am wondering if there exists a way to simulate paintbrush strokes in TikZ when filling in a shape. So given the following: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \tikz{ \draw[fill=red](0,0)rectangle(10,10); } \end{tikzpicture} \end{document} Instead of a solid red shape I was hoping to make it look like the red part was painted on with a paintbrush. I'm not exactly sure how what that would look like but I'm guessing maybe some randomly wavy lines that are a little darker and some maybe that are a little lighter? And I guess one would want for the paintbrush to have a thickness so that you'd be able to see the difference between one stroke and the one next to it. Looking at examples of actual paintbrush strokes online it looks like the light/dark parts vary a little on each line but that might be a complication not worth pursuing. Having all the strokes go down would be fine but being able to indicate a directions would be cool. And while I'm sure something like this is possible in various image editing programs, I need to do this in TeX/LaTeX as part of an automated file generating process. Edit: I do not believe this is a duplicate of the chalkboard solution as that one appears to use a bunch of small dots whereas a paintbrush involves long wavy lines of varying shades of the root color. The results would look very different. It could be that the chalkboard question provides an idea for an approach but using it as-is would not be a solution to my question. Update 1: I have done some experimentation with using TikZ decorations with wavy, random lines with rounded corners and it seems like this could be a way forward but I haven't made anything that looks close to convincing. Update 2: As per below, here is a link to a picture of close-up of brush strokes. This is pretty exaggerated but gets the point across. Here is an attempt at using wavy random lines: \documentclass{article} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing} \begin{document} \begin{tikzpicture} \tikz[line width=.1mm]{ \draw[fill=red](0,0)rectangle(10,10); \draw[line width = .5mm,decorate,decoration={random steps,segment length=12pt,amplitude=1pt},rounded corners=.1pt, color=red!50!brown] (1.5,0) -- (1.5,10); \draw[line width = .5mm,decorate,decoration={random steps,segment length=12pt,amplitude=1pt},rounded corners=.1pt, color=red!50!brown] (1.65,0) -- (1.65,10); \draw[line width = .5mm,decorate,decoration={random steps,segment length=12pt,amplitude=1pt},rounded corners=.1pt, color=red!50!brown] (1.8,0) -- (1.8,10); \draw[line width = .5mm,decorate,decoration={random steps,segment length=12pt,amplitude=1pt},rounded corners=.1pt, color=red!50!brown] (1.95,0) -- (1.95,10); } \end{tikzpicture} \end{document} As you can see it looks terrible. Update 3: Let me give a bit more detail about what I'm looking for. I am looking for something to fill large geometric shapes like squares, rectangles, and circles with sizes from half a page to almost a full page with one color. I have a program that generates music in many different styles (I'm a composer) but have decided to add artwork to it as well. So far I'm sticking with 20th century Modernist stuff as a lot of it seems simpler to do. I did a Mondrian one already (the squares and rectangles on thick crossing lines). And what inspired this question was the works of Kazimir Malevich, specifically his Black Square, Black Cross, Red Square and a few others of a similar style. My software randomly generates "paintings" that look similar but not exactly the same (for example, the black square varies in size but is still large, the red square uses different random dimensions for the quadrilateral, the black circle has different random dimensions and placed at random, etc). I had thought that since these are so simple that my users would appreciate having it be a bit more interesting to look at with the simulated brush strokes. Unfortunately I don't have any specific examples of paintings/painters in mind, just some vague notion that brush marks could be seen on paintings like those if you look closely enough(though I have no idea if you can see the brush strokes in Malevich's paintings). But then making it too subtle might get lost on the user when looking at it on their computer or phone so being a bit exaggerated might be better? It also occurs to me that maybe the bumps of the canvas underneath might help with the illusion?

  • Creating a surface plot of a function on the simplex (using PSTricks or TikZ?)
    by Martin J. Osborne on March 18, 2017 at 6:46 pm

    I'd like to create an exact surface plot of a function defined on the unit simplex {(x, y, z): x + y + z = 1}. Here's a sketch of the figure I'd like to create. I know about surface plots in PSTricks and TikZ, about barycentric coordinate systems in TikZ, and about ternaryaxis in pgfplots, but I don't see a way of combining them to produce what I want. (My difficulty is not with the specific form of the function; I'll be happy with an answer that plots the function x.) I'd like to say something like \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} % or some special type of axis \addplot3 {<f(x,y,z)>}; \end{axis} \end{tikzpicture} \end{document} where f(x,y,z) is the definition of my function. Is something like that possible?

  • Adding lighting effect to a rectangular glow box in TikZ
    by Arianna Angeletti on February 6, 2012 at 12:35 pm

    I would like to add to my first MWE in Can I have a glow around a box in TikZ? a lighting effect as shown in this example of the pgfmanual: By modifying the previous MWE: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \def\shadowradius{3pt} % \newcommand\drawshadowbis[1]{ \begin{pgfonlayer}{shadow} % \fill[inner color=blue,outer color=blue!10!black] ($(#1.south east)$) circle (\shadowradius); \fill[inner color=blue,outer color=blue!10!white] ($(#1.north west)$) circle (\shadowradius); %\fill[inner color=blue,outer color=blue!10!black] ($(#1.south west)$) circle (\shadowradius); %\fill[inner color=blue,outer color=blue!10!white] ($(#1.north east)$) circle (\shadowradius); % \fill[ top color=blue, bottom color=blue!10!black] ($(#1.south west)+((0,-\shadowradius)$) rectangle ($(#1.south east)$); \fill[left color=blue,right color=blue!10!black] ($(#1.south east)$) rectangle ($(#1.north east)+((\shadowradius,0)$); \fill[bottom color=blue,top color=blue!10!white] ($(#1.north west)$) rectangle ($(#1.north east)+((0,\shadowradius)$); \fill[right color=blue,left color=blue!10!white] ($(#1.south west)$) rectangle ($(#1.north west)+(-\shadowradius,0)$); \end{pgfonlayer} } % \pgfdeclarelayer{shadow} \pgfsetlayers{shadow,main} \begin{tikzpicture} \node [fill=blue,rectangle,rounded corners=0pt,draw=blue, ultra thick, text=white] (box) {Test!!!}; \drawshadowbis{box} \end{tikzpicture} \end{document} I get this: but I do not know how to define the colours of the missing angles. Any help will be really appreciated!

  • Can I have a glow around a box in TikZ?
    by Johannes on January 30, 2012 at 4:15 pm

    What I was wondering is, if I can have a glow effect for a box I am drawing with TikZ. Neither search here nor the (excellent) TikZ manual returned any results. There is a circular glow option, but I don't think that helps in my case, or does it!? Any input is appreciated :). Edit: I figured that these blurred shadows seem to be a fairly special PDF feature which is supported by few PDF viewers only (actually Acrobat Reader 9 for Linux was the only one that worked for me). (size of the blue box is the same)

  • TikZ rectangular node with different rounded corners
    by Arianna Angeletti on October 27, 2011 at 9:28 am

    This is my minimal example: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node[rounded corners=3pt, draw, fill=red!20]{Hallo!}; \end{tikzpicture} \end{document} I'd like to define different values for rounded corners (i.e. 5pt for north-west and north-east and 2pt for south-east and south-west).

  • What You See is What You Get (WYSIWYG) for PGF/TikZ?
    by Amelio Vazquez-Reina on July 27, 2011 at 3:30 pm

    Are there any WYSIWYG editors for PGF/TikZ? Perhaps something similar to LyX but for PGF/TikZ? If there is no WYSIWYG editor for this tandem, is there one perhaps that allows the user to easily generate PGF/TikZ templates? Alternatively, how can I most easily generate PGF/TikZ code from a visual conception? Do people mostly code their PGF/TikZ graphics from scratch?

  • Is there a way to draw 3D-style "buttons"?
    by Arianna Angeletti on December 22, 2010 at 12:09 pm

    I was wondering if there is a latex package to get pseudo-3D style "buttons" as are often seen on the web, or if not is there an easy way to draw them? An example of what I mean: