• Is that exists general method to plot ellipse without multiple intersections?
    by Explorer on July 18, 2025 at 2:49 pm

    I have a command \mydrawellipse in this link to draw slanted ellipses: \newcommand*\mydrawellipse[4][]{% % #2=pointA;#3==pointB;#4= ratio of y on x \tkzCalcLength(#2,#3)% \tkzGetLength{tmpdistance}% \tkzFindSlopeAngle(#2,#3) % \tkzGetAngle{tmpangle}% \begin{scope}[rotate=\tmpangle] \draw[dashed,thick,#1] (#3) arc [start angle=0,delta angle=180,x radius=\fpeval{\tmpdistance/2} cm,y radius=\fpeval{\tmpdistance * (#4) / 2}cm] (#2); \draw[thick,#1] (#2) arc[start angle=180,delta angle=180,x radius=\fpeval{\tmpdistance/2} cm,y radius=\fpeval{\tmpdistance * (#4) / 2}cm] (#3); \end{scope} } But when I use it to plot slanted ellipse in cylinders and cone: \documentclass[tikz,border=1cm]{standalone} \usetikzlibrary{spy} \usepackage{tkz-euclide} \usepackage{amsmath} \newcommand*\mydrawellipse[4][]{% % #2=pointA;#3==pointB;#4= ratio of y on x \tkzCalcLength(#2,#3)% \tkzGetLength{tmpdistance}% \tkzFindSlopeAngle(#2,#3) % \tkzGetAngle{tmpangle}% \begin{scope}[rotate=\tmpangle] \draw[thick,#1] (#3) arc [start angle=0,delta angle=180,x radius=\fpeval{\tmpdistance/2} cm,y radius=\fpeval{\tmpdistance * (#4) / 2}cm] (#2); \draw[thick,#1] (#2) arc[start angle=180,delta angle=180,x radius=\fpeval{\tmpdistance/2} cm,y radius=\fpeval{\tmpdistance * (#4) / 2}cm] (#3); \end{scope} } \begin{document} \tikzset{% every picture/.style={ spy using outlines={% circle,size=4cm, magnification=3, connect spies, } } }% \begin{tikzpicture} \tkzDefPoints{2/0/A,-2/0/B,2/6/C,-2/6/D} \tkzDrawSegments(A,C B,D) \mydrawellipse{A}{B}{0.5} \mydrawellipse{C}{D}{0.5} \tkzDefPoints{-2/2/P,2/4/Q} \tkzLabelPoints[left](P,Q) \mydrawellipse{P}{Q}{0.3} \spy[red] on (P) in node [left] at (-3,4); \spy[blue] on (Q) in node [right] at (4,3); \end{tikzpicture} \begin{tikzpicture} \tkzDefPoints{2/0/A,-2/0/B,0/6/C} \tkzDrawSegments(A,C B,C) \mydrawellipse{A}{B}{0.5} \tkzDefPoints{-1.5/1.5/P,.5/4.5/Q} \tkzLabelPoints[left](P,Q) \mydrawellipse{P}{Q}{0.15} \spy[red] on (P) in node [left] at (-3,4); \spy[blue] on (Q) in node [right] at (4,3); \spy[red] on (B) in node [left] at (-3,-2); \spy[blue] on (A) in node [right] at (4,-1.5); \end{tikzpicture} \end{document} The ellipse intersect with TWO tangent points, for which the major-axis's vertex of slanted ellipse is NOT at P and Q. I want to know is that elegant solution to refine the ellipse's plot to avoid this case?

  • Drawing lines in an AVM with tikz
    by Stefan Müller on July 18, 2025 at 1:04 pm

    I want to draw the following image for a beamer presentation. The code that should do the trick follows: \documentclass{beamer} \usepackage{array} \usepackage{tikz} \usetikzlibrary{tikzmark} \newcommand{\ms}[2][]{% \mbox{% \delimiterfactor=1000 \delimitershortfall=0pt \tabcolsep=0pt $\left[% \begin{tabular}{>{\upshape\scshape}l@{}>{\hspace*{5pt}\normalfont\itshape}l} \if\relax\detokenize{#1}\relax\else \multicolumn{2}{>{\normalfont\itshape}l}{#1}% \\ \fi #2% \end{tabular}% \right]$% }% \vspace{1mm}% } \newcommand{\sliste}[1]{% \mbox{% $\langle$\mbox{\upshape\scshape #1}$\rangle$}% } \begin{document} \frame{ \begin{tikzpicture}[overlay, remember picture] \ms{ subj & \subnode{subj2}{\ms{ gend & masc\\ num & sg\\ pers & 3\\ case & nom\\ pred & `PRO'}}\\ tense & pres\\ pred & \upshape `\textsc{seem-to}\sliste{(\textsc{xcomp})(\textsc{obl}\textsubscript{GO})}(\textsc{subj})'\\ obl\textsubscript{GO} & \ms{ pcase & \upshape \textsc{obl}\textsubscript{GO}\\ case & \upshape \textsc{acc}\\ gend & \upshape \textsc{fem}\\ num & \upshape \textsc{sg}\\ pers & 3\\ pred & \upshape `\textsc{pro}'}\\ xcomp & \ms{ subj & \subnode{subj1}{~}\\ prd & `sick\sliste{(\textsc{subj})}'}} \draw (subj1) -- (subj2); \end{tikzpicture} } \end{document} But I somehow do not get this to work.

  • tikz / tikzlibrary{calc,intersections}: draw a tangent line that intersects secant at right angle
    by Oregon Math Tutor on July 17, 2025 at 5:22 pm

    I need to draw a tangent line that intersects a secant line at a right angle outside the circle. The MWE below correctly renders a circle and a secant line, and labels the intersection points. However, I can't figure out how to reorient the tangent line so it intersects the secant at a 90° angle outside the circle. Questions: ❓ Questions: Is my secant line and labeling code efficient? How do I modify the code so the tangent intersects the secant at a right angle outside the circle? Thank you for taking time to assist me. mwe: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc,intersections} \usepackage{amsmath} \begin{document} \begin{tikzpicture}[scale=1.5] % Draw the circle with a name for intersection calculations \draw[thick, name path=circle] (0,0) circle (2); % Mark the center \fill (0,0) circle (1.5pt); \node at (0.2,-0.2) {$O$}; % Define the secant line path (extend beyond circle) \path[name path=secant] (-1,3) -- (3,-2); % Find intersection points automatically and store them \path[name intersections={of=circle and secant}] (intersection-1) coordinate (A) (intersection-2) coordinate (B); % Extend the secant line beyond the circle in both directions \draw[thick, red] (-1,3) -- (3,-2); % Mark intersection points \fill[red] (A) circle (1.5pt) (B) circle (1.5pt); % Labels for intersection points \node at (A) [above right] {$A$}; \node at (B) [below left] {$B$}; % Define tangent point on the circle \coordinate (T) at (1.6, 1.2); % Point on circle where tangent touches % Draw tangent line (perpendicular to radius at T) % The radius to T has direction (1.6, 1.2), so perpendicular direction is (-1.2, 1.6) \draw[thick, blue] ($(T) + 2*(-1.2, 1.6)$) -- ($(T) + 2*(1.2, -1.6)$); % Mark the tangent point \fill[blue] (T) circle (1.5pt); \node at (T) [above left] {$T$}; \end{tikzpicture} \end{document}

  • pgfplots generating images in RGB no matter what you define
    by Knudsen on July 17, 2025 at 5:51 am

    I have a pgfplot, that seems to obey all requirements to produce and image using the Gray colorspace only, following what the manual says as well as the answer to this question here: \documentclass{report} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture}[scale=0.7] \begin{axis}[ domain=0:4, samples=30, smooth, axis lines=center, xlabel={$K$}, ylabel={$L$}, zlabel={$f(K,L)$}, xmin=0, xmax=5, ymin=0, ymax=5, zmin=0, zmax=5, view={80}{30}, colormap/blackwhite ] % Define the function to plot \def\f(#1,#2){#1^0.5 * #2^0.5} \addplot3 [surf] {\f(x,y)}; \end{axis} \end{tikzpicture} \end{document} but when run with xelatex produces a PDF file that fed to Adobe Acrobat shows a bunch of elements in RGB:

  • Tikz edges are not drawn correctly between dynamically generated nodes
    by kaba on July 16, 2025 at 6:00 pm

    The following code generates nodes and edges dynamically. However, the edges are drawn strangely so that they connect to the right side of each node circle. What is wrong, and how can I fix this? If I instead draw an edge manually with \path (v1) edge (v0), then it draws the edge correctly. \documentclass[tikz, crop, border=1]{standalone} \usetikzlibrary{math} \usetikzlibrary{calc} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture}[ >={Stealth[black]}, every node/.style={circle,thick,draw}, every edge/.style={->, draw=black, thick} ] \tikzmath { \n = 2; } \foreach \x in {0, ..., \n} { \tikzmath { \s = 1.5; \y = \s^(-\x) * 4; } \node (v\x) at (4, \y) {}; \node (d\x) at (\y, \y) {}; \node (b\x) at (\y, 0) {}; } \node at (0, 0) {}; \tikzmath { \nn = \n - 1; } \foreach \x in {0, ..., \nn} { \tikzmath { \nx = \x + 1; } \path (d\nx) edge (d\x); \path (v\nx) edge (v\x); } \foreach \x in {1, ..., \n} { \path (b\x) edge (d\x); } \end{tikzpicture} \end{document}

  • draw symmetrical peaks [closed]
    by Nicolas on July 16, 2025 at 8:28 am

    To enhance a lesson, I would like to be able to reproduce this type of diagram and more particularly the double peak (which I can simplify by taking the same height) but I don't see what is the best method for this?

  • Plotting label outside of axis bounds causes incorrect drawing
    by crayman9 on July 16, 2025 at 4:16 am

    In the following code, which greatly simplifies an issue I'm seeing in more elaborate code, I'm attempting to draw a cropped blue-filled rectangle, and then over that plot, draw a black rectangle over approximately the lower right quadrant, and add 3 variously placed labels, one of which is outside of the defined display bounds. When correctly drawn, it should look like this: , however the picture ends up looking like this (black rectangle is shifted right with the rightmost part chopped off): The text string "Maverick" lies outside of the cropped area. If I either delete the line containing "Maverick" or change to plotting points rather than Labels in addplot, the figure comes out correct. Also if I change the Longitude of Maverick to -98.8, which is the left bound of the first axis (and crop), it works fine; and if I move it progressively further left (-99.0, -100.0, -101.0), the black rectangle progressively moves to the right until it eventually disappears. Why would plotting a label outside of the cropped area screw the plot up (shift the black rectangle right)? Here is the offending code: \documentclass[twocolumn]{article} \usepackage[margin=0.5in]{geometry} \usepackage{tikz} \usepackage{pgf} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage{lipsum} \begin{document} \lipsum[1-3] \pgfmathsetmacro{\latmin}{26.782} \pgfmathsetmacro{\latmax}{30.227} \pgfmathsetmacro{\longmin}{-98.8} \pgfmathsetmacro{\longmax}{-94.933} \begin{figure}[!t] \centering \begin{tikzpicture} \begin{axis}[ xmin=\longmin, xmax=\longmax, ymin=\latmin, ymax=\latmax, axis equal image=false, unit vector ratio=1 1.16, axis lines=none, grid=none, clip=true, width=\columnwidth, height=40cm, clip mode=individual, scale only axis=true, ] \begin{scope} \clip (axis cs:\longmin,\latmin) rectangle (axis cs:\longmax,\latmax); \filldraw[fill=blue!20, draw=black] (-106.64584, 25.837168) rectangle (-93.050803, 36.5); \addplot[ scatter, only marks, scatter src=explicit symbolic, mark=none, nodes near coords, nodes near coords style={ anchor=center, text centered, font=\scriptsize, }, point meta=explicit symbolic ] table [ col sep=comma, meta=County, x=Longitude, y=Latitude ] { County,Latitude,Longitude Austin,29.95,-96.32 Brazoria,29.15,-95.45 Maverick,28.920000000000002,-100.370000000000005 }; \end{scope} \end{axis} \begin{axis}[ at={(rel axis cs:1,0)}, anchor=south east, xmin=-106.64584, xmax=-93.050803, ymin=25.837168, ymax=36.5, axis lines=none, ticks=none, clip=true, axis equal image=false, width=0.5*\columnwidth, height=40cm, unit vector ratio=1 1.16, scale only axis=true, ] \draw (-106.64584, 25.837168) rectangle (-93.050803, 36.5); \end{axis} \end{tikzpicture} \end{figure} \lipsum[4-6] \end{document} Here is the variation of addplot that results in the correct figure: \addplot[ scatter, only marks, mark size=1pt ] table[ x=Longitude, y=Latitude, col sep=comma ] {

  • Why is xscale ignored when in \draw with pre-assigned coordinate?
    by Explorer on July 16, 2025 at 2:17 am

    It seemed maybe duplicated but I didn't sreach it. I found that xscale doesn't work with node's anchor but coordinate work as my expected? Here below is my code: \documentclass[tikz,border=3pt]{standalone} \begin{document} \begin{tikzpicture} % work mirror with coordinates \draw[blue] (0,0) -- (.5,.5); \draw[red,dashed,xscale=-1] (0,0) -- (.5,.5); % not mirror with node \node (A) at (2,3) {A}; \node (B) at (1,1) {B}; \draw[green] (A) -- (B); \draw[orange,dashed,xscale=-1] (A.center) -- (B.center); \end{tikzpicture} \end{document} My Questions: Why is the coordinate work, but node's anchor doesn't with xscale? Is that possible to make it work with node.center in this case?

  • How to draw a square with labeled vertices?
    by Intuition on July 15, 2025 at 12:45 pm

    Here is my thinking: \documentclass[12pt]{article} \usepackage{tikz} \begin{document} \usetikzlibrary{calc} \[\begin{tikzpicture} \coordinate (00) at (0,0); \coordinate (10) at (2,0); \coordinate (11) at (2,2); \coordinate (01) at (0,2); % \coordinate (00) at (0,0); \fill (00) circle (0.05); \fill (10) circle (0.05); \fill (11) circle (0.05); \fill (01) circle (0.05); \draw (00) node[below] {00} -- (10) node[below] {10} -- (11) node[above] {11} -- (01) node[above] {01}($ (01)!1!-90:(00) $) -- ($ (00)!1!90:(01) $) -- cycle; %-- ($ (10)!1!-90:(11) $) -- ($ (11)!1!90:(10) $) -- cycle; \end{tikzpicture}\] \end{document} but I do not know how to adjust the side that is on the left to actually close the square, any help will be greatly appreciated! Here is the picture I got: I think my mistake is in how to close the cycle, the last line in my code.

  • 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 tikz [closed]
    by 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-euclide
    by 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 known
    by 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 diagram
    by 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 TikZ
    by 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 bases
    by 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}

  • How to make sphere in TikZ
    by Mr.Price on January 27, 2025 at 1:42 pm

    I'm learning to make 3D figures like cone, triangle, sphere etc in TikZ and hopefully I managed to make nicely looking cones and triangels but the problem is with Sphere. This how I currently managed to make my simple sphere: \documentclass[border=2mm,12pt,tikz]{standalone} \usetikzlibrary{angles, quotes} \usepackage{amssymb} \usetikzlibrary {arrows.meta, shapes.geometric, trees, shapes, backgrounds,intersections, patterns} \usepackage{pgfplots} \usepgfplotslibrary{units} \usetikzlibrary{positioning} \usepackage{amsmath, amssymb} \usepackage{siunitx} \usepackage{tikz-3dplot} \begin{document} \def\myr{3} \tdplotsetmaincoords{75}{90} \begin{tikzpicture}[tdplot_main_coords] \begin{scope} [canvas is xy plane at z=0] % O \coordinate (O) (0,0); \node[right] at (O) {$O$}; % Back half circle (dashed) \draw[dashed] (\tdplotmainphi:\myr) arc(\tdplotmainphi:\tdplotmainphi+180:\myr) coordinate(R); % Front half circle (solid) + BL \draw[thick] (\tdplotmainphi:\myr) arc(\tdplotmainphi:\tdplotmainphi-180:\myr) coordinate(L); \end{scope} \begin{scope} [canvas is yz plane at x=0] \draw[thick] (O) circle(\myr); \end{scope} \fill (O) circle(1pt); \draw (O) -- (R) node[midway, above]{$r$}; \end{tikzpicture} \end{document} But I'm wondering how can I do this kind of sphere with circles across various axes, nicely filled in color, with some points and arrow indicating the rotation. Is it possible to extend my approach to obtain this effect or it will be more complicated?

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

  • Separate frames for overlays in handout mode
    by nimmmiaumit on April 9, 2024 at 9:30 am

    For my lecture, I often use TikZ to illustrate concepts graphically. There is usually a lot of information in the graph, and TikZ includes different illustrations on separate frames. In the handout mode, however, everything is collapsed into one, making it illegible. How can I maintain the handout mode for "typical" slides, but temporarily switch to having a separate page per overlay for a specific slide? Here is a MWE. The issue is that both parts of the tikzpicture are printed on top of each other. The solution given here suggests replacing each <X> by <X|handout:X>. That would work in this particular context, but it is tedious for slides that have many separate overlays (and I also use the transparency mode, so I'd really have to repeat it twice). \documentclass[handout]{beamer} \usepackage{tikz} \begin{document} \begin{frame} \begin{itemize}[<+->] \item Show all of this \item at once \item in the handout. \end{itemize} \end{frame} \begin{frame} % \begin{animatedhandout} % see below \centering \begin{tikzpicture} \only<1>{\draw (-1,-1) rectangle (1,1) (1,0) node[anchor=west] {Info 1};} \only<2>{\draw (0,0) circle (1) (1,0) node[anchor=west] {Info 2};} \end{tikzpicture} % \end{animatedhandout} \end{frame} \begin{frame} \begin{itemize}[<+->] \item Again, this should \item all be shown at once \item in the handout. \end{itemize} \end{frame} \end{document} I was thinking of defining a command \newcommand<>{\onlyev}[1]{ \only<#2 | handout:#2 | tran:#2 >{#1} } that is printed only on the specified slide in every mode ("only everywhere"). The issue is that argument #2 already includes the pointy braces, so \onlyev<7>{hello} would expand to \only<<7> | handout:<7> | tran:<7> >{hello} which does not have the desired effect. If anyone can help me strip the < and > symbol from my argument, I could use this approach. Alternatively, I've tried to define an environment animatedhandout which I could call inside a frame to temporarily switch to beamer mode based on this answer. \makeatletter \newenvironment{animatedhandout}{ \begingroup \gdef\beamer@currentmode{beamer} }{% \endgroup } \makeatother Unfortunately, this does not seem to switch back to handout mode after the slide (it also messes up the centering for some reason).

  • CircuiTikZ: Start ground relative to the closest component
    by Martín on June 18, 2019 at 6:02 pm

    Here is a short compilable example \documentclass{article} \usepackage{tikz} \usepackage{circuitikz} \begin{document} \begin{circuitikz} \draw node[ground]{} to [short,*-] (0,0) to [C] (0,2) to [short,-*] (0,2); \node[xshift=1.75cm](0,0){$ \leftarrow $ Start ground here}; \end{circuitikz} \end{document} which produces The question is: How do you draw the first line of the ground in the marked point? The CircuiTikZ documentation for the node ground does not define an anchor in that exact position.

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

  • Is it possible to use tikzmark inside minted?
    by Joey Eremondi on January 14, 2016 at 1:47 am

    As I've pointed out in a related question, I'd like to have some arrows pointing to parts of a source-code listing. I know this is possible with the listings package, but is it possible with minted? That is, is there a way that I can insert a mark at a specific point inside the code minted is displaying?

  • Tikz: how to change the order of overlapping objects?
    by Helena on April 12, 2015 at 10:11 am

    I want to draw some overlapping rectangles, for example: \documentclass{article} \usepackage{tikz} \usetikzlibrary{shapes,backgrounds} \begin{document} \begin{tikzpicture} \draw [fill=blue,ultra thick] (0.4,0.5) rectangle (0,1); \draw [fill=red,ultra thick] (0,0.3) rectangle (1,1); \draw [fill=green,ultra thick] (0,0) rectangle (0.5,0.5); \end{tikzpicture} \end{document} But I want (in this example) the green rectangle under the red and the red under the blue. Is that possible (without changing the order of commands)? More explanation: the latex commands are generated by a C++ program which computes coordinates of some rectangles. I want to draw them and they can overlap. The program computes the rectangles in some order and I want to show them in the reverse order. (It seems difficult to me to write the lines of C++ output to a file in reverse order.) Here is what I have and what I want:

  • Reusing parts of TikZ animation in beamer
    by hannes on September 9, 2013 at 12:14 pm

    I'd like to reuse part of an animated TikZ figure in beamer. Before switching to TikZ, I built PDF animations with IPE, and could select specific pages in the \includegraphics{} command. To do the same in TikZ, my approach would be to generate standalone tikz figures in PDFs and do the same as before. I'm wondering whether there is a more intelligent way that avoids the need for multiple files. Note that the \againframe{} command won't help, since I want to have other content on the slide with the repeated animation as well. Here is a minimal example: \documentclass{beamer} \usepackage{tikz} \tikzset{ invisible/.style={opacity=0}, visible on/.style={alt={#1{}{invisible}}}, alt/.code args={<#1>#2#3}{% \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path }} \begin{document} \begin{frame}{test} This is the first frame, which contains an animation: \begin{tikzpicture} \node[rectangle](a){A}; \node[rectangle,visible on=<2>] (b) at (0, 2) {B}; \draw[->,visible on=<2>] (a) -- (b); \end{tikzpicture} \end{frame} \begin{frame}{test2} This is the second frame, which should include the figure from the 1st, but only the final, i.e. second part of the animation. % ....? \end{frame} \end{document}

  • Keep column height in Beamer when replacing content
    by 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?

  • How can I draw the outline of a path in tikz?
    by Christoph on May 11, 2011 at 8:36 am

    Using the arrow tip library, I can draw thick arrows with triangular tips, like so: \begin{tikzpicture} \draw[line width=2ex, rounded corners=2ex, triangle 90 cap reversed-triangle 90 cap ] (0,0) -| (1,1); \end{tikzpicture} These arrows are filled. I want just the outline of this arrow, but just using the "double" style doesn't do that. Both the start and end tip are filled: \begin{tikzpicture} \draw[line width=2ex, rounded corners=2ex, double distance between line centers=2ex, double, line width=1pt, triangle 90 cap reversed-triangle 90 cap ] (0,0) -| (1,1); \end{tikzpicture} I think I need to create the outline of the first arrow (which is totally filled), and then draw a line along this outline. I just have no clue how I could do that. I ended up drawing each arrow twice, as first suggested by EEva, but refined in the way that Andrew suggested. I'm using a LaTeX length to store the width of the line "around" the arrow. This width is called \DblTriCapDelta and the tikz style that uses this length is called DblTriCap, as it produces a triangluar capped arrow with double stroke: \newlength{\DblTriCapDelta} \setlength{\DblTriCapDelta}{1pt} \tikzset{ DblTriCap/.style={ postaction={ draw, color=white, shorten >=1.4142\DblTriCapDelta, shorten <=2.4142\DblTriCapDelta, line width={\pgflinewidth-\DblTriCapDelta} } } } I have yet to define a key handler (never did that before). The current usage is: \begin{tikzpicture} \draw[line width=4mm, rounded corners=4mm, triangle 90 cap reversed-triangle 90 cap, DblTriCap ] (0,0) -| (1,1); \end{tikzpicture} I'd like to be able to choose the fill colour, but didn't quite get it to work.

  • Beamer vs. TikZ: uncover nodes step-by-step
    by 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.