• How to shrink with a certain amount of offset?
    by D G on May 14, 2026 at 1:09 pm

    I want a one cm offset between the blue path and the black one. \documentclass[tikz,margin=1cm]{standalone} \begin{document} \begin{tikzpicture} \draw[gray!50] (-8,0) grid (8,-8); \fill (0,0) node[above=12pt]{origin} circle (5pt); \draw[ultra thick] (-6,0) arc[x radius=12,y radius=8,start angle=90,end angle=0] -- (-6,-8) -- cycle; \draw[blue,ultra thick] (-5,-1) arc[x radius=10,y radius=6,start angle=90,end angle=0] -- (-5,-7) -- cycle; \end{tikzpicture} \end{document} Note: Both must be similar. Right now both are not similar.

  • Tikz: perpendicular line to intersect the x-axis
    by Tldi You on May 14, 2026 at 10:11 am

    I would like to draw a line starting from the point (200, 105.6), perpendicular to the failure envelope, and extending down to intersect the x-axis. I have implemented the following LaTeX/TikZ \documentclass[border=2pt]{standalone} \usepackage{pgfplots,siunitx} \pgfplotsset{compat=1.18} \usetikzlibrary{calc} \begin{document} \centering \begin{tikzpicture} \begin{axis}[ width=15cm, height=9.375cm, xmin=0, xmax=640, ymin=0, ymax=400, xtick={0,80,...,640}, ytick={0,80,...,400}, minor tick num=1, grid=both, grid style={black, thin}, minor grid style={black, thin}, xlabel={Contrainte normale ($\sigma_{nr}$), $kN/m^2$}, ylabel={Contrainte de cisaillement ($\tau_r$), $kN/m^2$}, axis line style={thick}, tick label style={font=\small}, label style={font=\small}, clip=false ] % Regression line: tau = 34 + sigma * tan(20) \addplot [domain=0:590, samples=2, thin, black] {34 + x*tan(20)}; % Data points on the line (open circles) \addplot [only marks, mark=o, mark size=3.5pt, fill=white, thin, black] coordinates { (100, 72.2) (200, 105.6) (300, 144.4) (400,177.7) }; % Solid dot and its label \node [circle, fill, inner sep=1.5pt] (dot) at (axis cs:320, 138) {}; \node [anchor=west, xshift=2pt] at (axis cs:320, 138) {\small (320, 138)}; % Perpendicular line from the 3rd circle (x=300) \coordinate (P) at (axis cs:200, {36 + 200*tan(20)}); \draw [very thick, black] (P) -- (axis cs:252.1, 0); % Right angle symbol \draw [very thick, black] ($(P) + ({-18*cos(20)}, {-18*sin(20)})$) -- ($(P) + ({-18*cos(20) + 18*sin(20)}, {-18*sin(20) - 18*cos(20)})$) -- ($(P) + ({18*sin(20)}, {-18*cos(20)})$); % Angle phi indicator \coordinate (phi_pt) at (axis cs:520, {34 + 520*tan(20)}); \draw [thin, black] (phi_pt) -- +(0.8cm, 0); \draw [thin, black] (phi_pt) +(0.5cm, 0) arc (0:20:0.5cm); % Box in top right \node [draw, thick, fill=white, align=center, inner sep=10pt] at (axis cs:520, 340) { $c = 34 \, kN/m^2$ \\ $\varphi = \ang{20}$ }; % Phi angle \coordinate (V) at (axis cs:520,223); \draw[thin] (V) -- ++(25pt,0); \draw[thin] ($(V)+(15pt,0)$) arc[start angle=0,end angle=20,radius=15pt]; \node[right] at ($(V)+(22pt,2pt)$) {$\varphi$}; \end{axis} \end{tikzpicture} \end{document} Do you have any suggestions or improvements? CURRENT RESULT:

  • expl3 syntax in pgfdeclaredataformat command
    by tkl on May 13, 2026 at 5:06 pm

    Is it possible to use expl3 syntax, specifically floating point operations, within a pgfdeclaredataformat command? Below is a minimal example, indeed with a workaround solution. Comment out the doesnotwork lines to get an error. Actual computations are different and involve a small Newton solver. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{datavisualization} \begin{document} \ExplSyntaxOn \def\tologarithmic#1#2{ % 0.43429 = 1/ln(10) \pgfkeys{/data~point/x=\fp_to_decimal:n{0.43429*ln(#1)}} \fp_log:n {0.43429*ln(#1)}% to see in the log file, that the calculation actually works! \pgfkeyssetvalue{/data~point/y}{\fp_to_decimal:n{0.43429*ln(#2)}} \pgfdatapoint } \ExplSyntaxOff \pgfdeclaredataformat{compute}{}{} {#1 #2}% line format {\tologarithmic{#1}{#2}}% code {}{} %\def\doesnotwork{% \begin{tikzpicture} \datavisualization[scientific axes, visualize as scatter, x axis=logarithmic, y axis=logarithmic ] data[format=compute,set=scatter] { 2.868E+03 2.804E-02 5.636E+04 2.061E-02 1.791E+06 1.079E-02 3.554E+07 7.080E-03 }; \end{tikzpicture} %}% end doesnotwork % the workaround solution \begin{tikzpicture} \datavisualization[scientific axes, visualize as scatter ] data[format=TeX code,set=scatter] { \tologarithmic{2.868E+03}{2.804E-02} \tologarithmic{5.636E+04}{2.061E-02} \tologarithmic{1.791E+06}{1.079E-02} \tologarithmic{3.554E+07}{7.080E-03} }; \end{tikzpicture} % that is how the graph should look like \begin{tikzpicture} \datavisualization[scientific axes, visualize as scatter, x axis=logarithmic, y axis=logarithmic ] data[set=scatter,separator=\space] { x y 2.868E+03 2.804E-02 5.636E+04 2.061E-02 1.791E+06 1.079E-02 3.554E+07 7.080E-03 }; \end{tikzpicture} \end{document}

  • Remember coordinate in nested tikzpicture with listings
    by Jason Cho on May 13, 2026 at 2:10 pm

    \documentclass{standalone} \usepackage{xcolor} \usepackage{tikz} \usepackage{listings} \begin{document} \begin{tikzpicture}[remember picture] \node[draw] {\begin{lstlisting}[language=c++, linewidth=140pt, basicstyle=\ttfamily\scriptsize] class Counter : public QObject { public: Counter() { value = 0; }!\tikz[remember picture]\node (l1){};! int getValue() { return value; }!\tikz[remember picture]\node (l2){};! }; \end{lstlisting}}; \draw[red, ->] (l1) -- (l2); \end{tikzpicture} \end{document} In this code snippet, I use listings to syntax highlight a piece of C++ code, where I mark two lines with name l1 and l2. Then I want to use the coordinates of l1 and l2. However, the output is off. How do I fix the location of the named coordinates? Requirements: I name these two points because there are a dozen of commands relying on these coordinates. Therefore I do not want to cram these commands between the escapechars of lstlisting. I want to measure the full size of the picture, including the main listing and adornments. For example, when I center the picture, the whole pic is centered, not only the main listing. I have checked: Remember coordinate in nested tikzpicture points to a weird place was solved by using a special command \subnode in tikz-qtree. access a coordinate in a nested \tikzpicture was solved by removing nesting.

  • Troubles with negative numbers on bar graph [duplicate]
    by Ismael Joaquim on May 12, 2026 at 9:00 am

    everyone. I'm having troubles with the negative labels in the first graph.Can someone help me with this? \documentclass{standalone} \usepackage{pgfplots} \usepackage{pgfplotstable} \usepackage{tikz} \usetikzlibrary{pgfplots.groupplots, calc} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{groupplot}[ group style={ group size=2 by 1, horizontal sep=1.2cm }, ybar, width=7.2cm, height=6.2cm, ymode=log, log origin=infty, title style={font=\normal\bfseries}, symbolic x coords={NaCl (B1),TiC (B1),FeSi (B20)}, xtick=data, tick label style={font=\small}, x tick label style={font=\small}, visualization depends on={y \as \originalvalue}, nodes near coords={% \pgfmathprintnumber[fixed,precision=3]{\originalvalue}% }, nodes near coords style={ font=\small, rotate=90, anchor=west }, enlarge x limits=0.20, grid=major, major grid style={dashed, gray!35}, ] % ====================================================== % (a) Regime \pm 10% V0 — DADOS REAIS DOS FICHEIROS % ====================================================== \nextgroupplot[ bar width=6pt, title={(a) Regime $\pm 10\%\,V_0$}, ylabel={RMSE (meV/célula)}, ymin=1e-2, ymax=1e1, legend to name=gruppolegend, legend style={ legend columns=6, draw=black, fill=white, font=\small, column sep=6pt, }, ] % Murnaghan — NaCl: 0.061718, TiC: 0.216179, FeSi: 0.256858 \addplot+[fill=blue!75, draw=blue!75!black] coordinates { (NaCl (B1),0.061718) (TiC (B1),0.216179) (FeSi (B20),0.256858) }; \addlegendentry{Murnaghan} % BM3 — NaCl: 0.027460, TiC: 0.057278, FeSi: 0.072263 \addplot+[fill=red!80, draw=red!80!black] coordinates { (NaCl (B1),0.027460) (TiC (B1),0.057278) (FeSi (B20),0.072263) }; \addlegendentry{BM3} % Vinet — NaCl: 0.037637, TiC: 0.105771, FeSi: 0.125342 \addplot+[fill=purple!75, draw=purple!75!black] coordinates { (NaCl (B1),0.037637) (TiC (B1),0.105771) (FeSi (B20),0.125342) }; \addlegendentry{Vinet} % q-EoS (n=2) — NaCl: 0.027461, TiC: 0.057532, FeSi: 0.072068 \addplot+[fill=green!70!black, draw=green!50!black] coordinates { (NaCl (B1),0.027461) (TiC (B1),0.057532) (FeSi (B20),0.072068) }; \addlegendentry{q-EoS $(n=2)$} % q-EoS (n=3) — NaCl: 0.027537, TiC: 0.058481, FeSi: 0.073480 \addplot+[fill=orange!90, draw=orange!70!black] coordinates { (NaCl (B1),0.027537) (TiC (B1),0.058481) (FeSi (B20),0.073480) }; \addlegendentry{q-EoS $(n=3)$} % ====================================================== % (b) Regime \pm 50% V0 — DADOS REAIS DOS FICHEIROS % ====================================================== \nextgroupplot[ bar width=6pt, title={(b) Regime $\pm 50\%\,V_0$}, ymin=1e0, ymax=1e4, ] % Murnaghan — NaCl: 38.483922, TiC: 179.827163, FeSi: 209.918058 \addplot+[fill=blue!75, draw=blue!75!black] coordinates { (NaCl (B1),38.483922) (TiC (B1),179.827163) (FeSi (B20),209.918058) }; % BM3 — NaCl: 2.118186, TiC: 44.043547, FeSi: 63.469045 \addplot+[fill=red!80, draw=red!80!black] coordinates { (NaCl (B1),2.118186) (TiC (B1),44.043547) (FeSi (B20),63.469045) }; % Vinet — NaCl: 23.998934, TiC: 27.367181, FeSi: 38.077585 \addplot+[fill=purple!75, draw=purple!75!black] coordinates { (NaCl (B1),23.998934) (TiC (B1),27.367181) (FeSi (B20),38.077585) }; % q-EoS (n=2) — NaCl: 1.962260, TiC: 54.617663, FeSi: 61.961751 \addplot+[fill=green!70!black, draw=green!50!black] coordinates { (NaCl (B1),1.962260) (TiC (B1),54.617663) (FeSi (B20),61.961751) }; % q-EoS (n=3) — NaCl: 3.740124, TiC: 59.084828, FeSi: 68.649034 \addplot+[fill=orange!90, draw=orange!70!black] coordinates { (NaCl (B1),3.740124) (TiC (B1),59.084828) (FeSi (B20),68.649034) }; \end{groupplot} % Legenda centralizada acima dos dois painéis \node at ($(group c1r1.south east)!0.5!(group c2r1.south west)+(0,-1.1cm)$) {\pgfplotslegendfromname{gruppolegend}}; \end{tikzpicture} \end{document}

  • How to draw two squares beside each other?
    by Intuition on May 11, 2026 at 11:23 am

    Here is the picture I want to draw: I know how to draw just one colored square, for example here is a code to it: \documentclass[12pt]{article} \usepackage[utf8]{inputenc} \usepackage[a4paper, margin=1.5in]{geometry} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{tikz-cd} \usepackage{amsmath,amsfonts,amssymb} \usepackage{amsthm} \usepackage{graphicx} \usepackage[all,cmtip]{xy} \usepackage[english]{babel} \usepackage{xurl} \usetikzlibrary{positioning, shapes.geometric} \begin{document} \begin{tikzpicture}[ every path/.style={thick}, every node/.style={circle,fill=black,draw,inner sep = 0pt, minimum size= 2pt} ] \draw[red] (0,0)--(2,0); \draw[cyan] (2,0)--(2,2); \draw[yellow] (2,2)--(0,2); \draw[red] (0,2)--(0,0); \draw[green] (0,0)--(2,2); %\draw[green] (0,2)--(2,0); \foreach \corner in {(0,0), (2,0), (2,2), (0,2)} \node at \corner {}; \end{tikzpicture} \end{document} Also, how to remove the common edge if I aligned the two squares beside each other? Any help will be greatly appreciated.

  • Tikz node text width and alignment messed up spaces and indentation
    by aky-her on May 10, 2026 at 5:52 pm

    I have a mono-spaced font (TeX Gyre Cursor), but when I use it in a Tikz node with text width = XYcm the spaces change size. Is there a way to either preserve the space size with the width command, or achieve automatic line breaks in tikz node in some other way that does not break the spaces? Additionally, when using alignemnt, it inserts an indent at the start of the text, which I was not able to remove with \setlength{parindent}{0pt}. What causes this indent and how can I remove it? Here is my full node code: \node at (3, 1.75) [ align = left, text width = 4.6cm, ] {\setlength{\parindent}{0pt}\textbf{\setfontsz{\sztext} Text line 1, Longer text line 2, Even way way way way longer text line 3, Text line 4}}; EDIT: here is the full code: \documentclass{article} \usepackage[paperheight=8cm, paperwidth=6cm, left=0pt, top=0pt, right=0pt, bottom=0pt]{geometry} \usepackage{tikz} \usepackage{fontspec} \usepackage{array} \setmainfont{TeX Gyre Cursor} \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}} %% horizontal centering \newcommand{\setfontsz}[1]{ \fontsize{#1}{1.2#1} \selectfont } \pagestyle{empty} %\renewcommand{\arraystretch}{2.2} \newcommand{\sztext}{8pt} \begin{document} %\vspace*{-\baselineskip} \begin{tikzpicture}[remember picture, overlay, shift = {(current page.south west)}] \node at (current page.center) [] {\includegraphics[height=\paperheight]{example-image-a.png}}; \node at (3, 1.75) [ align = left, text width = 4.6cm, ] {\setlength{\parindent}{0pt}\textbf{\setfontsz{\sztext} Text line 1, Longer text line 2, Even way way way way longer text line 3, Text line 4}}; \end{tikzpicture} \end{document}

  • How can I list or visualize all available anchors of a CircuitTikZ component?
    by internet on May 8, 2026 at 9:31 am

    I am using CircuitTikZ and often need to connect wires or labels to component anchors. However, it is not always easy to know which anchors are available for a specific component. For example, different components may provide anchors such as north, south, in, out, gate, collector, emitter, etc., and the available anchors vary depending on the component type. When building more complicated schematics, I frequently need to stop and search through the documentation to check anchor names. I was wondering whether there is a way to programmatically: List all available anchors of a given CircuitTikZ/TikZ shape/components, and/or Visualize those anchors directly on the rendered component. For example, something conceptually like: \showanchors{a component/shape} that would either print all anchor names and draw markers/labels on the component itself. So my question is: Is there a practical way to list all anchors associated with a TikZ/CircuitTikZ shape? My motivation is mainly usability and workflow efficiency. A tool like this would make it much easier to explore unfamiliar components and reduce the need to constantly check the manual, especially for beginners or occasional CircuitTikZ users. This is an example of visualizing the anchors to help wiring from CircuiTikz documentation. A possible MWE (clearly, the pin thing must be adjusted somehow to have a better distribution, and to take into account that labels can have spaces and strange characters, but well...). The task it to substitute the \allanchors definition with something automatic, see the comment above it. \documentclass[border=10pt]{standalone} \usepackage[T1]{fontenc} \usepackage[siunitx, RPvoltages]{circuitikz} \begin{document} \begin{tikzpicture}[every pin/.append style={text=red, inner sep=1pt, font=\tiny\ttfamily}] \node [npn](myshape) at (0,0) {}; % Example: this should be autofilled % Basically, for every shape named, say, "gizmo", the anchor "spot" % is a macro named pgf@anchor@gizmo@spot % --- so to do what you want, you should be able to find all % the macros with that pattern that exist % (and I do not know if this is possible in TeX in general, % maybe in LuaTeX...). \newcommand{\allanchors}{center,E,B,south} \foreach \anc in \allanchors { \node[circ, pin=45:\anc] at (myshape.\anc) {}; } \end{tikzpicture} \end{document}

  • How to get a line segment to line up nicely with a fill in TikZ?
    by Jasper on May 7, 2026 at 11:19 pm

    I have this MWE (it must be zoomed in on): I want the red line to go all the way to the green one on the top, but not exceed the dark gray on the bottom. Likewise, the green should be bounded by, and extruded to the boundary also. (The green one goes beyone on top, but we just can't see it due to the ligh gray triangle occluding it). I would like for this to be as automatic as possible. I want it to look like this: This is my use case: \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \fill[gray] (0,0) -- (1,1) -- (1,0) -- cycle; \draw[thick,green] (0.75,0.25) -- (0.25,0.25); \fill[gray!50!white] (0,0) -- (1,1) -- (0,1) -- cycle; \draw[thick,red] (0.1,0.25) -- (0.25,0.25); \end{tikzpicture} \end{document}

  • Draw simple figures: l3draw vs PGF performances
    by PHL on April 30, 2026 at 3:08 am

    I have some lua code that generates coordinates of many triangles/quadrilaterals I then want to draw/fill. See this answer about Penrose tilings for a concrete example. The drawing is actually done in TikZ via the luadraw package, but I am wondering if I can make the code faster by replacing TikZ with l3draw. Rewriting my actual code to remove TikZ and luadraw dependences (and use l3draw or any other drawing tool) is not a complex task, but will ask me some time due to my limited programming skills. So I would prefer to know in advance if this is a good idea or not. Apart possibly performance, is there any other reasons to use l3draw over pgf for this kind of task? Edit: I am not using TikZ/pgf for the rest of the document. Suggesting to use another environment (as picture) is a valid answer.

  • How to create a TikZ node whose top matches one node’s north and bottom matches another node’s south?
    by Lecthor on April 16, 2026 at 3:18 pm

    I have two rectangular TikZ nodes placed one below the other: B1 is above B2. I would like to create a third rectangular node B3, shifted to the right in the x-direction, such that: the top of B3 is aligned with B1.north the bottom of B3 is aligned with B2.south I am not sure what is the best TikZ way to do this cleanly. Here is a minimal example of the situation: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \tikzstyle{block} = [draw, fill=white, rectangle, inner xsep=0pt, align=center, font=\small]% \begin{tikzpicture} \node [block, text width=3em] (B1) {Block 1}; \node [block, anchor=north, text width=3em] (B2) at ([yshift=-5em]B1.south) {Block 2}; \node [block, anchor=west] (B3) at ([xshift=5em]$(B1.east)!0.5!(B2.east)$) {Block 3}; \end{tikzpicture} \end{document} I tried using minimum height with coordinate differences, but I could not make it work properly. What is the recommended approach?

  • pgf-PeriodicTable: monochrome (black/white) Periodic table - problem with radiation symbol and 'Ra' shorthand
    by cis on April 4, 2026 at 6:57 am

    I want to create a perfect monochrome Periodic table (for black and white printing, etc.). 1/2. Instead of the colored "radioactive symbol" (which seems to be set hard-coded by the package), I'd like to use an asterisk '*' or a simple text character. 2/2. Secondly, the term 'Ra' in the legend must also be replaced by the star (or the other symbol used). Note: The aforementioned "radioactive symbol" seems to be (hard-coded) retrieved from the file /texmf-dist/tex/latex/pgf-periodictable/pgfPT_radio_symbol.pdf → which is located near the package file. One could therefore "hack" the problem by placing a PDF file with the same name in one's working directory. However, I'm wondering if there's a more elegant solution. PS: Since I'm not yet very familiar with the package, general suggestions for improvement are welcome. My progress so far: \documentclass[paper=a4, paper=landscape]{scrarticle} \usepackage[margin=11mm,showframe=false,]{geometry} \usepackage{lmodern} \usepackage{pgf-PeriodicTable} \begin{document} \pgfPT[ cell font=\sffamily,% normal LaTeX font (avoids font warnings of pgf-PeriodicTable) csSolid, show title=false, %Z list={1,...,36,87,88},% test Z backcolor=white, Z color=black, Z font=\footnotesize\bfseries, %CS render mode=fill and outline,% default CS outline color=black,% Outline always black CS solid=black, % Solid: black CS liquid=gray,% Liquid: gray CS synt=white,% Synthetic: white ("inline color") CS gas=lightgray,% Gaseous: white (only outline visible) light gray name color=black, name font=\fontsize{5.125pt}{6.125pt}\selectfont,% default: \tiny but seems to large Ar color=black, capitalize element names=true,% please! period label color=black,% Color of period numbers (left) group label color=black,% Color of group numbers (top) %legend radio color=red,% test MNM line width=1.4pt,% default: 0.8pt MNM line color=black,% default: red!80!black %show MNM line=false,% alternative ] \end{document} PPS: The star for "radioactive" is not that unusual.

  • Drawing a pulley system
    by Fatai Bakare on February 1, 2026 at 8:32 am

    I need to draw a pulley system as in the figure. How can I do that? Specific information about the figure: A block of mass Mo is on a horizontal surface and attached by a string to a hanging block, also of mass Mo , as shown in the figure. Friction between the block and the horizontal surface is negligible. The masses of the string and pulley are negligible, and the pulley can rotate with negligible friction around its axle.

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

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

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

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

  • Fill area between hyperbola and line with pgfplots
    by Magnivul on March 29, 2025 at 7:25 pm

    This is my first time using TikZ and pgfplots, and I've been trying, to no avail, to color the area enclosed by the graphs of the functions x^2 - y^2 = 9 and y = 4x - 16. My problem is that fillbetween either fills area that isn't enclosed, or doesn't fill area that is enclosed, depending on the domain I try to clip it to. Currently what I've got looks like this: And I want the area at the bottom that is not enclosed by the graphs not to be colored. Any help would be much appreciated. Here is the TeX code: \documentclass{standalone} \usepackage[svgnames]{xcolor} \usepackage{tikz,pgfplots,tkz-euclide,tkz-graph} \pgfplotsset{compat=1.18} \usetikzlibrary{calc,shapes,angles,patterns,shadows,arrows.meta} \usepgfplotslibrary{statistics,fillbetween} \pgfplotsset{ standard/.style={ axis line style = thick, trig format=rad, axis x line=middle, axis y line=middle, xlabel = {\( x \)}, ylabel = {\( y \)}, every axis x label/.style={at={(current axis.right of origin)},anchor=west}, every axis y label/.style={at={(current axis.above origin)},anchor=south} } } \begin{document} \begin{tikzpicture} \begin{axis}[standard, scale only axis, ticklabel style = {font = \tiny}, grid = both, grid style = {dashed, gray!50}, xmin = -1, xmax = 7, ymin = -3, ymax = 5, xtick = {0,...,6}, ytick = {-2,-1,..., 4}, domain = 3:7, samples = 1000] \addplot[name path = f, line width = 0.5mm, Teal]{4*x - 16}; \addplot[name path = g1, line width = 0.5mm, MediumPurple]{sqrt(x^2 - 9)}; \addplot[name path = g2, line width = 0.5mm, MediumPurple]{-sqrt(x^2 - 9)}; \node[Teal] at (5.8, 1.5) {\( y = 4x - 16 \)}; \node[MediumPurple] at (2.2, 2.5) {\( x^2 - y^2 = 9 \)}; \addplot[SteelBlue!50, opacity = 0.8] fill between [of = f and g1, soft clip = {domain = 3:5}]; \end{axis} \end{tikzpicture} \end{document}

  • Drawing a shaded region with implicit functions
    by Davide on November 1, 2023 at 8:10 am

    basically the problem is the same as in a question i previously asked: Draw shaded region using tikz and pgfplots Now the problem is that the region i want to draw is more complicated, mainly because of the functions involved: This is what i want to obtain, but i don't know how to change the code in the answer in order to draw the graph showed in the image, also because tikz does not really get along with sqrt function. Does anyone know how to solve my problem?

  • Draw shaded region using tikz and pgfplots
    by Davide on October 30, 2023 at 8:57 pm

    I am trying to draw the following region The best i can do is the following code: \begin{figure}[H] \begin{center} \begin{tikzpicture} \begin{axis} [ axis lines = middle, xlabel={$x$}, ylabel={$y$}, xmin=-1, xmax=2, ymin=0, ymax=3, xmajorticks=false ] \addplot[smooth, thick, samples=200, name path=curve1] {1/(2*x)}; \addplot[smooth, thick, samples=200, name path=curve2] {1/x}; \addplot[smooth, thick, samples=200, name path=curve3] {2*x^2}; \addplot[smooth, thick, samples=200, name path=curve4] {3*x^2}; \addplot[color=black,fill=pink,fill opacity=0.4]fill between[of=curve1 and curve2, soft clip={domain=0.5503:0.7937}]; \end{axis} \end{tikzpicture} \end{center} \end{figure} Which creates the following image: Can someone help me? Because i don't know how to use the functions y=1/2x and y=1/x as a border to the shaded region.

  • Ghost shape in TikZ/pgf
    by JeT on October 7, 2021 at 10:09 pm

    My question I can easily draw the normal distribution thanks to this answer by Jake. What about the ghost ? Context This image always breaks the ice when teaching probabilities 🙂 (Not that I care so much about it, but Halloween is getting closer too) I presume it would be possible with Inkscape (but I am not familiar with it). This answer by Paul Gaborit uses the hobby package I tried to adapt (poorly as you'll see, far too manual to be honnest) in my MWE. I'd be happy to see different approaches too (pure tikz, pgfplot, other libraries...). \documentclass[tikz]{standalone} \usetikzlibrary{hobby} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture}[use Hobby shortcut] \draw[ help lines, line width=0.1pt, blue, ] (-20, -20) grid[step={($(5, 5) - (0, 0)$)}] (60, 100); \path (0,0) coordinate (z0) (10,10) coordinate (z1) (20,0) coordinate (z2) (30,10) coordinate (z3) (40,0) coordinate (z4) (50,10) coordinate (z5) (30,90) coordinate (z6) (0,70) coordinate (z7) (0,60) coordinate (z8) ; \draw[closed,black, line width= 3mm] (z0) .. (z1) .. (z2) .. (z3) .. (z4) .. (z5).. (z6).. (z7).. (z8); \end{tikzpicture} \end{document}

  • How to draw intersect of line sphere?
    by Yim Phearun on August 16, 2018 at 10:35 am

    How to draw intersect of line sphere?

  • Wiki engine to embed extensive Tex and PGF/Tikz code
    by Tobard on May 18, 2018 at 12:36 pm

    I would like to create a wiki (several authors) with scientific content, including text, equations, graphs and schemes. I wish to use LaTeX macros (including my own ones) and draw graphics with the powerful PGF/Tikz syntax. My aim is to minimize the work to turn a .tex file into a wiki page, and to keep code flexibility (ideal case would be to copy/paste raw .tex file content in a wiki page and the server should render it). Is Mediawiki able to do that? Is it possible to approach similar behavior with latex2html? Any feedback would be welcome! Thanks

  • non-square picture dimensions for a LaTeXiT circle
    by user1337 on October 17, 2017 at 10:46 am

    Running the following in LaTeXiT preamble: \documentclass[10pt]{article} \usepackage[usenames]{color} %used for font color \usepackage{amssymb} %maths \usepackage{amsmath} %maths \usepackage[utf8]{inputenc} %useful to type directly diacritic characters \usepackage{tikz} body \begin{tikzpicture} \draw (1.5,1.5) circle [radius=1.5]; \end{tikzpicture} produced the following picture When I right-clicked on it, and chose "Get Info" it says that it has dimensions 618 × 620. My questions are: how come such a symmetric shape resulted in uneven dimensions? Is there a way to predict the image dimensions from the TikZ parameters (e.g. radius)? Is there a natural way to get a circle with equal dimensions in TikZ? Thanks.

  • Drawing cylinder in 3D plane
    by user412674 on March 25, 2017 at 10:59 pm

    Can someone help me write the tikz code to generate the following images? I've tried adapting what some other people have done to generate a cylinder, but I want the cylinder with the axes and with the smaller cylinder inside. The code written here is perhaps most useful, Concentric Cylinders with tikz The code for a basic cylinder is given here 3D bodies in TikZ I'm new to tikz and have found that upon editing, the lines and dimensions go out of proportion and don't look reasonable any more. I also don't understand how to include lines in these cylinders or how to shade the inside cylinder.

  • How to add 25/50/75/100% filled circles to a table?
    by robert on January 11, 2016 at 3:56 pm

    Often I see in a paper a table with a column of circles which are filled for 25/50/75/100% to show priority/level of meeting requirements, to mention yes/no/unknown/NA etc? Do such (usage of) circles have a specific name? How can I add such circles to a table in an easy way? What are common other (visualization) techniques used in scientific papers to visualize this kind of levels/ranking/categorization? So far I have seen these circles and ++ .. --. But I am novice so maybe there are more techniques. Thanks

  • animal icons in Tikz
    by Epa on October 16, 2015 at 12:54 pm

    I have gone through the comprehensive symbols in LaTeX that provides some animals icons but not enough for fun documents. One of my math questions requires the illustration as follows, which is a repeated list of ducks and turtles: Could you help to draw these animals using Tikz?

  • The belt for chain of gears
    by kalakay on July 7, 2015 at 12:39 am

    I want to draw like this Gears I created based on rpapa's codes. \documentclass{article} \usepackage[dvipsnames,svgnames]{xcolor} \usepackage{tikz} \newcommand{\gear}[3]{% \def\modu{#1} \def\Zb{#2} \def\AngleA{#3} \pgfmathsetmacro{\Rpr}{\Zb*\modu/2} \pgfmathsetmacro{\Rb}{\Rpr*cos(\AngleA)} \pgfmathsetmacro{\Rt}{\Rpr+\modu} \pgfmathsetmacro{\Rp}{\Rpr-1.25*\modu} \pgfmathsetmacro{\AngleT}{pi/180*acos(\Rb/\Rt)} \pgfmathsetmacro{\AnglePr}{pi/180*acos(\Rb/\Rpr)} \pgfmathsetmacro{\demiAngle}{180/\Zb} \pgfmathsetmacro{\Angledecal}{(\demiAngle-2*\AnglePr)/2} \foreach \zz in{1,2,...,\Zb}{ \draw[DarkSlateGray!70!Sepia] ({(\zz))/\Zb*360-\Angledecal}:\Rb) -- (\zz/\Zb*360-\Angledecal:\Rp) to[bend right=\demiAngle] (\zz/\Zb*360+\Angledecal:\Rp) -- plot[domain=-0:\AngleT,smooth,variable=\t] ({{180/pi*(-\t+tan(180/pi*\t)) +\zz/\Zb*360+\Angledecal}:\Rb/cos(180/pi*\t)}) % to[bend right=\demiAngle] ({{180/pi*(\AngleT+tan(180/pi*-\AngleT)) +(\zz+1)/\Zb*360-\Angledecal}: \Rb/cos(180/pi*-\AngleT)}) % plot[domain=-\AngleT:-0,smooth,variable=\t] ({{180/pi*(-\t+tan(180/pi*\t)) +(\zz+1)/\Zb*360-\Angledecal}:\Rb/cos(180/pi*\t)}); } } \begin{document} \centering \begin{tikzpicture}[scale=0.05] \gear{3}{32}{20} \path[fill=DarkSlateGray!70!Sepia] circle(40); \draw[thick,double distance=2pt,fill=white] circle(20) ; \begin{scope}[xshift=100cm,rotate=180/16] \gear{3}{16}{20} \path[fill=DarkSlateGray!70!Sepia] circle(17.5); \draw[thick,double distance=2pt,fill=white] circle(8); \end{scope} \end{tikzpicture} \end{document} How do I draw the belt?

  • Transform paper folding diagram to 3D object or vice versa
    by Tarass on November 23, 2014 at 11:28 am

    I made this commands to make paper models, and I ask if it is possible to have a 3D view of them converting in tikz-3D, or backward. But it's easier to draw the flat model and generate the volume after. Calculations could be made with lualatex. If you have an idea to follow ? \documentclass[margin=2pt]{standalone} \usepackage{tikz,xparse} \usetikzlibrary{calc} \tikzset{% patron/.style={% line join=round, rounded corners=.05pt, draw, thin}, patron side/.style={patron}, patron languette/.style={patron}, } \newcounter{NodePat} \NewDocumentCommand{\PolygReg}{% O{3} % nb de cotés m % segment A/B O{A} % nom générique }{% \foreach \a/\b in {#2} {% \path[patron side] let \p1 = ($(\a)!.5!(\b)$) , \n1 = {veclen(\x1,\y1)} , \p2 = ($(\p1)!1/tan(180/#1)!90:(\b)$) in (\a)--(\b) \foreach \i [% evaluate=\i as \j using (\i-1)*360/#1] in {3,...,#1} {% -- ($(\p2)!1!\j:(\a)$) coordinate (#3\theNodePat) \pgfextra{\stepcounter{NodePat}} } -- cycle ; } } \NewDocumentCommand{\Languette}{% O{.15} % largeur D<>{45} % angle sur le premier node m % les deux nodes D<>{45} % angle sur le second node O{A} }{% \foreach \b/\a in {#3} {% \path[patron languette] let \p1 = ($(#5\b)!#1/sin(#2)!-#2:(#5\a)$), \p2 = ($(#5\a)!#1/sin(#4)!#4:(#5\b)$) in (#5\a) -- (#5\b) -- (\p1) -- (\p2) -- cycle ; } } \makeatletter \newcommand{\AffNodesPatron}[1][A]{% \newcount\X \X=1 \loop \expandafter\ifx\csname pgf@sh@pi@A\the\X\endcsname\pgfpictureid \node[font={\footnotesize},red] at (A\the\X) {A\the\X} ; \advance \X by 1 \else \X=0 \fi \unless\ifnum \X=0 \repeat } \makeatother \begin{document} \begin{tikzpicture}[scale=2] \coordinate (A1) at (0,0) ; \coordinate (A2) at (1,0) ; \setcounter{NodePat}{3} \PolygReg[4]{A1/A2} \PolygReg{A3/A2,A5/A2,A5/A6,A5/A7} \Languette{1/2,5/3,3/4,4/1} %\AffNodesPatron \end{tikzpicture} \begin{tikzpicture} \coordinate (A1) at (0,0) ; \coordinate (A2) at (1,0) ; \setcounter{NodePat}{3} \PolygReg[6]{A1/A2,A4/A3,A6/A5,A2/A1} \PolygReg[4]{A17/A16} \PolygReg[6]{A20/A19,A20/A24,A23/A22,A21/A19} \PolygReg[4]{A5/A4,A3/A2,A1/A6,A24/A23,A22/A21} \Languette<30>{3/7,7/8,8/9,9/10,10/4,37/38,5/11,11/12,12/13,13/14,14/6,41/42,% 42/1,15/16,16/19,21/45,22/29,32/23,28/20,17/18,2/39,39/40}<30> %\AffNodesPatron \end{tikzpicture} \end{document}

  • More on "Cylinder shading with pgf TiKZ"
    by Ignasi on July 5, 2013 at 11:39 am

    In his answer to Cylinder shading with PGF/TikZ, Jake provides a code to draw a shaded cylinder with a not shaded top. This code draws a cylinder node (from shapes.geometric library) and after that, with a second draw command, an ellipse is drawn over it. I've tried to join both steps within a mycylinder/.style with an append after command option without any success. I still don't completely understand what \pgfinterruptpath, \pgfextra do, so may be my code is not correct. I imagine that covering ellipse must be drawn after shading the cylinder but I don't know how to do it. Could you explain what's wrong? \documentclass[tikz,border=1mm]{standalone} \usetikzlibrary{calc,fit,backgrounds,positioning,arrows,shapes.geometric} \begin{document} \begin{tikzpicture}[font=\sffamily\small, >=stealth', mycylinder/.style={ draw, shape=cylinder, alias=cyl, % Will be used by the ellipse to reference the cylinder aspect=1.5, minimum height=3cm, minimum width=2cm, left color=blue!30, right color=blue!60, middle color=blue!10, % Has to be called after left color and middle color outer sep=-0.5\pgflinewidth, % to make sure the ellipse does not draw over the lines shape border rotate=90, append after command={% \pgfextra{% \pgfinterruptpath % \begin{pgfonlayer}{foreground layer} \fill [blue!10] let \p1 = ($(\tikzlastnode.before top)!0.5! (\tikzlastnode.after top)$), \p2 = (\tikzlastnode.top), \p3 = (\tikzlastnode.before top), \n1={veclen(\x3-\x1,\y3-\y1)}, \n2={veclen(\x2-\x1,\y2-\y1)}, \n3={atan2((\y2-\y1),(\x2-\x1))} in (\p1) ellipse [x radius=\n1, y radius = \n2, rotate=\n3]; % \end{pgfonlayer} \endpgfinterruptpath% } } } ] % Left cylinder. Wrong one. % I would like to draw right cylinder with only one command. \path node [mycylinder, label=below:Wrong] (disc) {}; % Right cylinder. Correct one but with two commands. \path node [mycylinder, right=1cm of disc, label=below:Good] (disc2) {}; \fill [blue!10] let \p1 = ($(cyl.before top)!0.5!(cyl.after top)$), \p2 = (cyl.top), \p3 = (cyl.before top), \n1={veclen(\x3-\x1,\y3-\y1)}, \n2={veclen(\x2-\x1,\y2-\y1)}, \n3={atan2((\y2-\y1),(\x2-\x1))} in (\p1) ellipse [x radius=\n1, y radius = \n2, rotate=\n3]; \end{tikzpicture} \end{document}

  • A Tunisian flag on Tikz using a macro "m-grams"
    by Fethi G. on January 18, 2013 at 7:47 am

    I tried to represent the flag of my country. I typed this code. But I believe that the position of stars, circles, ... is not so respected. In addition I have a left margin "white band" I want to eliminate it, but without result. Please can you help me get the correct code. %A tunisian flag %Author: Fethi GHARIANI %using Tom Bombadil code in http://tex.stackexchange.com/questions/58903/how-to-draw-star-in-tikz-background who uses a macro for drawing stars as well as "n-grams" \documentclass[fontsize=14pt]{scrartcl} \usepackage[norsk,francais]{babel} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[dvips=false,pdftex=false,vtex=false,paperwidth=24cm,paperheight=16cm,margin=0cm,bottom=0cm,top=0cm,nohead]{geometry} \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{shapes.geometric} % inner radius, outer radius, tips, rot angle, options étoile \newcommand{\tstar}[5]{ \pgfmathsetmacro{\starangle}{360/#3} \draw[#5] (#4:#1) \foreach \x in {1,...,#3} { -- (#4+\x*\starangle-\starangle/2:#2) -- (#4+\x*\starangle:#1) } -- cycle; } \newcommand{\ngram}[4]{% outer radius, tips, rot angle, options \pgfmathsetmacro{\starangle}{360/#2} \pgfmathsetmacro{\innerradius}{#1*sin(90-\starangle)/sin(90+\starangle/2)} \tstar{\innerradius}{#1}{#2}{#3}{#4} } \definecolor{rec}{rgb}{1,0,0} \definecolor{cir}{rgb}{1,1,1} \definecolor{hon}{rgb}{1,0,0} \definecolor{sta}{rgb}{1,1,1} \begin{document} \begin{tikzpicture} \fill[rec] rectangle (24cm,16cm); \fill[cir] (12,8) circle (4cm); \fill[hon] (12,8) circle (3cm); \fill[sta] (12.8,8) circle (2.4cm); \ngram{1.5}{5}{72}{red,thick,fill=red,xshift=13.2cm,yshift=8cm}; \end{tikzpicture} \end{document}

  • Rounded corners in TikZ trees.
    by Łukasz Lew on August 8, 2010 at 4:16 pm

    When I use TikZ tree with nodes with rounded corners, the connecting lines do not touch the nodes (near corners) but end where would rectangle end. Is there an easy way around it? \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} [sibling distance=100] \node[rectangle, draw, rounded corners = 3]{ } child { node { } } child { node { } } ; \end{tikzpicture} \end{document}