TikZ
- Distortion between `axis` environment and `tikzpicture`'s coordinate system?by Explorer on July 14, 2025 at 5:59 pm
I learnt from this link that the axis and tikzpicture coordinate system is independent. Consider the following example: \documentclass[tikz,border=5pt]{standalone} \usepackage{ctex} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines = middle, xmin = -1, xmax = 5, ymin = -2, ymax = 6, name = theAxis, % anchor=origin ] \coordinate (A) at (axis cs:1,0); \draw[blue] (A) node[above] {start$A(1,0)$} --++ (axis cs:0,3) node[align=center] {end$B$\\ Actually$(2,5)$?};% question here for (1,0)--++(0,3) inside axis \fill[blue] (0,0) circle[radius=2pt] node[below,align=center] {origin inside\\$O(0,0)$}; \draw[-latex,blue,very thick] (0,0) -- (1,0); \draw[-latex,blue,very thick] (0,0) -- (0,1); \end{axis} \draw [orange,thick] (theAxis.south west) rectangle (theAxis.north east); \draw[dashed,red] (A) node[below] {start$A'(2,2)$} --++ (0,3) node[above] {end$B'(2,5)$}; \fill[red] (0,0) circle[radius=2pt] node[below,align=center] {origin outside\\$O'(0,0)$}; \draw[-latex,red,very thick] (0,0) -- (1,0); \draw[-latex,red,very thick] (0,0) -- (0,1); \end{tikzpicture} \end{document} Questions: Why the (axis cs:1,0) --++ (axis cs:0,3) yield the slashed blue line, not just (axis cs:1,3) but "(axis cs:2,5)? Should I use calculation like --++(axis cs:0,3) inside axis environment, which is a little confusing? I didn't find this in the pgfplots's doc seemedly, best wishes for all the kindness in advance!
- Mimicking Mollenhauer's document style with packages recorder-fingering, musixtex and tikzby Olórin on July 14, 2025 at 3:39 pm
I would like to mimic following Mollenhauer's document style : using packages recorder-fingering, musixtex and tikz. I came from Chart for Recorder fingering notation in Musixtex with Tikz and Beamer but cannot wrap my head around Alan Munn's answer, especially that I have linked notes in my used case -- which is basically the score of BWV 1043 I. Adagio. I can't succeeed in having the score above the fingering nor do I how to introduce vertical lines separating each note and its corresponding fingering.
- Problem with \tkzClipSector and bounding box in tkz-euclideby Alain Matthes on July 14, 2025 at 3:06 pm
Here's a problem I can't solve. As you can see in the figure below, the clip is bounded by the sector, but the bounding box is modified. I can get around this problem easily, but I'd like to find out what's causing it. Here are some possible workarounds: 1) \tkzClipBB \tkzClipSector(O,A)(C) \tkzDrawLines[ultra thick](O,B A,C) 2) \tkzClipSector(O,A)(C) \tkzClipCircle(O,A) \tkzDrawLines[ultra thick](O,B A,C) 3) \pgfinterruptboundingbox \tkzClipSector(O,A)(C) \tkzDrawLines[ultra thick](O,B A,C) \endpgfinterruptboundingbox \documentclass{standalone} \usepackage{tkz-euclide} \begin{document} \begin{tikzpicture} \tkzDefPoints{0/0/O,2/0/A,0/6/B,-2/0/C} \tkzDrawPoints(O,A,C) \tkzDrawCircle(O,A) \tkzClipSector(O,A)(C) \tkzDrawLines[ultra thick](O,B A,C) \end{tikzpicture} \end{document} Note that if, instead of drawing a straight line, I fill in a disk, the problem is identical: \fbox{\begin{tikzpicture} \tkzDefPoints{0/0/O,2/0/A,0/6/B,-2/0/C} \tkzDrawPoints(O,A,C) \tkzDrawCircle(O,A) \tkzClipSector(O,A)(B) \tkzFillCircle[red](O,B) \end{tikzpicture}} Last remark: no problem if I clip a circle. \fbox{\begin{tikzpicture} \tkzDefPoints{0/0/O,2/0/A,0/6/B,-2/0/C} \tkzDrawPoints(O,A,C) \tkzDrawCircle(O,A) \tkzClipCircle(O,A) \tkzDrawLines[ultra thick](O,B A,C) \end{tikzpicture}} You can find the macros for sector layouts here : tkz-obj-eu-sectors.tex. I tried to find out from these macros when the bounding box could be modified, but without success! Do you have an explanation for this problem?
- The dashed pattern's joined at closed boundary of node?by Explorer on July 14, 2025 at 9:58 am
I have the following MWE: \documentclass[tikz,border=.5cm]{standalone} \begin{document} \begin{tikzpicture} \node[ circle, draw=blue,thick, densely dashed, fill=yellow, inner sep=2pt, font=\LARGE] {2}; \end{tikzpicture} \end{document} which yields: It seemed that is a small bug(or feature) of dashed's pattern provided by TikZ, although we can tune the dash pattern such as: \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \node[circle,draw=blue,densely dashed ,thick,fill=yellow, inner sep=2pt] {\LARGE 2}; \node[circle,draw=blue,dash pattern = on 3.01pt off 1.7pt,thick,fill=yellow, inner sep=2pt] at(1,0) {\LARGE 2}; \end{tikzpicture} \end{document} However, if the node-text varied, and the node's shape changed, and the frame of the node differed, tunning the parrerns for every case is cumbersome. My target is to make the on and off part along the frame more "well-distributed" automatically(without tunning the dash pattern case by case), avoid line joined with begin and the end of dashed. Is there exists better practice? Edit For Various text contents and shapes: \documentclass[tikz,border=.5cm]{standalone} \usetikzlibrary{shapes.geometric} \begin{document} \begin{tikzpicture} \node[ circle, draw=blue,thick, densely dashed, fill=yellow, font=\LARGE ] {2}; \node[ ellipse, draw=blue,thick, densely dashed, fill=yellow, font=\tiny ] at (1.25,0) {233333}; \end{tikzpicture} \end{document} At the above example shows, I don't want to manually change the dash pattern one by one according the shape and the node-content. That is to say: I want this "better-dashed" can handle all closed boundary of node's shapes, no matter whether they are ellipse or superellipse or diamond etc, I want to avoid bad join of the heaf and tail. I also want it automatically distrbuted across the bounder, regradless of the node-text's contents(2 or 2333), I hope the dashed position could be judge or calculated automatically, without manually tunning if the content is modified.
- How to plot labels from a CSV file?by crayman9 on July 13, 2025 at 9:49 pm
I am able to plot points from a CSV file in a tikz axis plot using the attached code. Rather than this, I would like to plot text strings (from the column "County") centered at the coordinates given by the Latitude and Longitude columns. How can I do this? \documentclass{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=none, clip=false ] \addplot[ only marks, mark=*, mark size=1pt ] table[ x=Longitude, y=Latitude, col sep=comma ] {test.csv}; \end{axis} \end{tikzpicture} \end{document} The following are the contents of test.csv: County,Latitude,Longitude Austin,29.949999999999999,-96.319999999999993 Brazoria,29.149999999999999,-95.450000000000003 Brazos,30.649999999999999,-96.349999999999994 Chambers,29.699999999999999,-94.549999999999997 Colorado,29.620000000000001,-96.530000000000001 FortBend,29.510000000000002,-95.760000000000005
- pgf Error: No shape named `spiralpath' is knownby Myo Nyunt on July 13, 2025 at 4:14 pm
I cannot manage to finish this document: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage{tikz} \usetikzlibrary{calc,intersections,through,backgrounds,arrows.meta} % <--- Add 'intersections' here if it's not already \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines = middle, xmin=-25, xmax=25, ymin=-25, ymax=25, axis equal image, clip = false, axis line style={shorten >=-15pt, shorten <=-15pt}, ] % Step 1: Draw the main spiral plot WITHOUT an arrowhead. % We will draw the arrowhead separately. \addplot [ domain=2*pi:4.25*pi, samples=400, smooth, thick, blue, % Store coordinates for later use by the arrow /pgfplots/every axis plot post/.append style={ name path=spiralpath, % 'name path' requires 'intersections' library overlay % Important to ensure it's a direct TikZ path } ] ({x*cos(deg(x))}, {x*sin(deg(x))}); % Step 2: Draw a small segment at the end of the *named* spiralpath with an arrowhead. % This method is robust because 'spiralpath' is now a standard TikZ named path. \draw[-{Stealth[length=4pt, width=4pt, fill=blue]}, thick, blue] (spiralpath.at 0.99) -- (spiralpath.at end); % Draw from 99% to end % --- Your other existing elements --- \draw[->, thick, black] (0,0) -- (20,20); % --- Angle Label 'θ' --- \node at (12.5,7) {$\theta$}; \node [left=1pt] at (14,14) {$r$}; \node [right] at (20,20) {$z = x + iy$}; \end{axis} \end{tikzpicture} \end{document}
- How to split arrows and draw arrowed triangles in TikZ?by pixel on July 13, 2025 at 12:21 pm
I'm trying to replicate the following figure in TikZ: And I have the following code so far: \documentclass{article} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{arrows.meta, positioning} \tikzset{ solidarrow/.style={-Stealth, thick}, dashedarrow/.style={-Stealth, thick, dashed}, box/.style={rectangle, draw, minimum width=3cm, minimum height=1cm, align=center}, every node/.style={font=\small, align=center}, } \begin{document} \begin{tikzpicture}[node distance=1.8cm and 2.2cm] % Nodes explicitly placed \node (CDGS) {Centered DGS}; \node (SVP) [below=of CDGS] {SVP}; \node (box) [box, below=of SVP] {CVP, SIVP, DGS}; \node (DGSS) [right=3.5cm of CDGS] {DGS $s \ge \gamma\sqrt{\log n}\cdot \lambda_n$}; \node (gSVP) [below=1.5cm of DGSS, xshift=-1cm] {$\gamma$-SVP}; \node (gSIVP) [right=3cm of gSVP] {$\gamma$-SIVP}; \node (gCVP) [below=of gSIVP] {$\gamma$-CVP}; \node (BDD) [right=2.5cm of gSIVP] {BDD$_{1/\gamma}$}; \node (guSVP) [above=of BDD] {$\gamma$-uSVP}; \node (gGapSVP) [below=of BDD] {$\gamma$-GapSVP}; \node (gGapCVP) [below=of gGapSVP] {$\gamma$-GapCVP}; % Solid Arrows \draw[solidarrow] (CDGS)--(SVP) node[midway,left]{[S16]}; \draw[solidarrow] (SVP)--(box) node[midway,left]{[GMSS99]}; \draw[solidarrow] (DGSS)--(gSVP) node[midway,left]{[GPV08, BL+13]}; \draw[solidarrow] (guSVP)--(gGapSVP) node[midway,right]{[LM09]}; \draw[solidarrow] (gGapSVP)--(gGapCVP) node[midway,right]{[GMSS99]}; % Dashed Arrows \draw[dashedarrow] (CDGS) to[bend left=20] node[midway,above]{\scriptsize$\gamma=\sqrt{n/\log n}$[S16]} (gSVP); \draw[dashedarrow] (DGSS)--(gSIVP) node[midway,right]{\scriptsize[Reg09] $\gamma\mapsto\sqrt{n\log n}\gamma$}; \draw[dashedarrow] (gSVP)--(gSIVP) node[midway,above]{\scriptsize$\gamma\mapsto\sqrt{n}\gamma$}; \draw[dashedarrow] (gSIVP)--(gCVP) node[midway,right]{[Mic08]}; \draw[dashedarrow] (gSVP) to[bend right=20] node[midway,below]{\scriptsize$\gamma\mapsto\sqrt{n}\gamma^2$[GMSS99]} (gCVP); \draw[dashedarrow] (gSIVP)--(BDD) node[midway,above]{\scriptsize$\gamma\mapsto n/\log n\gamma$}; \draw[dashedarrow] (BDD)--(guSVP) node[midway,right]{[BSW16]}; \draw[dashedarrow] (gSIVP)--(gGapSVP) node[midway,above]{\scriptsize$\gamma\mapsto n\gamma$[Ban93]}; \draw[dashedarrow] (gGapSVP) to[bend right=20] node[midway,left]{\scriptsize$\gamma\mapsto\sqrt{2}\gamma$} (BDD); \end{tikzpicture} \end{document} But the result is not nearly as in the picture. My biggest problem for starters are: How to split the arrows? As is done at the middle going from DGS to \gamma-SVP to \gamma-SIVP for example. How to form triangles? As is in the middle and right segment of the figure. Any help with replicating the above figure in TikZ is highly appreciated.
- Removing color from overlapping region of intersection of three sets in a Venn diagramby Jason on July 13, 2025 at 7:08 am
I have the following diagram from which I want to remove the colored grey region that comes in all the three sets. I am attaching minimal code example and also a screenshot below. Note that I want to avoid using any extra package like venndiagram. I want to do this using tikzpicture only. \begin{document} \setlength{\parindent}{0cm}{\Huge \Hello} \bigskip \bigskip \begin{center} Happy typesetting!\\ \medskip {How to remove the colored region that comes in all three sets} \end{center} \begin{tikzpicture} \begin{scope} [fill opacity = .3] \fill[draw=black,fill=gray, even odd rule] (3.5,2.5) circle (1.5) (6,2.5) circle (2) (5, 0) circle(2.2); \end{scope} \end{tikzpicture} \end{document} Current output: Expected output:
- Draw 3D triad in TikZby user2501235 on July 12, 2025 at 11:38 pm
I am attempting to mimic a 3D triad like the one shown below from a CAD system. So far I have been able to closely match the axes and the origin cube using TikZ but not sure exactly how to get the truncated 3D spheres. Here is a minimum working example. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{} \tikzstyle{isometric}=[x={(0.710cm,-0.410cm)},y={(0cm,0.820cm)},z={(-0.710cm,-0.410cm)}] \tikzstyle{dimetric} =[x={(0.935cm,-0.118cm)},y={(0cm,0.943cm)},z={(-0.354cm,-0.312cm)}] \tikzstyle{dimetric2}=[x={(0.935cm,-0.118cm)},z={(0cm,0.943cm)},y={(+0.354cm,+0.312cm)}] \tikzstyle{trimetric}=[x={(0.926cm,-0.207cm)},y={(0cm,0.837cm)},z={(-0.378cm,-0.507cm)}] \usepackage{xcolor} \definecolor{myblue}{HTML}{C7E9F1} \begin{document} \begin{tikzpicture} % Draw a triad \begin{scope}[trimetric] % Y-face \draw [fill=myblue!30!white] (-0.25,0.25,-0.25) --++(0.5,0,0) --++(0,0,0.5) --++(-0.5,0,0) -- cycle; % Z-face \draw [fill=myblue!50!white] (-0.25,0.25,0.25) --++(0.5,0,0) --++(0,-0.5,0) --++(-0.5,0,0) -- cycle; % x-face \draw [fill=myblue!80!white] (0.25,0.25,0.25) --++(0,0,-0.5) --++(0,-0.5,0) --++(0,0,0.5) -- cycle; % Axes \draw [ultra thick,-latex,red] (0.35,0,0) --(1.0,0,0); \draw [ultra thick,-latex,green!50!black] (0,0.35,0) --(0,1.0,0); \draw [ultra thick,-latex,blue] (0,0,0.35) --(0,0,1.0); \end{scope} \end{tikzpicture} \end{document} Here is the results from my TikZ attempt.
- Creating a tikz function for visualising a number in number systems with different basesby Damitr on July 12, 2025 at 6:02 am
I am creating a table which shows the how different base number systems will show this number. As a visual aid I am adding "bundles" (whole number of base numbers possible) and "tokens" (carry over from the remaining number) for a given number. See the image below Right now I am using tikz nodes to draw this on a grid using mostly manual setting (with some loops at places) and placing this inside a tabular cell. I want to know is there anyway to automate this? For example we give the number, lets say 12, and the base of the number system, lets say 5, then the function automatically finds the bundles and tokens and draws them accordingly. Any other way to visualise this would also be appreciated. In the MWE below I am only reproducing the code for base-5 system. \documentclass{article} \usepackage{tikz} \usepackage{booktabs} \tikzset{bundle/.style={circle,fill,inner sep=0pt,minimum size=3mm}} \tikzset{token/.style={circle,draw,inner sep=0pt,minimum size=3mm}} \begin{document} \begin{tabular}{p{1.25cm}p{1.5cm}p{1.25cm}p{1.cm}p{3.cm}} \toprule \textbf{Bundles Of} & \textbf{No. of Bundles} & \textbf{No. of Tokens} & \textbf{Write as} & \textbf{Base/}\newline \textbf{Numerals} \\ \midrule Five & \textbf{2} bundles \newline \begin{tikzpicture}[scale=0.4] \foreach \x in {0,1,2} { \foreach \y in {0,1} { \ifnum\x=2 \ifnum\y=0 \else \node[bundle] at (\x*1, \y*1) {}; \fi \else \node[bundle] at (\x*1, \y*1) {}; \fi } } \begin{scope}[shift={(0,2.5)}] \foreach \x in {0,1,2} { \foreach \y in {0,1} { \ifnum\x=2 \ifnum\y=0 \else \node[bundle] at (\x*1, \y*1) {}; \fi \else \node[bundle] at (\x*1, \y*1) {}; \fi } } \end{scope} \end{tikzpicture} & \textbf{2} tokens \newline \begin{tikzpicture}[scale=0.4] \node[token] at (0,0) {}; \node[token] at (1,0) {}; \end{tikzpicture} & \textbf{22} & Base Five \newline Quinary System \newline Numerals\newline 0, 1, 2, 3, 4\\ \bottomrule \end{tabular} \end{document}
- A TikZ node style with small caps [closed]by user50655 on July 11, 2025 at 10:02 pm
Does anyone know how to define a node style with text that has small caps. I tried node[\scshape] as well as \textsc to no avail?
- Draw parabole and secant plane in perspectiveby graograman on July 11, 2025 at 7:36 pm
I'd like to reproduce the following parabola in TeX but my approach is not working as I'd like it to. Because TeX doesn't have a 3D engine I drew the whole thing in Geogebra and then tried to reproduce it in code thus: \documentclass[12pt]{standalone} \usepackage{tikz} \usetikzlibrary{matrix, positioning, angles, decorations.pathreplacing, 3d, arrows.meta} \begin{document} \begin{tikzpicture}[parabola/.style={red}, scale=2] \draw [blue, dashed] (0,-1.5,0) -- (0,1.5,0); \draw (0.8,-1,0) arc (-10:-170:0.8cm and 0.3cm); \draw [dashed] (0.8,-1,0) arc (10:170:0.8cm and 0.3cm); \draw (0.8,1,0) arc (-10:-170:0.8cm and 0.3cm); \draw (0.8,1,0) arc (10:170:0.8cm and 0.3cm); \draw (0.8,1,0) -- (-0.78,-1,0); \draw (-0.78,1,0) -- (0.8,-1,0); \draw [fill, blue] (0,0,0) circle (0.5pt) node [left] {$S$}; \coordinate (a) at (-0.4,-0.8,0); \def\b{2} \def\h{1} \def\p{0.5} \pgfmathsetmacro{\rx}{\b/2} \pgfmathsetmacro{\ry}{\rx*\p} \pgfmathsetmacro{\ta}{90-atan2(\h,\ry)} \coordinate (parabend) at (-1*\ta:0.2*\rx-0 and \ry); \path (a) +(50+50*\p:\rx+0 and \ry) coordinate (tmp) +(-90+25*\p:\rx+0 and 0.9*\ry) coordinate (tmp2); \end{tikzpicture} \end{document} which renders the parabola bent like this: and I can't get the plane's edges straight or looking so at least. Maybe there's an easier way to draw the lines? I've looked at some examples but I can't make sense of them.
- Is that possible to use Line Definition by one point and slope in tkz-elements?by Explorer on July 11, 2025 at 9:42 am
I have the following code: \documentclass[border=4pt,tikz]{standalone} \usepackage{tkz-euclide,tkz-elements} \directlua{ init_elements() z.O = point(0, 0) z.F = point(1.5, 0) L.ab = line(point(-1.5, -1), point(-1.5, 1)) CO.PA = conic(z.F, L.ab, 1) PA.curve = CO.PA:points(-3.2, 4, 100) L.PF = line(z.F,point(2,2)) % I have to use dummy temp point(2,2) to determine the Line AB % Is that possible for tkz-elements to support Line Defined by (point, slope)? z.A, z.B = intersection(CO.PA,L.PF) } \begin{document} \begin{tikzpicture}[line cap=round] \tkzGetNodes \tkzInit[xmin=-2,xmax=3,ymin=-3.5,ymax=4] \tkzDrawX[noticks]\tkzDrawY[noticks] \tkzDrawCoordinates[smooth](PA.curve) \tkzDrawSegment[semithick](A,B) \tkzDrawPoints[blue](O,F,A,B) \tkzLabelPoints[blue,right](O,F,A,B) \end{tikzpicture} \end{document} I have to decide the LineAB's slope to determine the intersections, but I didn't found that tkz-elements support the method of define the Line with only one point and a slope but not line(<pointA>,<pointB>)? If I use line(z.F,point(2,2)), it's hard to dirctly control the slope as above; IMO, define a line by (<point>,<slope>) is a common requirement in geometry, is there better & elegant method to control the slope?
- aligning tikz nodes to the left or rightby Stefan Müller on July 11, 2025 at 9:04 am
I want the nodes to be aligned right and left respectively. I did this with \hphantomand spaces, but I guess there is a proper way to do this within tikz. How can I reach this? \documentclass[border=0.2cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[remember picture] \node(c1) at (-3,2) {nicht weglassbar}; \node(c2) at (-3,1) {\hphantom{nicht~}weglassbar}; \node(c3) at (1,2) {Argument}; \node(c4) at (1,1) {Adjunkt~~~~}; \draw (c1) to (c3); \draw (c2.east) to (c3.west); \draw (c2) to (c4); \end{tikzpicture} \end{document}
- Draw illustration (cylindric)by Alex on July 10, 2025 at 1:08 pm
I have a such image And I try to draw this in Tikz, and have some troubles: how to set the correct viewing angle (as in the picture) for set the correct position of the plane at an angle of $2pi/3$? \documentclass[tikz,border=3.14mm]{standalone} \usepackage{amssymb} \usepackage{amsmath,amsthm} %\pdfpkresolution=2400 %\pdfpkmode={supre} %\usepackage[exscale]{ccfonts} \usepackage{tempora} \usepackage{newtxmath} \usepackage{tikz} \usepackage{pgfplots} \usepackage{tikz} \usepackage{tikz-cd} \usetikzlibrary{ arrows, matrix, arrows.meta, backgrounds, fit, matrix, positioning, calc, patterns, arrows.meta, graphs, shapes.misc, shadows.blur, shapes.geometric, decorations.pathmorphing } \newcommand{\myunit}{1 cm} \tikzset{ node style sp/.style={draw,circle,minimum size=\myunit}, node style ge/.style={circle,minimum size=\myunit}, arrow style mul/.style={draw,sloped,midway,fill=white}, arrow style plus/.style={midway,sloped,fill=white}, } \pgfplotsset{compat=1.18} \usepackage{tikz,tikz-3dplot} \begin{document} \tdplotsetmaincoords{70}{110} \begin{tikzpicture}[tdplot_main_coords,scale=0.8] \tikzstyle{every node}=[font=\small] % Define parameters \def\R{2.5} \def\zheight{4} \def\zbottom{-2.5} \def\phiangle{60} % Draw the complete cylinder (from bottom to top) % Bottom circle (hidden, at z = zbottom) \draw[thick,dashed] (0,0,\zbottom) circle (\R); % Circle at z = 0 \draw[thick] (0,0,0) circle (\R); % Top circle at z = z₀ \draw[thick] (0,0,\zheight) circle (\R); % Cylinder sides (visible parts) \draw[thick] (\R,0,\zbottom) -- (\R,0,\zheight); \draw[thick] (-\R,0,\zbottom) -- (-\R,0,\zheight); % Dashed lines for hidden parts \draw[thick,dashed] (0,\R,\zbottom) -- (0,\R,\zheight); \draw[thick,dashed] (0,-\R,\zbottom) -- (0,-\R,\zheight); % Draw coordinate planes % z = 0 plane (gray, transparent) \filldraw[fill=gray!20, draw=gray, opacity=0.3] (-4,-4,0) -- (4,-4,0) -- (4,4,0) -- (-4,4,0) -- cycle; % z = z₀ plane (gray, transparent) \filldraw[fill=gray!20, draw=gray, opacity=0.3] (-4,-4,\zheight) -- (4,-4,\zheight) -- (4,4,\zheight) -- (-4,4,\zheight) -- cycle; % φ = 2π/3 plane \tdplotsetrotatedcoords{0}{0}{\phiangle} \begin{scope}[tdplot_rotated_coords] \filldraw[fill=gray!10, draw=gray, opacity=0.4] (0,0,0) -- (4,0,0) -- (4,0,\zheight) -- (0,0,\zheight) -- cycle; \end{scope} % Mark important points and labels \node at (0,0,0) [below left] {$O$}; \node at (3.5,0,0) [below] {$\varphi_0$}; \node at (0,0,\zheight) [left] {$z = z_0$}; \node at (0,0,-0.3) [below] {$z = 0$}; \node at (\R,0,2) [right] {$r = R$}; % Draw angle arc for φ₀ = 2π/3 \tdplotdrawarc[thick,->]{(0,0,0)}{1.5}{0}{\phiangle}{anchor=north}{$\varphi_0 = \varphi = \frac{2\pi}{3}$} % Draw radial line \draw[thick] (0,0,0) -- ({\R*cos(\phiangle)},{\R*sin(\phiangle)},0); % Add "2" label inside cylinder \node at (0,0,2) [font=\large] {$2$}; % Add dimensional indicators \draw[<->] (\R+0.5,0,0) -- (\R+0.5,0,\zheight) node[midway,right] {$z_0$}; \draw[<->] (0,0,-0.7) -- (\R,0,-0.7) node[midway,below] {$R$}; % Mark the cylinder boundary at z = z₀ \draw[thick] (0,0,\zheight) circle (\R); % Draw dashed construction lines \draw[dashed] (0,0,\zbottom) -- ({\R*cos(\phiangle)},{\R*sin(\phiangle)},\zbottom); \draw[dashed] (0,0,0) -- ({\R*cos(\phiangle)},{\R*sin(\phiangle)},0); \draw[dashed] (0,0,\zheight) -- ({\R*cos(\phiangle)},{\R*sin(\phiangle)},\zheight); \draw[dashed] ({\R*cos(\phiangle)},{\R*sin(\phiangle)},\zbottom) -- ({\R*cos(\phiangle)},{\R*sin(\phiangle)},\zheight); % Draw coordinate axes (on top, black) \draw[thick,-latex] (0,0,0) -- (5,0,0) node[anchor=north east]{$x$}; \draw[thick,-latex] (0,0,0) -- (0,5,0) node[anchor=north west]{$y$}; \draw[thick,-latex] (0,0,\zbottom-0.5) -- (0,0,5) node[anchor=south]{$z$}; \end{tikzpicture} \end{document} Current result:
- What are "best practices" for PGF/TikZ use of pgfmathparse and friends?by karlh on July 9, 2025 at 6:43 pm
I have encountered (sporadically) comments to the effect that \pgfmathparse, \pgfmathsetlength, and so forth should not be used unless absolutely necessary. For example, it is (I am told) preferable to say \pgfmathmax@{{\pgfmath@tonumber{\pgf@xa}}{\pgfmath@tonumber{\pgf@xb}}} \pgf@xa=\pgfmathresult pt rather than \pgfmathsetlength{\pgf@xa}{max(\pgf@xa,\pgf@xb)}. Similarly, \pgfmathparse{sin(\pgf@xa)} should, in code written for others to use, be written as \pgfmathsin{\pgf@xa}} or even \pgfmathsin@{\pgf@xa}, and similar for operations such as addition, subtraction, multiplication, etc. What advice do others have on when to invoke the math parser and when to do it without? Also, is there a significant difference between \pgfmathadd and \pgfmathadd@ (and other similar variants)? If the answer is "it is faster," how much faster? Is there an example I can generate relatively easily and/or tinker with for which I could actually observe the difference (or do a timing test)? Edit/clarification: This is in the context of writing new shape definitions, extending shapes, and so forth (i.e., library/package code).
- Which is faster to compile? Importing rendered images or rendering tikz codes together with the documentby Liu Zhiyu on July 9, 2025 at 8:20 am
I'm writing a huge document, which has many tikzpictures. I'm wondering which method is faster to compile? (1) Plain Tikz codes to compile with the document together. (2) Generating .pdf images in advance and importing the images. I think (2) is faster, which also has cleaner codes.
- Using the distance between two points as the radius of an arc in TikZby Lucy on July 8, 2025 at 4:23 pm
I have two points defined, and I want to use the distance between them as the radius of an arc, but the vector (logically) does not work because it is not a number. \path let \p1 = (P), \p2 = (C) in \pgfextra{\pgfmathsetmacro{\r}{veclen(\x2-\x1,\y2-\y1)}}; % \draw[shift={(A)}] (34:{\r}) arc (34:75:{\r});
- Adding annotations to polynomial long division using tikzby Damitr on July 8, 2025 at 12:26 pm
I am typesetting a polynomial long division using polynom. I would like to add text annotations as shown in the figure. Right now I have manually adjusted the tikz nodes to approximately align where I want them after a bit of trial and error for each node. But is there a way to automagically to do this. As for other divisions I would have to manually adjust all 4 of them. MWE \documentclass{article} \usepackage{polynom} \usepackage{tikz} \begin{document} \begin{tikzpicture}[remember picture,overlay] \node at (0,0) { \polylongdiv[vars=a]{8a^3 + 16a^2 - 2a + 4}{4a^2 -2a +1} }; \node[anchor=west] at (-2,1.25) {Divisor}; \node[anchor=west] at (3.7,0.7) {Dividend}; \node[anchor=west] at (2,1.8) {Quotient}; \node[anchor=west] at (3.7,-1.2) {Remainder}; \end{tikzpicture} \end{document}
- Clip bars for big values in bar chartby thinksolid on July 8, 2025 at 10:20 am
I would like to display my bars fully in the range of 0-80. Above that I want to clip the bars and display the real value above. It should be displayed that it is easy to understand. It should look something like this: The problem is, that my clipped bars dont display the original value, but the value that I clipped the bars to. Why does the saving of the variable not work? This is my code right now. \documentclass[a4paper]{article} \usepackage[left=3cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry} \usepackage{pgfplots} \usepackage{siunitx} \pgfplotsset{compat=newest} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing} \begin{document} \pgfplotstableread{ Hersteller Delta1 Delta2 Delta3 Delta 25 125 48 Traco 46 49 75 Cosel 12 46 18 Meanwell 13 51 46 Cincon 50 50 50 Recom 27 75 51 Daitron 21 13 160 }\datatable \begin{figure}[htbp] \centering \begin{tikzpicture} \begin{axis}[ width=\textwidth, height=9cm, ybar=2pt, bar width=12pt, tick align=inside, xtick pos=lower, ytick pos=left, symbolic x coords={Delta, Traco, Cosel, Meanwell, Cincon, Recom, Daitron}, xtick=data, xticklabel style={rotate=45, anchor=east}, ylabel={Magnetfeld in \si{\milli\tesla}}, ymin=0, ymax=80, ymajorgrids, restrict y to domain*=0:85, visualization depends on=rawy\as\rawy, % Save the unclipped values after end axis/.code={ % Draw line indicating break \draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05); }, nodes near coords={% \pgfmathprintnumber{\rawy}% Print unclipped values }, axis lines*=left, clip=false, legend style={ /tikz/every even column/.append style={column sep=15pt}, at={(0.5,-0.2)}, anchor=north, legend columns=-1 }, legend image code/.code={ \draw[#1,draw=none] (0cm,-0.125cm) rectangle (0.25cm,0.175cm); }, nodes near coords, nodes near coords align={vertical}, ] \addplot+[fill=green, draw=none, nodes near coords style={color=green}] table [x=Hersteller, y=Delta1] {\datatable}; \addplot+[fill=red, draw=none, nodes near coords style={color=red}] table [x=Hersteller, y=Delta2] {\datatable}; \addplot+[fill=blue, draw=none, nodes near coords style={color=blue}] table [x=Hersteller, y=Delta3] {\datatable}; \legend{Richtung 1, Richtung 2, Richtung 3} \end{axis} \end{tikzpicture} \caption{YYY} \label{fig:YYY} \end{figure} \end{document}
- TikZ pattern color not preserving CMYK values in PDF output (using pattern.meta) [duplicate]by Lucy on July 8, 2025 at 10:13 am
I'm having trouble with TikZ patterns and CMYK colors in LaTeX. Specifically, when I use a pattern with pattern color=blue (or a custom CMYK blue color), the resulting PDF output shows about 52% cyan and 13% yellow instead of the expected pure blue. Also, when I try black defined as a composite of all four CMYK colors, the pattern color doesn’t appear correctly. I’m compiling with pdfLaTeX (not XeLaTeX or LuaLaTeX), and I’ve tried turning off PDF compression with \pdfcompresslevel=0, and also tried using the pdfx package for PDF/X compliance, but either the color model switches to RGB or the problem persists. Here is a minimal example: \documentclass{article} \pdfcompresslevel=0 \usepackage{xcolor} \definecolor{modra}{cmyk}{1,0,0,0} % custom CMYK blue \usepackage{tikz} \usetikzlibrary{patterns.meta} \begin{document} \begin{tikzpicture} \coordinate (I) at (0,0); \coordinate (S) at (4,0); \coordinate (J) at (2,3); \draw[pattern={Lines[angle=45, distance=5pt]}, pattern color=modra, draw=none] (I) -- (S) -- (J) --cycle; \end{tikzpicture} \end{document} My questions are: Why does the pattern color output as roughly 52% cyan and 13% yellow in the PDF instead of the expected CMYK blue? Is there a way to make the TikZ pattern lines fully opaque and preserve the exact CMYK color definitions in the output? Are there known workarounds to preserve CMYK colors and get correct pattern rendering without switching to RGB or using pdfx? Thanks in advance for any help! Lucy
- Draw variable curves in Tikzby liuzp on July 7, 2025 at 6:18 pm
I'm trying to build a sample code that is able to reproduce the same curve multiple times, since I want to use it a few times but don't want to rewrite the full code every time. So, what I would like to define is a new square/.style curve that accepts two parameters #1 and #2, where #1 is a color and #2 is a number. From that it then draws a square colored #1 and with size #2, with black lines and grid on every unit interval up to #2. I tried the code bellow, but obviously it's missing the color part, and the grid part, while also not rendering the desired square. \tikzset{ square/.style args={1}{insert path={ (#1,0) -- (0,0) -- (0,#1) -- (#1,#1) -- cycle }} } Can you please, help me with this line of code? In a following matter, I would also like to define some cubes, is this possible in the same fashion way? Edit: I'm sorry if the question was unclear, I was lacking the proper vocabulary on the time, and could not explain in details what I wanted to do, but after your comments I think I can be. What I want to build is a tikz macro that can reproduce the drawing bellow passed the size and color As one can see, we have 3 progressive examples of grided and shaded squares, a 1x1 light blue square, a 2x2 light yellow square, and 3x3 light red square, that can be extended to an $$n \cross n$$ square of any color. As for the M (not) WE, what I can provide is this similar context of the whole document that spams dozens of other packages and features, and personal information. \documentclass[margin=5mm, varwidth]{standalone} \usepackage{tikz} \usepackage{multicol} \usetikzlibrary{ 3d, perspective, positioning, calc, arrows.meta, shapes } \tikzset{>={Stealth}} \tikzset{ square/.style args={1}{insert path={ (#1,0) -- (0,0) -- (0,#1) -- (#1,#1) -- cycle }} } \begin{document} \begin{enumerate} \item Item 1 \item Item 2 \begin{multicols}{3} \begin{enumerate} \item \tikz{\draw[style/.expanded=square 2]} \item Square 2 \item Square 3 \end{enumerate} \end{multicols} \item Item 3 \end{enumerate} \end{document} As for the cube case, I think that @cfr response should be sufficient for my purposes. Thanks in advance for all of your help.
- How to fill the overlap between two arcs?by Eugene Veklerov on October 15, 2024 at 11:57 pm
It is convenient for me to define two arcs as follows: \documentclass{article} \usepackage{tikz} \usepackage{tikzfill} \begin{document} \begin{tikzpicture} \def \R{3} \draw [domain=230:290] plot ({\R*cos(\x)+2.4}, {\R*sin(\x)+\R}); \draw [domain=50:110] plot ({\R*cos(\x)+1.497}, {\R*sin(\x)-2.15761}); \end{tikzpicture} \end{document} The space between the arcs look like a convex lens. How do I use a fill command to fill it? I would prefer a simple implementation.
- How can I fix this beamer presentation error?by Oussama Taoussi on June 23, 2022 at 8:11 am
I am making a beamer presentation that has some tikzpictures and pgfplots and I get this error : >Illegal parameter number in definition of \beamer@doifinframe. I tried adding fragile in \begin{frame} but the error still shows up, the pdf is still generated but when the presentation gets bigger(more tikzpictures and pgfplots} the output stops. %the error : <to be read again> 1 l.78 \end{figure}} You meant to type ## instead of #, right? Or maybe a } was forgotten somewhere earlier, and things are all screwed up? I'm going to assume that you meant ##. \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage{pgfplots} \usepackage{tikz} \usepackage{amsmath} \usetikzlibrary{positioning} \usetikzlibrary{calc} \pgfplotsset{width=10cm,compat=newest} \usetheme{Warsaw} \definecolor{mygreen}{rgb}{.125,.5,.25} \usecolortheme[named=mygreen]{structure} \begin{document} \begin{frame}[fragile,t]{La théorie des SVM}% \vspace{10pt} \only<1-3>{ \begin{block}{L'hyperplan optimale} L'hyperplan qui posséde une \alert{marge} maximale. \end{block}} \only<2-3>{ \begin{block}{La marge} Deux fois la \alert{distance minimale} entre l'hyperplan et les observations. \end{block}} \vspace{2pt} \only<3>{\begin{figure} \centering \begin{tikzpicture}[scale=0.6,marge/.style={<-,dashed,thick}, extended line/.style={shorten >=-#1,->}, extended line/.default=0.09cm] \begin{axis}[axis background/.style={fill=gray!10}, axis line style={->}, x label style={at={(axis description cs:0.5,-0.1)},very thick,anchor=north}, y label style={at={(axis description cs:-0.1,.5)},rotate=-90,thick,anchor=south},clip=false,xmin=0,xmax=10,ymin=1,ymax=8,axis lines=left,scatter/classes={ a={color=blue},b={color=red}}, xlabel=$x$, ylabel=$y$] %scatter \addplot+[ only marks,scatter src =explicit symbolic, scatter,mark size=2.9pt] coordinates{(3.67,1.47) [b] (6,2.5) [b] (6.2,3) [b] (5,2.55) [b] (4.89,3.22) [b] (2.8,1.5) [b] (2,2.071) [b]% (4,2) [b] (3.5,2.5) [b] (3,2) [b] (4.1,4.8) [a] (4.4,2.3) [b] (2.23,5.001) [a] (2.7,4.25) [a] (1.5,3.35) [a] (1.77,3.47) [a] (5,4.74) [a] % (3.45,5) [a] (2,4.2) [a] (2.6,5.3) [a] (2.4,4.6) [a] (3.24,4.47) [a]}; %hyperplanes \addplot[color=red, domain=0:7.5,left]{2/5*x + 2}; \addplot[color=red, domain=7.5:7.9,left]{2/5*x + 2}; \addplot[color=red, domain=9.44:10,left]{2/5*x + 2} node[sloped,pos=0.2](){$h(x)=0$}; \addplot[color=black,dashed, domain=0:10,left]{2/5*x + 1.26}; \addplot[color=black,dashed, domain=0:10,left]{2/5*x + 2.74}; %vecteur w \node (A) at (2,2/5*2+2) {}; \node (B) at (5,2/5*5+2) {}; \node (P) at (3.6,4.004) {}; \draw [extended line] ($(A)!(P)!(B)$) -- (P) node[sloped,above,pos=0.6](){$w$}; %marge \node (X) at (6,2/5*6+2.74) {}; \node (Y) at (9,2/5*9+2.74) {}; \node (T) at (6,2/5*6+1.26) {}; \node (Z) at (9,2/5*9+1.26) {}; \node (M) at (7.5,2/5*7.5+2) {}; \draw [marge] ($(X)!(M)!(Y)$) -- (M); \draw [marge] ($(T)!(M)!(Z)$) -- (M); %support vectors \end{axis} \end{tikzpicture} %\caption{Hyperplan optimale} \end{figure}} \only<3-5>{ \begin{block}{Normalisation} Pour les observations à limite de la marge on pose : $\arrowvert w\cdot x_{marge}+w_0\arrowvert=1$ , avec: $\begin{cases} w\cdot x_{marge+}+w_0=+1 \\ \ w\cdot x_{marge-}+w_0=-1 \end{cases}$ \end{block}} \only<5->{\begin{figure} \centering \begin{tikzpicture}[scale=0.6,marge/.style={<-,dashed,thick}, extended line/.style={shorten >=-#1,->}, extended line/.default=0.09cm] \begin{axis}[axis background/.style={fill=gray!10}, axis line style={->}, x label style={at={(axis description cs:0.5,-0.1)},very thick,anchor=north}, y label style={at={(axis description cs:-0.1,.5)},rotate=-90,thick,anchor=south},clip=false,xmin=0,xmax=10,ymin=1,ymax=8,axis lines=left,scatter/classes={ a={color=blue},b={color=red}}, xlabel=$x$, ylabel=$y$] %scatter \addplot+[ only marks,scatter src =explicit symbolic, scatter,mark size=2.9pt] coordinates{(3.67,1.47) [b] (6,2.5) [b] (6.2,3) [b] (5,2.55) [b] (4.89,3.22) [b] (2.8,1.5) [b] (2,2.071) [b]% (4,2) [b] (3.5,2.5) [b] (3,2) [b] (4.1,4.8) [a] (4.4,2.3) [b] (2.23,5.001) [a] (2.7,4.25) [a] (1.5,3.35) [a] (1.77,3.47) [a] (5,4.74) [a] % (3.45,5) [a] (2,4.2) [a] (2.6,5.3) [a] (2.4,4.6) [a] (3.24,4.47) [a]}; %hyperplanes \addplot[color=red, domain=0:7.5,left]{2/5*x + 2}; \addplot[color=red, domain=7.5:7.9,left]{2/5*x + 2}; \addplot[color=red, domain=9.44:10,left]{2/5*x + 2} node[sloped,pos=0.2](){$h(x)=0$}; \addplot[color=black,dashed, domain=0:10,left]{2/5*x + 1.26} node[sloped,below,pos=0.918](){$h(x)=-1$}; \addplot[color=black,dashed, domain=0:10,left]{2/5*x + 2.74} node[sloped,above,pos=0.85](){$h(x)=+1$}; %vector w \node (A) at (2,2/5*2+2) {}; \node (B) at (5,2/5*5+2) {}; \node (P) at (3.6,4.004) {}; \draw [extended line] ($(A)!(P)!(B)$) -- (P) node[sloped,above,pos=0.6](){$w$}; %marge \node (X) at (6,2/5*6+2.74) {}; \node (Y) at (9,2/5*9+2.74) {}; \node (T) at (6,2/5*6+1.26) {}; \node (Z) at (9,2/5*9+1.26) {}; \node (M) at (7.5,2/5*7.5+2) {}; \draw [marge] ($(X)!(M)!(Y)$) -- (M); \draw [marge] ($(T)!(M)!(Z)$) -- (M); %support vectors \node (svm) at (3.5,7) {Vecteurs de support}; \node (s1) at (5,4.74) {}; \node (s2) at (2,2.071) {}; \draw [->] (svm)--(s1); \draw [->] (svm)--(s2); \end{axis} \end{tikzpicture} %\caption{Hyperplan optimale} \end{figure}} \end{frame} \end{document}
- Tikz: positioning of circular framed photo in top right corner of paper, with control over the frame thickness and color, and x/y positionby Hossein Rouhabadi on August 18, 2020 at 2:43 pm
My question is about photo positioning in Tikz. I want to insert a photo on the top right corner, with a circular shape and a frame, thickness and color of which I can control. Can someone please guide me how I can bring the photo to the north east corner with the control inputs of color and thickness of the frame and the x and y shifts from paper edges? Thank you very much. \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc,arrows} \begin{document} \begin{tikzpicture}[remember picture,overlay] \draw[path picture={\node {\includegraphics[width=5.5cm]{example-image}}; } ] (0,0) circle [radius=2.5cm]; \end{tikzpicture} \end{document}
- How can I use \\ with \texttt inside a node?by codeaviator on January 18, 2017 at 8:34 pm
Take the following MWE: I made this node with tikz using the normal font: However, I need to use a monospaced font to get the following result: Since the node has two lines of text, I would normally do \texttt{line1\\line2}. However when I compile it I get lots of errors. If I do \texttt{line1}\\\texttt{line2} it compiles with no errors. Why can't I use \\ inside \texttt{}? Is there a solution to avoid putting \texttt{} on every line of text? \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node[draw,rectangle,align=center] {line1\\line2}; \end{tikzpicture} \end{document}
- How to push items to beginning of a slide in Beamer? [duplicate]by typos on January 7, 2017 at 12:18 pm
I have a slide that has some items and then underneath I have a figure, which is define as tikzpicture, while I want to point some arrows from items to the figure. The problem is that now both the figure and the items start from the center of the slide, and basically the figure is on top of the items. Any ideas how to solve this? \documentclass{beamer} \usepackage{tikz} \usetikzlibrary{positioning,tikzmark} \begin{document} \begin{frame}{Test} \begin{itemize} \item Item 1 \tikzmark{a} \item Item 2 \tikzmark{b} \item Item 3 \tikzmark{c} \item Item 4 \end{itemize} \centering \begin{tikzpicture}[remember picture,overlay] \node {\includegraphics[width=0.8\textwidth]{my-picture}}; \foreach \i/\j in {(0.5,0.66)/a} \draw [cyan,->] ({pic cs:\j}) -- \i; \end{tikzpicture} \end{frame} \end{document} The resulting layout should look like this sketch:
- Keep column height in Beamer when replacing contentby Little Bobby Tables on October 18, 2011 at 5:24 pm
I have a frame in Beamer that consists of two columns. The content of one column remains the same, the content of the other column is replaced on the second slide. \begin{frame} \begin{columns} \begin{column}{.5\textwidth} % some static content \end{column} \begin{column}{.5\textwidth} \begin{onlyenv}<1> % some tikz picture \end{onlyenv} \begin{onlyenv}<2> % some other tikz picture \end{onlyenv} \end{column} \end{columns} \end{frame} The problem with this configuration is that since the height of the second column changes, the position of the content of the first column also changes, and so the transition between the slides is not smooth - The first column "jumps" around. How can I keep the first column static, while changing the seconds?
- Beamer vs. TikZ: uncover nodes step-by-stepby Cactus on January 16, 2011 at 9:16 pm
I'm trying to uncover a TikZ image piece-by-piece like so: \documentclass{beamer} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{frame}{Linearity} \begin{center} \begin{tikzpicture} \node (Ctx) {\visible<2->{$\Gamma$}}; \node[below right=0.5cm and 0.1cm of Ctx] (E) {$E$}; \node[below right=0.5cm and 0.1cm of E] (psi1) {\visible<3->{$\Psi_1$}}; \end{tikzpicture} \end{center} \end{frame} \end{document} However, this gives the following error message: ! Package tikz Error: Giving up on this path. Did you forget a semicolon?. See the tikz package documentation for explanation. Type H <return> for immediate help. ... l.16 \end{frame} If I use \only instead of \visible, pdflatex runs OK but the output jumps around when going from slide to slide, since the invisible nodes don't take up space and thus the E node's position changes. So \visible is what I need.
- How do you draw the "snake" arrow for the connecting homomorphism in the snake lemma?by James Weigandt on October 8, 2010 at 4:32 am
How does one draw the "snake" arrow for the connecting homomorphism when using the snake lemma? I'd also be interested in drawing similar arrows act as "carriage returns" when considering a long exact sequence of cohomology. I'm sorry if this is a little vague. I'm hoping that someone who's already done this might be willing to share a template. I'd prefer things in xy-pic, but would also be interested to see other ways it can be done.