• Having an Elliptical Frame Go Around the Elliptical Image (on the Outside)
    by DDS on May 18, 2026 at 8:56 pm

    Consider the code: \documentclass{book} \usepackage{graphicx} \usepackage{tikz} %\definecolor{cadmiumgreen}{rgb}{0.0, 0.42, 0.235} \definecolor{Gold}{RGB}{228,168,73} \begin{document} \thispagestyle{empty} \begin{center} \begin{tikzpicture} \clip (0,0) ellipse[x radius=4.25cm, y radius=5.5cm]; %\fill[cadmiumgreen] ellipse[x radius=4.25cm, y radius=5.5cm]; \node at (0,0) {\includegraphics[scale=1.31,clip, trim = 0 0 0 0]{example-image-a}}; \draw[line width=12pt,Gold!75!black] (225:4.25cm and 5.5cm) arc[start angle=225, end angle=-45, x radius=4.25cm, y radius=5.5cm]; \end{tikzpicture} \end{center} \end{document} with the output: QUESTION: How may I get the from to go around the ellipse on the outside? (In other words, I don't want any part of the interior of the elliptical image to be covered by the frame.) Thank you.

  • Line across sphere
    by Sokoban on May 18, 2026 at 12:21 pm

    I am currently solving some Putnam problems for fun, and I wanted to visualize a few geometry questions. One exercise goes as follows: Let S be a spherical cap, where the distance between two points is given by the length of the shortest great-circle arc. Then there is no distance-preserving mapping to the Euclidean plane. I solved the exercise (which is not particularly difficult), and now I want to visualize the cap. I managed to draw almost everything except the distance between the north pole and a point on the rim of the cap. This is what I have so far: \documentclass{article} \usepackage{graphicx} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=3] \draw (0,0) circle (1); \draw[thick] (-1,0) arc (180:360:1 and 0.28); \draw (-1,0) arc (180:0:1 and 0.28); \draw[dashed] (-0.85,0.5) arc (180:360:0.85 and 0.18); \draw[dashed] (-0.85,0.5) arc (180:0:0.85 and 0.18); \fill (0,1.) circle (0.015); \node[right] at (0,1.1) {$N$}; \fill (0,0.5) circle (0.015); \node[left] at (0,0.5) {$O$}; \coordinate (P) at (0.85,0.5); \fill (P) circle (0.015); \draw[thick] (0,0.5) -- (P); \node[above] at (0.4,0.5) {$r$}; \node[blue,right] at (0.45,0.93) {$R$}; \node[left] at (-0.88,0.55) {$C$}; \end{tikzpicture} \end{document} What is still missing is a spherical arc from the north pole to the rim. However, I would like it to appear three-dimensional, rather than like the current 2D curve, but instead more like this: I tried my best, but I have no idea how to achieve this. Can someone help me? Also, I think I only need the spherical cap itself, not the entire sphere.

  • Tangential curve labels with 1D force-based collision avoidance along paths in pgfplots
    by cjorssen on May 17, 2026 at 8:44 pm

    I am trying to implement a dynamic labeling system for multiple curves within a pgfplots axis environment. The goal is to have curve labels that are both tangential (sloped) to their respective paths and capable of avoiding collisions by utilizing a 1D force-based relaxation mechanism to repel each other along the curves' domains. My Understanding of pgfplots Internals From what I understand of pgfplots internals, and please correct me if my assumption is flawed, the package operates on a deferred drawing (or accumulation) model, conceptually quite similar to how matplotlib handles figures in Python. It seems to split its workflow into distinct steps: A Survey Phase where it reads \addplot data, accumulates coordinates in memory, and computes the global axis limits. A Visualization Phase triggered at \end{axis} where it maps data coordinates to physical dimensions and emits the actual TikZ paths and nodes. Based on this understanding, it feels like the ideal place to inject a label-relaxation algorithm would be right between these two phases (perhaps using hooks like before end axis), after the data is parsed but before the final typesetting occurs. The Technical Bottleneck: The Node Bounding Box Dilemma The core difficulty I am facing is a classic "chicken-and-egg" problem: To know the dimensions (width, height, depth) of a label's bounding box for collision detection, TeX must first typeset the text into a box. However, we cannot definitively position or rotate that node along the path until the force-based algorithm has computed the final, relaxed $t$ parameters for all curves. If a LuaLaTeX-based approach is required to handle the physics/loop, I am completely open to it. But I am unsure how to elegantly pass TeX box dimensions into Lua, or how to query the generated curve paths before the rendering phase. Minimal Working Example (Current State) Here is a basic MWE where the labels are sloped but completely overlap: \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ domain=0:3.5, restrict y to domain = 0:10, samples=100, axis lines=left ] % Curve 1 \addplot[blue, thick] {x^2} node[pos = 0.2, sloped] {Function $f(x)$}; % Curve 2 \addplot[red, thick] {1/x} node[pos = 0.8, sloped] {Function $g(x)$}; \end{axis} \end{tikzpicture} \end{document} Tentative Logic / Pseudo-code (Force-Based Relaxation) Ideally, the macro or Lua script would perform a spring-embedder / force-directed approach constrained to 1D path coordinates: # Pre-computation phase for each label L_i: Typeset L_i into a temporary TeX box to get its dimensions (W_i, H_i) # Force-directed loop while system_not_in_equilibrium and max_iterations_not_reached: Initialize forces F_i = 0 for all labels for each curve i with label L_i: 1. Get baseline position P_i = curve_i(t_i) 2. Compute tangent angle theta_i at t_i 3. Construct Label Bounding Box B_i (using W_i, H_i) at P_i rotated by theta_i for each pair of labels (L_i, L_j): if Intersect(B_i, B_j): # Compute repulsive force based on overlap magnitude force_magnitude = calculate_repulsive_force(B_i, B_j) # Project force along the 1D direction of the respective curves F_i = F_i - force_magnitude F_j = F_j + force_magnitude # Update positions using a small step size (damping) for each label L_i: t_i = t_i + alpha * F_i ConstraintToValidDomain(t_i) Questions & Directions Is my mental model of the pgfplots accumulation process accurate enough to build upon, or am I missing a fundamental constraint of the package architecture? Is there an existing package or experimental snippet that already handles force-based label placement or relaxation algorithms along TikZ paths? If doing this via LuaLaTeX, what is the cleanest way to intercept the path coordinates generated by pgfplots and pass the TeX box dimensions to a Lua-based physics loop? Any pointers, conceptual corrections, or architectural advice would be highly appreciated. Real-World Use Case (Thermodynamic Diagrams) To provide some concrete context on why this automation is so critical for my workflow, here is a screenshot of the type of complex diagram I am currently generating (with luatex, FFI and the CoolProp shared library). It is a pressure-enthalpy (p-h) diagram widely used in refrigeration and chemical engineering, plotted in the (p, log h) plane for a pure substance. As you can see, the visual density is extremely high because it overlays several distinct families of isolines crossing each other: Isotherms (constant temperature) Isentropes (constant entropy) Isochores (constant specific volume) Vapor quality lines / isotitres (constant dryness fraction) Manually hardcoding and fine-tuning the pos parameter for dozens of labels across these intersecting families of curves is completely unmanageable—especially since the curves shift dramatically depending on the thermodynamic properties of the fluid being modeled. Having a generalized, tangential, force-directed algorithm to let these labels dynamically find their equilibrium along their respective paths would be an absolute game-changer for rendering complex engineering charts natively in pgfplots.

  • How to convert a custom macro for marking angles with multiple arcs into a TikZ style?
    by Med Elhadi Kh on May 17, 2026 at 8:59 am

    I have created a custom macro \MarkAngle that draws multiple arcs to mark an angle. It works well, but I want to convert it into a native TikZ style (e.g., using .style n args={4} or .code n args={4}) so I can use it cleanly within standard TikZ path options like this: \draw [red, thick, angle radius=1cm, mark angle={3}{A}{B}{C}]; Here is my Minimal Working Example (MWE), which includes my working \MarkAngle macro and my attempt at defining mark angle/.code n args={4}. However, using \pic inside a .code within a \draw path feels hacky and doesn't integrate perfectly. \documentclass[tikz,border=10pt]{standalone} \usetikzlibrary{decorations.markings, angles, quotes} % My working macro \newcommand{\MarkAngle}[5][]{% \begingroup \tikzset{angle radius=1cm, #1} \pgfkeysgetvalue{/tikz/angle radius}{\baseR} \foreach \i in {1,...,#2} { \pgfmathsetmacro{\currentR}{\baseR + (\i-1)*5} \ifnum\i=#2 \pic [draw, #1, angle radius=\currentR pt] {angle=#3--#4--#5}; \else \pic [draw, #1, fill=none, angle radius=\currentR pt] {angle=#3--#4--#5}; \fi } \endgroup } \begin{document} \begin{tikzpicture}[ mark segment/.style={ decoration={ markings, mark=at position 0.5 with { \foreach \i in {1,...,#1} { \pgfmathsetmacro{\xoffset}{(\i - (#1+1)/2) * 3} \draw (\xoffset pt, -4pt) -- (\xoffset pt, 4pt); }}}, postaction={decorate} }, % My attempt to convert it into a style mark angle/.code n args={4}{ \pgfmathsetmacro{\baseR}{scalar(\pgfkeysvalueof{/tikz/angle radius})} \foreach \i in {1,...,#1} { \pgfmathsetmacro{\currentR}{\baseR + (\i-1)*3} \ifnum\i=#1 \pic [draw, pic actions, angle radius=\currentR pt] {angle=#2--#3--#4}; \else \pic [draw, pic actions, fill=none, mark segment={}, angle radius=\currentR pt] {angle=#2--#3--#4}; \fi } } ] \coordinate (A) at (30:2); \coordinate (B) at (0,0); \coordinate (C) at (150:2); \draw (A) -- (B) -- (C); % Trying to use the style here \draw [red, thick, angle radius=1cm, mark angle={3}{A}{B}{C}]; \coordinate (D) at (0,2); \coordinate (E) at (0,0); \coordinate (F) at (2,0); \draw (D) -- (E) -- (F); \draw [blue, thick, angle radius=1cm, mark angle={2}{D}{E}{F}]; \end{tikzpicture} \end{document} My questions are: How can I properly define this as a TikZ style so that it respects path properties (like colors and line widths)? Is using .code the best approach here, or should this be defined entirely as a new custom pic type? Any advice on the most "TikZ-idiomatic" way to achieve this would be highly appreciated!

  • About the transformation of static coordinates (defined via \coordinate) in Tikz
    by user17911 on May 16, 2026 at 4:57 pm

    Would it be a correct assessment to say that in Tikz named coordinates defined via \coordinate are not impacted/altered by transformations (xshift, yshift, shift, rotate, rotate around, etc.)? The reason that I ask this question is because I was working on the following example and I wasn't able to to explain the behaviour of the program: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \coordinate (namedCoordinate) at (-3,1); \draw[color=blue, very thin, step=1cm] (-5,-5) grid (5,5); \draw[->] (-5,0) -- (5,0); \draw[->] (0,-5) -- (0,5); \draw[color=green,fill] (namedCoordinate) circle[radius=0.25]; \begin{scope}[xshift=6cm] \draw[color=red,fill] (namedCoordinate) circle[radius=0.15]; \end{scope} \begin{scope}[xshift=6cm] \draw[color=blue,fill] (-3,1) circle[radius=0.15]; \end{scope} \end{tikzpicture} \end{document} Note: I chose different radius for the circles just for the sake of clarity and to be able to distinguish them from each other easily. I was expecting the red circle to also be shifted but that didn't happen. Does this have something to do with how static coordinates function in Tikz once they have been defined with the \coordinate command and how and when they are substituted/intepreted? As you can see in the code above, the center of all the three circles is the same point in the Cartesian system (-3,1), except that for the red one, we used a named coordinate (namedCoordinate) to indicate its center, but in the case of the blue circle, we just provided a literal for that. The blue circle was shifted as expected 6 units horizontally to the right but the red one didn't! That is why, I was wondering whether \coordinate and transformations would go together in Tikz. I appreciate if you could kindly indicate where did I make a mistake because I've the impression that I have not been able to understand the concept properly.

  • Is there a way to draw this parabola in plain tikz without getting a dimension error?
    by Jasper on May 15, 2026 at 5:52 am

    Is there a way to draw this parabola in plain tikz without getting a dimension error? I don't want to drag out the big guns for what seems like it should be a simple diagram. \documentclass[tikz,border=1cm]{standalone} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \pgfmathsetmacro\FOCUSX{2} \pgfmathsetmacro\FOCUSY{1} \pgfmathsetmacro\LINEPX{-1} \pgfmathsetmacro\LINEPY{0} \pgfmathsetmacro\LINEDX{-3} \pgfmathsetmacro\LINEDY{2} \pgfmathsetmacro\LINEDL{sqrt((\LINEDX)^2 + (\LINEDY)^2)} \pgfmathsetmacro\LINEDX{\LINEDX/\LINEDL} \pgfmathsetmacro\LINEDY{\LINEDY/\LINEDL} \pgfmathsetmacro\LINEPERPX{\LINEDY} \pgfmathsetmacro\LINEPERPY{-\LINEDX} % Focus \fill (\FOCUSX,\FOCUSY) node[right]{$F$} circle[radius=0.1]; % Directrix \draw[dashed] (\LINEPX,\LINEPY) -- +(7*\LINEDX,7*\LINEDY) -- +(-7*\LINEDX,-7*\LINEDY); \fill (\LINEPX,\LINEPY) node[below left]{$P$} circle[radius=0.1]; \draw[->] (\LINEPX,\LINEPY) -- ++(\LINEDX,\LINEDY) node[below left]{$D$}; % Directrix normal \draw[->] (\LINEPX,\LINEPY) -- ++(\LINEPERPX,\LINEPERPY) node[above left]{$N$}; \foreach \ALPHA in {-4,-3.5,...,4} { \pgfmathsetmacro\QUADA{1-(\LINEPERPX)^2-(\LINEPERPY)^2} \pgfmathsetmacro\QUADB{ \LINEPERPX*(\LINEPX+\ALPHA*\LINEDX-\FOCUSX) +\LINEPERPY*(\LINEPY+\ALPHA*\LINEDY-\FOCUSY) } \pgfmathsetmacro\QUADB{-2*\QUADB} \pgfmathsetmacro\QUADC{ (\LINEPX+\ALPHA*\LINEDX-\FOCUSX)^2 +(\LINEPY+\ALPHA*\LINEDY-\FOCUSY)^2 } \pgfmathsetmacro\QUADC{-\QUADC} \pgfmathsetmacro\BETA{ (-\QUADB+sqrt((\QUADB)^2-4*\QUADA*\QUADC)) /(2*\QUADA) } \fill[green] ($(\LINEPX,\LINEPY) + \ALPHA*(\LINEDX,\LINEDY) + \BETA*(\LINEPERPX,\LINEPERPY)$) circle[radius=0.1]; } \end{tikzpicture} \end{document}

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

  • 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 plot a curved line a cross the thickness of the beams
    by Tldi You on May 3, 2026 at 7:36 am

    Deformed and undeformed configurations of the beam Hello everyone, I am trying to reproduce this image using LaTeX TikZ. I have written the code below, but I am encountering difficulties when drawing the curved line through the thickness (the yellow line). Any suggestions would be greatly appreciated. \documentclass[tikz,border=5mm]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta, decorations.pathmorphing, positioning, calc} \begin{document} \begin{tikzpicture}[>=Stealth, scale=1.5] % Styles \tikzset{ zigzag/.style={decoration={zigzag, segment length=2mm, amplitude=1mm}, decorate}, break/.style={decoration={zigzag, segment length=4mm, amplitude=2mm}, decorate}, dot/.style={circle, fill=black, inner sep=1.2pt}, hollowdot/.style={circle, draw=black, fill=white, inner sep=1.2pt} } % --- Undeformed Beam (Top Part) --- \begin{scope}[shift={(0,2.5)}] % Beam edges \draw (-1.5, 0.4) -- (2, 0.4); \draw (-1.5, -0.4) -- (2, -0.4); \draw [zigzag] (-1.5, -0.4) -- (-1.5, 0.4); \draw [zigzag] (2, -0.4) -- (2, 0.4); % Neutral axis \draw [dotted, thick] (-1.5, 0) -- (2.5, 0) node[right] {$x, u$}; \draw [->] (2.3, 0) -- (2.7, 0); % Center vertical line and z-axis indicator \draw (0, 0.4) -- (0, -0.4); \node [hollowdot] at (0,0) {}; \draw [->] (0.2, 0) -- (0.2, -0.3); \node [right, font=\small] at (0.2, -0.15) {$z$}; % Left coordinate system and x-dimension \draw (-2.8, 0) -- (-2.3, 0); \draw [break] (-2.3, 0) -- (-1.9, 0); \draw (-1.9, 0) -- (-1.5, 0); \draw (-2.8, 0) -- (-2.8, -0.8) node[below, font=\small] {$z, w$}; \draw [->] (-2.8, -0.6) -- (-2.8, -1); \draw [->] (-2.8, -0.6) -- (0, -0.6); \node [fill=white, inner sep=1pt, font=\small] at (-1.4, -0.6) {$x$}; % Vertical reference line extending down \draw [thin, gray!60] (0, -0.4) -- (0, -3.5); \end{scope} % --- Deformed Beam (Bottom Part) --- \begin{scope}[shift={(0,1)}] % Curved beam boundaries \draw (-1.5, 0.4) to[bend right=15] (2, 0.4); \draw (-1.5, -0.4) to[bend right=15] (2, -0.4); \draw [zigzag] (-1.5, -0.4) -- (-1.5, 0.4); \draw [zigzag] (2, -0.4) -- (2, 0.4); \draw [dashed] (-1.8, 0) to[bend right=15] (2.3, 0); % Reference point (u0, w0) on the neutral axis \coordinate (P0) at (0.8, -0.30); \node [hollowdot] at (P0) {}; \node [below right, xshift=50pt, yshift=-20pt, font=\small] (L0) {$(u_0, w_0)$}; \draw [->, shorten >=2pt] (L0.west) -- (P0); % Vertical dashed reference line through P0 %\draw [red,dashed] ($(P0) + (0, 1.2)$) -- ($(P0) + (0, -0.5)$); \draw [red,dashed] (P0) -- ($(P0) + (115:1.0)$); % Deformed cross-section line \draw [yellow,thick] ($(P0) + (-0.3, 0.6)$) to[bend left=25] ($(P0) + (0.1, -0.6)$); % Point (u, w) on the cross-section \coordinate (P) at ($(P0) + (-0.01, -0.25)$); \node [dot] at (P) {}; \node [left, xshift=-2pt, yshift=2pt, font=\small] at (P) {$(u, w)$}; % Rotation angles at the top % Angle phi_x (rotation of the cross-section) \draw [->] ($(P0) + (0, 0.8)$) arc (90:115:0.8); \node [left, font=\small] at ($(P0) + (105:0.9)$) {$\phi_x$}; % Angle -dw0/dx (rotation of the normal) \draw [->] ($(P0) + (0, 0.8)$) arc (95:90:0.8); \node [right, xshift=6pt, font=\small] at ($(P0) + (80:0.8)$) {$-\frac{\partial w_0}{\partial x}$}; \draw [green,dashed] (P0) -- ($(P0) + (90:1.2)$); % Slope angle at the neutral axis \draw [blue,dashed] (P0) -- ($(P0) + (1.5, 0)$); \draw [yellow,dashed] ($(P0) + (-0.5, -0.1)$) -- ($(P0) + (1.3, 0.20)$); % tangent line \draw [->] ($(P0) + (1.4, 0)$) arc (0:10:1.2); \node [right, font=\small] at ($(P0) + (5:1.4)$) {$-\frac{\partial w_0}{\partial x}$}; \end{scope} \end{tikzpicture} \end{document}

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

  • How can the edges be made 3D?
    by licheng on January 1, 2025 at 9:26 am

    Here is my diagram. I tried to make it more three-dimensional, but the issue lies with the edges. The edges are currently quite flat, and there are small flaws in certain areas. \documentclass[tikz,border=10pt]{standalone} \usepackage{tikz} \usetikzlibrary{3d, shapes.geometric} \begin{document} \begin{tikzpicture} \tikzset{ whitenode/.style={ draw=black, % Border color fill=white, % Fill color circle, % Shape of the node minimum size=6mm, % Size of the node inner sep=0pt, % No inner separation between the content and the border outer sep=0pt, % No outer separation shading=ball, % Simple 3D effect using shading ball color=white!70, % Ball color with some shading for 3D effect }, edge/.style={ draw=black, % Edge color opacity=0.7, % Make the edge slightly transparent for 3D effect line width=0.8mm % Edge line width } } % Define nodes using the 'whitenode' style \node [whitenode] (1) at (5.7995, 2.11179) {}; \node [whitenode] (2) at (9.17388, 2.70651) {}; \node [whitenode] (3) at (10, 3.63306) {}; \node [whitenode] (4) at (8.36783, 4.27714) {}; \node [whitenode] (5) at (5.54901, 4.40412) {}; \node [whitenode] (6) at (2.77852, 4.009) {}; \node [whitenode] (7) at (1.29142, 3.21177) {}; \node [whitenode] (8) at (2.31865, 2.3715) {}; \node [whitenode] (9) at (5.72793, 3.75831) {}; \node [whitenode] (10) at (9.14058, 4.27807) {}; \node [whitenode] (11) at (9.97777, 5.05103) {}; \node [whitenode] (12) at (8.33397, 5.56955) {}; \node [whitenode] (13) at (5.49357, 5.65148) {}; \node [whitenode] (14) at (2.69756, 5.3032) {}; \node [whitenode] (15) at (1.18826, 4.63275) {}; \node [whitenode] (16) at (2.21435, 3.94565) {}; \node [whitenode] (17) at (5.65479, 5.44088) {}; \node [whitenode] (18) at (9.10659, 5.88234) {}; \node [whitenode] (19) at (9.95512, 6.49543) {}; \node [whitenode] (20) at (8.29954, 6.88381) {}; \node [whitenode] (21) at (5.43722, 6.91918) {}; \node [whitenode] (22) at (2.61522, 6.61935) {}; \node [whitenode] (23) at (1.08316, 6.08036) {}; \node [whitenode] (24) at (2.10789, 5.55268) {}; \node [whitenode] (25) at (5.58004, 7.16071) {}; \node [whitenode] (26) at (9.07189, 7.52034) {}; \node [whitenode] (27) at (9.93205, 7.96701) {}; \node [whitenode] (28) at (8.26452, 8.22048) {}; \node [whitenode] (29) at (5.37996, 8.20771) {}; \node [whitenode] (30) at (2.53148, 7.95801) {}; \node [whitenode] (31) at (0.976083, 7.55535) {}; \node [whitenode] (32) at (1.99917, 7.19364) {}; % Draw edges using the 'edge' style \draw [edge] (1) to (2); \draw [edge] (2) to (3); \draw [edge] (3) to (4); \draw [edge] (4) to (5); \draw [edge] (5) to (6); \draw [edge] (6) to (7); \draw [edge] (7) to (8); \draw [edge] (8) to (1); \draw [edge] (9) to (10); \draw [edge] (10) to (11); \draw [edge] (11) to (12); \draw [edge] (12) to (13); \draw [edge] (13) to (14); \draw [edge] (14) to (15); \draw [edge] (15) to (16); \draw [edge] (16) to (9); \draw [edge] (17) to (18); \draw [edge] (18) to (19); \draw [edge] (19) to (20); \draw [edge] (20) to (21); \draw [edge] (21) to (22); \draw [edge] (22) to (23); \draw [edge] (23) to (24); \draw [edge] (24) to (17); \draw [edge] (25) to (26); \draw [edge] (26) to (27); \draw [edge] (27) to (28); \draw [edge] (28) to (29); \draw [edge] (29) to (30); \draw [edge] (30) to (31); \draw [edge] (31) to (32); \draw [edge] (32) to (25); \draw [edge] (1) to (9); \draw [edge] (9) to (17); \draw [edge] (17) to (25); \draw [edge] (2) to (10); \draw [edge] (10) to (18); \draw [edge] (18) to (26); \draw [edge] (3) to (11); \draw [edge] (11) to (19); \draw [edge] (19) to (27); \draw [edge] (4) to (12); \draw [edge] (12) to (20); \draw [edge] (20) to (28); \draw [edge] (5) to (13); \draw [edge] (13) to (21); \draw [edge] (21) to (29); \draw [edge] (6) to (14); \draw [edge] (14) to (22); \draw [edge] (22) to (30); \draw [edge] (7) to (15); \draw [edge] (15) to (23); \draw [edge] (23) to (31); \draw [edge] (8) to (16); \draw [edge] (16) to (24); \draw [edge] (24) to (32); \end{tikzpicture} \end{document} The situation with the red box that appears below is not what I intended to see. Maybe the link below is what I was hoping to see. draw-3d-molecules-with-tikz

  • Create a paraboloid and a right circular cone opening upward, with vertex at the origin
    by Dimitrios ANAGNOSTOU on October 22, 2024 at 10:14 am

    I want to create the following figure. Here is my try for the paraboloid. \documentclass[svgnames]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.16} \usepackage{tikz-3dplot} \begin{document} \tdplotsetmaincoords{70}{30} \begin{tikzpicture} \begin{axis} [ scale=1, axis lines=center, axis on top, samples=30, ticks=none, xlabel={$x$}, ylabel={$y$}, zlabel={$z=x^2+y^2$}, domain=-2:2, colormap/violet, ] \addplot3[surf,opacity=0.3,domain=-2:2] {x^2+y^2}; \end{axis} \end{tikzpicture} \end{document} However how can I remove the facets and get the appearance of the attached figure? Here is my code for the cone. \documentclass[svgnames]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.16} \usepackage{tikz-3dplot} \begin{document} \tdplotsetmaincoords{70}{30} \begin{tikzpicture} \begin{axis} [ scale=1, axis lines=center, axis on top, ticks=none, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}, samples=30, domain=0:2*pi, y domain=0:2, zmax=2, % z buffer=sort, colormap/violet, ] % Cone surface plot \addplot3[surf, opacity=0.5] ({y*cos(deg(x))}, {y*sin(deg(x))}, {y}); % Parametric equation of the cone \end{axis} \end{tikzpicture} \end{document} The same question here as well.

  • How \pgfpointxyz plots a point in 2d?
    by tush on October 2, 2024 at 2:19 pm

    When I instruct PGF to plot a point in the 3d space with \pgfpointxyz, how PGF projects this point on the 2D canvas? Inside the file pgfcorepoints.code.tex the definition of \pgfpointxyz says that \global\pgf@x=\pgftemp@x\pgf@xx% \global\advance\pgf@x by \pgftemp@y\pgf@yx% \global\advance\pgf@x by \pgftemp@z\pgf@zx% from which I understand that the projection matrix used is But I couldn't find any numerical value assigned to the TeX dimensions that comprise the matrix elements. Can anyone refer me to the values they take? Can anyone tell me if the math I presented here is correct at all? A MWE: \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{pgfpicture} \pgfsetarrowsend{to} \pgfpathmoveto{\pgfpointorigin} \pgfpathlineto{\pgfpointxyz{0}{0}{1}} \pgfusepath{stroke} \pgfpathmoveto{\pgfpointorigin} \pgfpathlineto{\pgfpointxyz{0}{1}{0}} \pgfusepath{stroke} \pgfpathmoveto{\pgfpointorigin} \pgfpathlineto{\pgfpointxyz{1}{0}{0}} \pgfusepath{stroke} \pgfpointxyz{0}{0}{1} %\makeatletter %\show\pgf@x %%\pgf@x is stored in \dimen145 %\showthe\dimen145 %\show\pgf@y %%\pgf@x is stored in \dimen145 %\showthe\dimen146 \end{pgfpicture} \end{document}

  • Issues With Drawing Arc Using Tikz-3dplot
    by Bored Comedy on May 13, 2024 at 10:42 pm

    Here is the diagram I drew. Here is the code used to generate it. \documentclass{standalone} \usepackage{amssymb} \usepackage{mathtools} \usepackage{bm} \usepackage{pgfplots} \usepackage{tikz-3dplot} \renewcommand{\vec}[1]{\bm{#1}} \begin{document} \centering \tdplotsetmaincoords{70}{60} \begin{tikzpicture}[tdplot_main_coords] \draw[<->] (-5, 0, 0) -- (5, 0, 0) node[right] {\(x_1\)}; \draw[<->] (-2.5, -4.33, 0) -- (2.5, 4.330, 0) node[right] {\(x_2\)}; \draw[<->, dashed, gray] (0, -5, 0) -- (0, 5, 0) node[right] {\(x_2\)}; \draw[->] (0, 0, 0) -- (0, -2.5, 4.33) node[above] {\(x_3\)}; \draw[<->, dashed, gray] (0, 0, -5) -- (0, 0, 5) node[right] {\(x_3\)}; \draw[->, thick, black] (0, 0, 0) -- (3, 0, 0) node[left] {\(\vec{e}_1\)}; \draw[->, thick, black] (0, 0, 0) -- (1.5, 2.598, 0) node[right] {\(\vec{e}_2\)}; \draw[->, thick, black] (0, 0, 0) -- (0, -1.5, 2.598) node[left] {\(\vec{e}_3\)}; \tdplotdrawarc{(0, 0, 0)}{1.5}{0}{60}{anchor=north}{\(60^\circ\)}; \tdplotsetthetaplanecoords{60}; \tdplotdrawarc[tdplot_rotated_coords]{(0, 0, 0)}{1.5}{-30}{90}{above right}{\(120^\circ\)}; \end{tikzpicture} \end{document} Now, if I'm not wrong, the angle between $\mathbf{e_3}$ and $\mathbf{e}_2$ should be 120 degrees. So really, everything is fine here. However, what happens if I rotated the view by a little bit, with \tdplotsetmaincoords{70}{110}? \documentclass{standalone} \usepackage{amssymb} \usepackage{mathtools} \usepackage{bm} \usepackage{pgfplots} \usepackage{tikz-3dplot} \renewcommand{\vec}[1]{\bm{#1}} \begin{document} \centering \tdplotsetmaincoords{70}{110} \begin{tikzpicture}[tdplot_main_coords] \draw[<->] (-5, 0, 0) -- (5, 0, 0) node[right] {\(x_1\)}; \draw[<->] (-2.5, -4.33, 0) -- (2.5, 4.330, 0) node[right] {\(x_2\)}; \draw[<->, dashed, gray] (0, -5, 0) -- (0, 5, 0) node[right] {\(x_2\)}; \draw[->] (0, 0, 0) -- (0, -2.5, 4.33) node[above] {\(x_3\)}; \draw[<->, dashed, gray] (0, 0, -5) -- (0, 0, 5) node[right] {\(x_3\)}; \draw[->, thick, black] (0, 0, 0) -- (3, 0, 0) node[left] {\(\vec{e}_1\)}; \draw[->, thick, black] (0, 0, 0) -- (1.5, 2.598, 0) node[right] {\(\vec{e}_2\)}; \draw[->, thick, black] (0, 0, 0) -- (0, -1.5, 2.598) node[left] {\(\vec{e}_3\)}; \tdplotdrawarc{(0, 0, 0)}{1.5}{0}{60}{anchor=north}{\(60^\circ\)}; \tdplotsetthetaplanecoords{60}; \tdplotdrawarc[tdplot_rotated_coords]{(0, 0, 0)}{1.5}{-30}{90}{above right}{\(120^\circ\)}; \end{tikzpicture} \end{document} The only thing I changed from the code above is that I used \tdplotsetmaincoords{70}{110}. This is not good! Am I overlooking something simple?

  • Creating a Tri-Cylinder Intersection Surface with Pgfplots
    by user279206 on January 25, 2024 at 8:18 pm

    As an edit to provide further clarification (to save you some reading) - we are trying to define the second diagram parametrically, so that the two flat parts are truncated and we are just left with the part we can use for the diagram. Hope this Helps! Thanks Have taken an interest in the techniques employed in this question: How to draw two intersecting cylinders?. Specifically, since I'm still learning Asymptote, I want to the the pgfplots method to diagram the intersection surface of three cylinders. I got a diagram of three intersecting cylinders to work by fiddling around with the code, but am stuck on creating their surface of intersection. Here's the diagram I have of the intersecting cylinders for reference (with credit to the inspiration, of course.) - see MWE #1 at the bottom: And this is what I've got so far (if I can solve for one part, then I can do the rest) - see MWE #2: And what I want is something with this kind of shape, except corresponding to three cylinders instead of two - credit to Stewart: MWE #1 \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{center} \begin{tikzpicture}[scale=3] \begin{axis}[% axis equal, enlargelimits = true, samples = 45, samples y = 45, axis lines = none, ticks = none, cyl/.style = {% surf, black!30!, variable = \u, variable y = \v, z buffer = sort, faceted color=black!70!, }, %view/h = 125, view/v = 25 ] \addplot3[% (-) Z-SEMIAXIS cyl, domain = -3:3, y domain = 0:360, ] ({cos(v)}, {sin(v)}, {min(u,abs(cos(v)),abs(sin(v)))}); \addplot3[% (-) X-SEMIAXIS cyl, domain = -3:3, y domain = 0:360, ] ({min(u,-abs(cos(v)),-abs(sin(v)))}, {cos(v)}, {sin(v)}); \addplot3[% (+) Y-SEMIAXIS cyl, domain = 0:360, y domain = -3:3, ] ({cos(u)}, {max(v,abs(cos(u)),abs(sin(u)))}, {sin(u)}); \addplot3[% (+) X-SEMIAXIS cyl, domain = -3:3, y domain = 0:360, ] ({max(u,abs(cos(v)),abs(sin(v)))}, {cos(v)}, {sin(v)}); \addplot3[% (+) X-SEMIAXIS cyl, domain = -3:3, y domain = 0:360, ] ({cos(v)}, {sin(v)}, {max(u,abs(cos(v)),abs(sin(v)))}); \addplot3[% (-) Y-SEMIAXIS cyl, domain = 0:360, y domain = -3:3, ] ({cos(u)}, {min(-abs(cos(u)),-abs(sin(u)),v)}, {sin(u)}); \end{axis} \end{tikzpicture} \end{center} \end{document} MWE #2 \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{center} \begin{tikzpicture}[scale=2] \begin{axis}[% axis equal, enlargelimits = true, samples = 45, samples y = 45, axis lines = none, ticks = none, cyl/.style = {% surf, black!30!, variable = \u, variable y = \v, z buffer = sort, faceted color=black!70!, }, %view/h = 125, view/v = 25 ] \addplot3[% (-) Z-SEMIAXIS cyl, domain = -3:3, y domain = 0:360, restrict z to domain=-2:2, ] ({max(abs(u),cos(v))}, {sin(v)}, {u}); \end{axis} \end{tikzpicture} \end{center} \end{document} Edit by @hpekristiansen: Here is a picture of the intersection of three cylinders Found here: https://abel.math.harvard.edu/archive/21a_summer_06/handouts/3cylinder.pdf

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

  • Curly braces around the tikz matrix
    by mmr on November 28, 2022 at 5:35 am

    I am planning to draw the following pictures like this: So far I have tried this: \documentclass[12pt]{article} \usepackage{multirow,graphics,graphicx,supertabular} \usepackage{mathtools} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{matrix,decorations.pathreplacing,calc,positioning,calligraphy} \begin{document} \begin{tikzpicture} \matrix (m) { \node {\textbf{Name}}; & \node{\textbf{Age}}; & \node {\textbf{Balance}}; \\ \hline \node {User 1}; & \node{35}; & \node {7}; \\ \node {User 2}; & \node{42}; & \node {7}; \\ \node { }; & \node{ }; & \node { }; \\ \node {User 3}; & \node{42}; & \node {7}; \\ \node {User 4}; & \node{42}; & \node {7}; \\ }; \draw[decorate] (m-2-2.north east) -- node[right=2pt] {$m$} (m-2-4.south east); % right \end{tikzpicture} \end{document} How can I achieve this desired output? Not exactly the arrow should be like. They should be clean and nicer arrows. Also I need this to draw:

  • Highlighting rows/columns/diagonals in matrix
    by Joe Wells on January 23, 2020 at 11:03 pm

    I'm trying to highlight rows/columns/diagonals in a matrix. I came across this example, which looks very clean. Unfortunately, it seems to cause some issue with spacing in the matrix, and I can't figure out why. Below is a MWE and the output: \documentclass{article} \usepackage{amsmath} \usepackage{tikz} \newcommand{\tikzmark}[2]{ \tikz[overlay,remember picture,baseline] \node[anchor=base] (#1) {$#2$}; } \begin{document} No highlighting: \begin{equation} A = \begin{bmatrix} a_{11} & 0 & 0 \\ 0 & a_{22} & 0 \\ 0 & 0 & a_{33}\\ \end{bmatrix} \end{equation} Highlighting: \begin{equation} A = \begin{bmatrix} \tikzmark{top}{a_{11}} & 0 & 0 \\ 0 & a_{22} & 0 \\ 0 & 0 & \tikzmark{bottom}{a_{33}}\\ \end{bmatrix} \end{equation} \begin{tikzpicture}[overlay,remember picture] \draw[opacity=.4,line width=3mm,line cap=round] (top.center) -- (bottom.center); \end{tikzpicture} \end{document} What is the \tikzmark command doing, and is there anything that can be done to preserve the standard matrix spacing?

  • Matrices with shadows
    by NaveganTeX on July 6, 2019 at 8:04 am

    I'm trying to draw the shadows and also the dots between the two matrices: \documentclass{article} \usepackage{amsmath} \begin{document} \centering \begin{tabular}{|c|c|c|c|c|c|c|c|} \hline 5 & 1 & 3& &2 & 1 & & \\ \hline 4 & 2 & & 3& & 4 & 3 & 1 \\ \hline 1 & 3 & & & & 2 & 5 & \\ \hline 2 & 5 & 1& 2 & & & & 1 \\ \hline 0 & 4 & & & 5 &3 &1 & \\ \hline & 2 & & 4& &4 & 1& 2 \\ \hline \hline \end{tabular} \begin{tabular}{|c|c|c|c|c|c|c|c|} \hline 1 & 1 & 1& &1 & 1 & & \\ \hline 0 & 1 & & & & 0 & 0 & 1 \\ \hline 0 & & & & & 0 & 0 & \\ \hline 1 & & 1& 1 & & & & 1 \\ \hline 0 & 1 & & & 1 &1 &1 & \\ \hline & 1 & & & & & & \\ \hline \hline \end{tabular} \end{document}

  • how do I draw a ribbon on a cylinder
    by userX on March 5, 2016 at 5:47 am

    I have this: \tdplotsetmaincoords{70}{15} \tikzset{every circle/.append style={x=1cm, y=1cm}} \begin{tikzpicture}[tdplot_main_coords] % --- Independent parameters --- \def\h{3} % cylinder height \pgfmathtruncatemacro\tA{-60} % A angle \def\zA{0} % A applicate \pgfmathtruncatemacro\tB{300} % B angle \def\zB{3} % B applicate \pgfmathtruncatemacro\n{1} % number of additional turns \pgfmathtruncatemacro\NbPt{351} % number of dots for drawing the helix portion \def\rhelixdots{0.02} % radius of dots forming helix \def\rAB{0.05} % radius of A and B dots % --- Draw cylinder --- % peripheral spokes \foreach \t in {20,40,...,360} { \draw[gray,very thin,dashed] ({cos(\t)},{sin(\t)},0) --({cos(\t)},{sin(\t)},\h); } % lower circle \draw[black,very thin] (1,0,0) \foreach \t in {2,3,...,360} { --({cos(\t)},{sin(\t)},0) } --cycle; % upper circle \draw[black,very thin] (1,0,\h) \foreach \t in {2,4,...,360} { --({cos(\t)},{sin(\t)},\h) } --cycle; % --- Draw helix --- \pgfmathsetmacro\tone{\tA} \pgfmathsetmacro\tlast{\tB+\n*360} \pgfmathsetmacro\ttwo{\tone+(\tlast-\tone)/(\NbPt-1)} \pgfmathsetmacro\p{360*(\zB-\zA)/(\tB-\tA+360*\n)} \foreach \t in {\tone,\ttwo,...,\tlast}{% \fill[red] ({cos(\t)},{sin(\t)},{\p*(\t-\tA)/360+\zA}) circle [radius=\rhelixdots]; } % --- Draw A and B --- %\node at ({cos(\tA)},{sin(\tA)},\zA-.3) {\color{red}{-}}; %\node at ({cos(\tA)},{sin(\tA)},\zA-.63) {horizontal width}; \end{tikzpicture} producing this but I would like something more like this. I don't know how to make the helix look more like a ribbon.

  • 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

  • Is there a (tikz) package that supports flowcharts according to ISO 5807?
    by user69453 on January 10, 2015 at 9:34 pm

    I wonder if there is a package that fully supports the flowchart symbols defined in ISO 5807:1985 (or at least a hugh amount of them)? I just found the tikz flowchart package from Adrian P. Robson. But this only contains five symbols. So does anybody know a package which provides a larger range of symbols?

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