TikZ
- What is the best way to draw a potato (like found in vector analysis/continuum mechanics courses)by Dimitrios ANAGNOSTOU on February 21, 2026 at 11:34 pm
I apologized if this is a duplicate. What is the best way to draw such figures with tikz (or other packages)? For the time being just the potato like figure. I do not care for the vectors and the infinitesimal mass element. I do not want someone to do the work for me. Just some advice or suggestions.
- Latex: Tikz - rectangle to inherit the width of another rectangleby GJW on February 21, 2026 at 1:44 pm
I would like node B to have exactly the same width as node A, without explicitly specifying a fixed dimension, with the following constraints: The two nodes are not adjacent in the source code. I do not want to hard-code a width (e.g., minimum width=3cm). Node A will always be at least as wide as node B. I would prefer a solution that does not rely on manually computing dimensions via \path let unless necessary. Here is a minimal example illustrating what I currently have: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \node [draw] (A) {Some text}; \path let \p1 = (A.south west), \p2 = (A.north east) in node [draw, minimum width=\x2-\x1-\pgflinewidth, minimum height=\y2-\y1-\pgflinewidth, below right] at ([yshift={\pgflinewidth}]A.south west) {more}; \end{tikzpicture} \end{document}
- Strange intersection glitch of knots package?by Explorer on February 21, 2026 at 9:20 am
This question based on the previous question: % Source - https://tex.stackexchange.com/a/759998 % Posted by Andrew Stacey % Retrieved 2026-02-21, License - CC BY-SA 4.0 \documentclass[tikz, border=1cm]{standalone} \usetikzlibrary{decorations.pathreplacing,knots} %\url{https://tex.stackexchange.com/q/759978/86} \begin{document} \begin{tikzpicture}[ basic strand/.style={ black, double=gray!10, double distance=1pt, line cap=round, thick, }, crossing strand/.style={ line width=2pt, only when rendering/.style={% draw=gray!10,% line width=1pt, double=none, } }, rounded corners=1pt, ] \begin{knot}[ consider self intersections=true, ignore endpoint intersections=false, background colour=black, every intersection/.style={ crossing strand }, only when rendering/.style={ basic strand }, clip width=1, flip crossing=1, ] \strand (7.5,7.5)--(6.5,5.5)--(7.5,3.5)--(6.5,1.5)--(4.5,0.5)--(2.5,1.5)--(0.5,0.5)--(1.5,2.5)--(0.5,4.5)--(1.5,6.5)--(3.5,7.5)--(5.5,6.5)--(7.5,5.5)--(6.5,3.5)--(7.5,1.5)--(5.5,0.5)--(3.5,1.5)--(1.5,0.5)--(0.5,2.5)--(1.5,4.5)--(0.5,6.5)--(2.5,7.5)--(4.5,6.5)--(6.5,7.5)--(5.5,5.5)--(7.5,4.5)--(6.5,2.5)--(7.5,0.5)--(5.5,1.5) --(3.5,0.5)--(1.5,1.5)--(0.5,3.5)--(1.5,5.5) --(0.5,7.5)--(2.5,6.5)--(4.5,7.5)--(6.5,6.5) --(4.5,5.5)--(5.5,3.5) % --(7.5,2.5) ; \end{knot} \end{tikzpicture} \end{document} With --(7.5,2.5) commented, it behaves good: However, if I uncommented that line, thing changed: Is that a bug or feature? Any possibility to improve this?
- Using tikz's backgrounds library to draw something behind textby Werner on February 21, 2026 at 7:20 am
Consider the following minimal example where I want to draw a rectangle behind a sequence of numbers (to highlight them): \documentclass{article} \usepackage{tikz} \usetikzlibrary{backgrounds,calc} \NewDocumentCommand{\tikzmark}{ m }{\tikz[overlay, remember picture] \node (#1) {};} \newcounter{seq} \NewDocumentCommand{\seqstart}{}{% \stepcounter{seq}% Start a new sequence \tikzmark{seq-start-\theseq}}% Set start marker \NewDocumentCommand{\seqend}{}{% \tikzmark{seq-end-\theseq}% Set end marker \tikz[remember picture, overlay] \scoped [on background layer] \fill [fill=blue!10!white] ($(seq-start-\theseq.south west) + (-0.5pt,1pt)$) rectangle ($(seq-end-\theseq.south east) + (0.5pt,1.1\normalbaselineskip)$);% } \begin{document} \[ 12, 15, 8, 11, 4, 7, 0, 3, 16, 19, 12, 15, 8, 11, 4, 7, 0, 3, \ldots \] \[ \seqstart{}12, 15, 8, 11, 4, 7, 0, 3, 16, 19\seqend{}, 12, 15, 8, 11, 4, 7, 0, 3, \ldots \] \end{document} The idea is that \seqstart would set a (counter-driven) \tikzmark representing the start of the sequence to be marked. Then \seqend would set a \tikzmark at the end and highlight it using the background layer. The counter allows for multiple such sequence marking within a larger document. However, the output shows that the rectangle highlighting a part of the sequence is not being drawn on background layer as requested. Why is that? How can I ensure the rectangle is drawn on the background layer behind document/text elements? The backgrounds library documentation (in the tikz documentation, section 45) mentions that on background layer can only be used inside a {scope} or \scoped, which is done above.
- How to draw self-overlapped path with double line style?by Explorer on February 20, 2026 at 4:52 pm
The question is similar to this solution, but not the same: \documentclass[tikz, border=1cm]{standalone} \usetikzlibrary{decorations.pathreplacing} % https://tex.stackexchange.com/a/572738/322482 \begin{document} \begin{tikzpicture}[ rounded corners=1pt, path decomposition/.style={% postaction={decoration={show path construction, lineto code={ \draw[#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast); }, curveto code={ \draw[#1] (\tikzinputsegmentfirst) .. controls (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast) ; }, closepath code={ \draw[#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast) {closepath};} } ,decorate}}] \draw[line cap=round, black, double=gray!10, thick, path decomposition={black, double=gray!10,thick}] (3,3) -- (1,1) -- (3,1) -- (1,3); % here below is what I want with only one path \begin{scope}[xshift=3cm] \draw[black, double=gray!10, thick, line cap=round] (3,3) -- (1,1) -- (1.5,1); \draw[black, double=gray!10, thick, line cap=round] (2.5,1) -- (3,1) -- (1,3); \draw[black, double=gray!10, thick] (1.3,1) -- (2.7,1); \end{scope} \end{tikzpicture} \end{document}
- How to draw a half‑sphere with 5‑degree lines along the x‑axis in TikZ/PGF? [closed]by AruGip on February 19, 2026 at 8:40 pm
I found this post and I'm trying to retrieve the version shown in the image below. Does anyone know how I can get that specific version? I've checked the documentation and explored the available properties, but I couldn't find anything that returns the same value shown there. Any ideas on how to achieve this?
- Create a directed graphby Dimitrios ANAGNOSTOU on February 19, 2026 at 4:15 pm
I want to create the following figure. Using the following code, I managed to get something close. But I cannot figure out how to get properly the diagonal vectors without too much trial and error. Any ideas? Thanks a lot! \documentclass[a4paper,11pt]{article} \usepackage[T1]{fontenc} \usepackage[french]{babel} \usepackage{tikz} \usetikzlibrary{positioning,arrows.meta} \begin{document} \begin{figure}[!htpb] \centering \begin{tikzpicture}[ node distance=3cm, box/.style={draw, rectangle, minimum size=1.2cm, font=\large}, arr/.style={->, >=Stealth, thick} ] % Nodes \node[box] (1) {1}; \node[box, below=of 1] (2) {2}; \node[box, right=of 1] (3) {3}; \node[box, below=of 3] (4) {4}; % Labels n_i \node[above=3mm of 1] {$n_1=3$}; \node[above=3mm of 3] {$n_3=1$}; \node[below=3mm of 2] {$n_2=2$}; \node[below=3mm of 4] {$n_4=2$}; % Horizontal 1 <-> 3 (two parallel arrows) \draw[arr] ([yshift=4pt]1.east) -- ([yshift=4pt]3.west); \draw[arr] ([yshift=-4pt]3.west) -- ([yshift=-4pt]1.east); % Vertical left \draw[arr] (1) -- (2); % Vertical right \draw[arr] (4) -- (3); % Bottom horizontal \draw[arr] (2) -- (4); % Diagonals \draw[arr] (2) -- (3); \draw[arr] ([xshift=-4pt]4.north) -- ([xshift=4pt]1.south); \draw[arr] ([xshift=-4pt]1.south) -- ([xshift=4pt]4.north); \end{tikzpicture} \end{figure} \end{document}
- I am trying to \protected@edef a bmatrix, and then I token.get_macro that token from Lua, so I can print it to the .tex at a later timeby Jasper on February 19, 2026 at 3:25 pm
I am trying to \protected@edef a bmatrix, and then I token.get_macro that token from Lua, so I can print it to the .tex at a later time. The error: WARNING: mathml missing for hash E6607B372B3A7F4DE18DB36E2B449CBD ! You can't use `\spacefactor' in math mode. \@->\spacefactor \@m {} \DocumentMetadata{ lang = en ,pdfversion = 2.0 ,pdfstandard = {UA-2} ,tagging = on } \tagpdfsetup {math/mathml/luamml/load=true} \documentclass{article} \usepackage{luacode,unicode-math,tikz} \begin{document} \makeatletter \protected@edef\COUNTDOOKU{\( \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \)} \makeatother \begin{tikzpicture} \begin{luacode*} tex.sprint( ("\\node at (0,0) {%s};") :format( token.get_macro("COUNTDOOKU") ) ) \end{luacode*} \end{tikzpicture} \end{document}
- Is it possible to implement loop in TikZ like xypic?by YCH817 on February 18, 2026 at 8:54 pm
I have tried plotting loop arrows with different sizes using xypic and tikz : \documentclass{article} \usepackage[a4paper, landscape=true]{geometry} \usepackage{graphicx} % Required for inserting images \usepackage[curve,pdf,all]{xy} \usepackage[svgnames,dvipsnames]{xcolor} \usepackage{tikz} \begin{document} $\begin{xy} (0,0)*+<5pt,3pt>[F-:<3pt>:red][F*:<3pt>:pink]{\vphantom{fg}x}="x", \ar@`{"x"+(-10,+10),"x"+(+10,+10)}^{1} \ar@`{"x"+(-20,+20),"x"+(+20,+20)}^{2} \ar@`{"x"+(-30,+30),"x"+(+30,+30)}^{3} \ar@`{"x"+(-40,+40),"x"+(+40,+40)}^{4} \ar@`{"x"+(-50,+50),"x"+(+50,+50)}^{5} \ar@`{"x"+(-60,+60),"x"+(+60,+60)}^{6} \ar@`{"x"+(+10,-10),"x"+(-10,-10)}^{1} \ar@`{"x"+(+20,-20),"x"+(-20,-20)}^{2} \ar@`{"x"+(+30,-30),"x"+(-30,-30)}^{3} \ar@`{"x"+(+40,-40),"x"+(-40,-40)}^{4} \ar@`{"x"+(+50,-50),"x"+(-50,-50)}^{5} \ar@`{"x"+(+60,-60),"x"+(-60,-60)}^{6} \end{xy}$ % --- \tikz{ \node [ draw, line width=.4pt, rounded corners=5pt, inner sep=3pt ] (x) at (0,0) {$x\vphantom{fg}$}; \foreach \i in {1,2,3,...,6} { \draw[->] (x) .. controls +(-\i,+\i) and +(+\i,+\i) .. (x) ; \draw[->] (x) .. controls +(+\i,-\i) and +(-\i,-\i) .. (x) ; }} \end{document} and here is the output : xypic : tikz : I noticed that the loop curve produced by tikz is a little bit squashed (especially the smallest curve, I think it is quite ugly -_-||), compared to the one produced by xypic. Since I am starting to use LuaLaTeX as compiling engine and I cannot use xypic with pdf option in LuaLaTex, I wonder if there is a good way to make tikz produce loop curves like the one produced by xypic. Also luamplib code is welcome.
- uneven commutative diagramby mappingmoe on February 18, 2026 at 11:33 am
I want to draw the following commutative diagram in LaTeX: I have tried tikzcd, but I think I won't work, since the rows have different size. Is there a clean way to do it? EDIT: my first approach was the following: \documentclass[a4paper]{article} \usepackage{tikz-cd} \begin{document} \begin{tikzcd} P \arrow{l}{pr} \arrow{d}{\pi} & TP \arrow{d}{T \pi}\\ I \arrow{ur}{\tilde{\gamma}} \arrow{r}{\dot{\gamma}} & M \arrow{l}{pr} & TM \end{tikzcd} \end{document}
- What packages are useful for drawing topological surfaces? [closed]by Sean Wakasa on February 18, 2026 at 8:37 am
I'm writing a mathematical paper that studies the fundamental groups of surface bundles, hence I need to create images of surfaces of genus greater than 1 with loops drawn on surface. What packages can I use to make such images? See page 8 of this paper for an example of such a surface.
- Spacing in Tikz Heatmapby itc on February 17, 2026 at 6:09 pm
I am struggling with the vertical space of my tikz heatmap. Specifically, my column labels are getting into the title of my diagram. The same is happening with the legend. I have put the MWE: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{matrix, positioning, backgrounds} \begin{document} \begin{tikzpicture}[ font=\sffamily, cell/.style={ rectangle, minimum width=2.5cm, minimum height=1cm, draw=white, line width=0.5mm, align=center }, label/.style={ anchor=east, font=\bfseries\small }, header/.style={ anchor=south, rotate=45, font=\bfseries\small, anchor=south west } ] % Define Colors representing the score (Low, Medium, High) \definecolor{scoreLow}{HTML}{F2F2F2} % Weak/Low \definecolor{scoreMed}{HTML}{84B7D6} % Medium/Partial \definecolor{scoreHigh}{HTML}{004C6D} % Strong/High % Legend formatting \matrix [draw=none, anchor=north west] at (-4, 2) { \node [fill=scoreHigh, text=white, minimum width=1cm] {High/Strong}; & \node [anchor=west] {Jddhdhshdhshss}; \\ \node [fill=scoreMed, text=black, minimum width=1cm] {Zprororo}; & \node [anchor=west] {Trump}; \\ \node [fill=scoreLow, text=black, minimum width=1cm] {Hhdueueu}; & \node [anchor=west] {Ghsshshshs}; \\ }; % --- THE DATA MATRIX --- % Row 1: H % High Behavioural Realism [cite: 29], Low Auditability [cite: 81], Low Probability [cite: 78], High Actionability [cite: 40] \node[cell, fill=scoreHigh, text=white] (c11) at (0,0) {High}; \node[cell, fill=scoreLow, text=black] (c12) at (2.5,0) {Low}; \node[cell, fill=scoreLow, text=black] (c13) at (5,0) {Low}; \node[cell, fill=scoreLow, text=black] (c14) at (7.5,0) {Risk}; \node[cell, fill=scoreHigh, text=white] (c15) at (10,0) {High}; % Row 2: A % Low Realism, High Auditability [cite: 82], Med Probability (Rankings) [cite: 109] \node[cell, fill=scoreLow, text=black] (c21) at (0,-1) {Low}; \node[cell, fill=scoreHigh, text=white] (c22) at (2.5,-1) {High}; \node[cell, fill=scoreMed, text=black] (c23) at (5,-1) {Med}; \node[cell, fill=scoreMed, text=black] (c24) at (7.5,-1) {Med}; \node[cell, fill=scoreMed, text=black] (c25) at (10,-1) {Med}; % Row 3: B % Input oriented [cite: 112], Low actionability alone [cite: 113] \node[cell, fill=scoreLow, text=black] (c31) at (0,-2) {Low}; \node[cell, fill=scoreMed, text=black] (c32) at (2.5,-2) {Med}; \node[cell, fill=scoreLow, text=black] (c33) at (5,-2) {Low}; \node[cell, fill=scoreHigh, text=white] (c34) at (7.5,-2) {High}; \node[cell, fill=scoreLow, text=black] (c35) at (10,-2) {Low}; % Row 4: C % Easier to document [cite: 94], Explore plausibility not prob [cite: 93] \node[cell, fill=scoreMed, text=black] (c41) at (0,-3) {Med}; \node[cell, fill=scoreHigh, text=white] (c42) at (2.5,-3) {High}; \node[cell, fill=scoreLow, text=black] (c43) at (5,-3) {Low}; \node[cell, fill=scoreMed, text=black] (c44) at (7.5,-3) {Med}; \node[cell, fill=scoreMed, text=black] (c45) at (10,-3) {Med}; % Row 5: D % Traceability/Coherence [cite: 96], Probabilistic [cite: 95] \node[cell, fill=scoreLow, text=black] (c51) at (0,-4) {Low}; \node[cell, fill=scoreHigh, text=white] (c52) at (2.5,-4) {High}; \node[cell, fill=scoreHigh, text=white] (c53) at (5,-4) {High}; \node[cell, fill=scoreLow, text=black] (c54) at (7.5,-4) {Low}; \node[cell, fill=scoreMed, text=black] (c55) at (10,-4) {Med}; % Row 6: E % Normative/Pathways[cite: 101], High Actionability \node[cell, fill=scoreLow, text=black] (c61) at (0,-5) {Low}; \node[cell, fill=scoreMed, text=black] (c62) at (2.5,-5) {Med}; \node[cell, fill=scoreLow, text=black] (c63) at (5,-5) {Low}; \node[cell, fill=scoreHigh, text=white] (c64) at (7.5,-5) {High}; \node[cell, fill=scoreHigh, text=white] (c65) at (10,-5) {High}; % Row 7: F % Calibration/Monitoring[cite: 133], High Probability, Low Realism \node[cell, fill=scoreLow, text=black] (c71) at (0,-6) {Low}; \node[cell, fill=scoreHigh, text=white] (c72) at (2.5,-6) {High}; \node[cell, fill=scoreHigh, text=white] (c73) at (5,-6) {High}; \node[cell, fill=scoreLow, text=black] (c74) at (7.5,-6) {Low}; \node[cell, fill=scoreMed, text=black] (c75) at (10,-6) {Med}; % Row 8: G % Adversarial[cite: 122], Low Auditability (often anecdotal) \node[cell, fill=scoreHigh, text=white] (c81) at (0,-7) {High}; \node[cell, fill=scoreLow, text=black] (c82) at (2.5,-7) {Low}; \node[cell, fill=scoreLow, text=black] (c83) at (5,-7) {Low}; \node[cell, fill=scoreLow, text=black] (c84) at (7.5,-7) {Low}; \node[cell, fill=scoreMed, text=black] (c85) at (10,-7) {Med}; % --- LABELS --- % Y-Axis Labels (Methods) \node[label] at (-1.5, 0) {H}; \node[label] at (-1.5, -1) {A}; \node[label] at (-1.5, -2) {B}; \node[label] at (-1.5, -3) {C}; \node[label] at (-1.5, -4) {D}; \node[label] at (-1.5, -5) {E}; \node[label] at (-1.5, -6) {F}; \node[label] at (-1.5, -7) {G}; % X-Axis Labels (Attributes) \node[header] at (0, 0.6) {Fuuueueueu djejejejjejejejejej}; \node[header] at (2.5, 0.6) {Ldhdhdhdd hdhdjddjdjdjdjeieeieiidjd}; \node[header] at (5, 0.6) {LLwhwuquahsajqjqjqjqjqqjssjsj}; \node[header] at (7.5, 0.6) {Kahhwuwuwuddeeicdjsjwjw}; \node[header] at (10, 0.6) {KKsiwiwiwiwyduweueeuee}; % Title \node[anchor=center, font=\bfseries\Large] at (3.5, 3.5) {Xfhfhhe jeeieiei nddjewoo djwiwoxdk msaaakkkwifjfjf}; \node[anchor=center, font=\small, text width=12cm, align=center] at (3.5, 2.8) {Xomtive fhfru dieieo difiwwi dkdfjdkwo ksksskskw.\\ \textit{Fsw7w8 ddijej doofoe cdirirfv iiroflvw dkoeowoxk dfeke.}}; \end{tikzpicture} \end{document} I have attached the screenshot as well:
- Introducing a vertical line in a quantikz circuitby Rob on February 17, 2026 at 10:44 am
I have the following circuit generated using quantikz: \documentclass{article} \usepackage{quantikz} \begin{document} \begin{center} \begin{quantikz}[row sep=.2cm, column sep=.5cm] \lstick{$|0\rangle$} & \gate{A} & \gate[2]{B} & \ghost{C} & \gate{D} & \\ \lstick{$|1\rangle$} & & & \gate[2]{C} & \gate{E} & \\ \lstick{$|1\rangle$} & & & & \gate{F} & \end{quantikz} \end{center} \end{document} How can I introduce some vertical lines as shown in the attached screenshot below
- Why does an error occur if I replace the code with the one that uses "foreach"?by Paco Robledo on February 16, 2026 at 1:19 pm
\documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage{amsmath} % <- \text{} erabiltzeko beharrezkoa \begin{document} \begin{tikzpicture}[transform shape] %horizontal projection %variable definitions \def\g{-9.8} %gravity \def\v{10} %velocity \def\ang{51} %angle \def\s{0.1} \pgfmathsetmacro{\c}{{(-1*(2/\g)*\v*sin(\ang))/2}} \begin{axis}[ width=.45\linewidth, %set bigger width height=2.2in, xmin={{\v*cos(\ang)*\c}},xmax=11.5, ymin=0,ymax={\v*\c*sin(\ang)+0.5*\g*(\c^2)},, xlabel=$x$, ylabel=$600 m$, axis x line = bottom, axis y line = left, y axis line style={-}, ticks = none,clip=false, ] \tikzset{every mark/.append style={fill=white}} %flight path \addplot[ dashed, domain={\v*cos(\ang)*\c}:10, samples=100,] {{\g*(x^2)/(2*\v^2*cos(\ang)^2)+x*tan(\ang)}}; %flight path \addplot[ dashed, domain=5:10, samples=100,] {{\v*\c*sin(\ang)+0.5*\g*(\c^2)}}; %vector at end \pgfmathsetmacro{\a}{{-1*(2/\g)*\v*sin(\ang)}} \coordinate (E) at (axis cs:{\v*cos(\ang)*\a},{\v*\a*sin(\ang)+0.5*\g*(\a^2)}){}; \coordinate (F) at (axis cs:{\v*cos(\ang)*\a+\s*\v*cos(\ang))}, {\v*\a*sin(\ang)+0.5*\g*\a^2+\s*(\v*sin(\ang)+\g*\a)}); \coordinate (G) at (axis cs:{\v*cos(\ang)*\a},{\v*\c*sin(\ang)+0.5*\g*(\c^2)}); \draw[very thick,->](E)--(F) node[right, at end,font=\tiny]{$\vec{V}$}; \draw[very thick,->](G)--(F |- G) node[midway,above,font=\tiny]{$\vec{V}$}; \draw[densely dashed,very thick,->](E)--(F |- E) node[midway,above,font=\tiny]{$\vec{V}_x$}; \draw[densely dashed,very thick,->](E)--(F-| E) node[midway,left,font=\tiny]{$\vec{V}_y$}; \path plot[mark=*] coordinates {(E)}; \path plot[mark=*] coordinates {(G)}; %vector at start \pgfmathsetmacro{\c}{{(-1*(2/\g)*\v*sin(\ang))/2}} \coordinate (L) at (axis cs:{\v*cos(\ang)*\c},{\v*\c*sin(\ang)+0.5*\g*(\c^2)}); \coordinate (M) at (axis cs:{\v*cos(\ang)*\c+\s*\v*cos(\ang))},{\v*\c*sin(\ang)+0.5*\g*\c^2+\s*(\v*sin(\ang)+\g*\c)}); \draw[very thick,->](L)--(M) node[midway,sloped,above,font=\tiny]{$\vec{V}$}; \path plot[mark=*] coordinates {(L)}; %vector 1/2 down \pgfmathsetmacro{\d}{{(-1*(2/\g)*\v*sin(\ang))*0.75}} \coordinate (P) at (axis cs:{\v*cos(\ang)*\d},{\v*\d*sin(\ang)+0.5*\g*(\d^2)}); \coordinate (Q) at (axis cs:{(\v*cos(\ang)*\d+\s*\v*cos(\ang))},{\v*\d*sin(\ang)+0.5*\g*\d^2+\s*(\v*sin(\ang)+\g*\d)}); \coordinate (O) at (axis cs:{\v*cos(\ang)*\d},{\v*\c*sin(\ang)+0.5*\g*(\c^2)}); \draw[very thick,->](P)--(Q) node[right, at end,font=\tiny]{$\vec{V}$}; \draw[very thick,->](O)--(Q |- O) node[midway,above,font=\tiny]{$\vec{V}$}; \draw[densely dashed,very thick,->](P)--(Q|-P) node[midway,above,font=\tiny]{$\vec{V}_x$}; \draw[densely dashed,very thick,->](P)--(Q-|P) node[midway,left,font=\tiny]{$\vec{V}_y$}; \path plot[mark=*] coordinates {(P)}; \path plot[mark=*] coordinates {(O)}; %vector 3/4 down \pgfmathsetmacro{\f}{{(-1*(2/\g)*\v*sin(\ang))*0.6}} \coordinate (R) at (axis cs:{\v*cos(\ang)*\f},{\v*\f*sin(\ang)+0.5*\g*(\f^2)}); \coordinate (S) at (axis cs:{(\v*cos(\ang)*\f+\s*\v*cos(\ang))},{\v*\f*sin(\ang)+0.5*\g*\f^2+\s*(\v*sin(\ang)+\g*\f)}); \coordinate (V) at (axis cs:{\v*cos(\ang)*\f},{\v*\c*sin(\ang)+0.5*\g*(\c^2)}); \draw[very thick,->](R)--(S) node[right, at end,font=\tiny]{$\vec{V}$}; \draw[very thick,->](V)--(S |- V) node[midway,above,font=\tiny]{$\vec{V}$}; \draw[densely dashed,very thick,->](R)--(S|-R) node[right, at end,font=\tiny]{$\vec{V}_x$}; \draw[densely dashed,very thick,->](R)--(S-|R) node[at end,below,font=\tiny]{$\vec{V}_y$}; \path plot[mark=*] coordinates {(R)}; \path plot[mark=*] coordinates {(V)}; %vector 1/4 down \pgfmathsetmacro{\e}{{(-1*(2/\g)*\v*sin(\ang))*0.875}} \coordinate (T) at (axis cs:{\v*cos(\ang)*\e},{\v*\e*sin(\ang)+0.5*\g*(\e^2)}); \coordinate (U) at (axis cs:{(\v*cos(\ang)*\e+\s*\v*cos(\ang))},{\v*\e*sin(\ang)+0.5*\g*\e^2+\s*(\v*sin(\ang)+\g*\e)}); \coordinate (W) at (axis cs:{\v*cos(\ang)*\e},{\v*\c*sin(\ang)+0.5*\g*(\c^2)}); \draw[very thick,->](T)--(U) node[right, at end,font=\tiny]{$\vec{V}$}; \draw[very thick,->](W)--(U |- W) node[midway,above,font=\tiny]{$\vec{V}$}; \draw[densely dashed,very thick,->](T)--(U|-T) node[midway,above,font=\tiny]{$\vec{V}_x$}; \draw[densely dashed,very thick,->](T)--(U-|T) node[midway,left,font=\tiny]{$\vec{V}_y$}; \path plot[mark=*] coordinates {(T)}; \path plot[mark=*] coordinates {(W)}; \end{axis} \end{tikzpicture} \end{document} With foreach: \begin{tikzpicture}[transform shape] %horizontal projection %variable definitions \def\g{-9.8} %gravity \def\v{10} %velocity \def\ang{51} %angle \def\s{0.1} \pgfmathsetmacro{\c}{{(-1*(2/\g)*\v*sin(\ang))/2}} \begin{axis}[ width=.45\linewidth, %set bigger width height=2.2in, xmin={{\v*cos(\ang)*\c}},xmax=11.5, ymin=0,ymax={\v*\c*sin(\ang)+0.5*\g*(\c^2)},, xlabel=$x$, ylabel=$600 m$, axis x line = bottom, axis y line = left, y axis line style={-}, ticks = none,clip=false, ] \tikzset{every mark/.append style={fill=white}} %flight path \addplot[ dashed, domain={\v*cos(\ang)*\c}:10, samples=100,] {{\g*(x^2)/(2*\v^2*cos(\ang)^2)+x*tan(\ang)}}; %flight path \addplot[ dashed, domain=5:10, samples=100,] {{\v*\c*sin(\ang)+0.5*\g*(\c^2)}}; %vector at end \pgfmathsetmacro{\a}{{-1*(2/\g)*\v*sin(\ang)}} \coordinate (E) at (axis cs:{\v*cos(\ang)*\a},{\v*\a*sin(\ang)+0.5*\g*(\a^2)}){}; \coordinate (F) at (axis cs:{\v*cos(\ang)*\a+\s*\v*cos(\ang))}, {\v*\a*sin(\ang)+0.5*\g*\a^2+\s*(\v*sin(\ang)+\g*\a)}); \coordinate (G) at (axis cs:{\v*cos(\ang)*\a},{\v*\c*sin(\ang)+0.5*\g*(\c^2)}); \draw[very thick,->](E)--(F) node[right, at end,font=\tiny]{$\vec{V}$}; \draw[very thick,->](G)--(F |- G) node[midway,above,font=\tiny]{$\vec{V}$}; \draw[densely dashed,very thick,->](E)--(F |- E) node[midway,above,font=\tiny]{$\vec{V}_x$}; \draw[densely dashed,very thick,->](E)--(F-| E) node[midway,left,font=\tiny]{$\vec{V}_y$}; \path plot[mark=*] coordinates {(E)}; \path plot[mark=*] coordinates {(G)}; %vector at start \pgfmathsetmacro{\c}{{(-1*(2/\g)*\v*sin(\ang))/2}} \coordinate (L) at (axis cs:{\v*cos(\ang)*\c},{\v*\c*sin(\ang)+0.5*\g*(\c^2)}); \coordinate (M) at (axis cs:{\v*cos(\ang)*\c+\s*\v*cos(\ang))},{\v*\c*sin(\ang)+0.5*\g*\c^2+\s*(\v*sin(\ang)+\g*\c)}); \draw[very thick,->](L)--(M) node[midway,sloped,above,font=\tiny]{$\vec{V}$}; \path plot[mark=*] coordinates {(L)}; \foreach \terd in {0.6,0.75,0.875} { \pgfmathsetmacro{\d}{{(-1*(2/\g)*\v*sin(\ang))*\terd}} \coordinate (P) at (axis cs:{\v*cos(\ang)*\d},{\v*\d*sin(\ang)+0.5*\g*(\d^2)}); \coordinate (Q) at (axis cs:{(\v*cos(\ang)*\d+\s*\v*cos(\ang))},{\v*\d*sin(\ang)+0.5*\g*\d^2+\s*(\v*sin(\ang)+\g*\d)}); \coordinate (O) at (axis cs:{\v*cos(\ang)*\d},{\v*\c*sin(\ang)+0.5*\g*(\c^2)}); \draw[very thick,->](P)--(Q) node[right, at end,font=\tiny]{$\vec{V}$}; \draw[very thick,->](O)--(Q |- O) node[midway,above,font=\tiny]{$\vec{V}$}; \draw[densely dashed,very thick,->](P)--(Q|-P) node[midway,above,font=\tiny]{$\vec{V}_x$}; \draw[densely dashed,very thick,->](P)--(Q-|P) node[midway,left,font=\tiny]{$\vec{V}_y$}; \path plot[mark=*] coordinates {(P)}; \path plot[mark=*] coordinates {(O)}; } \end{axis} \end{tikzpicture}
- tikz draw of solid effect of stack of unit cube legos: for mathlinksby Epa on February 4, 2026 at 8:06 am
How to make the solid effect view better, as shown in the photo attached? \documentclass[]{standalone} \usepackage{amsmath, amssymb, latexsym, amscd, amsthm} \usepackage{tikz} \newcommand{\drawboxa}[4]{ \pgfmathsetmacro \angle {30} \pgfmathsetmacro \xd {{2/3*cos(\angle)}} \pgfmathsetmacro \yd {{2/3*sin(\angle)}} \pgfmathsetmacro \x {{#1-1+(#2-1)*(\xd)}} \pgfmathsetmacro \y {{#3-1+(#2-1)*(\yd)}} \draw[fill=#4] (\x,\y) -- (\x+1,\y) -- (\x+1,\y+1) -- (\x,\y+1) -- cycle; \draw[fill=#4] (\x,\y+1) -- (\x+\xd,\y+1+\yd)coordinate[pos=.5](M) -- (\x+1+\xd,\y+1+\yd) -- (\x+1,\y+1) -- cycle; \draw[fill=#4] (\x+1,\y+1) -- (\x+1+\xd,\y+1+\yd) -- (\x+1+\xd,\y+\yd)coordinate[pos=.5](M2) -- (\x+1,\y)-- (\x+1,\y+1)coordinate[pos=.5](M3); \path(M2)--(M3)coordinate[pos=.5](M4); \draw[fill=#4] (M)++(.5,0)coordinate(T1)++(.15,0)arc(0:-180:.15cm and .06cm)--++(0,.1)arc(-180:0:.15cm and .06cm)coordinate(T2)--++(0,-.1) (T2)arc(0:180:.15cm and .06cm); \draw[fill=black,opacity=.1](M4)circle(.12cm and .15cm) (\x,\y)++(.5,.5)circle(.15); \draw(M4)circle(.12cm and .15cm) (\x,\y)++(.5,.5)circle(.15); } \newcommand{\drawboxb}[3]{ \pgfmathsetmacro \angle {30} \pgfmathsetmacro \xd {{2/3*cos(\angle)}} \pgfmathsetmacro \yd {{2/3*sin(\angle)}} \pgfmathsetmacro \x {{#1-1+(#2-1)*(\xd)}} \pgfmathsetmacro \y {{#3-1+(#2-1)*(\yd)}} \draw[fill=white] (\x,\y) -- (\x+1,\y) -- (\x+1,\y+1) -- (\x,\y+1) -- cycle; \draw[fill=white] (\x,\y+1) -- (\x+\xd,\y+1+\yd)coordinate[pos=.5](M) -- (\x+1+\xd,\y+1+\yd) -- (\x+1,\y+1) -- cycle; \draw[fill=white] (\x+1,\y+1) -- (\x+1+\xd,\y+1+\yd) -- (\x+1+\xd,\y+\yd)coordinate[pos=.5](M2) -- (\x+1,\y)-- (\x+1,\y+1)coordinate[pos=.5](M3); \path(M2)--(M3)coordinate[pos=.5](M4); \draw[fill=white] (M)++(.55,0)coordinate(T1)++(.15,0)arc(0:-180:.2cm and .07cm)--++(0,.1)arc(-180:0:.2cm and .07cm)coordinate(T2)--++(0,-.1) (T2)arc(0:180:.2cm and .07cm) (T2)++(-.2,0)circle(.16cm and .04cm); \draw(M4)circle(.15cm and .2cm)circle(.11cm and .16cm) (\x,\y)++(.5,.5)circle(.2)circle(.15); } \usepackage{tikzbricks} %\printanswers \newcommand{\drawboxc}[4]{ \pgfmathsetmacro \angle {30} \pgfmathsetmacro \xd {{2/3*cos(\angle)}} \pgfmathsetmacro \yd {{2/3*sin(\angle)}} \pgfmathsetmacro \x {{#1-1+(#2-1)*(\xd)}} \pgfmathsetmacro \y {{#3-1+(#2-1)*(\yd)}} \draw[fill=#4] (\x,\y) -- (\x+1,\y) -- (\x+1,\y+1) -- (\x,\y+1) -- cycle; \draw[fill=#4] (\x,\y+1) -- (\x+\xd,\y+1+\yd)coordinate[pos=.5](M) -- (\x+1+\xd,\y+1+\yd) -- (\x+1,\y+1) -- cycle; \draw[fill=#4] (\x+1,\y+1) -- (\x+1+\xd,\y+1+\yd) -- (\x+1+\xd,\y+\yd)coordinate[pos=.5](M2) -- (\x+1,\y)-- (\x+1,\y+1)coordinate[pos=.5](M3); \path(M2)--(M3)coordinate[pos=.5](M4)coordinate[pos=.4](M5); \draw[fill=#4](M4)circle(.12cm and .15cm)++(0,.15)coordinate(Y1)++(0,-.15)coordinate(Y2); \draw[fill=#4](M5)++(0,-.025)circle(.12cm and .15cm)++(0,.15)coordinate(Y3)++(0,-.3)coordinate(Y4) (Y3)--(Y1)arc(90:270:.12cm and .15cm)--(Y4)arc(270:90:.12cm and .15cm); \draw[fill=black,opacity=.1](\x,\y)++(.5,.5)circle(.15) (M)++(.5,0)coordinate(T1)circle(.15cm and .06cm); \draw(\x,\y)++(.5,.5)circle(.15) (T1)circle(.15cm and .06cm); } \begin{document} \begin{tikzpicture} \def\x{3} %so luong block \foreach\h in{1,...,\x}{ \drawboxa{1}{1}{\h}{blue!25} } \def\d{.3} \draw(1,-\d) node[scale=1.3]{3}; \draw(.8,\x+1.2*\d) node[scale=1.2, above]{three}; \begin{scope}[xshift=100] \def\x{2} %so luong block \foreach\h in{1,...,\x}{ \drawboxa{1}{1}{\h}{blue!25} } \draw(1,-\d) node[scale=1.3]{2}; \draw(.8,\x+1.2*\d) node[scale=1.2, above]{two}; \end{scope} \begin{scope}[xshift=200] \def\x{5} %so luong block \foreach\h in{1,...,\x}{ \drawboxa{1}{1}{\h}{blue!25} } \draw(1,-\d) node[scale=1.3]{5}; \draw(.8,\x+1.2*\d) node[scale=1.2, above]{five}; \end{scope} \end{tikzpicture} \vspace{1cm} \begin{tikzpicture} \def\x{5} %so luong block %drawbox{x}{z}{y} %x la toa do x %z la toa do lop tinh theo goc xien %y la toa do y \drawboxb{1}{0}{0} \end{tikzpicture} \begin{tikzpicture} \def\x{5} % so luong block xanh \def\v{2} % so luong block vang \def\b{1} % so luong block xanh duong \pgfmathtruncatemacro{\xx}{\x+1} \pgfmathtruncatemacro{\vv}{\x+\v} \pgfmathtruncatemacro{\vvv}{\vv+1} \pgfmathtruncatemacro{\bb}{\vv+\b} \ifnum\x>0 \foreach \h in {1,...,\x}{ \drawboxc{\h}{1}{1}{brown!35} } \fi \ifnum\v>0 \foreach \h in {\xx,...,\vv}{ \drawboxc{\h}{1}{1}{yellow!55} } \fi \ifnum\b>0 \foreach \h in {\vvv,...,\bb}{ \drawboxc{\h}{1}{1}{blue!25} } \fi \end{tikzpicture} \end{document} The code was from user 11232 How to draw stacked cubes of different sizes and colors?
- Simplifying an Asymptote figure for spherical coordinatesby Sebastiano on January 26, 2026 at 12:58 pm
I refer to the second code by the user Chris Chudzicki: % Source - https://tex.stackexchange.com/a/160528 % Posted by Chris Chudzicki, modified by community. See post 'Timeline' for change history % Retrieved 2026-01-26, License - CC BY-SA 3.0 \documentclass{article} \usepackage{asymptote} \begin{document} \begin{asy}[width=\textwidth] settings.render=6; settings.prc=false; import three; import graph3; import grid3; currentprojection=obliqueX; //Draw Axes pen thickblack = black+0.75; real axislength = 1.0; draw(L=Label("$x$", position=Relative(1.1), align=SW), O--axislength*X,thickblack, Arrow3); draw(L=Label("$y$", position=Relative(1.1), align=E), O--axislength*Y,thickblack, Arrow3); draw(L=Label("$z$", position=Relative(1.1), align=N), O--axislength*Z,thickblack, Arrow3); //Set parameters of start corner of polar volume element real r = 1; real q=0.25pi; //theta real f=0.3pi; //phi real dq=0.15; //dtheta real df=0.15; //dphi real dr=0.15; triple A = r*expi(q,f); triple Ar = (r+dr)*expi(q,f); triple Aq = r*expi(q+dq,f); triple Arq = (r+dr)*expi(q+dq,f); triple Af = r*expi(q,f+df); triple Arf = (r+dr)*expi(q,f+df); triple Aqf = r*expi(q+dq,f+df); triple Arqf = (r+dr)*expi(q+dq,f+df); pen thingray = gray+0.33; draw(A--Ar); draw(Aq--Arq); draw(Af--Arf); draw(Aqf--Arqf); draw( arc(O,A,Aq) ,thickblack ); draw( arc(O,Af,Aqf),thickblack ); draw( arc(O,Ar,Arq) ); draw( arc(O,Arf,Arqf) ); draw( arc(O,Ar,Arq) ); draw( arc(O,A,Af),thickblack ); draw( arc(O,Aq,Aqf),thickblack ); draw( arc(O,Ar,Arf) ); draw( arc(O,Arq,Arqf) ); pen thinblack = black+0.25; //phi arcs draw(O--expi(pi/2,f),thinblack); draw("$\varphi$", arc(O,0.5*X,0.5*expi(pi/2,f)),thinblack,Arrow3); draw(O--expi(pi/2,f+df),thinblack); draw( "$d\varphi$", arc(O,expi(pi/2,f),expi(pi/2,f+df) ),thinblack ); draw( A.z*Z -- A,thinblack); draw(L=Label("$r\sin{\theta}$",position=Relative(0.5),align=N), A.z*Z -- Af,thinblack); //cotheta arcs draw( arc(O,Aq,expi(pi/2,f)),thinblack ); draw( arc(O,Aqf,expi(pi/2,f+df) ),thinblack); //theta arcs draw(O--A,thinblack); draw(O--Aq,thinblack); draw("$\theta$", arc(O,0.25*length(A)*Z,0.25*A),thinblack,Arrow3); draw(L=Label("$d\theta$",position=Relative(0.5),align=NE) ,arc(O,0.66*A,0.66*Aq),thinblack ); // inner surface triple rin(pair t) { return r*expi(t.x,t.y);} surface inner=surface(rin,(q,f),(q+dq,f+df),16,16); draw(inner,emissive(gray+opacity(0.33))); //part of a nearly transparent sphere to help see perspective surface sphere=surface(rin,(0,0),(pi/2,pi/2),16,16); draw(sphere,emissive(gray+opacity(0.125))); // dr and rdtheta labels triple V= Af + 0.5*(Arf-Af); draw(L=Label("$dr$",position=Relative(1.1)), V--(1.5*V.x,1.5*V.y,V.z),dotted); triple U=expi(q+0.5*dq,f); draw(L=Label("$rd\theta$",position=Relative(1.1)), r*U ---r*(1.66*U.x,1.66*U.y,U.z),dotted ); \end{asy} \end{document} The code uses asymptote package to represent a volume element in spherical coordinates. Asymptote appears to be correctly installed in my MiKTeX distribution; however, the document does not compile and produces the following error: Package asymptote Warning: file `spy-1.pdf' not found on input line 15. (spy.aux)) No pages of output. Transcript written on spy.log. Sorry, but "MiKTeX Compiler Driver" did not succeed. I do not use Asymptote very often, so I am not sure about the cause of the problem. It is possible that the solution is related to what is discussed in the following TeX.StackExchange threads: 'filename-1.pdf' not found Asymptote Asymptote Code Generates .asy Files, But Asymptote Execution Fails In particular, I have not yet tried the solution proposed by the user user279206, and I do not know whether there is an alternative approach that would allow me to compile the document correctly with my MiKTeX distribution. In a previous question, I also asked whether it is possible to obtain the same arrow tip styles provided by Asymptote using TikZ: Arrows with spherical (conical) tips Since I do not understand Asymptote code, I kindly ask whether it would be possible to modify the original code by removing everything that is not strictly necessary, in order to obtain only the figure related to spherical coordinates, without the volume element and without additional unnecessary details to obtain this with the portion of a sphere. In TikZ there is a result: https://tikz.net/spherical_1/ This is my goal:
- Shuffle the puzzle pieces in TikZ interactive puzzle game (based on this TeX.SX project)by fsbmat on January 23, 2026 at 12:59 am
I’ve been working on a variation of the interactive puzzle from this excellent post on TeX StackExchange: 🔗 The TikZ Game Package – a TeX.SX Project ❓Goal I'd like to shuffle the pieces of the puzzle at the start (instead of them being in order) and still keep the interactive movement functionality working (i.e. clicking tiles to move them like a sliding puzzle). ✅ What I have working The puzzle layout builds correctly using TikZ, ocgx2, and media9. I implemented a manual shuffle using a LaTeX macro (\ShuffleIndex) to define the tile order. The initial view of the puzzle shows the image shuffled correctly. ❌ What is broken The JavaScript interaction no longer works after applying the shuffle. Clicking on the tiles gives an error: ReferenceError: onButtonClick is not defined It seems the function is not visible globally or the OCGs are not properly indexed. 💡 What I'm asking Would anyone be able to: Help fix the JavaScript so it works with the shuffled layout? Or alternatively — provide a working example based on the original post, but with the puzzle pieces already shuffled at start? 📎 What I’ve tried Here’s my current version (almost working, but with JS errors): \documentclass[tikz,margin=1mm]{standalone} \usepackage{xsavebox} \usepackage[tikz]{ocgx2} \usepackage{media9} \usepackage{multido} \usepackage{xcolor}\pagecolor{gray} \usepackage{multido} \usepackage{ifluatex} \ifluatex\def\pdfpageattr{\pdfvariable pageattr}\fi \usepackage{tikzmarmots} % imagem base \begin{xlrbox}{Image} \begin{tikzpicture} \useasboundingbox (0,0) rectangle (4.4,4.4); \node at (2.2,2.2) {\tikz\marmot[scale=2.1];}; \end{tikzpicture} \end{xlrbox} % peças do puzzle \multido{\nX=0+1.1,\iI=0+1}{4}{% \multido{\nY=3.3+-1.1,\iJ=0+1}{4}{% \ifnum\numexpr\iI+\iJ\relax>0 \begin{xlrbox}{Image.\the\numexpr\iI+\iJ*4\relax} \begin{tikzpicture} \clip (\nX,\nY) rectangle ++(1.1,1.1); \node[anchor=south west,inner sep=0pt] at (0,0) {\theImage}; \end{tikzpicture} \end{xlrbox} \fi } } \newcommand\MyStatus[2]{\ifnum#1=#2 visible\else invisible\fi} % JavaScript \pdfpageattr{ /AA << /O << /S/JavaScript /JS ( var tile=[], oldTile=[]; for(var i=0;i<4;i++){ tile[i]=[]; oldTile[i]=[]; for(var j=0;j<4;j++){ tile[i][j]=[]; oldTile[i][j]=i+j*4-1; } } var ocg=this.getOCGs(this.pageNum); for(var k in ocg){ var n=ocg[k].name.split('.'); tile[n[0]][n[1]][n[2]-1]=ocg[k]; } var si=0,sj=0; function onButtonClick(i,j){ if(si==i && sj!=j){ for(var y=sj;y!=j;sj<j?y++:y--){ if(y!=sj) tile[i][y][oldTile[i][y]].state=false; oldTile[i][y]=oldTile[i][sj<j?y+1:y-1]; tile[i][y][oldTile[i][y]].state=true; } } else if(sj==j && si!=i){ for(var x=si;x!=i;si<i?x++:x--){ if(x!=si) tile[x][j][oldTile[x][j]].state=false; oldTile[x][j]=oldTile[si<i?x+1:x-1][j]; tile[x][j][oldTile[x][j]].state=true; } } if(si==i||sj==j){ if(oldTile[i][j]>-1) tile[i][j][oldTile[i][j]].state=false; oldTile[i][j]=-1; si=i; sj=j; } } ) >> >> } \def\ShuffleIndex#1{% \csname ShuffleValue#1\endcsname% } \expandafter\def\csname ShuffleValue0\endcsname{5} \expandafter\def\csname ShuffleValue1\endcsname{12} \expandafter\def\csname ShuffleValue2\endcsname{3} \expandafter\def\csname ShuffleValue3\endcsname{14} \expandafter\def\csname ShuffleValue4\endcsname{1} \expandafter\def\csname ShuffleValue5\endcsname{6} \expandafter\def\csname ShuffleValue6\endcsname{11} \expandafter\def\csname ShuffleValue7\endcsname{9} \expandafter\def\csname ShuffleValue8\endcsname{8} \expandafter\def\csname ShuffleValue9\endcsname{2} \expandafter\def\csname ShuffleValue10\endcsname{7} \expandafter\def\csname ShuffleValue11\endcsname{10} \expandafter\def\csname ShuffleValue12\endcsname{15} \expandafter\def\csname ShuffleValue13\endcsname{4} \expandafter\def\csname ShuffleValue14\endcsname{13} \expandafter\def\csname ShuffleValue15\endcsname{0} \begin{document} \newcount\shufcount \shufcount=0 \begin{tikzpicture} \multido{\nX=0+1.1,\iI=0+1}{4}{% \multido{\nY=3.3+-1.1,\iJ=0+1}{4}{% \edef\CellIndex{\the\numexpr\iI+\iJ*4\relax}% \edef\RandIndex{\ShuffleIndex{\CellIndex}}% \multido{\iK=1+1}{15}{% \begin{scope}[ocg={ref=\iI.\iJ.\iK,% status=\MyStatus{\ShuffleIndex{\the\numexpr\iI+\iJ*4\relax}}{\iK}}]% \node[anchor=south west,inner sep=0pt]% at (\nX,\nY) {\xusebox{Image.\iK}};% \end{scope}% }% \draw[line width=0,% postaction={% path picture={% \node[anchor=south west,inner sep=0pt]% at (path picture bounding box.south west)% {\mediabutton[jsaction={onButtonClick(\iI,\iJ);}]{% \tikz \useasboundingbox% (path picture bounding box.south west)% rectangle% (path picture bounding box.north east);}};% }% }]% (\nX,\nY) rectangle ++(1.1,1.1);% }% }% \end{tikzpicture} \end{document} I made the following change to the code: \documentclass[tikz,margin=1mm]{standalone} \usepackage{xsavebox} \usepackage[tikz]{ocgx2} \usepackage{media9} \usepackage{multido} \usepackage{xcolor}\pagecolor{gray} \usepackage{multido} \usepackage{ifluatex} \ifluatex\def\pdfpageattr{\pdfvariable pageattr}\fi \usepackage{tikzmarmots} % imagem base \begin{xlrbox}{Image} \begin{tikzpicture} \useasboundingbox (0,0) rectangle (4.4,4.4); \node at (2.2,2.2) {\tikz\marmot[scale=2.1];}; \end{tikzpicture} \end{xlrbox} % peças do puzzle \multido{\nX=0+1.1,\iI=0+1}{4}{% \multido{\nY=3.3+-1.1,\iJ=0+1}{4}{% \ifnum\numexpr\iI+\iJ\relax>0 \begin{xlrbox}{Image.\the\numexpr\iI+\iJ*4\relax} \begin{tikzpicture} \clip (\nX,\nY) rectangle ++(1.1,1.1); \node[anchor=south west,inner sep=0pt] at (0,0) {\theImage}; \end{tikzpicture} \end{xlrbox} \fi } } \newcommand\MyStatus[2]{\ifnum#1=#2 visible\else invisible\fi} % JavaScript \pdfpageattr{ /AA << /O << /S/JavaScript /JS ( var tile=[], oldTile=[]; for(var i=0;i<4;i++){ tile[i]=[]; oldTile[i]=[]; for(var j=0;j<4;j++){ tile[i][j]=[]; oldTile[i][j]=i+j*4-1; } } var ocg=this.getOCGs(this.pageNum); for(var k in ocg){ var n=ocg[k].name.split('.'); tile[n[0]][n[1]][n[2]-1]=ocg[k]; } var si=0,sj=0; function onButtonClick(i,j){ if(si==i && sj!=j){ for(var y=sj;y!=j;sj<j?y++:y--){ if(y!=sj) tile[i][y][oldTile[i][y]].state=false; oldTile[i][y]=oldTile[i][sj<j?y+1:y-1]; tile[i][y][oldTile[i][y]].state=true; } } else if(sj==j && si!=i){ for(var x=si;x!=i;si<i?x++:x--){ if(x!=si) tile[x][j][oldTile[x][j]].state=false; oldTile[x][j]=oldTile[si<i?x+1:x-1][j]; tile[x][j][oldTile[x][j]].state=true; } } if(si==i||sj==j){ if(oldTile[i][j]>-1) tile[i][j][oldTile[i][j]].state=false; oldTile[i][j]=-1; si=i; sj=j; } } ) >> >> } \def\ShuffleIndex#1{% \csname ShuffleValue#1\endcsname% } \expandafter\def\csname ShuffleValue0\endcsname{5} \expandafter\def\csname ShuffleValue1\endcsname{12} \expandafter\def\csname ShuffleValue2\endcsname{3} \expandafter\def\csname ShuffleValue3\endcsname{14} \expandafter\def\csname ShuffleValue4\endcsname{1} \expandafter\def\csname ShuffleValue5\endcsname{6} \expandafter\def\csname ShuffleValue6\endcsname{11} \expandafter\def\csname ShuffleValue7\endcsname{9} \expandafter\def\csname ShuffleValue8\endcsname{8} \expandafter\def\csname ShuffleValue9\endcsname{2} \expandafter\def\csname ShuffleValue10\endcsname{7} \expandafter\def\csname ShuffleValue11\endcsname{10} \expandafter\def\csname ShuffleValue12\endcsname{15} \expandafter\def\csname ShuffleValue13\endcsname{4} \expandafter\def\csname ShuffleValue14\endcsname{13} \expandafter\def\csname ShuffleValue15\endcsname{0} \begin{document} \newcount\shufcount \shufcount=0 \begin{tikzpicture} \multido{\nX=0+1.1,\iI=0+1}{4}{% \multido{\nY=3.3+-1.1,\iJ=0+1}{4}{% \edef\CellIndex{\the\numexpr\iI+\iJ*4\relax}% \edef\RandIndex{\ShuffleIndex{\CellIndex}}% \multido{\iK=1+1}{15}{% \begin{scope}[ocg={ref=\iI.\iJ.\iK,% status=\MyStatus{\ShuffleIndex{\the\numexpr\iI+\iJ*4\relax}}{\iK}}]% \node[anchor=south west,inner sep=0pt]% at (\nX,\nY) {\xusebox{Image.\iK}};% \end{scope}% }% \draw[line width=0,% postaction={% path picture={% \node[anchor=south west,inner sep=0pt]% at (path picture bounding box.south west)% {\mediabutton[jsaction={onButtonClick(\iI,\iJ);}]{% \tikz \useasboundingbox% (path picture bounding box.south west)% rectangle% (path picture bounding box.north east);}};% }% }]% (\nX,\nY) rectangle ++(1.1,1.1);% }% }% \end{tikzpicture} \end{document} But when compiling and opening Adobe, the game displays errors! The main difference between the two codes is that the first version initializes the puzzle in its natural ordered state, while the second version attempts to introduce a manual shuffle at compilation time. In the first code, each grid cell determines its visible tile using the direct index \the\numexpr\iI+\iJ*4\relax, meaning the logical tile numbering matches the visual position expected by the JavaScript initialization (oldTile[i][j]=i+j*4-1). Thus, the OCG references, the visibility logic (\MyStatus), and the JavaScript tile matrix remain perfectly aligned. In contrast, the second code introduces a \ShuffleIndex mapping that reassigns which tile is visible in each cell by redefining the status condition through a precomputed permutation (ShuffleValue0–ShuffleValue15). Although the OCG naming convention (ref=\iI.\iJ.\iK) remains unchanged, the logical relationship between cell coordinates and tile indices is altered at the TeX level only. As a result, the visual layout becomes shuffled, but the JavaScript still assumes the original positional indexing when constructing oldTile, leading to a mismatch between the PDF layer structure and the JS tile state logic. In short, the first code preserves structural consistency between TeX indexing and JavaScript state management, whereas the second modifies only the initial visibility layer without updating the underlying JS tile model, which explains why interaction breaks after shuffling. I’d appreciate any tips or corrections. If I’m handling the OCG indexing or JavaScript scope wrong, please let me know how to fix it. Thanks in advance!
- How to draw an arrow?by Marcus on October 18, 2025 at 7:54 pm
How can I draw the following arrow? Here is the code for the boxes: \begin{tikzpicture} \def\w{2cm} \node[draw, rectangle, minimum width=\w, minimum height=1cm, anchor=west] (R1) at (0,0) {A}; \foreach [count=\i from 0] \letter in {A,B,C,D,E} { \node[draw, rectangle, minimum width=\w, minimum height=1cm, anchor=west] (R\i) at (\i*\w, 0) {\letter}; } \end{tikzpicture}
- Custom Sidebar Table of Contents in Beamerby wrb98 on September 17, 2024 at 2:15 pm
I'm working with a blank Beamer presentation template and want to recreate a sidebar similar to one shown in the image below. Unlike typical Beamer sidebars that extend to the page's edge, this one is part of a custom frame. I'd like the sidebar to display boxed sections with sharp drop shadows. The current section should be highlighted by a red shadow, while the current subsection should be bolded and appear on a white horizontal strip. Subsections from other sections should remain hidden until the presentation reaches that specific section, at which point they should appear in a dropdown list in the sidebar (e.g. in the image, we're on SO so subsections of SO are shown in the sidebar, but subsections of Section Two and Section Three are not). Note: By 'subsection' I really mean slide titles. How can I implement this effect in LaTeX? Any help would be appreciated. \documentclass[11pt]{beamer} \usepackage{tikz} \usepackage{microtype} \usepackage{xcolor} \usepackage{soul} \usetikzlibrary{calc} \usepackage{ lmodern, babel, amsmath, eurosym } \definecolor{darkpastelgreen}{rgb}{0.01, 0.75, 0.24} \usepackage[default]{sourcesanspro} \usepackage[T1]{fontenc} \setbeamertemplate{navigation symbols}{} \setbeamertemplate{background}{% \begin{tikzpicture}[overlay,remember picture] \fill[sharp corners,fill=darkpastelgreen] ($ (current page.north west) + (0.4cm,-0.4cm) $) rectangle ($ (current page.south east) + (-0.4cm,0.4cm) $); \end{tikzpicture}% \begin{tikzpicture}[overlay,remember picture] \fill[sharp corners,color=white] ($ (current page.north west) + (0.5cm,-0.5cm) $) rectangle ($ (current page.south east) + (-2cm,0.5cm) $); \end{tikzpicture}% } \setbeamersize{text margin left=0.8cm, text margin right=0.85cm} % Reduce side margins \setbeamertemplate{frametitle}{\color{black}\bfseries\insertframetitle \nointerlineskip \bigskip } \addtobeamertemplate{frametitle}{\vspace*{0cm}}{\vspace*{-0.4cm}} \addtolength{\headsep}{0.6cm} \begin{document} \begin{frame}[t]{} \frametitle{A Subsection} Slide content goes here... \end{frame} \end{document}
- How to draw tangent lines of equal length at three equidistant points on a curved path?by myhsia on February 7, 2024 at 2:11 pm
like the bend triangle below And the MWE is all I can draw. \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture} \draw (0,0) -- (4.5,0) -- (6,2) -- (1.5,2) -- cycle; \draw [xshift=3cm,yshift=1cm] (0,0) ellipse (1.2 and .6); \draw [xshift=3cm,yshift=1cm,->,teal] (0,.6) -- (.6,.6); \draw [xshift=3cm,yshift=1cm,->,teal] (1.2,0) -- (1.9,0); \draw [xshift=3cm,yshift=1cm,->,teal] (0,-.6) -- (.6,-.6); \draw [xshift=3cm,yshift=1cm,->,teal] ({-1.2*cos(30)},{-.6*sin(30)}) --++ (.6,0) node [above] {$v^a$}; \draw [xshift=3cm,yshift=1cm,->,teal] ({-1.2*cos(30)},{.6*sin(30)}) --++ (.6,0); \shade [xshift=3cm,yshift=1cm,ball color=teal] (-1.2,0) circle (.06); \end{tikzpicture} \end{document} Current result:
- How can I draw a graph of adjacency matrix in Tikz?by MAHSA on October 6, 2023 at 12:31 am
I want to draw this picture, but I can't How can help me?
- How can I create a lightbox/microfilm effect?by crmdgn on October 25, 2020 at 12:15 am
I'm putting together a beamer presentation, and in a moment of madness I had the idea to give it a sort of lightbox/microfilm/transparency effect, sort of like this or this or this. I tend to keep my slides very simple, so this is new territory for me. The only thing I can think to do is some sort of tikz gradient, but that doesn't really get me what I want: \documentclass{standalone} \usepackage{tikz} \usepackage{tcolorbox} \begin{document} \begin{tikzpicture} \fill [black!20] (-0.5,-0.5) rectangle (1.5,1.5); \path [pattern color=black!30] (-0.5,-0.5) rectangle (1.5,1.5); \tcbvignette{fade in=black} \end{tikzpicture} \end{document} That gives you more of a picture frame effect with mitered corners, as here: Is there another approach I can be taking? Is this even within the limits of tikz?
- How to make a tkz-tab red?by Romain on May 4, 2020 at 7:01 am
I need this tkz-tab \usepackage{tikz,tkz-tab} \begin{document} \begin{tikzpicture} \tkzTabInit{$x$ / 1 , $f\left(x\right)$ / 1}{$-\infty$ , $-\frac{b}{a}$ , $+\infty$} \tkzTabLine{ , \text{Opposé signe } a , z , \text{Signe de } a , } \end{tikzpicture} \end{document} to be red. The whole of it, text, lines, everything. I can't find anything on this forum and I tried to put a [color=red] next to the commands but it only gave me an error. PS: the text in the tab is in French but don't worry 😉
- Seven segment display with TikZby current_user on January 6, 2019 at 5:36 pm
Consider the following MWE: \documentclass[border=5pt,tikz]{standalone} \usepackage{ifthen} \newcommand{\binary}[3]{ \pgfmathsetmacro\number{int(#1*2^0+#2*2^1+#3*2^2)} } \newcommand{\sieben}[1]{ \draw[gray,opacity=.3,line width=3pt] (0,0) --+ (0,.5); \draw[gray,opacity=.3,line width=3pt] (0,.6) --+ (0,.5); \draw[xshift=.7cm,gray,opacity=.3,line width=3pt] (0,0) --+ (0,.5); \draw[xshift=.7cm,gray,opacity=.3,line width=3pt] (0,.6) --+ (0,.5); \draw[gray,opacity=.3,line width=3pt] (.1,1.18) --+ (.5,0); \draw[gray,opacity=.3,line width=3pt] (.1,-.05) --+ (.5,0); \draw[gray,opacity=.3,line width=3pt] (.1,.55) --+ (.5,0); \ifthenelse{\equal{#1}{0}}{ \draw[red,line width=3pt] (0,0) --+ (0,.5); \draw[red,line width=3pt] (0,.6) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,0) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,.6) --+ (0,.5); \draw[red,line width=3pt] (.1,1.18) --+ (.5,0); \draw[red,line width=3pt] (.1,-.05) --+ (.5,0); }{} \ifthenelse{\equal{#1}{1}}{ \draw[xshift=.7cm,red,line width=3pt] (0,0) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,.6) --+ (0,.5); }{} \ifthenelse{\equal{#1}{2}}{ \draw[red,line width=3pt] (.1,1.18) --+ (.5,0);; \draw[xshift=.7cm,red,line width=3pt] (0,.6) --+ (0,.5); \draw[red,line width=3pt] (.1,.55) --+ (.5,0); \draw[red,line width=3pt] (0,0) --+ (0,.5); \draw[red,line width=3pt] (.1,-.05) --+ (.5,0); }{} \ifthenelse{\equal{#1}{3}}{ \draw[xshift=.7cm,red,line width=3pt] (0,0) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,.6) --+ (0,.5); \draw[red,line width=3pt] (.1,1.18) --+ (.5,0); \draw[red,line width=3pt] (.1,-.05) --+ (.5,0); \draw[red,line width=3pt] (.1,.55) --+ (.5,0); }{} \ifthenelse{\equal{#1}{4}}{ \draw[red,line width=3pt] (0,.6) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,0) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,.6) --+ (0,.5); \draw[red,line width=3pt] (.1,.55) --+ (.5,0); }{} \ifthenelse{\equal{#1}{5}}{ \draw[red,line width=3pt] (0,.6) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,0) --+ (0,.5); \draw[red,line width=3pt] (.1,1.18) --+ (.5,0); \draw[red,line width=3pt] (.1,.55) --+ (.5,0); \draw[red,line width=3pt] (.1,-.05) --+ (.5,0); }{} \ifthenelse{\equal{#1}{6}}{ \draw[red,line width=3pt] (0,0) --+ (0,.5); \draw[red,line width=3pt] (0,.6) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,0) --+ (0,.5); \draw[red,line width=3pt] (.1,1.18) --+ (.5,0); \draw[red,line width=3pt] (.1,-.05) --+ (.5,0); \draw[red,line width=3pt] (.1,.55) --+ (.5,0); }{} \ifthenelse{\equal{#1}{7}}{ \draw[xshift=.7cm,red,line width=3pt] (0,0) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,.6) --+ (0,.5); \draw[red,line width=3pt] (.1,1.18) --+ (.5,0); }{} \ifthenelse{\equal{#1}{8}}{ \draw[red,line width=3pt] (0,0) --+ (0,.5); \draw[red,line width=3pt] (0,.6) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,0) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,.6) --+ (0,.5); \draw[red,line width=3pt] (.1,1.18) --+ (.5,0); \draw[red,line width=3pt] (.1,-.05) --+ (.5,0); \draw[red,line width=3pt] (.1,.55) --+ (.5,0); }{} \ifthenelse{\equal{#1}{9}}{ \draw[red,line width=3pt] (0,.6) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,0) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,.6) --+ (0,.5); \draw[red,line width=3pt] (.1,1.18) --+ (.5,0); \draw[red,line width=3pt] (.1,-.05) --+ (.5,0); \draw[red,line width=3pt] (.1,.55) --+ (.5,0); }{} \ifthenelse{\equal{#1}{a}}{ \draw[red,line width=3pt] (0,0) --+ (0,.5); \draw[red,line width=3pt] (0,.6) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,0) --+ (0,.5); \draw[xshift=.7cm,red,line width=3pt] (0,.6) --+ (0,.5); \draw[red,line width=3pt] (.1,1.18) --+ (.5,0); \draw[red,line width=3pt] (.1,.55) --+ (.5,0); }{} % \ifnum#1>9 % \draw[red,line width=3pt] (0,0) --+ (0,.5); % \draw[red,line width=3pt] (0,.6) --+ (0,.5); % \draw[red,line width=3pt] (.1,1.18) --+ (.5,0); % \draw[red,line width=3pt] (.1,-.05) --+ (.5,0); % \draw[red,line width=3pt] (.1,.55) --+ (.5,0); % \fi } \begin{document} \begin{tikzpicture}[xslant=0] \sieben{a} \begin{scope}[xshift=1.5cm] \binary{1}{1}{1} % seven in dual system \sieben{\number} \end{scope} \end{tikzpicture} \end{document} Here is the output: My problem is: When I uncomment the commented part in the definition of the command (\ifnum#1>9 …) and I type as an argument the letter "a", I get an error. But when I comment this part, I don't. My question is: How can I fix this error?
- Adding vertical hierarchy lines to a category column of a tableby badroit on August 8, 2014 at 8:15 pm
I often need to represent hierarchies within tables but I've yet to find an elegant way to do this. Oftentimes I do a variation on the following theme, with nested whitespace in the category column: \documentclass{article} \usepackage{booktabs} \newcommand{\lvl}{~~~} \begin{document} \begin{tabular}{lr} \toprule \textbf{Category} & \textbf{\%}\\ \midrule Animal & 100 \\ \lvl Human & 50 \\ \lvl\lvl Man & 20 \\ \lvl\lvl Woman & 30 \\ \lvl Fox & 30 \\ \lvl\lvl Vixen & 16 \\ \lvl\lvl Dog & 14 \\ \lvl Chicken & 20 \\ \lvl\lvl Cock & 8 \\ \lvl\lvl Hen & 12 \\ \bottomrule \end{tabular} \end{document} I might mix that up with midrules between categories and different fonts for different levels and so on. But the result can sometimes be very "busy", especially if there's a bunch of levels. Instead, I was playing around with the idea of adding lines to more elegantly represent the hierarchy, sketched as follows in red (a similar effect in the same spirit would also suffice): But I'm not sure how to realise this in LaTeX in an elegant way. I'm guessing I could somehow decorate a table with TikZ but I'd only know how to specify manual points (e.g., I'm not sure how to anchor rows in a table). Thus I'm looking for any suggestions of elegant solutions to achieve the above effect. (An ideal answer would avoid explicit coordinates/distances and would be "highly reusable".)
- LaTeX Beamer, TikZ and overlays — page numbering issueby georgmierau on March 20, 2014 at 10:09 am
I'm using \onslide<…-> for overlays in TikZ: \documentclass{beamer} \usepackage{tikz} \setbeamertemplate{footline}{\insertpagenumber{}} \begin{document} \begin{frame} \begin{tikzpicture} \draw node[] at (0, 0) {$s_0$}; \onslide<2->{ \draw node[] at (1, 1) {$s_1$}; } \onslide<3->{ \draw node[] at (2, 2) {$s_2$}; } \end{tikzpicture} \end{frame} \end{document} …and there are no more annoying additional bullets in the headline for every single overlay, but the page number is still increasing (so I'm getting only one bullet but 1, 2, 3 as page numbers). Is there any solution this problem?
- How to insert a linebreak in a TikZ matrix node?by Tim N on May 6, 2013 at 6:34 am
How can I get a linebreak inside a matrix node? The following gives the error: Package tikz Error: Giving up on this path. Did you forget a semicolon?. unless I remove the linebreak. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{chains} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture} \matrix (m) [ matrix of nodes ] { {some text} & {this node \\ does not work} \\ {other text} & {more text} \\ }; \end{tikzpicture} \end{document}
- Overlay diagrams in TikZby MYaseen208 on December 6, 2012 at 3:28 pm
I want to join the vertices labeled as (1), b, abc, and ac but could not succeed. I'd highly appreciate if you point me out what I'm doing wrong and what is the solution. Thanks \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture}[scale = 4, fill opacity = 1.0, thick, line cap = round, line join = round] %% Define coordinate labels. % t(op) and b(ottom) layers \path \foreach \layer/\direction in {b/{0, 0, 0}, t/{0, 1, 0}} { (\direction) \foreach \point/\label in {{0, 0, 0}/ll, {1, 0, 0}/lr, {1, 0, -1}/ur, {0, 0, -1}/ul} { +(\point) coordinate (\layer\label) } ($(\layer ll)!0.5!(\layer ur)$) coordinate (\layer md) }; % Put text next to the labels as requested. % Funilly enough we need to set fill opacity to 1. \draw \foreach \text/\label/\anchor in {% $\left(1\right)$/bll/east, $b$/bul/east, $c$/tll/east, $bc$/tul/east, $a$/blr/west, $ab$/bur/west, $ac$/tlr/west, $abc$/tur/west} { (\label) node[anchor=\anchor, fill opacity = 1] {\text} }; % Draw cube. \fill (0, 0, -1) circle (0.5pt); \foreach \direction in {(0, 0, 1), (0, 1, 0), (1, 0, 0)} { \draw[dashed, black] (bul) -- + \direction; } \fill[red!60, opacity=0.5] (tll) -- (tul) -- (bur) -- (blr); \fill[blue!60, opacity=0.5] (bll) -- (bul) -- (tur) -- (tlr); \draw (bll) -- (blr) -- (tlr) -- (tll) -- cycle; \draw (blr) -- (bur) -- (tur) -- (tlr) -- cycle; \draw (tll) -- (tlr) -- (tur) -- (tul) -- cycle; \foreach \point in {bll, blr, bur, tll, tlr, tul, tur} { \fill[fill opacity=1] (\point) circle (0.75pt); } \node[below] at (1.0, -0.2, 0.0) {$AC$}; \end{tikzpicture} \end{document}
- Create a math matrix in TikZ partition linesby aagaard on August 26, 2011 at 3:51 pm
I want to draw a math matrix in TikZ, where I can draw helping partition lines. So far I found it pretty simple to just draw a matrix with brackets. \begin{tikzpicture} \matrix [matrix of math nodes,left delimiter={[},right delimiter={]}] { 1 & 2 & 1 & 0 & 0 & 10 \\ 3 & 2 & 0 & 1 & 0 & 20 \\ -2 & -10 & 0 & 0 & 1 & 0 \\ }; \end{tikzpicture} However, I would like to partition the matrix with a vertical line between columns 5 and 6, and a horizontal line between rows 2 and 3. Furthermore it could nice to have "identification variables" outside the brackets (top).
- How can I do this diagram with tikz?by Peter E on July 11, 2011 at 8:05 pm
How can I do this diagram with tikz?