TikZ
- How to add extrusion glow of irregular shape different from `shadow scale`?by Explorer on May 1, 2026 at 6:50 pm
What I want to achieve is something like: Noted that the "glow" here is somewhat like a "shadow" path out of the border. However, I have tried blur shadow={shadow xshift=0pt,shadow yshift=0pt,shadow scale=1.05}: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{shadows.blur,spy} \begin{document} \begin{tikzpicture}[spy using outlines={circle, magnification=3, size=3cm}] \draw[fill=gray!25,draw,rounded corners,blur shadow={shadow xshift=0pt,shadow yshift=0pt,shadow scale=1.05}] (40:4) arc[start angle=40,end angle=140,radius=4] -- (140:2) arc[start angle=140,end angle=40,radius=2] -- cycle; \draw[fill=white] (0,2.75) -- ++(.5,-.25) -- (0,3.5) -- ++(-.5,-1) -- cycle; \spy[red] on (140:2) in node at (-2,-1); \spy[blue] on (40:2) in node at (+2,-1); \end{tikzpicture} \end{document} The shadow glow is not what I was after: Is that possible to provide the shadows for such ideal glow for irregular shape?
- `Arc` operation not work together with `rounded corners` within \path?by Explorer on May 1, 2026 at 6:08 pm
I have the following code: \documentclass[tikz,border=5pt]{standalone} \begin{document} \begin{tikzpicture} \draw[fill=gray!25,draw,rounded corners=8pt] (40:2) -- (40:4) arc[start angle=40,end angle=140,radius=4] (140:4) -- (140:2) arc[start angle=140,end angle=40,radius=2] (40:2) -- cycle; \end{tikzpicture} \end{document} which I think would get a rounded sector, but in fact: Any paraphase on this? Maybe related ?
- Borromean Knot Brunnian linkby Julio Michael Stern on April 30, 2026 at 10:18 pm
I am trying to use TiKZ to draw a Borromean knot with 3 Wasp figures. I am getting the wrong superpositions. A single wasp is produced by the following code. Can someone help me to write a TiKZ code for this Brunnian entanglement with 12 crossings. Wasp: \documentclass[border=5mm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} % Estilos para o anel do mosaico \tikzset{ vespa ring/.style={ draw=red, line width=11pt, line join=round }, white stripe/.style={ draw=white, line width=2pt, % Removida a opacidade para evitar manchas line join=round } } % Macro final da "Cintura de Vespa" com cabeça circular e elevada \newcommand{\vespawaist}{ (0.8, 0) % Cintura direita .. controls (0.8, 1.0) and (2.0, 1.8) .. (1.5, 2.4) % Ombro .. controls (1.0, 3.0) and (-1.0, 3.0) .. (-1.5, 2.4) % Topo elevado .. controls (-2.0, 1.8) and (-0.8, 1.0) .. (-0.8, 0) % Cintura esquerda .. controls (-0.8, -1.0) and (-2.0, -1.8) .. (-1.5, -2.4) % Ombro inferior .. controls (-1.0, -3.0) and (1.0, -3.0) .. (1.5, -2.4) % Base elevada .. controls (2.0, -1.8) and (0.8, -1.0) .. (0.8, 0) % Fecha -- cycle } % Desenho em camadas para garantir o branco puro \draw[vespa ring] \vespawaist; \draw[white stripe] \vespawaist; \end{tikzpicture} \end{document}
- Apply transformation xslant to node shape but not textby Paul on April 30, 2026 at 6:11 pm
I want to create a multi part parallelogram input block for a flowchart. There is no multi part trapezium shape that exist so for now I used a standard rectangular multi part shape with the xslant option to make it look like a parallelogram. I defined a style that I can easily reuse. The problem is that the text is also slanted, and if possible I would like it normal. Is there a way to apply xslant only to the shape and not to the text ? I tried creating a second node only for the text but the problem is that the paralellogram doesn't resize properly to fit the text. My MWE : \documentclass[class=article]{standalone} \usepackage[]{xcolor} \usepackage{tikz} \usetikzlibrary{shapes} \tikzstyle{io} = [rectangle split, rectangle split parts=2, xslant=0.4, draw, rectangle split part fill={blue!50,blue!20}, text centered, minimum width=4.25cm, minimum height=2cm] \begin{document} \begin{tikzpicture} \draw (0,0) node[io,name = ,align = center]{Parameters\nodepart{two} $\alpha$, $\eta$}; \end{tikzpicture} \end{document} Thanks for your help.
- Use "plot" inside a \draw path in tikzby flawr on April 30, 2026 at 5:36 pm
Is there a way to continue a path we draw using \draw with a plot, just as we do for instance also with arc or similar commands? In the example below I have a straight line, but I'd like the plot to append directly to that line, as indicated by the red dots. I can of course do that e.g. with plot[shift={(1,1)},...], but that means that I have to repeat that second coordinate in the path, which makes it again more cumbersome to use if we want to change something later (and the second straight line segment then points to the original endpoint without the shift). So this is more a question about "ergonomically" using this plot command inside other paths. E.g., I also like using the ++ syntax to precisely extend a path a certain distance horizontally, without having to repeat the previous y-coordinate, and I was wondering whether there is something similar we can do with the plot command inside such a path. \documentclass{standalone} \usepackage{tikz} \usepackage{xcolor} \usepackage{pgfplots} \pgfplotsset{compat=1.17} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture}[domain=0:4] \draw[black!10!white, dashed] (0, 0) grid (4, 2); \draw (0, 1) -- (1, 1) node[left] {} plot[domain=0:1, samples=100] function{sin(6.3*x)} node[right] {} -- ++(1, 0); \end{tikzpicture} \end{document}
- Horizontally centering a tikz node on a pageby Sambo on April 30, 2026 at 3:30 pm
My question is essentially the same as this question, but I'm asking again because the answer provided is not very resilient. In particular, it doesn't work for the kind of diagram I want. I want to use Tikz to draw a diagram with lots of nodes and arrows; essentially, a flowchart. The diagram should start with a single node which is centered on the page (in the MWE below, this is the "Hello there" box). If I try to just use the \centering command, the whole picture gets centered, which is not what I want. The answer I linked above suggests using the \useasboundingbox command. However, this doesn't seem to do what I want. Here is my minimal working example: \documentclass[a4paper, 11pt]{article} \usepackage{tikz} \begin{document} This is a line of text which has been written with no purpose other than to help illustrate how the figure below appears on a page. \begin{figure}[ht] \centering \begin{tikzpicture}[rect/.style={rectangle, draw=black, thin}] \node[rect] (box1) at (0,0) {Hello there}; % Location 1 \node[rect] (box2) at (5,-1) {Hi}; % Location 2 \end{tikzpicture} \end{figure} This is a line of text which has been written with no purpose other than to help illustrate how the figure above appears on a page. \end{document} The linked answer suggests using the command \useasboundingbox (box1.south east) rectangle (box1.north west);. If I put this command at location 2, then the bounding box includes both boxes "Hello there" and "Hi", and the box "Hello there" is not centered (see below). If I put this command at location 1, then the bounding box only includes the "Hello there" box; this centers it the way I want, but then the box "Hi" ends up overlapping with the text below (see below). How can I make the "Hello there" box be centered on the page?
- Draw simple figures: l3draw vs PGF performancesby 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.
- Representation of a double cone with section and orthogonal projectionsby Sebastiano on April 29, 2026 at 8:08 pm
I should create a drawing that illustrates this domain in 3D: T= \{(x, y, z) \in \mathbb{R}^3\colon x^2 +y^2\leq (z-9)^2, 0\leq z\leq 3 \}. It is a double cone with vertex at (0,0,3) if it were x^2 +y^2= (z-9)^2. I may have to change the scale but I don’t want the drawing to look worse. How can I colour the two-sloped cone part that satisfies the inequality x^2 +y^2\leq (z-9)^2? ...and then adding 0\leq z\leq 3? \documentclass{article} \usepackage{tikz} \usetikzlibrary{patterns} \usepackage{tikz-3dplot} \usepackage[active,tightpage]{preview} \PreviewEnvironment{tikzpicture} \setlength\PreviewBorder{2pt} \begin{document} \tdplotsetmaincoords{60}{110} \begin{tikzpicture}[tdplot_main_coords,scale=0.9] \pgfmathsetmacro{\tini}{0.5*pi} \pgfmathsetmacro{\tfin}{1.85*pi} \pgfmathsetmacro{\tend}{2.5*pi} \def\h{10.2} \draw[thick,->] (0,0,0) -- (3.5,0,0) node[below left] {$x$}; \draw[dashed] (0,0,0) -- (-2.5,0,0); \draw[thick,->] (0,0,0) -- (0,3.5,0) node[right] {$y$}; \draw[dashed] (0,0,0) -- (0,-2.5,0); \draw[thick,->] (0,0,0) -- (0,0,12) node[above] {$z$}; \fill (0,0,9) circle (1pt); \node[right] at (0,0,9) {$(0,0,9)$}; \foreach \angulo in {0,2,...,358}{ \draw[cyan,very thick,opacity=0.12,rotate around z=\angulo] plot[domain=0:2,smooth,variable=\t] ({0},{\t},{9 + \t}); \draw[cyan,very thick,opacity=0.12,rotate around z=\angulo] plot[domain=0:2,smooth,variable=\t] ({0},{\t},{9 - \t}); } \foreach \z in {7.6,7.8,...,10.4}{ \pgfmathsetmacro{\r}{abs(\z-9)} \draw[cyan,thick,opacity=0.35] plot[domain=\tini:\tfin,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{\z}); } \foreach \z in {7.6,7.8,...,10.4}{ \pgfmathsetmacro{\r}{abs(\z-9)} \draw[cyan,thick,opacity=0.35] plot[domain=\tfin:\tend,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{\z}); } \pgfmathsetmacro{\r}{abs(\h-9)} \draw[red,very thick] plot[domain=0:360,smooth,variable=\t] ({\r*cos(\t)},{\r*sin(\t)},{\h}); \node[red, above right] at ({\r},0,\h) {$z=h$}; \fill[yellow,opacity=0.35] plot[domain=0:360,smooth,variable=\t] ({\r*cos(\t)},{\r*sin(\t)},0); \draw[red,thick] plot[domain=0:360,smooth,variable=\t] ({\r*cos(\t)},{\r*sin(\t)},0); \foreach \angle in {0,45,...,315}{ \pgfmathsetmacro{\x}{\r*cos(\angle)} \pgfmathsetmacro{\y}{\r*sin(\angle)} \draw[gray,dashed,opacity=0.5] (\x,\y,0) -- (\x,\y,\h); } \node[blue,right] at (0,0,11.5) {$x^2 + y^2 = (z-9)^2$}; \end{tikzpicture} \end{document}
- Creating a custom symbol in TikZ whose colour agrees with that of the surrounding textby varkor on April 29, 2026 at 11:36 am
I have created a custom ⍟ symbol using TikZ, which works well, except that it ignores the colour of the surrounding text. MWE: \documentclass{article} \usepackage{tikz} \usepackage{scalerel} \newsavebox{\whitecircstar}\sbox{\whitecircstar}{\kern.075em\tikz{\node[draw, circle,line width=.36pt, inner sep=0]{$*$};}\kern.075em} \newcommand{\ostar}{\mathbin{\scalerel*{\usebox{\whitecircstar}}{\odot}}} \begin{document} \textcolor{red}{Before $\ostar$ After} \end{document} Output: How can I make \ostar the same colour as the surrounding text? My understanding was that . was a special symbol for the current colour in xcolor, but adding color=. to the node arguments had no effect.
- Multiple splits in Tikz rectangle with distinct linesby iago on April 29, 2026 at 9:24 am
My goal is to get a rectangle like the one below, but with text in the nested rectangles. Line types could be for example the following: I saw tikz: Multiple splits of rectangle, but it does not answer the question on the line types. Beyond that, I am a beginner using Tikz, and I'd like the answer explained, since the linked answer is complex to understand. Thanks!
- How to add a translucent background picture on a title page, behind titles?by Cham on April 28, 2026 at 10:08 pm
I would like to add a very large picture on a title page, covering the whole page with a large offset (picture pasted to the upper-left side of the page), blended on the page background (below the title, author's name and other text elements), with some transparency effect, and background blending effect. How should we achieve this? The picture is supposed to be partly shown on the page, about half of it showing on the upper-left side, like an "intrusion" on the page (sorry for the bad english description. I hope you get the picture). Here's a MWE to be modified, showing a title page prototype: \documentclass[11pt,twoside]{book} \usepackage[T1]{fontenc} \usepackage[tt=false]{libertinus} \usepackage[french]{babel} \usepackage[stretch=50]{microtype} \usepackage[letterpaper,left=1.25in,right=1in,top=0.5in,bottom=0.5in,includeheadfoot,headheight=15pt]{geometry} \usepackage{titlesec} \usepackage{graphicx} \usepackage[dvipsnames]{xcolor} \usepackage{float} \usepackage{fancyhdr} \usepackage[titles]{tocloft} \usepackage{shadowtext} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \frontmatter % Title Page : \begin{titlepage} \definecolor{lightbrown}{RGB}{177, 149, 93} \definecolor{darkbrown1}{RGB}{58, 41, 26} \definecolor{darkbrown2}{RGB}{50, 30, 0} % Frame : \begin{tikzpicture}[remember picture, overlay] \draw[line width = 1in,color = white] ($(current page.north west) + (0.25in,0.25in)$) rectangle ($(current page.south east) + (0.25in,-0.25in)$); \draw[line width = 0.25pt,color = black] ($(current page.north west) + (0.75in,-0.25in)$) rectangle ($(current page.south east) + (-0.25in,0.25in)$); %\draw[line width = 1pt,color = darkbrown1] ($(current page.north west) + (1in,-0.5in)$) rectangle ($(current page.south east) + (-0.5in,0.5in)$); \end{tikzpicture} \shadowoffsetx{2.5pt} \shadowoffsety{3.5pt} \shadowcolor{gray!80} \definecolor{pagetitre}{RGB}{150,120,100} \pagecolor{pagetitre} \centering \vspace*{\baselineskip} \vfill {\textcolor{black}{\fontsize{26}{0}\selectfont\sffamily\textbf{\shadowtext{Some Nice Title Here}}}} \\[2.5\baselineskip] {\textcolor{black}{\huge\sffamily\scshape Someone}} \vfill \vfill \includegraphics[width=11cm]{example-grid-100x100pt} \vfill {\textcolor{black}{\Large\selectfont\sffamily\scshape Some copyright notice}} \end{titlepage} \pagecolor{white} Blabla \end{document} So how can I add a very large picture blended with the page background colour, with some transparency effect, and a large up-left offset? The large picture should fit inside the frame defined with the tikzpicture environment, and stay below all text on the title page.
- How to tweak the exact positon in the normal direction of the path by `anchor`?by Explorer on April 28, 2026 at 6:28 am
As the follow-up of my previous question, the code below comes from cfr's solution: % Source - https://tex.stackexchange.com/a/762315 % Posted by cfr % Retrieved 2026-04-28, License - CC BY-SA 4.0 \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{arrows.meta} \makeatletter \newcommand\dualharpoon{} \newcommand\dualharpoon@aux{} \newcommand\dualharpoon@noaux{} \protected\def\dualharpoon{% \@ifnextchar[\dualharpoon@aux\dualharpoon@noaux } \protected\def\dualharpoon@noaux{% \dualharpoon@aux[]% } \long\protected\def\dualharpoon@aux[#1]#2#3#4#5{% \path (#4.center); \pgfgetlastxy{\temp@ax}{\temp@ay} \path (#5.center); \pgfgetlastxy{\temp@bx}{\temp@by} \pgfmathsetmacro\temp@angle{atan2(\temp@by-\temp@ay,\temp@bx-\temp@ax)} \draw[-foo,mystyle] (#4.{\temp@angle - 10}) -- % node[ % draw=blue, % % anchor={90+\temp@angle}, % sloped,inner sep=0pt,#1 % ] {#2} node[ draw, % draw=red, anchor={90+\temp@angle},%<- sloped,inner sep=0pt,#1 ] {#2} (#5.{190 + \temp@angle}); %%%%%%%%%%%%%%%%%%%% \draw[foo-,mystyle] (#4.{\temp@angle + 10}) -- node[ draw, anchor={270+\temp@angle},%<- sloped,inner sep=0pt,#1 ] {#3} (#5.{170 + \temp@angle}); } \makeatother \begin{document} \begin{tikzpicture}[ foo/.tip={Stealth[harpoon,swap]},scale=1.5, mystyle/.style={thick, shorten >=2pt,shorten <=2pt}, ] \foreach \i in {0,20,...,340}{ \node[draw,circle,fill=teal] (In-\i) at (\i:3) {}; \node[draw,circle,fill=magenta] (Out-\i) at (\i:5) {}; \dualharpoon[scale=.8]{$\Delta$}{$\nabla$}{In-\i}{Out-\i} } \end{tikzpicture} \end{document} And I tweaked some label arguments, but I found that the label position is not exactly what I want with anchor={90+\temp@angle}, I want every angles gives the alignment with the normal direction: To show the anchor's behavior more clearly: % Source - https://tex.stackexchange.com/a/762315 % Posted by cfr % Retrieved 2026-04-28, License - CC BY-SA 4.0 \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{arrows.meta} \makeatletter \newcommand\dualharpoon{} \newcommand\dualharpoon@aux{} \newcommand\dualharpoon@noaux{} \protected\def\dualharpoon{% \@ifnextchar[\dualharpoon@aux\dualharpoon@noaux } \protected\def\dualharpoon@noaux{% \dualharpoon@aux[]% } \long\protected\def\dualharpoon@aux[#1]#2#3#4#5{% \path (#4.center); \pgfgetlastxy{\temp@ax}{\temp@ay} \path (#5.center); \pgfgetlastxy{\temp@bx}{\temp@by} \pgfmathsetmacro\temp@angle{atan2(\temp@by-\temp@ay,\temp@bx-\temp@ax)} \draw[-foo,mystyle] (#4.{\temp@angle - 10}) -- node[ draw=blue, % anchor={90+\temp@angle}, sloped,inner sep=0pt,#1 ] {#2} node[ draw=red, anchor={90+\temp@angle},%<- sloped,inner sep=0pt,#1 ] {#2} (#5.{190 + \temp@angle}); %%%%%%%%%%%%%%%%%%%% % \draw[foo-,mystyle] (#4.{\temp@angle + 10}) -- node[ % draw, % anchor={270+\temp@angle},%<- % sloped,inner sep=0pt,#1 % ] {#3} (#5.{170 + \temp@angle}); } \makeatother \begin{document} \begin{tikzpicture}[ foo/.tip={Stealth[harpoon,swap]},scale=1.5, mystyle/.style={thick, shorten >=2pt,shorten <=2pt}, ] \foreach \i in {0,20,...,340}{ \node[draw,circle,fill=teal] (In-\i) at (\i:3) {}; \node[draw,circle,fill=magenta] (Out-\i) at (\i:5) {}; \dualharpoon[scale=.8]{$\Delta$}{$\nabla$}{In-\i}{Out-\i} } \end{tikzpicture} \end{document} It also reminded me of Jasper Habicht's another solution, but..., I found it not quite easy to decide the position of the midpoint of path from A to B... Any suggestions on this?
- How to add two-sided harpoon arrows with proper label position elegantly?by Explorer on April 27, 2026 at 5:14 pm
Learning from the link here and here, I have the following code: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture}[ foo/.tip={Stealth[harpoon,swap]}, mystyle/.style={thick, shorten >=2pt,shorten <=2pt}, ] \node[draw,circle,fill=teal] (A) at (0,1) {A}; \node[draw,circle,fill=magenta] (B) at (0,-1) {B}; \node[draw,circle,fill=cyan] (C) at (2.5,.5) {C}; \draw[-foo,mystyle,transform canvas={xshift=-0.3ex}] (A) -- node[left] {$\Delta$} (B); \draw[foo-,mystyle,transform canvas={xshift=+0.3ex}] (A) -- node[right] {$\nabla$} (B); % \draw[dualharpoon={$\Delta$}{$\nabla$}] (A) -- (B); % ? \draw[-foo,mystyle,transform canvas={yshift=-0.3ex}] (B) -- node[below right=-3pt] {$f(x)$} (C); \draw[foo-,mystyle,transform canvas={yshift=+0.3ex}] (B) -- node[above left=-3pt] {$g(x)$} (C); % \draw[dualharpoon={$f(x)$}{$g(x)$}] (B) -- (C); % ? \end{tikzpicture} \end{document} I want more smartly syntax like: \draw[dualharpoon={$\Delta$}{$\nabla$}] (A) -- (B); \draw[dualharpoon={$f(x)$}{$g(x)$}] (B) -- (C); which control exactly how much to xshift/yshift moved towards in the direction perpendicular to the connection between the two nodes, in addition, I also don't want to decide the node's position by above left=-3pt manually. Any suggestions on how to support such two-sided harpoon arrow with label? Edited after cfr's answer(first edition): % Source - https://tex.stackexchange.com/a/762315 % Posted by cfr % Retrieved 2026-04-28, License - CC BY-SA 4.0 \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{arrows.meta} \makeatletter \newcommand\dualharpoon{} \newcommand\dualharpoon@aux{} \newcommand\dualharpoon@noaux{} \protected\def\dualharpoon{% \@ifnextchar[\dualharpoon@aux\dualharpoon@noaux } \protected\def\dualharpoon@noaux{% \dualharpoon@aux[]% } \long\protected\def\dualharpoon@aux[#1]#2#3#4#5{% \path (#4.center); \pgfgetlastxy{\temp@ax}{\temp@ay} \path (#5.center); \pgfgetlastxy{\temp@bx}{\temp@by} \edef\temp@angle{\fpeval{(atan((\temp@by-\temp@ay)/(\temp@bx-\temp@ax)))*(180/pi)}} \draw[-foo,mystyle] (#4.{\temp@angle - 5}) -- coordinate (temp@1) (#5.{185 + \temp@angle}); \node[anchor={90+\temp@angle}] at (temp@1) {#2} ; \draw[foo-,mystyle] (#4.{\temp@angle + 5}) -- coordinate (temp@2) (#5.{175 + \temp@angle}); \node[anchor={270+\temp@angle}] at (temp@2) {#3}; } \makeatother \begin{document} \begin{tikzpicture}[ foo/.tip={Stealth[harpoon,swap]}, mystyle/.style={thick, shorten >=2pt,shorten <=2pt}, ] \node[draw,circle,fill=teal] (A) at (0,1) {A}; \node[draw,circle,fill=magenta] (B) at (0,-1) {B}; \node[draw,circle,fill=cyan] (C) at (2.5,.5) {C}; \node[draw,circle,fill=olive] (D) at (-3,1) {D}; \dualharpoon{$\Delta$}{$\nabla$}{A}{B} \dualharpoon{$g(x)$}{$f(x)$}{B}{C} \dualharpoon{$p$}{$q$}{B}{D} \end{tikzpicture} \end{document}
- Table header text dropped when including pgfplotstable inside tikzpicture graphby Kevin Zembower on April 26, 2026 at 4:52 pm
I notice a strange phenomenon when trying to create a data table side-by-side with its graph. The header text of the table next to the graph disappears, while a stand-alone table is fine. Here's my MWE: \documentclass[]{article} \usepackage{pgfplots} \pgfplotsset{ scale only axis, compat=1.18, } \usepackage{pgfplotstable} %To read data files once \pgfplotstableset{ %Setting for data table appearance every head row/.style={before row=\hline,after row=\hline}, every last row/.style={after row=\hline} } \begin{document} \pgfplotstableread{ x y 1 2 2 4 3 6 4 8 }\datatable Table standing alone: \pgfplotstabletypeset{\datatable} Table and graph side by side (pfgtabletypeset inside tikzpicture): \begin{figure}[h] \begin{tikzpicture} \begin{axis} \addplot table {\datatable}; \end{axis} \hskip 10cm \pgfplotstabletypeset{\datatable} \end{tikzpicture} \caption{Graph and datatable side-by=side} \end{figure} \end{document} Here's what I see: My two questions are: How to restore the table header text? How to position the table vertically so it's centered on the graph? Thanks so much for your suggestions and advice. -Kevin
- why \begin{align*}..\end{align*} spacing is different inside tikz Matrix node than outside?by Nasser on April 26, 2026 at 4:33 am
I am learning how to use tikz Matrix to layout few things. Notice that inside tikz matrix node, the alignment is not the same as outside tikz using standard &= for align math environment. I had to to put align environment inside a minipage to make it work inside tikz matrix node. It will not let me just use align directly since not paragraph mode. But the issue is the spacing between left side of &= and right side is different than outside tikz. \documentclass[12pt,varwidth]{standalone} %need varwidth to use align inside standalon \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \fbox{\begin{minipage}{1.5in} \vspace{0pt} % Fixes top spacing issues \noindent % Ensures no paragraph indentation {\small All plots used the same initial conditions \begin{align*} x(0) &=1\\ x'(0) &=1\\ \end{align*} } \end{minipage} } \begin{tikzpicture} \matrix (m) [matrix of math nodes, nodes={anchor=center}, row sep=3.5em, column sep=2.5em, nodes in empty cells, draw] { 1& 2& \begin{minipage}{1.5in} \vspace{0pt} % Fixes top spacing issues \noindent % Ensures no paragraph indentation {\small All plots used the same initial conditions \begin{align*} x(0) &=1\\ x'(0) &=1\\ \end{align*} } \end{minipage} &4 \\ 5& 6 & 7 & 8 \\ }; \foreach \i in {1,2,3,4} \foreach \j in {1,2} \draw [help lines] (m-\j-\i.south west) rectangle (m-\j-\i.north east); \end{tikzpicture} \end{document} Compiled with lualatex gives lualatex, TL 2026
- Additive color mixing in set diagramsby Alma Arjuna on December 13, 2025 at 3:19 pm
I've made a pretty set diagram! I'm not happy with how the colors are interacting on the set intersections, though. Because of the order the sets are built, each one is visibly 'above' or 'below' each other, breaking the symmetry of the figure. Of course, this behavior is expected. Can we make so that the colors interact additively instead? I know I can go intersection-by-intersection changing the colors to whatever I want, but this seems very inefficient and I wouldn't know how to manually combine the colors anyway... Here is the code. \documentclass[tikz,border=2mm]{standalone} \usetikzlibrary{calc} \tikzstyle{vertex}=[circle,fill=black,inner sep=2.2pt] \begin{document} \begin{tikzpicture}[scale=1] \coordinate (A) at (18:{sqrt(5)}); \coordinate (B) at (90:{sqrt(5)}); \coordinate (C) at (162:{sqrt(5)}); \coordinate (D) at (234:{sqrt(5)}); \coordinate (E) at (306:{sqrt(5)}); \def\set{ellipse (2.618cm and 0.382cm)} \fill[magenta, opacity=.36] ($(A)!0.5!(C)$) \set; \fill[cyan, opacity=.36, rotate=72] ($(B)!0.5!(D)$) \set; \fill[yellow, opacity=.36, rotate=144] ($(C)!0.5!(E)$) \set; \fill[violet, opacity=.36, rotate=216] ($(D)!0.5!(A)$) \set; \fill[green, opacity=.36, rotate=288] ($(E)!0.5!(B)$) \set; \node[vertex] at (A) {}; \node[vertex] at (B) {}; \node[vertex] at (C) {}; \node[vertex] at (D) {}; \node[vertex] at (E) {}; \coordinate[vertex] (F) at ($(A)!0.382!(C)$); \coordinate[vertex] (G) at ($(B)!0.382!(D)$); \coordinate[vertex] (H) at ($(C)!0.382!(E)$); \coordinate[vertex] (I) at ($(D)!0.382!(A)$); \coordinate[vertex] (J) at ($(E)!0.382!(B)$); \end{tikzpicture} \end{document}
- How can I draw grid of cylinders?by minthao_2011 on November 25, 2025 at 9:02 am
I used Mathematica and tried grid of cylinder I don’t know how to draw with other tools. How can I draw it?
- Draw a car with TikZby mzn on April 6, 2024 at 7:05 pm
Original question I have drawn a simple car with this code: \begin{document} \begin{tikzpicture} \shade[top color=red, bottom color=white, shading angle={135}] [draw=black,fill=red!20,rounded corners=1.2ex,very thick] (1.5,.5) -- ++(0,1) -- ++(1,0.3) -- ++(3,0) -- ++(1,0) -- ++(0,-1.3) -- (1.5,.5) -- cycle; \draw[very thick, rounded corners=0.5ex,fill=black!20!blue!20!white,thick] (2.5,1.8) -- ++(1,0.7) -- ++(1.6,0) -- ++(0.6,-0.7) -- (2.5,1.8); \draw[thick] (4.2,1.8) -- (4.2,2.5); \draw[draw=black,fill=gray!50,thick] (2.75,.5) circle (.5); \draw[draw=black,fill=gray!50,thick] (5.5,.5) circle (.5); \draw[draw=black,fill=gray!80,semithick] (2.75,.5) circle (.4); \draw[draw=black,fill=gray!80,semithick] (5.5,.5) circle (.4); \shade[top color=red, bottom color=white, shading angle={135}] [draw=black,fill=red!20,rounded corners=1.2ex,very thick] (1.5,.5) -- ++(0,1) -- ++(1,0.3) -- ++(3,0) -- ++(1,0) -- ++(0,-1.3) -- (1.5,.5) -- cycle; \draw[very thick, rounded corners=0.5ex,fill=black!20!blue!20!white,thick] (2.5,1.8) -- ++(1,0.7) -- ++(1.6,0) -- ++(0.6,-0.7) -- (2.5,1.8); \draw[thick] (4.2,1.8) -- (4.2,2.5); \draw[draw=black,fill=gray!50,thick] (2.75,.5) circle (.5); \draw[draw=black,fill=gray!50,thick] (5.5,.5) circle (.5); \draw[draw=black,fill=gray!80,semithick] (2.75,.5) circle (.4); \draw[draw=black,fill=gray!80,semithick] (5.5,.5) circle (.4); \end{tikzpicture} \end{document} what should we do if we want to have 3 cars at a distance from each other? Edit based on the answers [![enter image description here][1]][1][![enter image description here][1]][1]I have drawn a simple car with this code: \documentclass[border=10pt]{standalone} \usepackage{tikz} \tikzset{ pics/my car/.style={ code={ \tikzset{my car/.cd, #1} \shade[my car/car color, shading angle={135}, draw=black, rounded corners=1.2ex, very thick] (1.5,.5) -- ++(0,1) -- ++(1,0.3) -- ++(3,0) -- ++(1,0) -- ++(0,-1.3) -- (1.5,.5) -- cycle; \draw[very thick, rounded corners=0.5ex, fill=black!20!blue!20!white, thick] (2.5,1.8) -- ++(1,0.7) -- ++(1.6,0) -- ++(0.6,-0.7) -- (2.5,1.8); \draw[thick] (4.2,1.8) -- (4.2,2.5); \draw[fill=gray!50, thick] (2.75,.5) circle[radius=.5cm] (5.5,.5) circle[radius=.5cm]; \draw[fill=gray!80, semithick] (2.75,.5) circle[radius=.4cm] (5.5,.5) circle[radius=.4cm]; \coordinate (-front) at (1.5,1); \coordinate (-back) at (6.5,1); \coordinate (-top) at (4.25,2.5); \coordinate (-bottom) at (4.25,0); } }, my car/car color/.style={ top color=red, bottom color=white } } \begin{document} \begin{tikzpicture} \pic (car 1) at (0,0) {my car}; \pic (car 2) at (10,0) {my car={car color/.append style={top color=blue}}}; \pic (car 3) at (20,0) {my car={car color/.append style={top color=green}}}; \pic (car 4) at (30,0) {my car={car color/.append style={top color=black}}}; %\draw[<-, shorten <=5pt, shorten >=5pt, ultra thick] % (car 1-back) -- (car 2-front); \draw[line width=5pt][<-, shorten <=5pt, shorten >=5pt] (car 1-top) to[out=90, in=90] (car 2-top); \draw[line width=5pt][<-, shorten <=5pt, shorten >=5pt] (car 2-top) to[out=90, in=90] (car 3-top); \draw[line width=5pt][<-, shorten <=5pt, shorten >=5pt] (car 3-top) to[out=90, in=90] (car 4-top); \end{tikzpicture} \end{document}
- Draw a unicorn in TikZ 🦄by Martin Thoma on March 31, 2023 at 2:42 pm
I'm currently reading Sparks of Artificial General Intelligence: Early experiments with GPT-4. This paper by Microsoft employees experiments with the capabilities of GPT-4, a successor of ChatGPT. One task is to draw a unicorn with tikz.ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ They claim: GPT-4 produces impressive outputs that are [...] at least comparable (if not superior) to what a human would do. Who wants to prove them wrong? 😄🦄🌈 edit: Please don't include PNG / JPG / other pixel image formats. MS-SPO is the only one allowed to do that (as a grandfathering-rule) - kudos for finding the loophole in this question and for thinking outside of the box 😁👍 edit: We now have 200 fun questions! 🥂🥳
- How to hatch pattern this table excluding the circled region?by rakatex on May 23, 2020 at 8:53 pm
I would like to circle the elements in the matrix table (How to create a small cell with borders in the top corner of a cell in the table?) and hatch pattern the matrix table excluding the circled numbers and inlays. I would also like to fill the cells in the demand and supply with red color as indicated in the figure. Please help me. Please note that the red lines drawn in the figure are approximate, in the final solution, I would like to have perfectly slanted group of lines (45 degree hatch lines). \documentclass[tikz,border=3mm]{standalone} \usepackage{amsmath} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture}[mmat/.style={matrix of math nodes,nodes in empty cells, row sep=-\pgflinewidth,column sep=-\pgflinewidth, nodes={minimum width=5.5em,minimum height=3.5em, draw,anchor=center, text depth=0.25ex,text height=0.8em}}, inlay/.style={label={[draw,thin,anchor=north east,minimum width=0.7cm, minimum height=0em,inner sep=1.4pt]north east:#1}}] \matrix[mmat] (mat){ & P & Q & R & S & \textit{Supply} \\ A & |[inlay=10]| 300 & |[inlay=20]| 200 & |[inlay=30]| 0 & |[inlay=40]| 0 & 500 \\ B & |[inlay=50]| 0 & |[inlay=60]| & |[inlay=70]| & |[inlay=80]| & 500 \\ C & |[inlay=90]| 0 & |[inlay=100]| & |[inlay=110]| & |[inlay=120]| & 500 \\ Demand & |[inlay=130]| 300 & |[inlay=140]| 200 & |[inlay=150]| 1000 & |[inlay=160]| 500 & 2000 \\ }; \draw (mat-1-1.north west) -- (mat-1-1.south east); \draw[stealth-] ([yshift=2ex,xshift=-0.5ex]mat-1-1.east) -- ++ (-2ex,0) node[left,font=\itshape]{To}; \draw[stealth-] ([xshift=3ex,yshift=0.5ex]mat-1-1.south west) -- ++ (0,2ex) node[above,font=\itshape]{From}; \end{tikzpicture} \end{document}
- Beamer: Overlay with `pgfplots` that read data from a tableby tvk on May 2, 2019 at 1:30 am
I want to show a chart by the package pgfplots only on a subsequent slide of a frame. However using \uncover or \visible on the chart generates an error: Package pgfplots Error: Could not read table file '" {Other Categories} 0 0 . } with the MWE below. If I remove the \uncover, the file compiles and produces a static frame as I show below. How can I display the chart only on certain slides? MWE: \documentclass{beamer} \setbeamercovered{dynamic} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.16} \begin{document} \begin{frame}[fragile] \uncover<2->{ \begin{figure} \caption{A Stacked Bar Chart} \smallskip {\centering \begin{tikzpicture}[scale=0.7] \begin{axis}[ ybar stacked, xlabel={Category}, ylabel={Quantity}, ymin=0, symbolic x coords={A,B/C,D,Other Categories}, xtick=data, legend style={ at={(0.5,-0.3)}, anchor=north, }, axis lines=left, enlarge x limits=true, enlarge y limits={true,upper}, ] \addplot[fill=white] table [header=false,x index = {0}, y index = {1}] { {Other Categories} 24.4417 18.9708 28.7252 28.7150 A 27.1738 2.9262 28.9467 14.5613 B/C 3.8096 8.3549 4.7284 24.0084 D 27.4013 16.4064 29.1178 4.2566 }; \addplot[fill=red] table [header=false,x index = {0}, y index = {1}] { {Other Categories} 0 0 . . A 8.4352 19.1898 . . B/C 18.3147 13.1148 . . D 15.8441 0.7142 . . }; \legend{White part, Red part} \end{axis} \end{tikzpicture} \par} \end{figure} } \end{frame} \end{document} Static frame:
- Powerful pedagogic graph of lognormal distributionby JeT on October 14, 2018 at 1:54 am
I found this graph to explain the transformation from normal to lognormal distribution. I am no latex expert and I was wondering if anyone knew how to reproduce it ? thank you ! Here is MWE \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.7} \begin{document} \begin{tikzpicture} \begin{axis}[rotate=-90,grid=both, samples at={-4,-3.99,...,6}, ] \addplot[smooth,very thick,color=blue,samples=100] {(1/sqrt(2*pi*1))*exp(-(x-0)^2/(2*1)}; \addlegendentry{$\mathcal{N}(0,1)$} \end{axis} \begin{scope}[shift={(6,8)}] \begin{axis}[grid=both, samples at={-4,-3.99,...,6}, ] \addplot[color=red,very thick,samples=100] {(1/x)* (1/sqrt(2*pi*1))*exp(- (ln(x)-0)^2/(2*1)}; \addlegendentry{$\mathcal{LN}(0,1)$} \end{axis} \end{scope} \begin{scope}[shift={(6,0)}] \begin{axis}[grid=both, samples at={-3,-2.99,...,3}, ] \addplot[color=red,very thick,samples=100] {exp(-x)}; \addlegendentry{$x=e^y$} \end{axis} \end{scope} \end{tikzpicture} \end{document}
- Table with graphics in beamerby bkarpuz on September 1, 2017 at 11:50 am
How can we create a table as in the following picture? Here is what I have done. \documentclass[10pt,notheorems]{beamer} \usepackage{tikz} \usetikzlibrary{babel,decorations.markings,positioning,shapes,arrows} \usepackage{pgfplots} \pgfplotsset{compat=newest} \hypersetup{bookmarksdepth=4,bookmarksnumbered=true,bookmarksopen=true} \definecolor{mc1}{rgb}{0.368417,0.506779,0.709798} \usetheme{Warsaw} \usecolortheme{seahorse} \setbeamertemplate{theorems}[numbered] \setbeamertemplate{caption}[numbered] \begin{document} \begin{frame}[fragile]{Table of intervals}{} \begin{table} \centering \begin{tabular}{ccc} Notation & Set description & Picture \\ \hline $(a,b)$ & $\{x:\ a<x<b\}$ & \begin{tikzpicture} \begin{axis}[ %scaled ticks=false, axis lines=middle, %axis line style={draw=none}, width=50mm, height=20mm, xmin=0,xmax=4, ymin=-1,ymax=1, xtick={1,3}, xticklabels={$a$,$b$}, y axis line style={draw=none}, ytick=\empty, %yticklabels={} ] \addplot[very thick,color=mc1,smooth,samples=2,domain=1.1:2.9]{0}; \addplot[thick,color=mc1,fill opacity=0,only marks,mark=*] coordinates{(1,0)}; \addplot[thick,color=mc1,fill opacity=0,only marks,mark=*] coordinates{(3,0)}; \end{axis} \end{tikzpicture} \\ $[a,b]$ & $\{x:\ a\leq{}x\leq{}b\}$ & \begin{tikzpicture} \begin{axis}[ %scaled ticks=false, axis lines=middle, %axis line style={draw=none}, width=50mm, height=20mm, xmin=0,xmax=4, ymin=-1,ymax=1, xtick={1,3}, xticklabels={$a$,$b$}, y axis line style={draw=none}, ytick=\empty, %yticklabels={} ] \addplot[very thick,color=mc1,smooth,samples=2,domain=1:3]{0}; \addplot[thick,color=mc1,only marks,mark=*] coordinates{(1,0)}; \addplot[thick,color=mc1,only marks,mark=*] coordinates{(3,0)}; \end{axis} \end{tikzpicture} \\ $[a,b)$ & $\{x:\ a\leq{}x<b\}$ & \begin{tikzpicture} \begin{axis}[ %scaled ticks=false, axis lines=middle, %axis line style={draw=none}, width=50mm, height=20mm, xmin=0,xmax=4, ymin=-1,ymax=1, xtick={1,3}, xticklabels={$a$,$b$}, y axis line style={draw=none}, ytick=\empty, %yticklabels={} ] \addplot[very thick,color=mc1,smooth,samples=2,domain=1:2.9]{0}; \addplot[thick,color=mc1,only marks,mark=*] coordinates{(1,0)}; \addplot[thick,color=mc1,fill opacity=0,only marks,mark=*] coordinates{(3,0)}; \end{axis} \end{tikzpicture} \\ $\vdots$ & $\vdots$ & $\vdots$ \\ $(-\infty,\infty)$ & $\mathbb{R}$ & \begin{tikzpicture} \begin{axis}[ %scaled ticks=false, axis lines=middle, %axis line style={draw=none}, width=50mm, height=20mm, xmin=0,xmax=4, ymin=-1,ymax=1, xtick={1,3}, xticklabels={$a$,$b$}, y axis line style={draw=none}, ytick=\empty, %yticklabels={} ] \addplot[->,very thick,color=mc1,smooth,samples=2,domain=0:4]{0}; \end{axis} \end{tikzpicture} \end{tabular} \caption{Table of intervals}\label{tbltoi} \end{table} \end{frame} \end{document} How can I align the pictures properly? I would be very glad to hear suggestions.
- The Pappus Chainby kalakay on April 17, 2017 at 5:59 am
I drew a circle for Pappus chain on an arbelos. How to draw other circles? \documentclass[10pt]{article} \usepackage[a4paper,margin=2cm]{geometry} \usepackage[x11names]{xcolor} \usepackage{fouriernc} \usepackage{tikz} \usetikzlibrary{calc,intersections} \begin{document} \centering \begin{tikzpicture}[scale=1.5,line join=round,font=\small] \coordinate[label=below:$A$] (A) at (0,0); \coordinate[label=below:$B$] (B) at (4,0); \coordinate[label=below:$C$] (C) at (6,0); \draw[thick,lightgray](0,0)--(6,0); \draw[Burlywood4,thick] (6,0) arc [radius=3, start angle=0, delta angle=180] -- (0,0) arc [radius=2, start angle=180, delta angle=-180]--(4,0) arc [radius=1, start angle=-180, delta angle=-180]--cycle; \path[name path=b1] (6,0) arc [radius=3, start angle=0, delta angle=180]; \path[name path=b2] (0,0) arc [radius=2, start angle=180, delta angle=-180]; \path[name path=b3] (4,0) arc [radius=1, start angle=-180, delta angle=-180]; \draw[olive!50,name path=b4] (4,0) arc (225:60:{sqrt(2)}); \draw[violet!50,name path=b5] (4,4) arc (45:-40:{2*sqrt(2)}); \path [name intersections={of = b4 and b5, by={D}}]; \path [name intersections={of = b2 and b4, by={T,E}}]; \path [name intersections={of = b3 and b5, by={F}}]; \coordinate (K) at ($(E)!.5!(F)$); \coordinate (L) at ($(D)!.5!(F)$); \coordinate (M) at ($(K)!1cm!90:(F)$); \coordinate (N) at ($(L)!1cm!90:(D)$); \path[name path=g1] (K)--(M); \path[name path=g2] (L)--(N); \path [name intersections={of = g1 and g2, by={O}}]; \draw[thick,Red4] let \p1=( $(E)-(O) $ ) in (O) circle ({veclen(\x1,\y1)}); \foreach \p in {D,E,F,O} \draw[fill,DodgerBlue4] (\p) circle(1pt); %\foreach \p in {D,E,F} %\node[above] at (\p) {$\p$}; \end{tikzpicture} \end{document}
- Drawing cylinder in 3D planeby user412674 on March 25, 2017 at 10:59 pm
Can someone help me write the tikz code to generate the following images? I've tried adapting what some other people have done to generate a cylinder, but I want the cylinder with the axes and with the smaller cylinder inside. The code written here is perhaps most useful, Concentric Cylinders with tikz The code for a basic cylinder is given here 3D bodies in TikZ I'm new to tikz and have found that upon editing, the lines and dimensions go out of proportion and don't look reasonable any more. I also don't understand how to include lines in these cylinders or how to shade the inside cylinder.
- Customizing toc in book class (appendix and coloring sections depending on current chapter)by Alexis on June 12, 2016 at 11:01 am
I'm trying to customize my TOC as in this post (second example) and I'm having two issues. The first one is documented but I can't figure out what I'm doing wrong : I want to write "Appendix" instead of "Chapter". If I don't customize \titlecontents{chapter} then everything works fine, but if I do, I get a "Chapter" instead of "Appendix". I've tried all sorts of configs (I think it's due to the book class), with/without \begin{appendices}, loading (or not) the appendix package with the titletoc options... Any help would be very appreciated ! The second "problem" I'm having is I'm trying to customize the look of the subsections in the TOC according to the chapter they're in. Each chapter has its own color and I would like the sections to have the same color as the chapter they're in. Here is my MWE and the result. \documentclass[11pt]{book} \usepackage[table]{xcolor} \usepackage{ifthen} \usepackage{tikz,pgf} \definecolor{chapa}{HTML}{15CA7F} \definecolor{chapb}{HTML}{CA16BD} \definecolor{chapc}{HTML}{DE1841} \makeatletter \newcommand{\ch@p}{chapa} \newcommand{\ch@ngeCouleurs}[1] { \ifthenelse{\equal{#1}{1}}{\renewcommand{\ch@p}{chapa}}{} \ifthenelse{\equal{#1}{2}}{\renewcommand{\ch@p}{chapb}}{} \ifthenelse{\equal{#1}{3}}{\renewcommand{\ch@p}{chapc}}{} } \usepackage[titletoc]{appendix} \usepackage{titletoc} \usepackage{titlesec} \contentsmargin{-1.5cm} \titlecontents{chapter}[4pc] {\addvspace{30pt}% \ch@ngeCouleurs{\thecontentslabel}% \begin{tikzpicture}[remember picture, overlay]% \draw[\ch@p,fill=\ch@p] (-4.2,-.1) rectangle (-.8,.5);% \pgftext[left,x=-3.7cm,y=0.2cm]{\color{white}\large\bfseries\sc\@chapapp\ \thecontentslabel};% \end{tikzpicture}% \large\bfseries\color{\ch@p!80!black}}% {} {} {\titlerule\, Page \thecontentspage \begin{tikzpicture}[remember picture, overlay] \draw[\ch@p] (2pt,0) rectangle (6,0.1pt); \end{tikzpicture}% } [\addvspace{.2cm}]% \titlecontents{section}[0pc] {\addvspace{5pt}} { \color{\ch@p}\contentslabel[\thecontentslabel]{2pc}\color{black}} {} {\hfill\small\color{black}\thecontentspage} [\addvspace{3pt}] \makeatother \begin{document} \tableofcontents \chapter{One chapter} \section{First section} \section{First subsection} \chapter{Another chapter} \section{Foo} \section{Bar} \begin{appendices} \chapter{First appendix} \end{appendices} \end{document} The result (2.1 and 2.2 should be in purple, and "Chapter A" should be "Appendix A"). I think I know how to work around the coloring problem of the appendix (comes from the fact that the chapter counter has been reset which can be avoided using packages totcount and assoccnt). But I don't understand why my \ch@ngeCouleurs macro has no effect on the \titlecontents{section}. If I could access the chapter number in the \titlecontents{section}, that would solve my problem. Thank you for reading my (long) post ! And thanks to anyone who can provide help !
- Transform paper folding diagram to 3D object or vice versaby Tarass on November 23, 2014 at 11:28 am
I made this commands to make paper models, and I ask if it is possible to have a 3D view of them converting in tikz-3D, or backward. But it's easier to draw the flat model and generate the volume after. Calculations could be made with lualatex. If you have an idea to follow ? \documentclass[margin=2pt]{standalone} \usepackage{tikz,xparse} \usetikzlibrary{calc} \tikzset{% patron/.style={% line join=round, rounded corners=.05pt, draw, thin}, patron side/.style={patron}, patron languette/.style={patron}, } \newcounter{NodePat} \NewDocumentCommand{\PolygReg}{% O{3} % nb de cotés m % segment A/B O{A} % nom générique }{% \foreach \a/\b in {#2} {% \path[patron side] let \p1 = ($(\a)!.5!(\b)$) , \n1 = {veclen(\x1,\y1)} , \p2 = ($(\p1)!1/tan(180/#1)!90:(\b)$) in (\a)--(\b) \foreach \i [% evaluate=\i as \j using (\i-1)*360/#1] in {3,...,#1} {% -- ($(\p2)!1!\j:(\a)$) coordinate (#3\theNodePat) \pgfextra{\stepcounter{NodePat}} } -- cycle ; } } \NewDocumentCommand{\Languette}{% O{.15} % largeur D<>{45} % angle sur le premier node m % les deux nodes D<>{45} % angle sur le second node O{A} }{% \foreach \b/\a in {#3} {% \path[patron languette] let \p1 = ($(#5\b)!#1/sin(#2)!-#2:(#5\a)$), \p2 = ($(#5\a)!#1/sin(#4)!#4:(#5\b)$) in (#5\a) -- (#5\b) -- (\p1) -- (\p2) -- cycle ; } } \makeatletter \newcommand{\AffNodesPatron}[1][A]{% \newcount\X \X=1 \loop \expandafter\ifx\csname pgf@sh@pi@A\the\X\endcsname\pgfpictureid \node[font={\footnotesize},red] at (A\the\X) {A\the\X} ; \advance \X by 1 \else \X=0 \fi \unless\ifnum \X=0 \repeat } \makeatother \begin{document} \begin{tikzpicture}[scale=2] \coordinate (A1) at (0,0) ; \coordinate (A2) at (1,0) ; \setcounter{NodePat}{3} \PolygReg[4]{A1/A2} \PolygReg{A3/A2,A5/A2,A5/A6,A5/A7} \Languette{1/2,5/3,3/4,4/1} %\AffNodesPatron \end{tikzpicture} \begin{tikzpicture} \coordinate (A1) at (0,0) ; \coordinate (A2) at (1,0) ; \setcounter{NodePat}{3} \PolygReg[6]{A1/A2,A4/A3,A6/A5,A2/A1} \PolygReg[4]{A17/A16} \PolygReg[6]{A20/A19,A20/A24,A23/A22,A21/A19} \PolygReg[4]{A5/A4,A3/A2,A1/A6,A24/A23,A22/A21} \Languette<30>{3/7,7/8,8/9,9/10,10/4,37/38,5/11,11/12,12/13,13/14,14/6,41/42,% 42/1,15/16,16/19,21/45,22/29,32/23,28/20,17/18,2/39,39/40}<30> %\AffNodesPatron \end{tikzpicture} \end{document}
- How can we make a pumpkin, jack-o-lantern, or other halloween spirit, ghoul, or skeleton?by A.Ellett on October 31, 2014 at 7:04 pm
We have questions about Christmas trees and Hearts for Valentines but we have no questions that specialize in Halloween or Dia de los Muertos art. Here it goes: Using TikZ or PSTricks or any other of your favorite LaTeX tools, create pumpkins, ghouls, etc., appropriate to the season. I think multiple submissions should be fine provided different objects are created.
- Cut bottom of tabular by Zig-Zag pattern (in latex beamer)by Daniel F on June 8, 2013 at 11:20 pm
I try to present a part of a huge table inside the latex beamer environment. A small part of this table is sufficient to understand what is inside so i decided to indicate the cut-out be a bottom zig-zag line as shown below: \begin{tikzpicture} \node(elenore)[minimum width=3cm, minimum height=1cm] at (0, 0) { \begin{tabular}{c| c c | l } \cline{2-3} & \multicolumn{2}{c|}{comparison} & \\ \cline{1-4} \multicolumn{1}{|c|}{A} & B & C & \multicolumn{1}{l|} {value} \\ \cline{1-4} \multicolumn{1}{|c|}{(1,\texttt{X},\texttt{\$},U,11)} & & (\texttt{a},\texttt{\$},1) & \multicolumn{1}{l|}{C}]$} \\ \multicolumn{1}{|c|}{(2,\texttt{r},1,10)} & (\texttt{O},1) & & \multicolumn{1}{l|}{$H_{1} = [\texttt{aa}]$} \\ \multicolumn{1}{|c|}{(3,\texttt{a},\texttt{a},3,2)} & & (\texttt{a},\texttt{a},6) & \multicolumn{1}{l|}{$H_5 = [\texttt{yyyyyy}]$} \\ \multicolumn{1}{|c|}{(4,\texttt{a},5,1)} & (\texttt{a},5) & & \multicolumn{1}{l|}{$H$ = [\texttt{text}]$} % \\ \end{tikzpicture} \draw[decoration={zigzag, mirror,segment length=6.25mm}, decorate] (elenore.south west) -- (elenore.south east); My Problem is: how can i stick the zig-zag line perfectly from the beginning of the very left table border to the very right one? Currently it overlaps a little bit what looks quite ugly. Any idea?
- Penrose tiling in TikZby Yuji on June 27, 2012 at 3:54 pm
How can I auto-generate a Penrose tiling by TikZ? Here's my code for Mathematica: GG = (Sqrt[5]+1)/2; standardthin = {1/2+Sqrt[GG^2-(1/2)^2] I , 0, 1}; standardthick = {GG/2+Sqrt[1-(GG/2)^2] I, 0, GG}; sectthin[n_, t_] := If[n > 0, Join[sectthin[n-2, {t[[2]], t[[3]], (GG*t[[3]]+t[[1]])/(GG+1)}], sectthick[n-1, {(GG*t[[3]]+t[[1]])/(GG+1), t[[1]], t[[2]]}]], {thin @@ N[t]}]; sectthick[n_, t_] := If[n > 0, Join[sectthick[n-2, {(GG*t[[2]]+t[[3]])/(GoldenRatio+1),t[[1]],t[[2]]}], sectthin[n-1, {t[[3]], (GG*t[[2]]+t[[3]])/(GG+1), t[[1]]}]], {thick @@ N[t]}]; addtothick[n_, t_, d_] := If[d == 0, {}, Join[{frame @@ t}, If[EvenQ[d], Join[addtothick[n+2, {t[[2]], t[[3]], ((GG+1)*t[[1]]-GG*t[[3]])},d/2], sectthin[n+1, {((GG+1)*t[[1]]-GG*t[[3]]), t[[1]], t[[2]]}]], Join[addtothin[n+1, {t[[2]], t[[3]], ((GG+1)*t[[1]]-t[[2]])/GG}, (d-1)/2], sectthin[n-1, {t[[3]], ((GG+1)*t[[1]]-t[[2]])/GG, t[[1]]}]]]]]; addtothin[n_, t_, d_] := If[d == 0, {}, Join[{frame @@ t}, If[EvenQ[d], Join[addtothin[n+2, {((GG+1)*t[[3]]-GG*t[[2]]), t[[1]], t[[2]]}, d/2], sectthick[n+1, {t[[3]], ((GG+1)*t[[3]]-GG*t[[2]]), t[[1]]}]], Join[addtothick[n+1, {t[[3]], ((GG+1)*t[[2]]-t[[1]])/GG, t[[1]]}, (d -1)/2], sectthick[n-1, {t[[2]], t[[3]], ((GG+1)*t[[2]]-t[[1]])/GG}]]]]]; triangle[a_, b_, c_] := Graphics[Line[{Re[#], Im[#]} & /@ {a, b, c, a}]]; thin := triangle; thick := triangle; frame[a_, b_, c_] := Graphics[{Thickness[0.005], Line[{Re[#], Im[#]} & /@ {a, b, c, a}]}] Show[addtothin[0, standardthin, 200], AspectRatio -> Automatic] which creates something like this: