TikZ
- How to plot a curved line a cross the thickness of the beamsby Tldi You on May 3, 2026 at 7:36 am
Deformed and undeformed configurations of the beam Hello everyone, I am trying to reproduce this image using LaTeX TikZ. I have written the code below, but I am encountering difficulties when drawing the curved line through the thickness (the yellow line). Any suggestions would be greatly appreciated. \documentclass[tikz,border=5mm]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta, decorations.pathmorphing, positioning, calc} \begin{document} \begin{tikzpicture}[>=Stealth, scale=1.5] % Styles \tikzset{ zigzag/.style={decoration={zigzag, segment length=2mm, amplitude=1mm}, decorate}, break/.style={decoration={zigzag, segment length=4mm, amplitude=2mm}, decorate}, dot/.style={circle, fill=black, inner sep=1.2pt}, hollowdot/.style={circle, draw=black, fill=white, inner sep=1.2pt} } % --- Undeformed Beam (Top Part) --- \begin{scope}[shift={(0,2.5)}] % Beam edges \draw (-1.5, 0.4) -- (2, 0.4); \draw (-1.5, -0.4) -- (2, -0.4); \draw [zigzag] (-1.5, -0.4) -- (-1.5, 0.4); \draw [zigzag] (2, -0.4) -- (2, 0.4); % Neutral axis \draw [dotted, thick] (-1.5, 0) -- (2.5, 0) node[right] {$x, u$}; \draw [->] (2.3, 0) -- (2.7, 0); % Center vertical line and z-axis indicator \draw (0, 0.4) -- (0, -0.4); \node [hollowdot] at (0,0) {}; \draw [->] (0.2, 0) -- (0.2, -0.3); \node [right, font=\small] at (0.2, -0.15) {$z$}; % Left coordinate system and x-dimension \draw (-2.8, 0) -- (-2.3, 0); \draw [break] (-2.3, 0) -- (-1.9, 0); \draw (-1.9, 0) -- (-1.5, 0); \draw (-2.8, 0) -- (-2.8, -0.8) node[below, font=\small] {$z, w$}; \draw [->] (-2.8, -0.6) -- (-2.8, -1); \draw [->] (-2.8, -0.6) -- (0, -0.6); \node [fill=white, inner sep=1pt, font=\small] at (-1.4, -0.6) {$x$}; % Vertical reference line extending down \draw [thin, gray!60] (0, -0.4) -- (0, -3.5); \end{scope} % --- Deformed Beam (Bottom Part) --- \begin{scope}[shift={(0,1)}] % Curved beam boundaries \draw (-1.5, 0.4) to[bend right=15] (2, 0.4); \draw (-1.5, -0.4) to[bend right=15] (2, -0.4); \draw [zigzag] (-1.5, -0.4) -- (-1.5, 0.4); \draw [zigzag] (2, -0.4) -- (2, 0.4); \draw [dashed] (-1.8, 0) to[bend right=15] (2.3, 0); % Reference point (u0, w0) on the neutral axis \coordinate (P0) at (0.8, -0.30); \node [hollowdot] at (P0) {}; \node [below right, xshift=50pt, yshift=-20pt, font=\small] (L0) {$(u_0, w_0)$}; \draw [->, shorten >=2pt] (L0.west) -- (P0); % Vertical dashed reference line through P0 %\draw [red,dashed] ($(P0) + (0, 1.2)$) -- ($(P0) + (0, -0.5)$); \draw [red,dashed] (P0) -- ($(P0) + (115:1.0)$); % Deformed cross-section line \draw [yellow,thick] ($(P0) + (-0.3, 0.6)$) to[bend left=25] ($(P0) + (0.1, -0.6)$); % Point (u, w) on the cross-section \coordinate (P) at ($(P0) + (-0.01, -0.25)$); \node [dot] at (P) {}; \node [left, xshift=-2pt, yshift=2pt, font=\small] at (P) {$(u, w)$}; % Rotation angles at the top % Angle phi_x (rotation of the cross-section) \draw [->] ($(P0) + (0, 0.8)$) arc (90:115:0.8); \node [left, font=\small] at ($(P0) + (105:0.9)$) {$\phi_x$}; % Angle -dw0/dx (rotation of the normal) \draw [->] ($(P0) + (0, 0.8)$) arc (95:90:0.8); \node [right, xshift=6pt, font=\small] at ($(P0) + (80:0.8)$) {$-\frac{\partial w_0}{\partial x}$}; \draw [green,dashed] (P0) -- ($(P0) + (90:1.2)$); % Slope angle at the neutral axis \draw [blue,dashed] (P0) -- ($(P0) + (1.5, 0)$); \draw [yellow,dashed] ($(P0) + (-0.5, -0.1)$) -- ($(P0) + (1.3, 0.20)$); % tangent line \draw [->] ($(P0) + (1.4, 0)$) arc (0:10:1.2); \node [right, font=\small] at ($(P0) + (5:1.4)$) {$-\frac{\partial w_0}{\partial x}$}; \end{scope} \end{tikzpicture} \end{document}
- Layering schematic diagrams in tikz + matplotlibby Academic on May 2, 2026 at 11:59 pm
When I generate diagrams with matplotlib/seaborn, I find it difficult to set up the padding and what not for it fit properly and have proper consistency across diagrams. Does anyone use this stack and get things running porperly? What I am doing now is gnerating csvs and directly doing tikz but I would like to avoid that.
- 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 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}
- Arranging nodes to have a nice circle shapeby user516076 on April 5, 2026 at 1:42 am
I need your help to make the label, i.e. the numbers to be arranged circular nicely and spot-on (not estimating and guessing using rectangle coordinate, which is very difficult). i'm thinking of polar coordinate, but how to implement it so that it can be positioned exactly in the middle of each part? You see, I used manual and it looks ugly and messy... \documentclass[tikz,border=5pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=1.2, every node/.style={font=\Large}] % Radii \def\R{3} \def\r{1.75} % Outer circle (black) \draw[black, line width=1.2pt] (0,0) circle (\R); % Inner circle (cyan) \draw[cyan!70!black, line width=1.2pt] (0,0) circle (\r); % Straight dividing lines (green) \draw[green!60!black, line width=1.2pt] (-\R,0) -- (\R,0); \draw[green!60!black, line width=1.2pt] ({\R*cos(60)},{\R*sin(60)}) -- ({\R*cos(240)},{\R*sin(240)}); \draw[green!60!black, line width=1.2pt] ({\R*cos(120)},{\R*sin(120)}) -- ({\R*cos(300)},{\R*sin(300)}); % Outer ring numbers (red) % Top sector \node[red] at (-0.55, 2.35) {3}; \node[red] at ( 0.55, 2.35) {5}; % Upper-right sector \node[red] at (1.90, 1.65) {4}; \node[red] at (2.30, 0.65) {7}; % Lower-right sector \node[red] at (2.35,-0.65) {0}; \node[red] at (1.90,-1.65) {6}; % Bottom sector \node[red] at (-0.55,-2.35) {2}; \node[red] at ( 0.55,-2.35) {10}; % Lower-left sector \node[red] at (-1.90,-0.65) {4}; \node[red] at (-2.30,-1.65) {1}; % Upper-left sector \node[red] at (-2.30, 0.65) {8}; \node[red] at (-1.90, 1.65) {7}; % Inner circle numbers (red) \node[red] at ( 0.00, 0.95) {?}; \node[red] at ( 1.05, 0.25) {5}; \node[red] at ( 1.00,-0.65) {15}; \node[red] at ( 0.00,-1.10) {8}; \node[red] at (-0.95,-0.60) {11}; \node[red] at (-1.05, 0.25) {6}; \end{tikzpicture} \end{document} At least, I wish to have something similar to this:
- 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?
- Drawing a quadruple arrowby user31416 on November 2, 2024 at 7:59 pm
I have this code for drawing single, double and triple arrows using tikz. It works nicely. But somehow it does not work for quadruple arrows (i.e. arrows with one arrow head but four lines). Can someone help me? Here's a MWE: \documentclass{standalone} \usepackage{tikz} % Define custom arrow styles \tikzset{ singlearrow/.style={->, >=latex, line width=0.15mm, shorten >=1pt}, doublearrow/.style={ line width=0.15mm, draw, ->, >=latex, double distance=0.4mm, shorten >=1pt }, triplearrow/.style={ line width=0.15mm, draw, ->, >=latex, double distance=0.8mm, shorten >=1pt, postaction={draw[line width=0.15mm, ->, >=latex, xshift=0mm, yshift=-0.4mm]}, >={Latex[length=5pt, width=4pt]} % Larger arrowhead for triple arrow } } \begin{document} \begin{tikzpicture} % Single arrow \draw[singlearrow] (0,0) -- (2,0) node[midway, above] {Single Arrow}; % Double arrow \draw[doublearrow] (0,-1) -- (2,-1) node[midway, above] {Double Arrow}; % Triple arrow \draw[triplearrow] (0,-2) -- (2,-2) node[midway, above] {Triple Arrow}; \end{tikzpicture} \end{document}
- 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}
- Drawing 3D diceby Ole Christian on March 5, 2024 at 10:49 am
I want to create 3D dice in LaTeX. I am familiar with the excellent package "customdice", but it unfortunately only produces 2D images. I am also inspired by the answer from hpekristiansen to this question. It creates beautiful dice, but I am uanble to change from colored circles to the familiar circle symbols for the numbers 1 to 6. One idea I had was to try to put the images from customdice on each of the surfaces, but I am unable to make it work. I believe the package customdice doesn't agree well to the packages required in the question linked above. Could anyone help me create "normal" dice faces on the surfaces on the answer linked above?
- witharrows package but with arrows in between equal signsby Sung Chan Song on January 4, 2024 at 5:37 pm
I am trying to do something very similar to what witharrows package does. However, while the witharrows package connects two lines of equations with an arrow to the right side of the equations, as the figure below shows, I wish to put vertical arrows in between the equal signs like the figure shown below. Is there anyway to do this? either by making a change to witharrows or defining a new command? I am pretty new to Latex so I need some guidance. Thanks in advance!
- 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:
- 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 !
- drawing a cluster of gearsby Epa on October 14, 2015 at 6:51 am
I can draw individuals gears like the following but I was unable to align them in the following manner. Could you help? \documentclass{standalone} \usepackage{tikz} \usepackage{amsmath, latexsym, amscd, amsthm} \newcommand{\gear}[5]{% \foreach \i in {1,...,#1} {% [rotate=(\i-1)*360/#1] (0:#2) arc (0:#4:#2) {[rounded corners=1.5pt] -- (#4+#5:#3) arc (#4+#5:360/#1-#5:#3)} -- (360/#1:#2) }} \begin{document} \begin{tikzpicture} \draw[ultra thick] \gear{16}{1.6}{1.8}{10}{2}; \end{tikzpicture} \end{document}
- 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}
- 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:
- Creating gears in TikZby azetina on June 5, 2012 at 10:54 pm
I am trying to create a gear in TikZ in which the number of spikes can be determined and the size as well. I was looking through the pgfmanual and stumbled upon the decorations section and I tried a piece of code there. Here is what I have so far: \documentclass[letterpaper]{article} \usepackage{tikz} \usetikzlibrary{decorations} \begin{document} \pgfdeclaredecoration{example}{initial} { \state{initial}[width=20pt] { \pgfpathlineto{\pgfpoint{0pt}{5pt}} \pgfpathlineto{\pgfpoint{5pt}{5pt}} \pgfpathlineto{\pgfpoint{5pt}{-5pt}} \pgfpathlineto{\pgfpoint{10pt}{-5pt}} \pgfpathlineto{\pgfpoint{10pt}{5pt}} } \state{final} { \pgfpathlineto{\pgfpointdecoratedpathlast} } } \tikz[decoration=example] { \draw [red,decorate] (0,0) circle (1cm); } \end{document} which yields: Of course the above is not satisfactory. Is there a way a gear can be drawn in TikZ or any other graphics package? Update: For those interested in ready made svg images, the NounProject provides some sample files. Follow this link: Engrenages.