• Gradients in TikZ
    by karlh on December 10, 2025 at 3:53 am

    Based on the documentation, I would expect the two rectangles generated by this code to look identical: \documentclass{article} \usepackage{tikz} \begin{document} \pgfdeclarehorizontalshading{myshadingA} {1cm}{rgb(0cm)=(1,0,0); color(2cm)=(green); color(4cm)=(blue)} \begin{tikzpicture} \pgfuseshading{myshadingA} \shade [shading=myshadingA] (-2,-1) rectangle (2,-3); \end{tikzpicture} \end{document} However, this is clearly not the case. What am I doing wrong and/or misinterpreting in the documentation?

  • Tikz comma shape
    by Andrew on December 9, 2025 at 6:40 pm

    I am using tikz to make a PA Dutch hex sign-like image. How can I make the comma-like shape that is seen below? I will ultimately be replicating it and rotating it around a center point, but I don't know how to get the basic shape to begin with.

  • drawing arc using intersection with triangle
    by troy on December 9, 2025 at 5:26 pm

    I've been trying to adapt the answer https://tex.stackexchange.com/a/239471 to the drawing I've been attempting, but I'm getting a strange result. I want draw an arc that begins and ends where it intersects with a triangle and spanning the interior of the triangle. My attempt at this is below. What I'm getting is a small, almond-shaped loop near one of the intersections. \documentclass[tikz]{standalone} \usepackage{pgfplots} \usetikzlibrary{fillbetween} \usetikzlibrary{3d} \usetikzlibrary{calc} \usetikzlibrary{intersections} \usetikzlibrary{perspective} \begin{document} \begin{tikzpicture}[scale=1.25, font=\sffamily] \pgfmathsetmacro{\alphasma}{1.4} \coordinate (O) at (0,0,0); \node at (O) {O}; \begin{scope}[scale=4,purple,very thick] \coordinate (X) at (0,0,1); \coordinate (Y) at (1,0,0); \draw[->] (O) -- (Y) node[anchor=north east]{\Large Y}; \draw[->] (O) -- (X) node[anchor=south]{\Large X}; \end{scope} \begin{scope}[3d view={90}{0.1}] \begin{scope}[scale=5,orange] \begin{scope}[rotate around y=20,black] \begin{scope}[rotate around z=-10,cyan] \begin{scope}[ canvas is xy plane at z=0, very thick ] \path[name path=lambdaArc] (O) circle [x radius=.95,y radius=.45]; \draw[name path=O-X-Y,dashed] (O) -- ($(O)!2*\alphasma!(X)$) -- ($(O)!2*\alphasma!(Y)$) -- cycle; \draw[red,thin, intersection segments={of=lambdaArc and O-X-Y,sequence=L3}]; \draw[orange,dashed] (O) circle [x radius=.95,y radius=.45]; \end{scope} \end{scope} \end{scope} \end{scope} \end{scope} \end{tikzpicture} \end{document} This is part of a larger diagram I am making. Deleting the extraneous parts leaves some scopes and structure that look unnecessary, but I left them as-is.

  • How to distribute items (cards) evenly on a A4 page in Latex?
    by user32017992 on December 8, 2025 at 12:02 pm

    I need to print cards (bussiness for example) on both sides of A4 paper so they must match exactly.I was trying to do some calculations and search for hidden margin, but none of those worked. code: https://github.com/moravechynek/latex_cards \documentclass[a4paper,12pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage[english]{babel} \usepackage{graphicx} \graphicspath{{graphics/}} \usepackage{tikz} \usepackage{geometry} \geometry{margin=0mm} \setlength{\parindent}{0pt} % Card size (mm) \newcommand{\cardW}{63.5} \newcommand{\cardH}{88.9} % Gaps (mm): 4 gaps for 3 cards \newcommand{\gapX}{4.875} % (210 - 3*63.5) / 4 \newcommand{\gapY}{7.575} % (297 - 3*88.9) / 4 % A4 dimensions \newcommand{\Awidth}{210} \newcommand{\Aheight}{297} % Padding inside card \newcommand{\pad}{3} % FRONT CARD TEMPLATE \newcommand{\CardFront}[2]{% \begin{tikzpicture}[x=1mm, y=1mm] \useasboundingbox (0,0) rectangle (\cardW,\cardH); \draw[rounded corners=2mm, line width=0.3mm] (\pad,\pad) rectangle (\cardW-\pad,\cardH-\pad); \node[anchor=north,font=\LARGE] at (\cardW/2, \cardH-\pad-15) {#1}; \end{tikzpicture} } % BACK CARD TEMPLATE \newcommand{\CardBack}[1]{% \begin{tikzpicture}[x=1mm, y=1mm] \useasboundingbox (0,0) rectangle (\cardW,\cardH); \draw[rounded corners=2mm, line width=0.3mm] (\pad,\pad) rectangle (\cardW-\pad,\cardH-\pad); \node[anchor=north,font=\normalsize] at (\cardW/2, \cardH/1.4-\pad) {#1}; \end{tikzpicture} } \def\CardEntries{ 4 000, 4 800, 6 000, 8 000, 10 000, 12 000, 24 000, 16 000, 20 000 } \begin{document} \thispagestyle{empty} % FRONT SIDE (9 CARDS) \begin{tikzpicture}[x=1mm,y=1mm] \foreach [count=\idx from 0] \tl/\price in \CardEntries { \pgfmathtruncatemacro{\row}{floor(\idx/3)} \pgfmathtruncatemacro{\col}{\idx - 3*\row} \pgfmathsetmacro{\cx}{\gapX*(\col+1) + \cardW*\col + \cardW/2} \pgfmathsetmacro{\cy}{\Aheight - (\gapY*(\row+1) + \cardH*\row + \cardH/2)} \node at (\cx,\cy) {\CardFront{\tl}{\price}}; } \end{tikzpicture} \newpage \thispagestyle{empty} % BACK SIDE (9 CARDS) \begin{tikzpicture}[x=1mm,y=1mm] \foreach [count=\idx from 0] \tl/\price in \CardEntries { \pgfmathtruncatemacro{\row}{floor(\idx/3)} \pgfmathtruncatemacro{\col}{\idx - 3*\row} \pgfmathsetmacro{\cx}{\gapX*(\col+1) + \cardW*\col + \cardW/2} \pgfmathsetmacro{\cy}{\Aheight - (\gapY*(\row+1) + \cardH*\row + \cardH/2)} \node at (\cx,\cy) {\CardBack{Back}}; } \end{tikzpicture} \end{document}

  • Drawing a sphere and ellipsoid together
    by Knudsen on December 8, 2025 at 4:00 am

    I would like to draw a sphere, of radius 3, and an ellipsoid of semi-axis 2, 3 and 4 together. They intersect at two great circles on the sphere (marked in red). I started out with the sphere and the great circles: \documentclass[border=2mm]{standalone} \usepackage{tikz} \usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools \begin{document} \begin{tikzpicture}[3d/install view={phi=120,theta=70},line cap=butt, line join=round,declare function={R=3;},c/.style={circle,fill,inner sep=1pt}] \path (0,0,0) coordinate (O) ; \draw[blue,3d/screen coords] (O) circle[radius=R]; \shade[ball color=white,3d/screen coords,opacity=0.7] (O) circle[radius=R]; % \shade[ball color=blue!30,3d/screen coords,opacity=0.7,xscale=2,yscale=3,zscale=4] (O) circle[radius=1]; \path pic[blue]{3d/circle on sphere={R=R,C={(O)}}}; \path pic[red]{3d/circle on sphere={R=R, n={(0.592,0,-1)}}}; % plane x = sqrt{7/10) z \path pic[red]{3d/circle on sphere={R=R, n={(0.592,0,1)}}}; % plane x = sqrt{7/10) z \draw[3d/hidden] (0,0,0) -- (0,0,R) (O)--(R,0,0) (O)--(0,R,0) (O)--(0,-R,0); \draw[3d/visible, -stealth] (R,0,0) -- (R + 4,0,0) node[below]{$x$}; \draw[3d/visible, -stealth] (0,R,0) -- (0,R + 1,0) node[right]{$y$}; \draw[3d/visible, -stealth] (0,0,R) -- (0,0,R + 1.5) node[above]{$z$}; \end{tikzpicture} \end{document} and everything is right so far: but when I remove the comment on the line that I would expect to draw the ellipsoid \shade[ball color=blue!30,3d/screen coords,opacity=0.7,xscale=2,yscale=3,zscale=4] (O) circle[radius=1]; I get something that is far from what I expected, including the fact that the zscale is not understood. How can one add the intersecting elipsoide to this image?

  • How to draw cone with infinitely many extremal rays
    by Fradns on December 6, 2025 at 10:21 am

    Suppose we are working in the three-dimensional real vector space V. A cone is a subset C of V such that if an element v of V lies in C, then all of its nonnegative multiples also lie in C. I would like to draw, using TikZ, a cone that simulates infinitely many extremal rays, all accumulating toward a fixed one. A section of the cone should therefore look like a “polygon with infinitely many sides”. For example, the cone here Tikz: cones with a wide base is a circular one. I would like mine to be "polyhedral" away from the accumulation ray. How would you do that?

  • TikZ: Generate a pixelated (Minecraft-style) circle by filling unit grid squares [duplicate]
    by Jax on December 6, 2025 at 8:35 am

    I'm trying to draw a pixelated (blocky) circle in TikZ where each filled 1×1 square corresponds exactly to an integer grid cell (think Minecraft blocks). Given a center and radius, I want a compact TikZ/PGF macro or clear algorithm that selects which unit squares to fill so the rasterized shape matches a standard discrete circle (midpoint/Bresenham or distance-threshold) while preserving octant symmetry and avoiding visual gaps or doubled squares on diagonals. What is a simple, robust method to compute the set of grid cells for a given (integer or real) radius, and how can that be implemented cleanly in TikZ? Short macro examples, notes on rounding/aliasing pitfalls, and advice on scaling to a fixed cell size would be especially useful. For a quick visual reference I compared expected output with a pixel-circle preview online (pixel-circle preview).

  • The method of marching cubes (for implicit surfaces) is very slow, and does not reach the level of accuracy of existing pictures. How to improve?
    by Jasper on December 6, 2025 at 5:58 am

    I was inspired by some of the illustrations in https://math.stackexchange.com/a/46222. I wanted to try graphing implicit surfaces myself, and came across the method of marching cubes. See https://paulbourke.net/geometry/polygonise/. I collaborated with AI to produce the following code. If you are opposed to AI, this is your fair chance to recognize this fact and not participate in answering this question. It is extremely slow for many subdivisions, and unfortunately, I need many subdivisions to even remotely approach the desired graphic. The desired graphic is something like this: I would very much like for my attempt to be almost isomorphic (same shape) to the original picture. I cut out a large portion of occlusion code to get this to run in my lifetime. I hope to use far less triangles, and for it to adapt to regions of high and low density if possible. One idea I had was to take an initial coarse subdivision set, then up the samples in regions where the surface was not found up to a maximum depth. Then we could only sample highly where it is needed. This is just speculation though, and sounds very difficult to achieve. Obviously the desired technology exists currently, because of the desired picture's existence. MWE: \documentclass[tikz,border=3mm]{standalone} \usepackage{luacode} \begin{document} % Run LuaTeX code to generate the triangles \begin{luacode*} -- Parameters local nx, ny, nz = 80, 80, 80 -- grid resolution local x0, y0, z0 = -1, -1, -1 local x1, y1, z1 = 1, 1, 1 local isovalue = 0.0 local dx = (x1-x0)/nx local dy = (y1-y0)/ny local dz = (z1-z0)/nz -- Scalar function local function f(u, v, w) return (2.92*(u-1)*u*u*(u+1) + 1.7*v*v)^2 * ((v*v - 0.88)^2) + (2.92*(v-1)*v*v*(v+1) + 1.7*w*w)^2 * ((w*w - 0.88)^2) + (2.92*(w-1)*w*w*(w+1) + 1.7*u*u)^2 * ((u*u - 0.88)^2) - 0.02 end -- On-demand vertex value local function vertex_value(i,j,k) return f(x0 + i*dx, y0 + j*dy, z0 + k*dz) end -- Edge bisection local function edge_root(p0,p1,v0,v1,tol) local a,b = 0,1 local fa,fb = v0,v1 for iter=1,20 do local m = 0.5*(a+b) local pm = { x = p0.x + m*(p1.x-p0.x), y = p0.y + m*(p1.y-p0.y), z = p0.z + m*(p1.z-p0.z) } local fm = f(pm.x, pm.y, pm.z) if math.abs(fm)<tol then return pm end if fa*fm<=0 then b,fb = m,fm else a,fa = m,fm end end return {x=p0.x+0.5*(p1.x-p0.x), y=p0.y+0.5*(p1.y-p0.y), z=p0.z+0.5*(p1.z-p0.z)} end -- Minimal demo marching cubes table -- https://paulbourke.net/geometry/polygonise/ local raw_table = {{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1}, {3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1}, {3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1}, {3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1}, {9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, {2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1}, {8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1}, {9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, {4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1}, {3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1}, {1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1}, {4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1}, {4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, {5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1}, {2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1}, {9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, {0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, {2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1}, {10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1}, {5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1}, {5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1}, {9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1}, {0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1}, {1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1}, {10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1}, {8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1}, {2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1}, {7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1}, {2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1}, {11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1}, {5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1}, {11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1}, {11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, {1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1}, {9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1}, {5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1}, {2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, {5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1}, {6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1}, {3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1}, {6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1}, {5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1}, {1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, {10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1}, {6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1}, {8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1}, {7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1}, {3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, {5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1}, {0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1}, {9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1}, {8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1}, {5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1}, {0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1}, {6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1}, {10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1}, {10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1}, {8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1}, {1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1}, {0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1}, {10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1}, {3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1}, {6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1}, {9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1}, {8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1}, {3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1}, {6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1}, {0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1}, {10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1}, {10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1}, {2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1}, {7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1}, {7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1}, {2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1}, {1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1}, {11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1}, {8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1}, {0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1}, {7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, {10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, {2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, {6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1}, {7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1}, {2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1}, {1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1}, {10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1}, {10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1}, {0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1}, {7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1}, {6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1}, {8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1}, {9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1}, {6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1}, {4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1}, {10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1}, {8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1}, {0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1}, {1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1}, {8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1}, {10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1}, {4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1}, {10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, {5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, {11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1}, {9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, {6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1}, {7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1}, {3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1}, {7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1}, {3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1}, {6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1}, {9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1}, {1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1}, {4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1}, {7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1}, {6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1}, {3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1}, {0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1}, {6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1}, {0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1}, {11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1}, {6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1}, {5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1}, {9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1}, {1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1}, {1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1}, {10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1}, {0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1}, {5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1}, {10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1}, {11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1}, {9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1}, {7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1}, {2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1}, {8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1}, {9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1}, {9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1}, {1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1}, {9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1}, {9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1}, {5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1}, {0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1}, {10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1}, {2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1}, {0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1}, {0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1}, {9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1}, {5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1}, {3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1}, {5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1}, {8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1}, {0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1}, {9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1}, {1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1}, {3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1}, {4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1}, {9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1}, {11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1}, {11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1}, {2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1}, {9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1}, {3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1}, {1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1}, {4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1}, {3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1}, {0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1}, {1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}} -- Convert raw_table to marching_cubes_table (list of triangles per config) local triTable = {} for idx, entry in ipairs(raw_table) do local triangles = {} local i = 1 while entry[i] ~= -1 do if entry[i+2] ~= -1 then table.insert(triangles, {entry[i], entry[i+1], entry[i+2]}) i = i + 3 else break end end triTable[idx] = triangles -- 1-based end -- Edge to corners mapping (1-based) local edge_to_corners = { {1,2},{2,3},{3,4},{4,1}, {5,6},{6,7},{7,8},{8,5}, {1,5},{2,6},{3,7},{4,8} } -- Corner offsets and edges local cornerOffsets = {{0,0,0},{1,0,0},{1,1,0},{0,1,0},{0,0,1},{1,0,1},{1,1,1},{0,1,1}} local edgeIndex = {{1,2},{2,3},{3,4},{4,1},{5,6},{6,7},{7,8},{8,5},{1,5},{2,6},{3,7},{4,8}} -- Preallocated triangle points local pts = {{},{},{}} -- Open output file local f = io.open("triangles.tex","w") f:write([[ \documentclass[tikz,border=3mm]{standalone} \begin{document} \begin{tikzpicture} ]]) -- Main loop for i=0,nx-1 do for j=0,ny-1 do for k=0,nz-1 do -- corner values on-demand local cubeVals = {} for ci=1,8 do local ox,oy,oz = cornerOffsets[ci][1], cornerOffsets[ci][2], cornerOffsets[ci][3] cubeVals[ci] = vertex_value(i+ox,j+oy,k+oz) end -- cube index local cubeIndex = 0 for ci=1,8 do if cubeVals[ci]<isovalue then cubeIndex = cubeIndex + 2^(ci-1) end end if cubeIndex ~=1 and cubeIndex ~=256 then local x = x0 + i*dx local y = y0 + j*dy local z = z0 + k*dz -- corner positions local p = {} for ci=1,8 do p[ci] = {x=x+cornerOffsets[ci][1]*dx, y=y+cornerOffsets[ci][2]*dy, z=z+cornerOffsets[ci][3]*dz} end -- triangles -- triangles for _, tri in ipairs(triTable[cubeIndex+1] or {}) do for ei=1,3 do local e = tri[ei] local c1,c2 = edgeIndex[e+1][1], edgeIndex[e+1][2] local v1,v2 = cubeVals[c1], cubeVals[c2] local pos = edge_root(p[c1],p[c2],v1,v2,1e-6) pts[ei].x = pos.x pts[ei].y = pos.y pts[ei].z = pos.z -- <--- THIS LINE IS MISSING end f:write(string.format([[\draw[fill=blue!20,draw=blue!60,line join = round, ultra thin] (%.5f,%.5f,%.5f) -- (%.5f,%.5f,%.5f) -- (%.5f,%.5f,%.5f) -- cycle; ]], pts[1].x, pts[1].y, pts[1].z, pts[2].x, pts[2].y, pts[2].z, pts[3].x, pts[3].y, pts[3].z)) end end end end end f:write([[\end{tikzpicture}\end{document}]]) f:close() \end{luacode*} \end{document}

  • TikZ word search diagram v2
    by yannis on December 4, 2025 at 7:16 pm

    As a continuation of TikZ word search diagram here is the problem I'm facing. I did what Explorer suggested and it worked fine except that my rounded rectangles look like sausages or like Hieroglyphic cartouches because at their narrow ends they have lines on the secondary axis: Here is the code: \documentclass{article} \usepackage[cmyk]{xcolor} \definecolor{myPB}{cmyk}{0.85,0.75,0,0} \definecolor{myLB}{cmyk}{0.1,0.06,0,0} \usepackage{tikz} \usetikzlibrary{matrix,backgrounds} \newlength{\mydrawlinewidth} \setlength{\mydrawlinewidth}{1pt} \NewDocumentCommand{\markA}{ O{red} m m }{% \draw[rounded corners=6mm,opacity=.5, line width=2pt,myPB,fill=myLB] ([xshift=5pt,yshift=-5pt]yannis-#2.north west) rectangle ([xshift=-5pt,yshift=5pt]yannis-#3.south east); } \NewDocumentCommand{\markB}{ O{red} m m }{% \draw[rounded corners=6mm,opacity=.5,line width=2pt,myPB,fill=myLB] ([yshift=2pt]yannis-#2.north) -- ([xshift=2pt]yannis-#3.east) -- ([yshift=-2pt]yannis-#3.south) -- ([xshift=-2pt]yannis-#2.west) -- cycle; } \NewDocumentCommand{\markC}{ O{red} m m }{% \draw[rounded corners=6mm,opacity=.5,line width=2pt,myPB,fill=myLB] ([xshift=2pt]yannis-#2.east) -- ([yshift=-2pt]yannis-#3.south) -- ([xshift=-2pt]yannis-#3.west) -- ([yshift=2pt]yannis-#2.north) -- cycle; } \begin{document} \begin{tikzpicture} \matrix (yannis) [% matrix of nodes,% column sep=0mm,% row sep=0mm, nodes={ % draw, rectangle,anchor=center, line width=0.5pt, inner sep=2pt,outer sep=0pt, %font=\bfseries\huge, minimum size=1.1cm, } ] { S & G & A & Q & Q & T & C & E & F & R & E & P & Y & W & R \\ W & L & Q & E & L & B & A & R & A & P & M & O & C & E & L \\ Y & I & T & S & X & E & L & I & Y & A & H & U & W & R & A \\ B & K & E & E & Y & C & W & L & J & T & M & A & K & B & F \\ J & E & R & I & O & R & T & M & K & E & R & L & Q & E & T \\ P & N & P & L & S & B & R & W & H & D & U & U & E & H & E \\ E & E & R & R & E & W & V & S & S & M & L & N & K & E & R \\ H & S & E & E & H & T & A & P & H & Y & S & I & C & A & L \\ S & S & T & D & S & H & E & U & Q & V & L & V & R & Z & I \\ O & R & N & N & I & F & L & L & A & S & N & E & E & K & F \\ M & T & I & U & N & L & G & E & P & H & U & R & A & S & E \\ W & K & O & Q & U & P & U & H & A & M & G & S & T & M & I \\ A & F & A & R & P & J & M & S & L & R & O & E & E & H & C \\ B & X & H & C & A & I & H & S & A & M & S & C & D & F & G \\ I & P & R & O & P & H & E & T & S & N & S & I & F & X & Q \\ }; \begin{scope}[on background layer] \markA{1-6}{1-12} \markA{1-14}{6-14} \markC{1-15}{7-9} \markA{2-2}{9-2} \markA{2-4}{2-13} \markA{3-3}{11-3} \markA{3-4}{11-4} \markA{3-6}{3-12} \markA{3-15}{11-15} \markC{4-11}{9-6} \markA{6-5}{13-5} \markA{6-12}{13-12} \markA{7-1}{11-1} \markB{7-5}{14-12} \markA{8-8}{8-15} \markA{8-13}{14-13} \markB{10-7}{15-12} \markB{11-2}{15-6} \markA{14-3}{14-10} \markA{15-2}{15-9} \end{scope} \end{tikzpicture} \end{document} How can I fix this? @mickep I replaced the snippets by a complete minimal example.

  • I would like to discretize the "tiles" into rectangular prismatic groups, sort each group, then sort the groups by each other or be shown a better way
    by Jasper on December 4, 2025 at 7:58 am

    I have built a comparator which can determine the occlusive relationship between two 0--2-dimensioal affine tiles (using their simplicial representations). In English, if I have two tiles (a tile is a point, line segment, or triangle), I can determining which one occludes the other, or if there is no occlusion (the inconclusive case). Currently, this requires an extremely expensive SCC topological sort (quadratic based on the number of tiles). I have the idea that I would like to speed this up, and I have a proposal for doing so (though, I am all ears to alternative ideas too). Basically, my idea is to partition the scene into rectangular prismatic regions (possibly with some overlap), sorting each one individually. Then, each rectangular prismatic region could use a waaay simpler sorting method on the set of rectangular prismatic region, once their constituent parts are sorted. This is my AI generated SCC topological sort routine, which has been working for ages. I am confident in it, based on it having not failed yet. How could I go about implementing this without visual artefacts from tiles which cross the boundary of two or more prisms? Alternatively, what better methods might I consider which I haven't yet? -- occlusion graph + SCC topo sort (bboxes computed on Cartesian coords) local n = #items local bboxes, graph = {}, {} for i = 1, n do bboxes[i] = { get_bbox2(items[i]) }; graph[i] = {} end for i = 1, n - 1 do for j = i + 1, n do if bboxes_overlap2(bboxes[i], bboxes[j]) then local r = cmp(items[i], items[j]) if r == true then table.insert(graph[i], j) elseif r == false then table.insert(graph[j], i) end end end end local index, stack, indices, lowlink, onstack, sccs = 0, {}, {}, {}, {}, {} for i = 1, n do indices[i], lowlink[i] = -1, -1 end local function dfs(v) indices[v], lowlink[v] = index, index; index = index + 1 stack[#stack+1] = v; onstack[v] = true for _, w in ipairs(graph[v]) do if indices[w] == -1 then dfs(w); lowlink[v] = math.min(lowlink[v], lowlink[w]) elseif onstack[w] then lowlink[v] = math.min(lowlink[v], indices[w]) end end if lowlink[v] == indices[v] then local scc = {} while true do local w = table.remove(stack); onstack[w] = false scc[#scc+1] = w if w == v then break end end sccs[#sccs+1] = scc end end for v = 1, n do if indices[v] == -1 then dfs(v) end end local scc_index, scc_graph, indeg = {}, {}, {} for i, comp in ipairs(sccs) do for _, v in ipairs(comp) do scc_index[v] = i end scc_graph[i], indeg[i] = {}, 0 end for v = 1, n do for _, w in ipairs(graph[v]) do local si, sj = scc_index[v], scc_index[w] if si ~= sj then table.insert(scc_graph[si], sj); indeg[sj] = indeg[sj] + 1 end end end local queue, sorted = {}, {} for i = 1, #sccs do if indeg[i] == 0 then queue[#queue+1] = i end end while #queue > 0 do local i = table.remove(queue, 1) for _, v in ipairs(sccs[i]) do sorted[#sorted+1] = items[v] end for _, j in ipairs(scc_graph[i]) do indeg[j] = indeg[j] - 1 if indeg[j] == 0 then queue[#queue+1] = j end end end In fact, I would also like to employ a similar strategy for partitioning, since it is also quadratic, but I think that if I saw it for occlusion, that it would be simple to re-implement for partitioning. This MWE, for example, takes ages to compile, and I believe it should be speed-up-able. This version is currently on TeXLive and MikTeX (and on CTAN), so there is no need to use the GitHub version. \documentclass[tikz,border=1cm]{standalone} \usepackage{lua-tikz3dtools} % https://github.com/Pseudonym321/TikZ-Animations/tree/master1/TikZ/lua-tikz3dtools \begin{document} \begin{luatikztdtoolspicture}[ C1 = { {{-3,-3,0,1}} } ,C2 = { {{3,3,-10,1}} } ,light = { {{0,0,-2,1}} } ] \pgfmathsetmacro{\param}{0} \setobject[ name = {T} ,object = { matrix_multiply( matrix_multiply( euler(pi/2,pi/4+pi/4*sin(\param),5.25*pi/6+\param) ,translate(0,0,-5) ) ,matrix_multiply( { {1,0,0,0} ,{0,1,0,0} ,{0,0,1,0} ,{0,0,0,1} } ,matrix_multiply(xscale(1/2),yscale(1/2)) ) ) } ] \setobject[ name = {I} ,object = { matrix_inverse(T) } ] \appendsurface[ ustart = {-2} ,ustop = {2} ,usamples = {20} ,vstart = {-2} ,vstop = {2} ,vsamples = {20} ,transformation = {T} ,x = {u} ,y = {v} ,z = {u^4 + v^4 - 4*u*v + 1} ,fill options = { preaction = { fill = green ,fill opacity = 0.2 } ,postaction = { draw = blue ,ultra thin ,line join = round } } ,filter = { abs(matrix_multiply(A,I)[1][3])<2.01 and abs(matrix_multiply(B,I)[1][3])<2.01 and abs(matrix_multiply(C,I)[1][3])<2.01 and abs(matrix_multiply(A,I)[1][2])<2.01 and abs(matrix_multiply(B,I)[1][2])<2.01 and abs(matrix_multiply(C,I)[1][2])<2.01 and abs(matrix_multiply(A,I)[1][1])<2.01 and abs(matrix_multiply(B,I)[1][1])<2.01 and abs(matrix_multiply(C,I)[1][1])<2.01 } ] \appendsolid[ ustart = {-2} ,ustop = {2} ,usamples = {2} ,vstart = {-2} ,vstop = {2} ,vsamples = {2} ,wstart = {-2} ,wstop = {2} ,wsamples = {2} ,transformation = {T} ,x = {u} ,y = {v} ,z = {w} ,fill options = { preaction = { fill = none ,fill opacity = 0.5 } ,postaction = { draw = none ,ultra thin ,line join = round ,line cap = round } } ] \appendcurve[ ustart = {0} ,ustop = {4} ,usamples = {2} ,x = {0} ,y = {0} ,z = {u} ,transformation = {T} ,arrow tip = {true} ,draw options = { draw ,ultra thin ,line cap = round } ] \appendlabel[ x = {0} ,y = {0} ,z = {4.3} ,transformation = {T} ,name = {\(z\)} ] \appendcurve[ ustart = {0} ,ustop = {4} ,usamples = {2} ,x = {0} ,y = {u} ,z = {0} ,transformation = {T} ,arrow tip = {true} ,draw options = { draw ,ultra thin ,line cap = round } ] \appendlabel[ x = {0} ,y = {4.3} ,z = {0} ,transformation = {T} ,name = {\(y\)} ] \appendcurve[ ustart = {0} ,ustop = {4} ,usamples = {2} ,x = {u} ,y = {0} ,z = {0} ,transformation = {T} ,arrow tip = {true} ,draw options = { draw ,ultra thin ,line cap = round } ] \appendlabel[ x = {4.3} ,y = {0} ,z = {0} ,transformation = {T} ,name = {\(x\)} ] \foreach \p in {-4,-3,...,4} { \appendcurve[ ustart = {-4} ,ustop = {4} ,usamples = {2} ,x = {u} ,y = {\p} ,z = {0} ,transformation = {T} ,draw options = { draw = black!70!white ,ultra thin ,line cap = round ,densely dashed } ] \appendcurve[ ustart = {-4} ,ustop = {4} ,usamples = {2} ,x = {\p} ,y = {u} ,z = {0} ,transformation = {T} ,draw options = { draw = black!90!white ,ultra thin ,line cap = round ,densely dashed } ] } \appendsurface[ ustart = {-4} ,ustop = {4} ,usamples = {2} ,vstart = {-4} ,vstop = {4} ,vsamples = {2} ,transformation = {T} ,x = {u} ,y = {v} ,z = {0} ,fill options = { preaction = { fill = gray!70!white ,fill opacity = 0.6 } ,postaction = { draw = none ,ultra thin ,line join = round } } ] \end{luatikztdtoolspicture} \end{document}

  • Is there a way in TikZ or Lua to make a short function which converts letters to their corresponding alphabetical position (and vice versa)?
    by Jasper on December 2, 2025 at 5:38 pm

    Is there a way in TikZ or Lua to make a short function which converts letters to their corresponding alphabetical position (and vice versa)? The only way I can think of it so string check each letter, but that sounds too computationally expensive. M(non)WE: \documentclass[tikz,border=1cm]{standalone} \newcommand{\letterpos}[1]{ \pgfmathparse{#1 == a} \ifnum\pgfmathresult=1 1 \fi \pgfmathparse{#1 == ab} \ifnum\pgfmathresult=1 2 \fi \pgfmathparse{#1 == c} \ifnum\pgfmathresult=1 3 \fi \pgfmathparse{#1 == d} \ifnum\pgfmathresult=1 4 \fi \pgfmathparse{#1 == e} \ifnum\pgfmathresult=1 5 \fi } \begin{document} \begin{tikzpicture} \foreach \letter in {a,b,...,e} { \node at (\letterpos{\letter},0) {\letter}; } \end{tikzpicture} \end{document}

  • Circuitikz: customize the style of the rotary switch position display
    by cis on November 27, 2025 at 8:54 pm

    I've been experimenting with a rotary switch. I want 7 switch positions with a gap at the bottom. My question is: can the thick black line be replaced with a nice arrow? By the way: it seems exceptionally difficult to set the switch to a specific position (1, 2, ..., 7). My method of calculating the angle \s works, but if there's an easier way, please let me know. \documentclass[margin=5pt, multi=circuitikz]{standalone} \usepackage[]{circuitikz} \def\S{5}% switch position 1,2,...,7; 7=\N \pgfmathsetmacro\s{-2*(\S+4)*180/8}% switch angle <-- I do not know a easier methode \def\No{7}% number of switch positons \pgfmathsetmacro\RSangle{6*180/8}% complete angle of the rotary switch <-- seems to be good \begin{document} \begin{circuitikz} \draw (0,0) node[rotary switch=\No in \RSangle wiper \s, rotate=90, ](S){}; \foreach \i in {1,...,\No}{%% requires "calc" \path[] ($(S.aout \i)!1ex!(S.sqout \i)$) node[font=\tiny, text=red]{\i}; }%% \end{circuitikz} \end{document}

  • TikZ word search diagram
    by yannis on November 26, 2025 at 11:50 pm

    How can I draw such a "word-search" diagram in TikZ? I need to place the letters on a grid and then to add red horizontal, vertical, diagonal or antidiagonal highlighting boxes as in the picture.

  • How to get a structure of this nodes tower with proper coordinates?
    by Explorer on November 25, 2025 at 5:54 pm

    What I want to achieve is something as below(sorry for drawing in a hurry): The only requirements is vertical alignment(shown as the red dashed lines), the spacing of each nodes could be design, given that would not ruin the figure is okay. What I have tried is as below: \documentclass[tikz,border=5pt]{standalone} \newcommand\mynode[2][1]{% \node[draw,thick,minimum width=8cm,minimum height=2cm,font=\Huge\bfseries,scale=#1] at (#2) {AAAA}; } \begin{document} \begin{tikzpicture} % \mynode[1]{0,0} % \mynode[.45]{-2.25,-2} % \mynode[.45]{2.25,-2} % \mynode[.225]{-3.25,-3} % \mynode[.225]{1.25,-3} % \mynode[.225]{-1.25,-3} % \mynode[.225]{3.25,-3} %... \foreach \x[ evaluate=\x as \y using {int(2^(\x-1))} ] in {1,...,6}{ \foreach \t in {1,...,\y}{ \def\xx{\fpeval{-4 + (8/(\y+1))*\t*1.25}} \def\yy{\fpeval{(8/(\x+1))*1.25}} \mynode[\fpeval{1/\y}]{\xx,\yy} } } \end{tikzpicture} \end{document} It gives: I found that dilemma to determine the proper spacing, and exact coordinates calculation to guarentee vertical alignment at the same time. Is that any powerful tikz tools or something other (box, coffin?) to achieve this? Or I maybe just to make more effort to solve the better numerical relationship or working with the recursive structure?

  • Book design with TikZ
    by Francesco Sieni on November 7, 2025 at 10:25 am

    there's a way to desgin a book cover like this one? MWE The only thing i managed to do were the frames \documentclass{book} \usepackage[paperwidth=115mm, paperheight=195mm]{geometry} \usepackage{tikz} \usepackage{tikzpagenodes} \usetikzlibrary{calc} \begin{document} \thispagestyle{empty} %external frame \tikz[overlay,remember picture]\draw($(current page.north east)+(-1.0cm,-1.0cm)$)--($(current page.north west)+(1.0cm,-1.0cm)$)--($(current page.south west)+(1.0cm,1.0cm)$)--($(current page.south east)+(-1.0cm,1.0cm)$)--cycle; %inside \tikz[overlay,remember picture]\draw($(current page.north east)+(-1.1cm,-1.1cm)$)--($(current page.north west)+(1.1cm,-1.1cm)$)--($(current page.south west)+(1.1cm,1.1cm)$)--($(current page.south east)+(-1.1cm,1.1cm)$)--cycle; \end{document} It doesn't matter if the color of the page (in this case black) because then I would like to invert it (i.e. white page and black frames,) Can you help me? Thank you very much!

  • pgfplots: Using set layers in an overlay picture
    by schtandard on July 5, 2025 at 1:58 pm

    Using pgfplots, I want to draw a plot as an overlay picture, making use of layers inside that plot. However, when I say \begin{tikzpicture} [overlay] \pgfplotsset{set layers} \begin{axis} \end{axis} \end{tikzpicture} I get two ! Dimension too large. errors. pgfplots seems to attempt to set both unit lengths (\pgf@x and \pgf@y) to -32000.0pt. Why is that and how can I avoid it? For tinkering, here is a slightly more useful MWE. Interestingly, the result looks fine in this example. (In larger pictures, the errors do cause havoc, though.) \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} [remember picture] \draw [green] coordinate (test) circle [radius=5cm]; \end{tikzpicture} \begin{tikzpicture} [remember picture, overlay] \pgfplotsset{set layers} \begin{axis} [at=(test), anchor=center, ymajorgrids] \addplot+ {x^2}; \begin{pgfonlayer}{axis grid} \fill [red] (axis cs:3,20) circle [radius=2cm]; \end{pgfonlayer} \end{axis} \end{tikzpicture} \end{document}

  • Tikz - ! Missing number, treated as zero
    by Latexfan on July 5, 2025 at 5:48 am

    I get error: ! Missing number, treated as zero. <to be read again> { l.34 } Here is the code: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[norsk]{babel} \usepackage{tikz} \usetikzlibrary{arrows.meta, angles, quotes, calc} \usepackage{amsmath} \begin{document} \begin{center} \begin{tikzpicture}[scale=0.65] \draw[very thin,color=gray] (-13,-1.5) grid (13,1.5); % Akser \draw[->, thick] (-13,0) -- (13.5,0) node[right] {$x$}; \draw[->, thick] (0,-1.5) -- (0,1.7) node[above] {$y$}; % x-aksen merker (flere π-enheter) \foreach \x/\lab in {-4/-4\pi, -3/-3\pi, -2/-2\pi, -1/-\pi, 1/\pi, 2/2\pi, 3/3\pi, 4/4\pi} \draw ({\x*3.14},0.1) -- ({\x*3.14},-0.1) node[below] {\small$\lab$}; % y-aksen merker \foreach \y in {-1,1} \draw (0.1,\y) -- (-0.1,\y) node[left] {\small$\y$}; % Selve grafen \foreach \k in {-2,-1,0,1,2} { \draw[domain=-3.14:0, thick, samples=50] plot(\x + {2*3.14*\k}, {-1*\x/3.14}); \draw[domain=0:3.14, thick, samples=50] plot(\x + {2*3.14*\k}, {\x/3.14}); } % Åpne punkter (grensepunkter) \foreach \k in {-2,-1,0,1,2} { \draw[fill=white] ({3.14*\k},0) circle (3pt); \draw[fill=white] ({3.14*(2*\k+1)},1) circle (3pt); \draw[fill=white] ({3.14*(2*\k+1)},-1) circle (3pt); } \end{tikzpicture} \end{center} \end{document} What should I change in the code? Thanks

  • Designing notation for langle and rangle with tick marks (for Hermitian inner products)
    by D.R on June 17, 2025 at 2:27 am

    Because of differing conventions of where to put the conjugate linear part of a Hermitian/sesquilinear inner product, I want to design a notation for inner product that has the asymmetry built into it. Here's what I have so far: "ticked rangle" with a small apostrophe-like tick coming of the top of it, i.e. it's rangle exactly, but there's an extra short tiny line segment with slope ~1 attached to the very top vertex of rangle \newcommand{\trangle}[1][1]{% \mathclose{% \tikz[baseline={(r.base)}]{ \node[inner sep=0pt, outer sep=0pt, scale=#1] (r) {$\rangle$}; \draw[line width=0.4pt] ([xshift=-0.4ex,yshift=0ex]r.north) -- ++(-0.3ex,-0.3ex); }% }% } \[ \langle x \trangle \rangle \quad \big\langle x \trangle[1.4] \big\rangle \quad \Big\langle x \trangle[1.6] \Big\rangle \] I am very open to other design choices, but regarding this one, I would like things to look more uniform for all sizes of rangle rangle has rounded corners at the end, while tikz line segments end quite harshly in rectangular corners no spacing change between just rangle. That is, the space between x and \rangle should look the same as the space between x and \trangle. Again, I am very open to hearing other more visually appealing ways of making this notation!

  • Is there better method to declare tikz picture with proper baseline and fontsize?
    by Explorer on June 13, 2025 at 11:52 am

    I want to use tikz to custom construct the following "steel" symbols: With my poor tikz practice, I get the following MWE: \documentclass{article} \usepackage{tikz} \newcommand*\steelA{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw (0,-.85ex) -- (0,.85ex); }}% \newcommand*\steelB{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw (0,-.85ex) -- (0,.85ex) (-.3em,-.85ex) -- (.3em,-.85ex); }}% \newcommand*\steelC{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw[xshift=-.1em] (0,-.85ex) -- (0,.85ex); \draw[xshift=.1em] (0,-.85ex) -- (0,.85ex); \draw (-.3em,-.85ex) -- (.3em,-.85ex); }}% \newcommand*\steelD{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw[xshift=-.1em] (0,-.85ex) -- (0,.85ex); \draw[xshift=.1em] (0,-.85ex) -- (0,.85ex); \draw (-.3em,-.85ex) -- (.3em,-.85ex) (-.3em,.85ex) -- (.3em,.85ex); }}% \begin{document} A\steelA B A\steelB B A\steelC B A\steelD B { \Huge% A\steelA B A\steelB B A\steelC B A\steelD B }% \end{document} But there are some drawbacks: poor method to handle the absolute distance(with some hard-encoded parameters(eg. .85ex)) the handle of baseline is not eleagnt, and not perfectly align: I want the top of the symbol EXACTLY the same height as A and B; and the bottom of the symbol the same depth as A and B When I test the different fontsize, it seemed that the symbol's thickness is too thin, is that possible to automaticallly change the thickness? Or in other word, how to better turn a tikzpicture into a "text symbol"? Sorry for (a little) mix three requirements together, but sepreate it into three questions seemed a bit inefficient. Thanks in advance! Edited with the symbol's information: but I don't know anything about these symbols, so maybe this style does not really make sense It comes from a standard file "GB 50010-2010"(I'm sorry for I can't provide the link here) at Page.22. The steel is graded into FOUR levels:

  • How can I draw this figure by drawing packages?
    by SandyM on April 13, 2025 at 10:22 am

    Que: How can I achieve the attached figure from my MWE? MWE: \documentclass{article} \usepackage{amsmath} \usepackage{amssymb} \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{calc,intersections,through,backgrounds} \usepackage{tkz-euclide} \usepackage{amsthm} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \tkzDefPoints{0/0/A,3/0/B,6/0/D,4.25/0/E} \tkzDefPoints{3/3/C} \tkzDrawSegments(A,D) \tkzDrawSegments(A,C) \tkzDrawSegments(B,C) \tkzDrawPoints(A,B,C,D,E) \tkzLabelPoints(A,B,C,D,E) \tkzDrawArc[style=dashed,color=red,](A,E)(C) \tkzDrawArc[style=dashed,rotate,color=red](A,E)(55) \tkzMarkRightAngle[fill=yellow!80,size=.35,draw](A,B,C) \end{tikzpicture}

  • how to draw mutually tangent circles
    by underflow on April 10, 2025 at 7:18 pm

    I need to draw two concentric circles plus additional circles that the mutually tangent, like this: I tried using \draw (0,0) arc [radius=1, start angle=-30, end angle= 60]; \draw (0,0) arc [radius=3, start angle=-30, end angle= 60]; to draw the concentric arcs, but it seems that the "(0,0)" specify the starting point and not the center of the arc. Eventually I hacked together an ad hoc tikz code to make this picture (see below), but I wonder if there is a more standard/non-adhoc ways to do this? E.g. is there a way to get tizk to polar polar graphs directly? BONUS Q: How do I color the wedge bounded by the two line segments and the outer arc? Thanks! My hacky code that produces this picture: \documentclass{amsart} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [ultra thick, domain=0.0:2] plot(\x, { sqrt(4-\x*\x)}); \draw [ultra thick, domain=1.7:2] plot(\x, {-sqrt(4-\x*\x)}); \draw [ultra thick, domain=-0.3:0.6] plot(\x, { sqrt(0.36-\x*\x)}); \draw [ultra thick, domain= 0.4:0.6] plot(\x, {-sqrt(0.36-\x*\x)}); \draw [ultra thick] (1.3, 0) circle [radius=0.7]; \draw [ultra thick] (0.5, 1.2) circle [radius=0.7]; \draw [thick] (0,0) -- (2,0); \draw [thick] (0,0) -- (0.76,1.85); \end{tikzpicture} \end{document}

  • Given a normal vector, is it possible to re-orient tikz arrows and node letters so that they are level with an arbitrary plane?
    by Jasper on October 5, 2024 at 2:23 am

    Note: I realize that this question is asking a lot, I just really want this functionality. Sorry for such a long and involved question. Also, a normal vector to the plane in my diagram is (1.5,-2,1). Given a normal vector, is it possible to re-orient tikz arrows and node letters so that they are level with an arbitrary plane? Similar to how the arrow is drawn in perspective in this example from page 84 of the asymptote manual: https://tex.stackexchange.com/a/267497/319072 is above my level, though it does seem to implement this feature, given angles. I want to do something similar, using a normal vector. https://tex.stackexchange.com/a/531156/319072 only seems to implement is for the xy, yz and xz planes. Here is a non-MWE (the reason for it being so long is to help you visualize the problem) \documentclass[tikz, border=0.2cm]{standalone} \usetikzlibrary{spy} \usepackage{tikz-3dplot} \newcommand{\planeFunction}[2]{ % Purpose: defines a plane. % #1 - x variable % #2 - y variable % Return: the output in z. -1.5*(#1)+2*(#2)+2 } \begin{document} \tdplotsetmaincoords{60}{45} \begin{tikzpicture}[tdplot_main_coords,spy using outlines={circle, magnification=4, size=2cm, connect spies}] % plane \foreach \Vt in {-2,-1.9,...,1}{ \draw[very thin,densely dotted] (\Vt,-2,{\planeFunction{\Vt}{-2}}) -- (\Vt,1,{\planeFunction{\Vt}{1}}); \draw[very thin,densely dotted] (-2,\Vt,{\planeFunction{-2}{\Vt}}) -- (1,\Vt,{\planeFunction{1}{\Vt}}); } % xy grid \foreach \Vt in {-2.8,-2.6,...,2.8}{ \draw[very thin,densely dotted] (\Vt,-3) -- (\Vt,3); \draw[very thin,densely dotted] (-3,\Vt) -- (3,\Vt); } % xy axes \draw[->] (-3,0) -- (3,0) node[pos=1,below right] {$x$}; \draw[->] (0,-3) -- (0,3) node[pos=1,above right] {$y$}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% arrow on xy grid - how do I make it level with the plane? %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \spy on (2.8,0) in node at (6,-2); % shadow of domain on the xy plane \fill[opacity=0.3] (-2,-2) -- (-2,1) -- (1,1) -- (1,-2) -- cycle; \begin{scope} \clip (-4/3,-2) -- (1,-0.25) -- (1,1,{\planeFunction{1}{1}}) -- (-2,1,{\planeFunction{-2}{1}}) -- (-2,-2,{\planeFunction{-2}{-2}}) -- cycle; \fill[white] (-4/3,-2) -- (1,-0.25) -- (1,1,{\planeFunction{1}{1}}) -- (-2,1,{\planeFunction{-2}{1}}) -- (-2,-2,{\planeFunction{-2}{-2}}) -- cycle; % plane \foreach \Vt in {-2,-1.9,...,1}{ \draw[very thin,densely dotted] (\Vt,-2,{\planeFunction{\Vt}{-2}}) -- (\Vt,1,{\planeFunction{\Vt}{1}}); \draw[very thin,densely dotted] (-2,\Vt,{\planeFunction{-2}{\Vt}}) -- (1,\Vt,{\planeFunction{1}{\Vt}}); } \end{scope} % intersection line \draw (1,-0.25) -- (-4/3,-2); % shadow of plane \fill[opacity=0.3] (1,-2,{\planeFunction{1}{-2}}) -- (1,1,{\planeFunction{1}{-2}}) -- (1,1,{\planeFunction{1}{1}}) -- cycle; \fill[opacity=0.3] (1,-2,{\planeFunction{1}{-2}}) -- (-2,-2,{\planeFunction{1}{-2}}) -- (-2,-2,{\planeFunction{-2}{-2}}) -- cycle; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% arrow on plane - how do I make it level with the plane? %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \draw[->] (0,0,{\planeFunction{0}{0}}) -- (-1,-1,{\planeFunction{-1}{-1}}); \spy on (-1,-1,{\planeFunction{-1}{-1}}) in node at (-4,7); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% letter on plane - how do I make it level with the plane? %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \node at (-1.5,0.5,{\planeFunction{-1.5}{0.5}}) {$\overline{C}$}; \spy on (-1.5,0.5,{\planeFunction{-1.5}{0.5}}) in node at (-6,0); \end{tikzpicture} \end{document}

  • Using latex tikz package alongside anki version 23.12.1
    by croakouttatune on February 25, 2024 at 4:44 am

    Summary of the problem I've been attempting to get the latex tikz package working alongside my anki version (23.12.1) without success. I've also posted about this problem directly to the anki forum. I'm doing this (working with tikz) to include drawing that are illustrative to my flashcard notes in anki. I use a markdown convertion notetaking process, that is described and documented in github dot com slash lervag slash apy, but for most part this is exactly the same as adding the notes directly with the anki editor. This is the particular drawing that I've been trying to configure. [latex] \begin{tikzpicture} % Draw the circles \draw[thick] (0,0) circle (1); \draw[thick] (0,0) circle (2); \draw[thick] (0,0) circle (3); % Add lines to labels \draw[->, thick] (0,0.2) -- (4,0.2) node[right] {Identity}; \draw[->, thick] (0,1.5) -- (4,1.5) node[right] {Processes}; \draw[->, thick] (0,2.5) -- (4,2.5) node[right] {outcomes}; \end{tikzpicture} [\latex] I had thought that as soon as I added the tikz package to the premable that the problem would resolve itself. This is the updated preamble. \documentclass[12pt]{article} \special{papersize=3in,5in} \usepackage{tikz} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{amssymb,amsmath} \usepackage{tabularx} % added line for tables \usepackage[table]{xcolor} % added to color rows \pagestyle{empty} \setlength{\parindent}{0in} \begin{document} [X] I also have the "create scalable images with dvisvgm" checked off. HOWEVER, this doesn't seem to be the case and instead the text is rendered as the plaintext coding directly into the flashcard. Research into a solution I've looked up other posts on the topic, and couldn't find anything specifically geared towards tikz but instead found an article focused on getting the latex working within anki. Things That I've Tried I installed the Edit latex build process that is also described in the anki webseite documentation, and re-configured the build process to include pdflatex, which is in my path, and which I use for testing tex documents in vim with the command, autocmd BufWritePost *.tex execute "!pdflatex --shell-escape -output-directory=/tmp/ %" , and the configuration in the Edit latex build process is as follows: { "pngCommands": [ [ "latex", "-interaction=nonstopmode", "tmp.tex" ], [ "dvipng", "-D", "200", "-T", "tight", "tmp.dvi", "-o", "tmp.png" ] ], "svgCommands": [ [ "pdflatex", "-output-format=dvi", "-shell-escape", "-interaction=nonstopmode", "tmp.tex" ], [ "dvisvgm", "--no-fonts", "-Z", "2", "tmp.dvi", "-o", "tmp.svg" ] ] } I've noticed that when the command doesn't execute with success the error is rendered in place of the image, since this occurred a few times when I attempted the process of adding latex sections in the anki editor.

  • Using TikZ (or other package) to draw a gameboard, somewhat similar to chess (Hnefatafl)
    by LewisE on February 14, 2024 at 9:53 am

    I need to write some documentation and need to display a Hnefatafl board. Basically it is an 11x11 board, some of the squares would be highlighted (e.g. cross hatching). The pieces are basically equivalent to black pawn, white pawn, black King - and I could use either circles or even chess board pieces to represent, the board would have chess style rank and file notation (1-11, A-K etc.). Really looking for some advise, I think I may need to write some (hopefully simple) package, would tikZ be the best place to start or is there a chess package or something else that could enable the above? I'm relatively new to LaTeX, I can do the basics, but need to learn a bit more. I'd appreciate any advise on how to go about this. Thanks in advance!

  • Drawing Three Tangential Lines on a TikZ Diagram to a Specific Point on a Circle's Circumference
    by Marco Moldenhauer on November 30, 2023 at 8:20 pm

    How to draw the three red lines shown in the TikZ picture below: Line 1: Start from the inner circle's circumference at 0 degrees, extending tangentially to the north, and reach the middle circle. Position the number '20' along the midway point of this line. Line 2: Initiate from the middle circle's circumference at 180 degrees, extending tangentially to the south, and connect to the middle circle. Position the number '21' along the midway point of this line. Line 3: Begin from the inner circle's circumference at 270 degrees, extending tangentially to the east, and reach the outer circle. Place the letter 'x' at the midway point of this line. Look at the drawing below for illustration. CODE: \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw (0,0) circle (1); \draw (0,0) circle (2); \draw (0,0) circle (2.7); \end{tikzpicture} \end{document} OUTPUT (red lines and characters added only for clarification): FINAL WORK (Thanks to the community):

  • 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! 🥂🥳

  • pdflatex not working anymore after updating pdflatex.ini and initexmf --dump=pdflatex
    by user140574 on August 3, 2017 at 10:36 am

    I tried to overcome the well known tex capacity exceed problem, when using large Surf-plot with many datapoints. I tried this by typing into the cmd (Windows 7, MikTex 2.9): initexmf --edit-config-file=pdflatex main_memory=5000000 extra_mem_bot=5000000 font_mem_size=5000000 pool_size=5000000 buf_size=5000000 **initexmf --dump=pdflatex** Now, pdflatex does not work anymore, a dvi is built, but no output. The log also says that the system maybe just failed. pdflatex is broke... Any Ideas? (I cannot think of a proper MWE.)

  • How to prune nodes in a tree using graph syntax
    by Charl Meyers on March 2, 2016 at 10:33 am

    I want to indicate that nodes have been removed from a tree. Lets say the code looks like this: \documentclass{article} \usepackage{tikz} \usetikzlibrary{graphs} \usetikzlibrary{graphdrawing} \usegdlibrary{trees} \begin{document} \tikz[tree layout]\graph[nodes={draw, circle}] { a -- {b -- {e -- {k[label=below:1], l[label=below:4]}, f -- m[label=below:6]}, c -- g -- {y[label=below:0], z[label=below:2]}, d -- i[label=below:4]} }; \end{document} And I want to cut off b to f. How do I do it? I am using this syntax because this looks familiar to dot language and I am not very antiquated with latex. P.S. have a look at http://www.graphviz.org/doc/info/lang.html if you don't know that dot language is.

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

  • Help drawing a very simple number line using TikZ
    by JimmyJackson on December 3, 2013 at 11:16 pm

    I want to draw a very simple number line, i found some code that got me started here. I have modified the code to get the following picture The problem is that I want the numbers below the line to show up as {-3,2,1,0,1,2,3} but I can't figure out how to modify the following code to do this. \usetikzlibrary{arrows} \begin{tikzpicture} \draw[latex-] (-6.5,0) -- (6.5,0) ; \draw[-latex] (-6.5,0) -- (6.5,0) ; \foreach \x in {-6,-4,-2,0,2,4,6} \draw[shift={(\x,0)},color=black] (0pt,3pt) -- (0pt,-3pt); \foreach \x in {-6,-4,-2,0,2,4,6} \draw[shift={(\x,0)},color=black] (0pt,0pt) -- (0pt,-3pt) node[below] {$\x$}; \draw[*-o] (0.92,0) -- (2.08,0); \draw[very thick ] (0.92,0) -- (1.92,0); \end{tikzpicture} It would nice if I could just divide \x by 2 in place of node[below] {$\x$}, but I don't know how to do this. Thanks!