TikZ
- Bidirectional hyperlinks between exercises and figures in LaTeXby Sebastiano on November 8, 2026 at 10:12 pm
I have the following minimal working example: \documentclass[12pt,a4paper]{amsart} \usepackage{tikz} \usepackage[colorlinks=true,linkcolor=blue]{hyperref} \newtheorem{Es}{Esercizio} \begin{document} \section{Esercizi} \begin{Es} My solution Link to figure \end{Es} \bigskip \begin{Es} My solution \end{Es} \newpage \section*{Figure} %%%%%%%%%%%%%%%%% Add automatically link to exercise \begin{figure}[htbp] \centering \begin{tikzpicture}[scale=1.25] \draw[->] (-1.8,0) -- (1.8,0) node[below right] {$x$}; \draw[->] (0,-1.8) -- (0,1.8) node[below left] {$y$}; \draw[gray, thick] (0,0) circle (1); \draw[gray,very thick] (0,0) circle (1.5); \fill (0,0) circle (0.025); \node[below left] at (0,0) {$O$}; \draw[blue, very thick, domain=45:225, samples=100] plot ({1.5*cos(\x)},{1.5*sin(\x)}); \draw[blue, fill=white, very thick] ({1.5*cos(45)},{1.5*sin(45)}) circle (0.06); \draw[blue, fill=white, very thick] ({1.5*cos(225)},{1.5*sin(225)}) circle (0.06); \draw[dashed, gray] (0,0) -- ({1.6*cos(45)},{1.6*sin(45)}); \draw[dashed, gray] (0,0) -- ({1.6*cos(225)},{1.6*sin(225)}); \node[above right] at ({1.5*cos(45)},{1.5*sin(45)}) {$\frac{\pi}{4}$}; \node[below left] at ({1.5*cos(225)},{1.5*sin(225)}) {$\frac{5\pi}{4}$}; \end{tikzpicture} \caption{Soluzioni della disequazione $\sin x-\cos x>0$.} \label{fig:soluzioni_seno_coseno} \end{figure} \end{document} How can I modify this example to automatically create bidirectional hyperlinks between each Es environment and its corresponding TikZ figure, so that clicking at the end of an exercise takes me to its figure and clicking at the end of the figure takes me back to the exercise, without manually specifying exercise numbers, figure numbers, \hypertarget, or \hyperlink? Here an example PDF in this link https://www.lorenzoroi.net/prelievi/ProblemiEsame3.pdf PS: In this question Hyperlinks from exercises to solutions and vice versa there are mdframed and tcolorbox which I don’t need for the exercises, and I’d like it to be, for example, ‘Exercise 1 (solution)’, and at the end, in a final section, the image relating to Exercise 1 which, when clicked, takes me to the solution to the exercise, just like the PDF file mentioned above. <<<<I'm looking for a very simple solution that doesn't include packages released after 2018>>>>
- Drawing 3D atomic orbitals in LaTeX [closed]by sstac on November 4, 2026 at 12:54 pm
I am trying to recreate a few graphics found on a paper: https://www.researchgate.net/publication/376028984_Visualizing_atomic_orbitals_of_an_electron_by_Latex The images I want to recreate: The author supposedly wanted to share the source code, but the link in abstract is (at least for me) not working and I wasn't able to reach out to the author, so I decided to try to recreate the graphics myself. Unfortunaley I don't have much experience in drawing in latex/tikz/pgfplots (I did some 3d graphics in tikz-3dplot tho, but that was some time ago) so I am interested if someone can guess or say how were such graphics created? Thanks in advance! Best, Stipe Edit: Narrowed the question, removed the whole bunch of images.
- Triangle Nesting ( Similar to Sierpinski Triangles ) [duplicate]by Discrete on August 15, 2026 at 7:09 pm
Im curious to know if there is a more efficient way to have triangles repeat themselves in one another without needing to run the \draw command for each line of the triangle; similar to Sierpinski's triangles is essentially what it is but in a different way for nesting. So far i've been doing the \draw command as such \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} [scale = 3] \draw[thick] (0,0) -- (2,0) -- (1,1.73205) -- cycle; \draw[thick] (0,0) -- (1,0.8) (2,0) -- (1,0.8) -- (1,1.73205) -- (1,0.8); \draw[thick] (1,0.8) -- (1.566667,0.769); \end{tikzpicture} \end{document} Ive provided an example above of what it should look like however I need to define what the colors mean and some rules it has. Meaning of Colors: Black = 1st Generation triangles, Blue = 2nd Generation triangles, and Red = 3rd Generation triangles as well each generation has a specific intersection where all the points meet ( for example black has a intersection in the middle where all points meet ) I should also say that each generation has its own "sub section" where the rule above applies to each sub section and these sub sections are divided by the lines of the previous generation. ( for example a 3rd generation sub section can have a different intersection than another 3rd generation sub section this is so each has one intersection which will for the sake of simplicity be set in the center for all generations) if you have any questions on this to better help me feel free to ask and I apologize if some of it seems confusing it is a rather "niche" section of discrete geometry relating to triangles and other two dimensional shapes ( side note i'd like this concept to be done with other two dimensional shapes as well so if theres a way to set the starting shape to say a circle or another shape that would be amazing; and it would follow the same rules I have revealed here).
- Tangential curve labels with 1D force-based collision avoidance along paths in pgfplotsby 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.
- I want a command which can take two arbitrary ellipses, and shade the region between them, bounded by their mutual tangentsby Jasper on November 2, 2025 at 9:31 pm
I want a command which can take two arbitrary ellipses, and shade the region between them, bounded by their mutual tangents. \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \fill (-5,0) ellipse[x radius = 1, y radius = pi]; \fill ({sqrt(2)},e) ellipse[x radius = {sqrt(pi)}, y radius = {sqrt(e^sqrt(pi))}]; \end{tikzpicture} \end{document}
- Tikz perspective library - Draw 2D shape in perspective?by Atiroocky on June 26, 2025 at 3:12 pm
My goal is to draw some shapes on top of image (from camera) that respect the vanishing points of the image. After defining my two vanishing points coordinates, I managed to draw some basic shapes, but only from lines. (\draw[](tpp cs: x=0,y=0,z=0)--(tpp cs: x=1,y=1,z=0) My question : how can I render shapes in perspective like circle, rectangle, etc., that I usually define with \draw[](0,0)rectangle(1,2); ? In this MWE, how can I draw a "perspective" circle on the yz plane ? \documentclass{standalone} \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary {% perspective, } \begin{document} \newcommand\simplecuboid[3]{% \draw[red!50,] (tpp cs:x=0,y=0,z=#3) -- (tpp cs:x=0,y=#2,z=#3) -- (tpp cs:x=#1,y=#2,z=#3) -- (tpp cs:x=#1,y=0,z=#3) -- cycle; \draw[red,] (tpp cs:x=0,y=0,z=0) -- (tpp cs:x=0,y=0,z=#3) -- (tpp cs:x=0,y=#2,z=#3) -- (tpp cs:x=0,y=#2,z=0) -- cycle; \draw[red!80,] (tpp cs:x=0,y=0,z=0) -- (tpp cs:x=0,y=0,z=#3) -- (tpp cs:x=#1,y=0,z=#3) -- (tpp cs:x=#1,y=0,z=0) -- cycle; \draw[red!50,] (tpp cs:x=0,y=#2,z=0) -- (tpp cs:x=#1,y=#2,z=0) -- (tpp cs:x=#1,y=#2,z=#3) -- (tpp cs:x=0,y=#2,z=#3) -- cycle; \draw[red!50,] (tpp cs:x=#1,y=0,z=0) -- (tpp cs:x=#1,y=#2,z=0); } \newcommand\xx{8.5} \newcommand\yy{16} \newcommand\zz{0} \begin{tikzpicture}[% 3d view={-25}{11}, perspective={ p = {(\xx,13,0)}, q = {(2.85,\yy,0)}, % r = {(0,0,\zz)} }, scale=1, vanishing point/.style={fill,circle,inner sep=2pt}] \begin{scope}[shift={(-6.5,-15,0)}] \simplecuboid{8}{15}{3} \filldraw[red, fill=red!30, fill opacity=0.2] (tpp cs: x=0,y=0,z=0)-- (tpp cs: x=0,y=15,z=0)-- (tpp cs: x=8,y=15,z=0)-- (tpp cs: x=8,y=0,z=0); \node[vanishing point,label = right:p] (p) at (\xx,13,0){}; \node[vanishing point,label = left:q] (q) at (2.85,\yy,0){}; \foreach \x in {-2,...,15}{ \draw[green!30] (tpp cs:x=\x,y=-5,z=0) -- (tpp cs:x=\x,y=20,z=0);} \foreach \y in {-5,...,20}{ \draw[green!30] (tpp cs:x=-2,y=\y,z=0) -- (tpp cs:x=15,y=\y,z=0);} \begin{scope}[dotted] \foreach \y in {0,15}{ \foreach \z in {0,3}{ \draw (tpp cs:x=0,y=\y,z=\z) -- (p.center);}} \foreach \x in {0,8}{ \foreach \z in {0,3}{ \draw (tpp cs:x=\x,y=0,z=\z) -- (q.center);}} \end{scope} \filldraw[blue, fill=green, fill opacity=0.1] (tpp cs: x=0,y=0,z=0)-- (tpp cs: x=0, y=0,z=1.5)-- (tpp cs: x=0, y=1,z=1.5)-- (tpp cs: x=0, y=1,z=0)-- cycle; \filldraw[red, fill=green, fill opacity=0.1] (tpp cs: x=0,y=3,z=1)-- (tpp cs: x=0, y=3,z=2)-- (tpp cs: x=0, y=4,z=2)-- (tpp cs: x=0, y=4,z=1)-- cycle; \end{scope} \end{tikzpicture} \end{document} Output : Thank for your help.
- Surface plots using Tikzby skm on December 27, 2024 at 11:09 am
I want to show surface approximation plots, in which I have two variables called calculated and approximated. I need to show two 3D surface plots corresponding to these two variables, whose values are stored in .dat file. I want to have plot as shown in this SO answer. I am able to compile and run the code provided in the answer. However, when I try to make some dummy modifications i.e. adding another hard-coded plot, the code is not running. My non-running Code: \documentclass[border=1cm]{standalone} \usepackage{amsmath} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \pgfplotsset{colormap={violet}{rgb255=(25,25,122) rgb255=(238,140,238) color=(white)}} \begin{document} \begin{tikzpicture}[ declare function={ f(\x,\y)=-exp(-(\x^2+\y^2)/1.3; }] \begin{axis}[ view={30}{20}, mesh/interior colormap name=violet, colormap/viridis, hide axis, xmin=-2, xmax=2, ymin=-2, ymax=2, zmin=-2.5, zmax=0, ] \addplot3[ surf, samples=4, % Reduced number of samples for demonstration domain=-2:2, domain y=-2:2, point meta=explicit, ] table { x y z -2 -2 -2 -1 -2 -1.5 0 -2 -1 1 -2 -0.3 2 -2 0.2 -2 -1 -1.5 -1 -1 -0.8 0 -1 -0.3 1 -1 0.2 2 -1 0.7 -2 0 -1 -1 0 0.1 0 0 0.7 1 0 1.2 2 0 1.5 -2 1 0.2 -1 1 0.6 0 1 1 1 1 1.3 2 1 1.5 -2 2 0.8 -1 2 1 0 2 1.3 1 2 1.5 2 2 1.8 }; \end{axis} \end{tikzpicture} \end{document} How to get a figure like below (Plus added plot using hard-coded or file-loaded values)?
- How to improve the achievement of gradient color path?by Explorer on November 16, 2024 at 2:13 pm
What I want to replicate is the following gradient elliptic paths: I follow the solution from here and here to achieve the gradient colorm of path(to achieve pattern "darkcolor"-"lightcolor"-"darkcolor"), with the following code: \documentclass[tikz,border=8pt]{standalone} % https://tex.stackexchange.com/a/702274 % https://tex.stackexchange.com/q/141378 \usetikzlibrary{shadings,decorations.markings} \colorlet{lightmagenta}{magenta!50} \colorlet{lightcyan}{cyan!50} \tikzset{ multicolor/.style n args={2}{ decorate, decoration={ markings, mark=between positions 0 and \pgfdecoratedpathlength step 1pt with { \csname pgf@relevantforpicturesizetrue\endcsname \pgfmathparse{round(100-abs(200*(\pgfkeysvalueof{/pgf/decoration/mark info/distance from start}/\pgfdecoratedpathlength)-100))} \pgfsetstrokecolor{#2!\pgfmathresult!#1} \pgfsetlinewidth{\pgflinewidth} \pgfsetroundcap \pgfpathmoveto{\pgfpointorigin} \ifdim\dimexpr\pgfkeysvalueof{/pgf/decoration/mark info/distance from start}+1pt\relax>\pgfdecoratedpathlength \pgfpathlineto{\pgfpointorigin} \else \pgfpathlineto{\pgfpoint{1pt}{0pt}} \fi \pgfusepath{stroke} } } } } \begin{document} \begin{tikzpicture} \foreach \x[evaluate=\x as \y using int(\x*2)] in {22.5,45,...,360} {% \path[ line width=1pt, multicolor={magenta}{lightmagenta}, overlay,rotate around={\x:(\x:2cm)} ] (\x:2cm) ellipse (2.4cm and 1.2cm); \path[ line width=1pt, multicolor={cyan}{lightcyan}, overlay,rotate around={\y:(\y:1cm) }] (\y:1cm) ellipse (2.5cm and 2.2cm); } \end{tikzpicture} \end{document} It gives the following result: However, in the origiaal ideal image, the path was not with the same line width. Any better suggestions to replicate the ideal result?
- Tikz library: what prevents this code from working? Unable to call the sin() functionby Adam Daniels on February 7, 2024 at 5:10 am
I've tried to call a mathematical function in the x-coordinate part of an (x,y) coordinate, to no avail. Strangely it works for the y-coordinate. Something must be wrong with the syntax but I can't figure it out. This code demonstrates the problem: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw (0,0) to [out=30,in=-120] (.5,{cos(60)}); % WORKS \draw (0,0) to [out=30,in=-120] ({.5},{cos(60)}); % WORKS \draw (0,0) to [out=30,in=-120] ({sin(30)},.5); % ATTEMPT 1: DOES NOT WORK \draw (0,0) to [out=30,in=-120] (sin(30),.5); % ATTEMPT 2: DOES NOT WORK \draw (0,0) to [out=30,in=-120] ({sin(30)},{.5}); % ATTEMPT 3: DOES NOT WORK \draw (0,0) to [out=30,in=-120] ({sin(30),.5}); % ATTEMPT 4: DOES NOT WORK \draw (0,0) to [out=30,in=-120] {(sin(30),.5)}; % ATTEMPT 5: DOES NOT WORK \draw (0,0) to [out=30,in=-120] ({{sin(30)},.5}); % ATTEMPT 6: DOES NOT WORK \draw (0,0) to [out=30,in=-120] {({sin(30)},.5)}; % ATTEMPT 7: DOES NOT WORK \end{tikzpicture} \end{document} Your help is greatly appreciated. Best regards,
- Add angles in TikZ-3dby Echelle-courte on April 13, 2023 at 2:26 am
I've done this figure in TikZ, but I don't know how to add and label the angles in TikZ-3D, how can I do it? Here's the original figure : Here's mine plus the code : \documentclass[tikz]{standalone} \usepackage{tikz} \usepackage{tikz-3dplot} \begin{document} \tdplotsetmaincoords{60}{-30} \begin{tikzpicture}[tdplot_main_coords, >=stealth, scale=2.5] \draw[->, thick] (0,0,0)--(0,0,3) node[left] {$\vec{z}_{n-1}$}; \draw[->, thick] (0,0,0)--(3,0,0) node[below] {$\vec{x}_{n-1}$}; \draw[dashed] (0,0,0)--(0,0.53,0.47); \draw[dashed] (1.75,0,0)--(1.75,0,1); \draw[->, thick] (1.75,0,0)--(1.75,2,1.75) node[left] {$\vec{z}_{n}$}; \draw[dashed] (1.75,0.97,0.85)--(3,0.97,0.85); \draw[->, thick] (1.75,0.97,0.85)--(3,0.97,1.5) node[below] {$\vec{x}_n$}; \draw[<->, thick] (0,0.32,0.25)--(1.75,0.32,0.25) node[above, midway] {$d_n$}; \draw[<->, thick] (2.75,0,0)--(2.75,0.97,0.85) node[right, midway] {$r_n$}; \end{tikzpicture} \end{document}
- TikZ - 3D surface plotby sobat on January 25, 2022 at 4:33 pm
I want to draw something like this: For the moment I just managed to draw a 3D plate and I don't know how to do it with the 3D sinus curves. I managed to draw something like that, but I don't know how to do for have 2 color in the curve and the same shape. It's not that good !! \documentclass {standalone} \usepackage{pgfplots} \pgfplotsset{compat = newest} \begin{document} \begin{tikzpicture} \begin{axis}[hide axis] \addplot3 [ domain=-2:2, domain y = -2:2, samples = 40, samples y = 40, surf, fill=pink, faceted color = teal] {-exp(-(x^2+y^2)/1.3}; \end{axis} \end{tikzpicture} \end{document} Could you help me?!
- How to draw an icosahedron with triangulated facesby InsideOut on January 21, 2022 at 3:58 pm
I would like to draw something like this by using TikZ. Here I have found several answers on how to draw such a Platonic solid but no one has the faces divided like this. I do not really care about colours. What really matters to me is to draw such icosahedron as an origami like the picture below. Here I've found a way fro drawing an icosahedron but without subdivision of the faces. How can I do? Thanks!
- zoombox array with adjustable width ratioby Alessandro Cuttin on February 17, 2021 at 9:21 pm
I've become an avid user of the zoomboxarray library created by Jake. Soon, one becomes aware that a fixed ratio (1:1) between the width of the subcaptionboxes containing the full image and the \zoomboxes is set. While this is convenient most of the times, it may happen that the \zoomboxes are just too big (for example: only one column of zoomboxes with a wide image). Reducing the width of the \zoomboxes in favor of a wider image can improve the end result. So, the ratio of the widths of the subcaptionboxes changes to -for example- 2:1. I'd like to be able to set such ratio. In a first attempt, I tried to hardcode a 2:1 ratio adapting Jake's code. The width of the \zoomboxes can be changed by dividing the \imagewidth by 2 inside the definition of the zoomboxarray style: width=(\imagewidth / 2) / \pgfkeysvalueof{/tikz/zoomboxarray columns} - (\pgfkeysvalueof{/tikz/zoomboxarray columns} - 1) / \pgfkeysvalueof{/tikz/zoomboxarray columns} * \pgfkeysvalueof{/tikz/zoomboxarray inner gap} -\pgflinewidth, The horizontal shift between \zoomboxes also needs to be adjusted: \pgfmathsetmacro\xpos{ (\columncount-1)*((\imagewidth / 2) / \pgfkeysvalueof{/tikz/zoomboxarray columns} + \pgfkeysvalueof{/tikz/zoomboxarray inner gap} / \pgfkeysvalueof{/tikz/zoomboxarray columns} ) + \pgflinewidth } Though, I still haven't found a way to effectively reduce the width of the zoomboxes container and of the related subcaptionbox. The width of the \phantomimage is certainly the key, but in a way that is obscure to me. Here's the full code of an MWE (the image is downloaded from the original question), where it can be seen (with the use of the \fbox{}) that the zoomboxes node is still too large. \documentclass{article} \usepackage{graphicx} \usepackage{caption} \usepackage{subcaption} \usepackage{tikz} \usepackage{pgfplots} \usetikzlibrary{spy,calc} \usepackage{hyperref} \newif\ifblackandwhitecycle \gdef\patternnumber{0} \pgfkeys{/tikz/.cd, zoombox paths/.style={ draw=orange, very thick }, black and white/.is choice, black and white/.default=static, black and white/static/.style={ draw=white, zoombox paths/.append style={ draw=white, postaction={ draw=black, loosely dashed } } }, black and white/static/.code={ \gdef\patternnumber{1} }, black and white/cycle/.code={ \blackandwhitecycletrue \gdef\patternnumber{1} }, black and white pattern/.is choice, black and white pattern/0/.style={}, black and white pattern/1/.style={ draw=white, postaction={ draw=black, dash pattern=on 2pt off 2pt } }, black and white pattern/2/.style={ draw=white, postaction={ draw=black, dash pattern=on 4pt off 4pt } }, black and white pattern/3/.style={ draw=white, postaction={ draw=black, dash pattern=on 4pt off 4pt on 1pt off 4pt } }, black and white pattern/4/.style={ draw=white, postaction={ draw=black, dash pattern=on 4pt off 2pt on 2 pt off 2pt on 2 pt off 2pt } }, zoomboxarray inner gap/.initial=5pt, zoomboxarray columns/.initial=2, zoomboxarray rows/.initial=2, subfigurename/.initial={}, figurename/.initial={zoombox}, zoomboxarray/.style={ execute at begin picture={ \begin{scope}[ spy using outlines={% zoombox paths, width= (\imagewidth / 2) / \pgfkeysvalueof{/tikz/zoomboxarray columns} - (\pgfkeysvalueof{/tikz/zoomboxarray columns} - 1) / \pgfkeysvalueof{/tikz/zoomboxarray columns} * \pgfkeysvalueof{/tikz/zoomboxarray inner gap} -\pgflinewidth, height=\imageheight / \pgfkeysvalueof{/tikz/zoomboxarray rows} - (\pgfkeysvalueof{/tikz/zoomboxarray rows} - 1) / \pgfkeysvalueof{/tikz/zoomboxarray rows} * \pgfkeysvalueof{/tikz/zoomboxarray inner gap}-\pgflinewidth, magnification=3, every spy on node/.style={ zoombox paths }, every spy in node/.style={ zoombox paths } } ] }, execute at end picture={ \end{scope} \node at (image.north) [anchor=north,inner sep=0pt] {\subcaptionbox{\label{\pgfkeysvalueof{/tikz/figurename}-image}}{\phantomimage}}; \node at (zoomboxes container.north) [anchor=north,inner sep=0pt] {\subcaptionbox{\label{\pgfkeysvalueof{/tikz/figurename}-zoom}}{\phantomimage}}; \gdef\patternnumber{0} }, spymargin/.initial=0.5em, zoomboxes xshift/.initial=1, zoomboxes right/.code=\pgfkeys{/tikz/zoomboxes xshift=1}, zoomboxes left/.code=\pgfkeys{/tikz/zoomboxes xshift=-1}, zoomboxes yshift/.initial=0, zoomboxes above/.code={ \pgfkeys{/tikz/zoomboxes yshift=1}, \pgfkeys{/tikz/zoomboxes xshift=0} }, zoomboxes below/.code={ \pgfkeys{/tikz/zoomboxes yshift=-1}, \pgfkeys{/tikz/zoomboxes xshift=0} }, caption margin/.initial=4ex, }, adjust caption spacing/.code={}, image container/.style={ inner sep=0pt, at=(image.north), anchor=north, adjust caption spacing }, zoomboxes container/.style={ inner sep=0pt, at=(image.north), anchor=north, name=zoomboxes container, xshift=\pgfkeysvalueof{/tikz/zoomboxes xshift}*(\imagewidth+\pgfkeysvalueof{/tikz/spymargin}), yshift=\pgfkeysvalueof{/tikz/zoomboxes yshift}*(\imageheight+\pgfkeysvalueof{/tikz/spymargin}+\pgfkeysvalueof{/tikz/caption margin}), adjust caption spacing }, calculate dimensions/.code={ \pgfpointdiff{\pgfpointanchor{image}{south west} }{\pgfpointanchor{image}{north east} } \pgfgetlastxy{\imagewidth}{\imageheight} \global\let\imagewidth=\imagewidth \global\let\imageheight=\imageheight \gdef\columncount{1} \gdef\rowcount{1} \gdef\zoomboxcount{1} }, image node/.style={ inner sep=0pt, name=image, anchor=south west, append after command={ [calculate dimensions] node [image container,subfigurename=\pgfkeysvalueof{/tikz/figurename}-image] {\phantomimage} node [zoomboxes container,subfigurename=\pgfkeysvalueof{/tikz/figurename}-zoom] {\phantomimage} } }, color code/.style={ zoombox paths/.append style={draw=#1} }, connect zoomboxes/.style={ spy connection path={\draw[draw=none,zoombox paths] (tikzspyonnode) -- (tikzspyinnode);} }, help grid code/.code={ \begin{scope}[ x={(image.south east)}, y={(image.north west)}, font=\footnotesize, help lines, overlay ] \foreach \x in {0,1,...,9} { \draw(\x/10,0) -- (\x/10,1); \node [anchor=north] at (\x/10,0) {0.\x}; } \foreach \y in {0,1,...,9} { \draw(0,\y/10) -- (1,\y/10); \node [anchor=east] at (0,\y/10) {0.\y}; } \end{scope} }, help grid/.style={ append after command={ [help grid code] } }, } \newcommand\phantomimage{% \phantom{% \rule{\imagewidth}{\imageheight}% }% } \newcommand\zoombox[2][]{ \begin{scope}[zoombox paths] \pgfmathsetmacro\xpos{ (\columncount-1)*((\imagewidth / 2) / \pgfkeysvalueof{/tikz/zoomboxarray columns} + \pgfkeysvalueof{/tikz/zoomboxarray inner gap} / \pgfkeysvalueof{/tikz/zoomboxarray columns} ) + \pgflinewidth } \pgfmathsetmacro\ypos{ (\rowcount-1)*( \imageheight / \pgfkeysvalueof{/tikz/zoomboxarray rows} + \pgfkeysvalueof{/tikz/zoomboxarray inner gap} / \pgfkeysvalueof{/tikz/zoomboxarray rows} ) + 0.5*\pgflinewidth } \edef\dospy{\noexpand\spy [ #1, zoombox paths/.append style={ black and white pattern=\patternnumber }, every spy on node/.append style={#1}, x=\imagewidth, y=\imageheight ] on (#2) in node [anchor=north west] at ($(zoomboxes container.north west)+(\xpos pt,-\ypos pt)$);} \dospy \pgfmathtruncatemacro\pgfmathresult{ifthenelse(\columncount==\pgfkeysvalueof{/tikz/zoomboxarray columns},\rowcount+1,\rowcount)} \global\let\rowcount=\pgfmathresult \pgfmathtruncatemacro\pgfmathresult{ifthenelse(\columncount==\pgfkeysvalueof{/tikz/zoomboxarray columns},1,\columncount+1)} \global\let\columncount=\pgfmathresult \ifblackandwhitecycle \pgfmathtruncatemacro{\newpatternnumber}{\patternnumber+1} \global\edef\patternnumber{\newpatternnumber} \fi \end{scope} } \begin{document} \begin{figure}[ht]\centering \fbox{ \begin{tikzpicture}[ zoomboxarray,black and white=cycle, ] \node [image node] { \includegraphics[width=0.45\textwidth]{gallery} }; \zoombox{0.27,0.9} \zoombox[color code=red,magnification=6]{0.4,0.83} \zoombox{0.42,0.45} \zoombox[magnification=5]{0.95,0.52} \end{tikzpicture} } \caption{The National Gallery of Canada} \end{figure} \end{document} How can I effectively adjust the width of the \zoomboxes node, possibly as a parameter of the tikzpicture environment?
- Drawing Super Mario Bros.....in LaTeXby Sebastiano on October 2, 2019 at 10:20 pm
There are several questions about TeX.SE. that concern designs for recurrences such as fireworks, lunar calendar, the pi-greek, and into my mind I'm remembering a protagonist of an old video game: Super Mario Bros. But is it possible to make detailed drawings of the protagonists of video games with LaTeX? I'm just curious to see only how the users build Super Mario Bros. Thank you everyone.
- Tangent to ellipse using Tikzby MocS on July 25, 2019 at 11:17 pm
I would like to draw 2 ellipses and a 6-sided polygon that is inscribed in the first ellipse and circumscribed about second ellipse. I am working with package TikZ and I am a beginner, so this is as far as I got: \documentclass[tikz]{standalone} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \clip (-3,-2) rectangle (3,2); \coordinate (A) at (170:2 and 1); \coordinate (B) at (100:2 and 1); \coordinate (C) at (40:2 and 1); \coordinate (F) at (220:2 and 1); \coordinate (E) at (-90:2 and 1); \coordinate (D) at (-30:2 and 1); \coordinate (X) at (intersection of A--E and D--B); \coordinate (Y) at (intersection of A--F and D--C); \coordinate (Z) at (intersection of C--E and F--B); \draw[black,thick] (0,0) ellipse (2 and 1); \draw[black,thin] ($(A)!-0.0!(B)$)--($(A)!1.0!(B)$); \draw[black,thin] ($(C)!-0.0!(B)$)--($(C)!1.0!(B)$); \draw[black,thin] ($(C)!-0.0!(D)$)--($(C)!1.0!(D)$); \draw[black,thin] ($(F)!-0.0!(E)$)--($(F)!1.0!(E)$); \draw[black,thin] ($(E)!-0.0!(D)$)--($(E)!1.0!(D)$); \draw[black,thin] ($(A)!-0.0!(F)$)--($(A)!1.0!(F)$); \foreach \p in {A,B,C,D,E,F} \fill[black] (\p) circle (0.04); \draw[black] ($(A)+(120:0.3)$) node{$A$}; \draw[black] ($(B)+(100:0.3)$) node{$B$}; \draw[black] ($(C)+(90:0.3)$) node{$C$}; \draw[black] ($(D)+(-90:0.3)$) node{$D$}; \draw[black] ($(E)+(-80:0.3)$) node{$E$}; \draw[black] ($(F)+(-110:0.3)$) node{$F$}; \end{tikzpicture} \end{document} So this gives me the outer ellipse, 6 points on it, and the tangents to the inner ellipse. But I am stuck, as I don't know how to draw the inner ellipse. Any help will be appreciated.
- How can I get correct spacing when reusing Forest trees and when calign is center (default), last etc.?by cfr on July 22, 2017 at 2:28 pm
Forest allows me to reuse (part of) a tree in another tree. However, when calign has certain values, including the default center, this does strange things to the spacing of some nodes. How can this be avoided in a less hackish way than by the use of the commented code block, which is a really horrible workaround? The following example is based on my answer to David Emerson's question. \documentclass[border=10pt,multi,tikz]{standalone} \usepackage{forest} \begin{document} \forestset{ default preamble={ for tree={ align=center, child anchor=parent, draw, }, % before packing={% horrible hack - this shouldn't be needed at all! % where={>On=On=&{n}{1}{n children}{0}}{ % if nodewalk valid={next}{ % s'+=100mm, % }{} % }{}, % } }, } \Forest*{ [Manager 1, name=m1 [Individual\\Contributor 1] [Individual\\Contributor 2] [Individual\\Contributor 3] [Individual\\Contributor 4] [Individual\\Contributor 5] [Individual\\Contributor 6] ] } \Forest*{ [, replace by=m1] } \end{document}
- Drawing topology of network with TikZby MEDIOUNI on June 26, 2016 at 12:07 am
I want to draw with TikZ a topology as illustrated below: The shape of node preferred is ball, can you help me ?
- 3D effects for hollow and solid cylinder in tikzby ravi on November 4, 2015 at 6:01 am
I want to make following things in tikz- Solid Cylinder Hollow Cylinder The solid cylinder is little tilted and touching the top surface of hollow cylinder. The hollow cylinder is open from both the ends. Below is my code- \begin{tikzpicture}[scale=0.5, transform shape] \begin{scope}[shift={(0,0)},rotate=30] \coordinate (ll) at (-2,0); %lower left \coordinate (lr) at ( 2,0); %lower right \coordinate (ul) at (-2,4); %upper left \coordinate (ur) at ( 2,4); %upper right \shade [shading angle=90] (ll) arc (-180:-60:2 cm and .75cm) -- +(0,4) arc (-60:-180:2 cm and .75cm) -- cycle; \shade [shading angle=270] (lr) arc (0:-60:2 cm and .75cm) -- +(0,4) arc (-60:0:2 cm and .75cm) -- cycle; \draw [thick] (ll) arc (-180:0:2 cm and .75cm) -- (ur) arc (0:-180:2 cm and .75cm) -- cycle; \draw [thick, shade, shading angle=30] (ul) arc (-180:180:2 cm and .75cm); \end{scope} \fill [top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25] (0,0) circle (2cm and 0.5cm); \fill [left color=gray!50!black,right color=gray!50!black,middle color=gray!50,shading=axis,opacity=0.25] (2,0) -- (2,-6) arc (360:180:2cm and 0.5cm) -- (-2,0) arc (180:360:2cm and 0.5cm); \fill [top color=gray!90!,bottom color=gray!2,middle color=gray!30,shading=axis,opacity=0.25] (0,-6) circle (2cm and 0.5cm); \draw (-2,-6) -- (-2,0) arc (180:360:2cm and 0.5cm) -- (2,-6) ++ (-2,0) circle (2cm and 0.5cm); \draw [densely dashed] (-2,0) arc (180:0:2cm and 0.5cm); \end{tikzpicture} Below is the generated picture - The above output is fine but it is difficult to differentiate between hollow and solid object. How to achieve it? Please suggest.
- Tikz weird 3D lookby Michael A on September 10, 2015 at 10:28 pm
I've got a slight problem with the way TikZ draws my 3D figure. The edges of the top and bottom of the cylinder in the picture don't seem to match correctly even though I don't think I made a mistake. Does anybody know why it does this or is there a better way to draw this? (still quite new to TikZ and 3D drawing) \documentclass[11pt,a4paper,onesided]{report} \usepackage[ngerman]{babel} \usepackage{amsmath,amsfonts,amssymb,amsthm} \usepackage{pgfplots} \usetikzlibrary{calc,fit,patterns,decorations.markings,matrix,3d} \begin{document} \begin{tikzpicture}[scale=1] \draw[thin,->] (-2,0) -- (5,0); \draw[thin,->] (0,-2) -- (0,3); %Zylinder \draw[] (1.5,-1.5) -- (1.5,1.5); \draw[] (3.5,-1.5) -- (3.5,1.5); \begin{scope}[canvas is zx plane at y=0] \draw (0,2.5) circle (2cm); \draw[fill=gray,opacity=0.5] (0,2.5) circle (1cm); % \draw[->] (-2,0) -- (3,0); \end{scope} \begin{scope}[canvas is zx plane at y=1.5] \draw (0,2.5) circle (1cm); \end{scope} \begin{scope}[canvas is zx plane at y=-1.5] \draw (0,2.5) circle (1cm); \end{scope} \begin{scope}[every node/.append style={ xslant=1,sloped} ] \node at (2.4,-.2) {\scalebox{1}[.7]{$T_0$}}; \node at (4,.4) {\scalebox{1}[.7]{$T$}}; \node at (-.8,-.2) {\scalebox{1}[.7]{$\mathbb{R}^n$}}; \end{scope} \end{tikzpicture} \end{document} The result:
- TikZ Fill for Fraction Diagramby WeCanLearnAnything on August 4, 2015 at 11:34 pm
I'm trying to shade in one third of this circle. Obviously, it's not working. What did I do wrong? I got no error messages for either of my attempts in the code below, but neither filled anything in. Both just gave this circle. \documentclass[12pt,letterpaper]{article} \usepackage{tikz} \usepackage{xcolor} \begin{document} How to shade in $\frac{1}{3}$ of this? \begin{tikzpicture} \draw (0,0) circle (3cm); \draw (90:3)--(0,0); \draw (210:3)--(0,0); \draw (330:3)--(0,0); \fill[gray] arc[start angle=-30, end angle =90, radius=3cm]; \end{tikzpicture} % In this attempt, I put the color=gray part in the same square brackets as all the other stuff. \begin{tikzpicture} \draw (0,0) circle (3cm); \draw (90:3)--(0,0); \draw (210:3)--(0,0); \draw (330:3)--(0,0); \fill arc[color=gray, start angle=-30, end angle =90, radius=3cm]; \end{tikzpicture} \end{document}
- Using calc: Draw tangent lines to an ellipse path by tikzby AboAmmar on July 17, 2014 at 11:30 pm
I wonder if one can draw tangent lines out of a point to a path of an ellipse using tikz. Actually for the case of circle paths this can be accomplished easily as given in the tikz-pgf manual, but for other paths it wouldn't be an easy task. I have tried to solve this problem with the help of some threads, but my solution, unfortunately, relies on some mathematical background. I wonder if I could solve the same problem with pure tikz. Here is my solution: \documentclass{standalone} \usepackage{tikz,pgfplots} \usetikzlibrary{calc,intersections,arrows} \usepackage{times} \begin{document} \begin{tikzpicture}[scale=1,>=latex',scale=1.5,outer sep=0,inner sep=0,line width=0.7pt] \def\a{2} \def\b{1} % radii of Ellipse \def\cx{0} \def\cy{0} % determines center of Ellipse \def\xp{0} \def\yp{-5} % coordinates of point P \coordinate (P) at (\xp,\yp); \coordinate (A) at (0,\b); % up \coordinate (B) at (0,-\b); % down \coordinate (C) at (\a,0); % right \draw[name path=ellipse,fill=gray!30,opacity=0.5](\cx,\cy)circle[x radius=\a,y radius=\b]; \path[name path=linePC] (P)--(C); \path[name path=linePC] (P)--(C); \path [name intersections={of = ellipse and linePC}]; \coordinate (E) at (intersection-2); \coordinate (F) at (intersection of A--C and B--E); \path let \p1=(F) in node (G) at (-1.2*\a,\y1){}; \path[name path=lineFG] (F)--(G); \path [name intersections={of = ellipse and lineFG}]; \coordinate (X) at (intersection-1); \coordinate (Y) at (intersection-2); \draw (X)--(P)--(Y); %%%%%%%%%%%%%%%%%%%%%% Second Ellipse%%%%%%%%%%%%%% \def\a{1} \def\b{0.5} % radii of Ellipse \def\cx{0} \def\cy{0} % determines center of Ellipse \def\xp{0} \def\yp{-5} % coordinates of point P \coordinate (P) at (\xp,\yp); \coordinate (A) at (0,\b); % up \coordinate (B) at (0,-\b); % down \coordinate (C) at (\a,0); % right \draw[name path=ellipse,fill=white](\cx,\cy)circle[x radius=\a,y radius=\b]; \path[name path=linePC] (P)--(C); \path[name path=linePC] (P)--(C); \path [name intersections={of = ellipse and linePC}]; \coordinate (E) at (intersection-2); \coordinate (F) at (intersection of A--C and B--E); \path let \p1=(F) in node (G) at (-1.2*\a,\y1){}; \path[name path=lineFG] (F)--(G); \path [name intersections={of = ellipse and lineFG}]; \coordinate (X) at (intersection-1); \coordinate (Y) at (intersection-2); \draw (X)--(P) (P)--(Y); \draw [->,thin](0,-5.5)--(0,1.5) node[above]{$z$}; \draw [<-,shorten <=0.2pt,thin](P)--+(0.4,-0.1) node[right]{Gap}; \draw [->,thin](0,-2.2) arc (90:65.4:2.5); \node [fill=white] at (0.5,-2.5){$\theta_2$}; \draw [->,thin](0,-3.5) arc (90:79:1.6); \node at (0.13,-3.7){$\theta_1$}; \end{tikzpicture} \end{document} I appreciate your help and thank you in advance.
- Can we make a love heart with LaTeX?by Sibbs Gambling on October 20, 2013 at 4:48 pm
I understand that this post may cause some down votes because it seems a bit off-topic, but having seen the discussions on Christmas Tree with LaTeX I am still willing to try. How do you draw a red cute love heart using LaTeX?
- Is it possible to draw a 3d cylinder using TikZ-3dplot?by Sebastian Schmitz on October 15, 2013 at 10:40 am
I want to draw a clyinder between two planes. I want to specify the distance between the planes and position and radius of the cylinder. I would like to use tikz-3dplot, because it allows a free rotation of the Viewpoint if everything is implemented with it. There are a few Threads in which the creation of 3D bodies in TikZ, Drawing simple 3D cylinders in TikZ and Drawing 3D cylinder have been discussed. Unfortunately those solution seem not to work with tikz-3dplot, because they all manipulate the 'Viewpoint' themself. This leads to the Problem, that a manipulation of the viewpoint with \tdplotsetmaincoords only rotates all Objects except the Cylinders. Another User had a very similar question which yielded no answer yet. How to draw a 3d cylinder using TikZ-3dplot? To summarize: I want to draw a cylinder in 3d using tikz-3dplot. At the Moment i can draw the circle at the end of the cylinder and a line from border to border, which only recognizes rotation around the x-axis. The Question is how can i put the lines correctly at the side of the cylinder. Example of Code: \documentclass[convert = false, tikz]{standalone} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{textcomp} \usepackage{amsmath} \usepackage{tikz-3dplot} \begin{document} %Configure here Rotation around x and y axis \pgfmathsetmacro{\x}{60} \pgfmathsetmacro{\y}{100} \tdplotsetmaincoords{\x}{\y} \begin{tikzpicture}[ tdplot_main_coords] \coordinate (O) at (0, 0, 0); \draw[-latex] (O) -- (-8, 0, 0) node[font = \small, pos = 1.1] {\(x\)}; \draw[-latex] (O) -- (0, 6, 0) node[font = \small, pos = 1.1] {\(y\)}; \draw[-latex] (O) -- (0, 0, 6) node[font = \small, pos = 1.1] {\(z\)}; % define size of planes \pgfmathsetmacro{\planesize}{4} %plane1 \filldraw[blue, opacity = .2] (0, 0, 0) -- (0, \planesize, 0) -- (0, \planesize, \planesize) -- (0, 0, \planesize) -- cycle; %Define Plane in which the circles of the cylinder are drawn. \tdplotgetpolarcoords{0}{1}{0} \tdplotsetthetaplanecoords{\tdplotresphi} %\tdplotdrawarc[coordinate system, draw styles]{center}{r}{angle start}{angle end}{label options}{label} %circle on first plane \pgfmathsetmacro{\radius}{0.5} \tdplotdrawarc[tdplot_rotated_coords]{(1,1,0)}{\radius}{0}% {360}{}{} %circle on second plane \tdplotdrawarc[tdplot_rotated_coords]{(1,1,4)}{\radius}{0}% {360}{}{} %line from middle to middle \draw[tdplot_rotated_coords] (1,1,0) -- (1, 1, 4) node[font = \small, pos = 1.1] {}; %First Edge of cylinder \draw[tdplot_rotated_coords] ({1+sin(\x)*\radius}, {1+cos(\x)*\radius},0) -- ({1+sin(\x)*\radius}, {1+cos(\x)*\radius}, 4) node[font = \small, pos = 1.1] {}; %plane2 \filldraw[blue, opacity = .2] (-4, 0, 0) -- (-4, \planesize, 0) -- (-4, \planesize, \planesize) -- (-4, 0, \planesize) -- cycle; \end{tikzpicture} \end{document}
- Hide Tikz node in Beamerby jorgehumberto on July 14, 2013 at 4:34 pm
I am using Tikz to create a flow chart for a Beamer presentation. I managed to get Beamer to uncover each item in the flowshart one by one, but I would like to be able to show one node and then hide it. Is there any way to do this? Here's my code: \begin{frame}{The Detection Method} \tikzstyle{LargeBlock} = [rectangle, draw, fill=blue!20, text width=10em, text badly centered, rounded corners] \tikzstyle{decision} = [diamond, draw, fill=red!20, text badly centered,text width=1.2cm] \tikzstyle{block} = [rectangle, draw, fill=blue!20, text width=5em, text badly centered, rounded corners, minimum height=1em] \tikzstyle{ImgBlock} = [rectangle, draw] \tikzstyle{line} = [draw, -latex'] \tikzstyle{cloud} = [draw, ellipse,fill=red!20, minimum height=1em] \tikzstyle{EmptyAnchor} = [ellipse,minimum height=1em] \begin{tikzpicture}[node distance = 1cm, auto] \pause{} % Step 1 \node [LargeBlock, anchor=north] (init) {Simulated Planet + Star CCFs};\pause{} % Step 2 \node [decision, right=1 cm of init] (build) {$\sum CCFs$}; \path [line] (init) -- (build); \pause{} % Step 3 \node [block, below=0.5 cm of build] (template) {Star Template}; \path [line] (build) -- (template); \pause{} % Step 4 \node [decision, below=0.5 cm of init] (normalise) {$\frac{CCFs}{Template}$}; \path [line] (init) -- (normalise); \path [line] (template) -- (normalise); \pause{} % Step \node [EmptyAnchor, below=1.5 cm of normalise] (empty0) {}; \node [EmptyAnchor, right=2.5 cm of empty0] (empty3) {}; \node [ImgBlock, right=5 cm of empty0] (img1) {{\pgftext{\includegraphics[width=4.5cm,page=6]{./figures/Jupiter_3days_EELT.pdf}}}}; \path [line,dashed] (normalise) |- (empty3); \pause{} % Step 5 \path [line] (init) -- (build); \node [LargeBlock, below=0.5 cm of normalise] (NormCCFs) {Normalized CCFs}; \path [line] (normalise) -- (NormCCFs); \pause{} % Step 6 \node [decision, below=0.5 cm of NormCCFs] (stack) {$stack$ $CCFs$}; \node [EmptyAnchor, below=0.5 cm of NormCCFs] (empty1) {}; \path [line] (NormCCFs) -- node[color=red]{Correct Planet RV} (stack); \pause{} % Step 7 \node [EmptyAnchor, right=2 cm of stack] (empty2) {}; \node [ImgBlock, right=5 cm of empty1] (stop) {{\pgftext{\includegraphics[width=4.5cm,page=8]{./figures/Jupiter_3days_EELT.pdf}}}}; \path [line,dashed] (stack) -- (empty2); \end{tikzpicture} \end{frame} I want node (img1) to appear and then vanish when node (NormCCFs) appears. Any takers?
- Intersecting planes not shown correctly with TikZby George Urvey on April 17, 2013 at 10:14 am
I made a plot in MATLAB of a deformed and an undeformed model. I converted the figure to TikZ using matlab2tikz and added it to my .tex file. I then noticed that the two configurations, which are intersecting, are not displayed correctly. To illustrate what I mean, I've stripped down the TikZ code to make to rectangles cross in a 3D space: \begin{tikzpicture} \begin{axis}[% width=5cm,height=5cm, view={-37.5}{45}, scale only axis, xmin=-3, xmax=23, ymin=0, ymax=20, zmin=-5, zmax=5, hide axis] \addplot3 [fill=white!80!red,opacity=0.5,draw=black] table[row sep=crcr]{ 20 0 0\\ 20 20 0\\ 0 20 0\\ 0 0 0\\ }; \addplot3 [fill=white!80!blue,opacity=0.8,draw=black] table[row sep=crcr]{ 15 5 -4\\ 15 15 0\\ 5 15 4\\ 5 5 0\\ }; \end{axis} \end{tikzpicture} The result looks like this: As can be seen one plane lies entirely on top of the other, while in fact they intersect (i.e. about half of the blue plane lies 'underneath' the red plane). With my minimum TikZ knowledge I was hoping someone here could help me fix this problem, such that the planes indeed intersect.
- generate simple cylindrical shape with text in latex (tikz)by KatyB on December 11, 2012 at 3:06 pm
I am attempting to generate the following diagram in latex: I've been using the tikz package, which although its capabilities seem to be endless, it does have a rather steep learning curve. I am currently learning how to generate simple diagrams including circles, arrows, squares, and have no idea how to include text yet. I am working through the manual so I will eventually have a good understanding of the tool, but as of yet, the diagram shown is beyond my capabilities. Could someone specify how I should go around generating this diagram? Many thanks for your help.
- Drawing 3D cylinderby Jana on July 15, 2012 at 9:20 am
I need to draw a lot of 3D cylinders with different dimensions. Has anyone maybe already defined a command like \3Dcylinder{x}{y}{z}? I found 3D bodies in TikZ and tried the third answer. But I don't understand how the parameters work. Also I found Drawing simple 3D cylinders in TikZ. But I don't know how to use it to easily draw a bunch of different cylinders.
- Creating gears in TikZby azetina on June 5, 2012 at 10:54 pm
I am trying to create a gear in TikZ in which the number of spikes can be determined and the size as well. I was looking through the pgfmanual and stumbled upon the decorations section and I tried a piece of code there. Here is what I have so far: \documentclass[letterpaper]{article} \usepackage{tikz} \usetikzlibrary{decorations} \begin{document} \pgfdeclaredecoration{example}{initial} { \state{initial}[width=20pt] { \pgfpathlineto{\pgfpoint{0pt}{5pt}} \pgfpathlineto{\pgfpoint{5pt}{5pt}} \pgfpathlineto{\pgfpoint{5pt}{-5pt}} \pgfpathlineto{\pgfpoint{10pt}{-5pt}} \pgfpathlineto{\pgfpoint{10pt}{5pt}} } \state{final} { \pgfpathlineto{\pgfpointdecoratedpathlast} } } \tikz[decoration=example] { \draw [red,decorate] (0,0) circle (1cm); } \end{document} which yields: Of course the above is not satisfactory. Is there a way a gear can be drawn in TikZ or any other graphics package? Update: For those interested in ready made svg images, the NounProject provides some sample files. Follow this link: Engrenages.
- Drawing simple 3D cylinders in TikZby Jake on October 14, 2011 at 9:42 am
I'm trying to draw some simple 3D objects in TikZ. I can do spheres and cuboids okay, but I'm struggling with circular cylinders: When rotating the scene (I use tikz-3dplot for this), the end faces have to be transformed from circles into ellipses. Using \draw ... circle; doesn't work, because a path defined like that will always stay circular. If I use \draw ... to ... to ... constructs with the in and out set to adequate values, I can "simulate" circles that transform slightly better: The "corner" points of the circle end up in the right place, but the in and out angles are not transformed appropriately. What can I do to get "3D circles", i.e. circles that turn into ellipses when the 3D space is rotated? Here's an example showing the problem: \documentclass{article} \usepackage{tikz} \usepackage{tikz-3dplot} \begin{document} \tdplotsetmaincoords{40}{20} \noindent The vertical cylinder walls\\ are not aligned properly \ldots \begin{tikzpicture}[tdplot_main_coords] \draw (0,0) circle [radius=1cm]; \end{tikzpicture} \begin{tikzpicture}[tdplot_main_coords] \draw (1,0,2) -- (0,1,2) -- (-1,0,2) -- (0,-1,2) -- cycle (-1,0,0) -- (0,-1,0) -- (0,-1,2) -- (-1,0,2) -- cycle (1,0,2) -- (0,-1,2) -- (0,-1,0) -- (1,0,0) -- cycle; \end{tikzpicture} \begin{tikzpicture}[tdplot_main_coords] \draw [in=225, out=-45, relative] (0.5,0.5,2) to (-0.5,0.5,2) to (-0.5,-0.5,2) to (0.5,-0.5,2) to (0.5,0.5,2) (0.5,0.5,0) to (-0.5,0.5,0) to (-0.5,-0.5,0) to (0.5,-0.5,0) to (0.5,0.5,0) (0.5,0.5,2) -- (0.5,0.5,0) (-0.5,-0.5,2) -- (-0.5,-0.5,0); \end{tikzpicture} \tdplotsetrotatedcoords{40}{50}{-30}\vspace{0.5cm} \noindent\ldots and the support points\\don't get transformed correctly \begin{tikzpicture}[tdplot_rotated_coords] \draw (0,0) circle [radius=1cm]; \end{tikzpicture} \begin{tikzpicture}[tdplot_rotated_coords] \draw (1,0,2) -- (0,1,2) -- (-1,0,2) -- (0,-1,2) -- cycle (-1,0,0) -- (0,-1,0) -- (0,-1,2) -- (-1,0,2) -- cycle (1,0,2) -- (0,-1,2) -- (0,-1,0) -- (1,0,0) -- cycle; \end{tikzpicture} \begin{tikzpicture}[tdplot_rotated_coords] \draw [in=225, out=-45, relative] (0.5,0.5,2) to (-0.5,0.5,2) to (-0.5,-0.5,2) to (0.5,-0.5,2) to (0.5,0.5,2) (0.5,0.5,0) to (-0.5,0.5,0) to (-0.5,-0.5,0) to (0.5,-0.5,0) to (0.5,0.5,0) (0.5,-0.5,2) -- (0.5,-0.5,0) (-0.5,0.5,2) -- (-0.5,0.5,0); \end{tikzpicture} \end{document}
- Plotting an implicit function using TikZby Pieter on October 31, 2010 at 8:09 am
How could one plot an implicit function, like (x^2+y^2)^3-4x^2y^2 using TikZ? I know gnuplot supports them, but they are drawn using a surface built from the function and intersecting the result with the z=0 plane. How would one implement this work flow directly from TikZ? I know you can easily pass explicit functions to gnuplot but I don't want to split up the implicit function in its constituent parts if it's not necessary. Of course, it's possible to plot in the gnuplot program and save the results, but I'm curious whether there is a more direct way :).