TikZ
- Coil decoration on curved path looks strangeby nogrodrigo on June 13, 2026 at 3:52 pm
I am trying to achieve something like this in TikZ: The black path should go straight up and the red one should go down bent to the right, both must look like a coil. I have tried to do this using bezier curves and arcs, but the coil decoration of the bent path looks very strange, it's pointy in some parts. What am I doing wrong? MWE: \documentclass{article} \usepackage{xcolor} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing} \begin{document} \begin{tikzpicture} \draw[-latex, decorate, decoration = {coil, aspect = 1.2}, color = red] (0,2) arc (90:-90:1); \draw[-latex, decorate, decoration = {coil, aspect = 1.2}] (0,0) -- (0,2); \draw[-latex, decorate, decoration = {coil, aspect = 1.2}] (3,0) -- (3,2); \draw[-latex, decorate, decoration = {coil, aspect = 1.2}, color = red] (3,2) .. controls (4,2) and (4,0) .. (3,0); \end{tikzpicture} \end{document}
- Tikz customize in big operators symbols, can't display big tikz operatorsby mathrm alpha on June 13, 2026 at 8:59 am
I followed the LaTeX question reference below to adapt it to the tikz big operators version, but it didn't display in tikz "⅌" symbol. How can I define a big plus operator that works like \bigcup? ⅌ apply in tikz text symbols? % Source - https://tex.stackexchange.com/a/394912 % Posted by GuM, modified by community. See post 'Timeline' for change history % Retrieved 2026-06-13, License - CC BY-SA 3.0 \documentclass{article} \usepackage{tikz,iftex,amsmath} \usepackage{graphicx} \makeatletter \newcommand*\@bigper[1]{\vcenter{\hbox{#1$\m@th ⅌$}}} \newcommand*\bigper{% \DOTSB % omit this line if you are not using the amsmath package \mathop{% \mathchoice {\@bigper ⅌}% {\@bigper \LARGE}% {\@bigper {}}% {\@bigper \footnotesize}% }% \slimits@ % omit this line if you are not using the amsmath package } \makeatother \ifPDFTeX \usepackage[utf8]{inputenc} \else \usepackage{newunicodechar} \fi \DeclareRobustCommand{\TikZPerSign}{% \tikz[ baseline=-.25ex, x=.13em, y=.13em, line cap=round, line join=round ]{% % Fixed box: this is important for text-like behaviour. \path[use as bounding box] (-3.05,-3.35) rectangle (3.95,4.35); % 1. The horizontal ellipse \draw[line width=.05em] (0.4,0) ellipse[x radius=2.2,y radius=.7]; % 2. The main U shape \draw[line width=.05em] (-.6,1.5) .. controls (-.6,-3.2) and (.6,-3.2) .. (.6,1.5); % 3. The top-left flourish \draw[line width=.05em] (-.6,1.5) .. controls (-1.8,2.8) and (-3.0,1.5) .. (-2.2,1.2); \fill (-.5,1.9) circle[radius=.22]; % 4. The large right loop \draw[line width=.05em] (.6,1.5) .. controls (.6,4.2) and (3.5,3.2) .. (3.5,.5) .. controls (3.5,-.8) and (2.5,-1.2) .. (1.8,-1.0); }% } \ifPDFTeX \DeclareUnicodeCharacter{214C}{\TikZPerSign} \else \newunicodechar{⅌}{\TikZPerSign} \fi \begin{document} $$\sum^1_2 \bigper^3_4$$ \end{document}
- TeX chinese image poetry image text layoutby mathrm alpha on June 12, 2026 at 4:06 am
Someone helped me figure out how to create LaTeX Chinese image poetry, The vertical CJK text was not arranged according to the size of the shape. Source: https://jedi.nehs.hc.edu.tw/newsletter/306/poem.html LaTeX code I've tried with tikz text typesetting: \documentclass{article} \usepackage{tikz} \usepackage[margin=0.5in]{geometry} \usepackage{xeCJK} \definecolor{carcolor}{RGB}{242, 186, 166} \begin{document} \centering \begin{tikzpicture} % Wheels (車輪) \fill[carcolor, rounded corners=6pt] (1.8, 0.7) rectangle (2.6, 1.5); \fill[carcolor, rounded corners=6pt] (3.4, 0.7) rectangle (4.2, 1.5); % Main body of the car (主車身) \fill[carcolor, rounded corners=10pt] (0, 1) rectangle (6, 2.3); % Top cabin part (車頂) \fill[carcolor, rounded corners=12pt] (1.6, 2.2) rectangle (4.4, 3.6); \linespread{0.8}\selectfont \scriptsize % 第 1 行:叭叭(最右側,車身內) \node[text width=0.35cm, align=center] at (5.2, 1.65) {叭\\叭}; % 第 2 行:我是(車身內) \node[text width=0.35cm, align=center] at (4.8, 1.65) {我\\是}; % 第 3 行:一輛車(進入車頂邊緣) \node[text width=0.35cm, align=center] at (4.3, 1.9) {一\\輛\\車}; % 第 4 行:我可以載人(深入車頂) \node[text width=0.35cm, align=center] at (3.8, 2.3) {我\\可\\以\\載\\人}; % 第 5 行:也可以載貨物(深入車頂) \node[text width=0.35cm, align=center] at (3.3, 2.45) {也\\可\\以\\載\\貨\\物}; % 第 6 行:雖然身不大(深入車頂) \node[text width=0.35cm, align=center] at (2.8, 2.45) {雖\\然\\身\\不\\大}; % 第 7 行:卻是大力士(深入車頂) \node[text width=0.35cm, align=center] at (2.3, 2.45) {卻\\是\\大\\力\\士}; % 第 8 行:不管是跑車(進入車頂邊緣) \node[text width=0.35cm, align=center] at (1.8, 2.3) {不\\管\\是\\跑\\車}; % 第 9 行:客車或是貨車(字數多,稍微往下靠在車身與車頂間) \node[text width=0.35cm, align=center] at (1.3, 1.9) {客\\車\\或\\是\\貨\\車}; % 第 10 行:全都是(左側,車身內) \node[text width=0.35cm, align=center] at (0.8, 1.65) {全\\都\\是}; % 第 11 行:神奇 車!(最左側,車身內) \node[text width=0.35cm, align=center] at (0.4, 1.65) {神\\奇\\車\\!}; \end{tikzpicture} \end{document} I only realized how strange the text position and height were when I used it.
- How do I draw the feedback loop in my latex code for my research paper?by Sajid Mahfuz on June 11, 2026 at 10:21 pm
How do I create the feedback loop shown in the image? I’ve also been trying to make all the arrow lengths uniform, but I keep failing (bear with me, I’m a beginner in LaTeX), and I need the diagram to be larger. I’ve attached my code and the image. \documentclass{article} \usepackage{tikz} \usetikzlibrary{arrows.meta, positioning, calc} \begin{document} \begin{center} \begin{tikzpicture}[ node distance=1.2cm and 1.2cm, block/.style={ draw, rectangle, minimum width=2.5cm, minimum height=0.9cm, line width=1pt, align=center }, innerblock/.style={ draw, rectangle, minimum width=1.8cm, minimum height=0.9cm, line width=1pt, % changed from 0.5pt to 1pt align=center }, disturbance/.style={ draw, rectangle, minimum width=1.8cm, minimum height=0.9cm, fill=red!10, line width=1pt, align=center }, arrow/.style={-{Triangle[length=2mm,width=2mm]}, line width=1pt} ] % ================= INPUT ================= \node[circle, draw, minimum size=0.8cm, line width=1pt] (sum) at (0,0) {}; % changed to 1pt % X inside circle (also 1pt) \draw[line width=1pt] (sum.north east) -- (sum.south west); \draw[line width=1pt] (sum.north west) -- (sum.south east); \draw[arrow] (-1.2,0) -- (sum.west); \node[left=1.2cm] {$Z_D$}; % ================= CONTROL ================= \node[block, above right=0.5cm and 1.0cm of sum] (sdre) {SDRE}; \node[block, below right=0.5cm and 1.0cm of sum] (pi) {PI}; \draw[arrow] (sum.east) -- ++(0.2,0) |- (sdre.west); \draw[arrow] (sum.east) -- ++(0.2,0) |- (pi.west); % ================= ACTUATION ================= \node[block, right=1.0cm of sdre] (actuator) {Actuator}; \node[block, right=1.0cm of pi] (thrust) {Thrust}; \draw[arrow] (sdre.east) -- (actuator.west); \draw[arrow] (pi.east) -- (thrust.west); % ================= THRUST MAP ================= \node[block, below=0.8cm of pi] (thrustMap) {Thrust Map}; \draw[arrow] (pi.south) -- (thrustMap.north); \draw[arrow] (thrustMap.east) -| (thrust.south); % ================= DYNAMICS ================= \node[innerblock, right=1.0cm of actuator] (att_dyn) {Attitude Dynamics}; \node[innerblock, right=1.0cm of thrust] (alt_dyn) {Altitude Dynamics}; \draw[arrow] (actuator.east) -- (att_dyn.west); \draw[arrow] (thrust.east) -- (alt_dyn.west); % ================= DISTURBANCES ================= \node[disturbance, above=0.6cm of att_dyn] (distAtt) {Gust}; \node[disturbance, below=0.6cm of alt_dyn] (distAlt) {Gust}; \draw[arrow] (distAtt.south) -- (att_dyn.north); \draw[arrow] (distAlt.north) -- (alt_dyn.south); % ================= OUTPUT MERGE ================= \coordinate (mergeTop) at ($(att_dyn.east)+(0.6,0)$); \coordinate (mergeBottom) at ($(alt_dyn.east)+(0.6,0)$); \draw[line width=1pt] (att_dyn.east) -- (mergeTop); \draw[line width=1pt] (alt_dyn.east) -- (mergeBottom); \draw[line width=1pt] (mergeTop) -- (mergeBottom); % Midpoint of the vertical line \coordinate (mergeMid) at ($(mergeTop)!0.5!(mergeBottom)$); % Output arrow from that midpoint \draw[arrow] (mergeMid) -- ++(0.8,0) node[right] {Output}; \end{tikzpicture} \end{center} \end{document}
- Two overlapping circles with lens effect between two colored rectangles in TikZby Morace Elegbele on June 11, 2026 at 3:43 pm
I am trying to reproduce the following header style for exercises in a LaTeX document using TikZ. The header consists of two rectangles side by side: A blue rectangle on the left with rounded corners An orange rectangle on the right with rounded corners Each rectangle has a circle on its inner edge (right edge of the blue one, left edge of the orange one). The two circles overlap and their intersection should appear as a white lens-shaped area (vesica piscis effect), as if the circles were drawn on top of the rectangles and cut through both. The exercise number is placed inside the blue circle area, and the word "Exercice" appears in the orange rectangle. I tried using even odd rule and \clip with \begin{scope} but I cannot get the intersection to look clean — either one circle hides the other, or the background rectangle shows through. Here is my current code: [coller votre code ici] And here is the image I want to reproduce: [joindre l'image] How can I achieve this effect cleanly in TikZ? My code: \documentclass[a4paper,12pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{tikz} \usepackage{xcolor} \definecolor{bleuFonce}{RGB}{30,100,180} \definecolor{orangeTitre}{RGB}{255,140,0} \newcounter{numexo} \newcommand{\titreExercice}{% \stepcounter{numexo}% \begin{tikzpicture} % Rectangle bleu avec bords arrondis \fill[bleuFonce, rounded corners=8pt] (0,0) rectangle (4.5,0.7); % Grand cercle bleu débordant à gauche \fill[bleuFonce,even odd rule] (2.3,0.35) circle(0.42); % Cercle blanc intérieur gauche \fill[white] (2.3,0.35) circle (0.28); % Rectangle orange avec bords arrondis (par dessus à droite) \fill[orangeTitre, rounded corners=8pt] (2.8,0) rectangle (5.8,0.7); % Grand cercle orange débordant à gauche du rectangle orange \fill[orangeTitre,even odd rule] (2.8,0.35) circle (0.42); % Cercle blanc intérieur droit \fill[white] (2.8,0.35) circle (0.28); % Numéro dans le cercle blanc gauche \node[bleuFonce, font=\large\bfseries] at (0.1,0.35) {\thenumexo}; % Texte "Exercice" en blanc \node[white, font=\large\bfseries] at (4.5,0.35) {Exercice}; \end{tikzpicture}% } \begin{document} \titreExercice \bigskip \titreExercice \end{document}
- Drawing tikz five line style arrows in text display [closed]by mathrm alpha on June 11, 2026 at 12:15 pm
Although a five-line arrow was unearthed, but: This is simply a very long, cramped five-line tikz arrows result, not the size of the blue arrow in the image. Furthermore, none of the blue arrows in the answer (in the image) scaled down to the the same text size (arrows can be black). \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{nfold} \begin{document} \begin{tikzpicture} \draw[double equal sign distance, nfold=5, arrows=-Implies] (0,-0.7) -- (3,-0.7); \end{tikzpicture} \end{document} References: Drawing a quadruple arrow
- tikz: absolute coordinates of a node placed in a second node positioned relative to a third nodeby pluton on June 10, 2026 at 4:18 pm
A MWE is probably better than lengthy explanations: \documentclass[tikz,10pt]{standalone} \usetikzlibrary{positioning} % savedbox with a sketch \newsavebox{\sdbox} \sbox{\sdbox}{% \begin{tikzpicture}[scale=0.35] \node (rbox) [fill=red] at (1,0) {}; \node (bbox) [fill=blue] at (1,1) {}; \end{tikzpicture}% } \begin{document} \begin{tikzpicture}[scale=0.5,font=\small] % blocks \node (comp) {computer}; \node[right = 1cm of comp] (sb) {\usebox{\sdbox}}; % arrow \draw[->] (rbox) -- (comp); \end{tikzpicture} \end{document} Upon compilation, you'll notice that the arrow does not link the node (rbox) from its absolute position after the node (sb) is drawn, as it should go from the red rectangle to the computer box. Would it be possible to achieve that goal?
- How to tweak the bounding box of `overarrows`? [duplicate]by Explorer on June 10, 2026 at 10:00 am
This post comes from my previous solution, then I simplified them: \documentclass{article} \usepackage{showframe} \usepackage[tikz]{overarrows} \usetikzlibrary{decorations.markings} \NewOverArrowCommand[tikz]{\underarrowA}{% add tikz options={line cap=round,decoration={markings,mark=at position 0.5 with {\draw[-](-1pt,-1pt)--(1pt,1pt);\draw[-](-1pt,1pt)--(1pt,-1pt);}}}, add path options={postaction={decorate}}, arrows={->[scale=0.5]}, path = {(0,0) -- (1,0)}, center arrow, arrow under, min length=15, space after arrow=0.4ex, } \NewOverArrowCommand[tikz]{\underarrowC}{% path options={arrows={<[scale=0.5]->[scale=0.5]}},% path={% (0,0) -- (0.5,0) to[loop below,in=-45,out=225,min distance=4mm,every loop/.style={}] (0.5,0) -- (1,0) }, center arrow, arrow under, min length=15, space after arrow=0.4ex, } \setlength{\parindent}{0pt} \setlength{\fboxsep}{0pt} \usepackage{lipsum} \begin{document} $\underarrowA{v} \qquad \underarrowA{vvv} \qquad \underarrowA{ABCD} $ $\underarrowC{v} \qquad \underarrowC{vvv} \qquad \underarrowC{ABCD} $ \fbox{$A\underarrowA{v}B$} \fbox{$A\underarrowC{v}B$} \bigskip \end{document} We could see from the above that the bounding box of arrowC is larger than expected. I wonder whether there are good suggesion to refine this?
- PGFPlots / TikZ: Filtering data from a file when the x-axis contains string valuesby joseldsm on June 10, 2026 at 9:57 am
I am generating a plot in PGFPlots/TikZ where the x-axis contains string values and the y-axis contains numerical data. The data is imported from a CSV file, and everything works correctly so far. However, when I use skip coordinates between index, the filtering is applied to the y-values and not to the x-axis categories. In this case, I want to draw only the data with the string value B. Is there a way to correctly apply this filtering to both x-axis ? Thanks! Here is the MWE. Keep in mind that in my case the data are extract from csv file. \documentclass{article} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=1.18} \pgfplotstableread{ String Value A 0 A 6 A 4 B 9 B 5 B 1 B 3 B 7 C 4 C 7 C 9 C 3 }\data \begin{document} \begin{tikzpicture} \begin{axis}[ ybar, ymin=0, xtick=data, xticklabels from table={\data}{String}, nodes near coords ] \addplot table[ x expr=\coordindex, y={Value}, skip coords between index={0}{3}, skip coords between index={8}{100} ]{\data}; \end{axis} \end{tikzpicture} \end{document}
- Make a special integral symbols in tikzby mathrm alpha on June 10, 2026 at 8:34 am
Although you can draw \int extended parts "\qsymb" in Tikz, it doesn't fit when zoomed in with math-mode. \documentclass{article} \usepackage{tikz} \usepackage{graphicx} \usepackage{amsmath} \usepackage[margin=0.5in]{geometry} \newcommand{\qsymb}{% \mathbin{ \vcenter{\hbox{ \scalebox{0.075}{ \begin{tikzpicture}[line width=2.5pt, line cap=round, line join=round, yscale=0.6] \draw (0.2, 2.4) -- (2.7, 3.9) -- (4.7, 2.9) -- (2.2, 1.4) -- cycle; \draw (2.2, 1.4) -- (4.2, 0.4) -- (1.7, -0.6) -- (-0.3, 0.4) -- cycle; \end{tikzpicture}% }% }}% }% } \newcommand{\qint}{\int\!\!\!\!\!\!\!\!\qsymb} \newcommand{\qiint}{\iint\!\!\!\!\!\!\!\!\!\!\qsymb} \begin{document} $A \qint B \qiint C$\\ $$A \qint B \qiint C$$ \end{document}
- ⅌ apply in tikz text symbols?by mathrm alpha on June 8, 2026 at 11:58 am
The original drawing instructions in ⅌: \documentclass{article} \usepackage{tikz} \usepackage[margin=0.5in]{geometry} \begin{document} \centering \begin{tikzpicture}[scale=2] % The stylized symbol is a calligraphic character, likely a script 'P' or 'V' with an ellipse. % We recreate it using thick paths and curves. % 1. The horizontal ellipse \draw[line width=6pt] (0.4, 0) ellipse (2.2 and 0.7); % 2. The main "U" shape (the stems) % Left stem starts from the flourish, goes down, curves at the bottom, and goes up to form the right stem. \draw[line width=14pt, line cap=round] (-0.6, 1.5) .. controls (-0.6, -3.2) and (0.6, -3.2) .. (0.6, 1.5); % 3. The flourish on the top left % A decorative hook and a small "bud" on top of the left stem. \draw[line width=14pt, line cap=round] (-0.6, 1.5) .. controls (-1.8, 2.8) and (-3.0, 1.5) .. (-2.2, 1.2); \fill (-0.5, 1.9) circle (0.25); % 4. The large loop on the right (completing the 'P' shape) % It starts from the top of the right stem, loops over to the right, and curves back down. \draw[line width=14pt, line cap=round] (0.6, 1.5) .. controls (0.6, 4.2) and (3.5, 3.2) .. (3.5, 0.5) .. controls (3.5, -0.8) and (2.5, -1.2) .. (1.8, -1.0); \end{tikzpicture} \end{document} However, after reading his/her command usage, This convert to can typed ⅌ text symbols method doesn't seem to work for multiple overlapping shapes in tikz (or maybe I just don't know how to use it). Is there better method to declare tikz picture with proper baseline and fontsize?
- How to place the `pic` in a recursive layer order more elegantly?by Explorer on June 7, 2026 at 2:06 pm
What I want to replicate is something as below: My very first (failed) attempt is as below: \documentclass[tikz,border=5pt]{standalone} \definecolor{myyellow}{RGB}{224,239,158} \definecolor{myteal}{RGB}{47,89,85} \begin{document} \begin{tikzpicture}[ cover/.style={line width=3pt,myyellow,fill=myteal}, myrect/.pic={\draw[cover] (0,0) rectangle (3,3) --cycle;} ] \foreach \i in {0,45,...,315} {\pic[rotate=\i] {myrect};} % \foreach \i in {0,10,...,350} {\pic[rotate=\i] {myrect};} \end{tikzpicture} \end{document} The last layer's order should be at the behind of the first one, which is not easy to be handle within the forloop \pic. Here below is my workaround: \documentclass[tikz,border=5pt]{standalone} \definecolor{myyellow}{RGB}{224,239,158} \definecolor{myteal}{RGB}{47,89,85} \begin{document} \tikzset{cover/.style={line width=3pt,myyellow,fill=myteal},myrect/.pic={\draw[cover] (0,0) |- (3,3) --++(0,-\fpeval{3*(2-sqrt(2))}) --(45:3)--cycle;}} \begin{tikzpicture} \pic{myrect}; \end{tikzpicture} \begin{tikzpicture} \foreach \i in {0,45,...,315} {\pic[rotate=\i] {myrect};} % \foreach \i in {0,10,...,350} {\pic[rotate=\i] {myrect};} \end{tikzpicture} \end{document} However, if I want to extend the angle step: \foreach \i in {0,10,...,350} {\pic[rotate=\i] {myrect};} that is not quite easy to get the code: \draw[cover] (0,0) |- (3,3) --++(0,-\fpeval{3*(2-sqrt(2))}) --(45:3)--cycle; exactly, the ++(0,-\fpeval{3*(2-sqrt(2))}) here. Any suggestions to solve the layer order issues?
- Improved visualization of the domains of integration in ℝ³by Sebastiano on April 24, 2026 at 9:26 pm
Before of this question, I would like to thank the authors of the answers and everyone who appreciated my question. I had previously created these two figures related to two triple integrals. Is there a better way to improve their presentation and make them clearer and more visually appealing? T={(x, y, z) ∈ ℝ³: (x²+y²)¹/² ≤ z ≤ 1} \documentclass[12pt]{article} \usepackage{tikz,tikz-3dplot} \begin{document} \begin{center} \tdplotsetmaincoords{60}{130} \begin{tikzpicture}[tdplot_main_coords,scale=3] \pgfmathsetmacro{\h}{0.6} \pgfmathsetmacro{\raggio}{\h} \draw[thick,->] (0,0,0) -- (1.5,0,0) node [below left] {\footnotesize$x$}; \draw[dashed] (0,0,0) -- (-1.5,0,0); \draw[thick,->] (0,0,0) -- (0,1.5,0) node [right] {\footnotesize$y$}; \draw[dashed] (0,0,0) -- (0,-1.5,0); \draw[thick,->] (0,0,1.0) -- (0,0,1.5) node [above] {\footnotesize$z$}; \draw[dashed] (0,0,0) -- (0,0,1.0); \foreach \altura in {0.01,0.02,...,1.0}{ \draw[cyan,opacity=0.5] plot[domain=0:2*pi,smooth,variable=\t] ({\altura*cos(\t r)},{\altura*sin(\t r)},{\altura}); } \draw[blue,thick,fill=brown!50,opacity=0.6] plot[domain=0:2*pi,smooth,variable=\t] ({\raggio*cos(\t r)},{\raggio*sin(\t r)},{\h}); \draw[dashed,fill=yellow,opacity=0.4] plot[domain=0:2*pi,smooth,variable=\t] ({\raggio*cos(\t r)},{\raggio*sin(\t r)},0); \foreach \t in {0,10,30,60,90,120,150,250,280,310}{ \draw[black,dashed,thin,opacity=0.7] ({\raggio*cos(\t)},{\raggio*sin(\t)},{\h}) -- ({\raggio*cos(\t)},{\raggio*sin(\t)},0); } \fill[gray,opacity=0.1] (-1.2,-1.2,\h) -- (1.2,-1.2,\h) -- (1.2,1.2,\h) -- (-1.2,1.2,\h) -- cycle; \draw[red,very thick] (0,0,\h) -- (0,\raggio,\h); \node at (0,1.5,\h) {\small $z=h$}; \node at (0,0.5,0.75) {\small $z$}; \node at (0,0.25,-0.35) {\small $T(z=0)$}; \node at (0,.75,1.3) {\small $T(z=h)=T(z)$}; \end{tikzpicture} \end{center} \end{document} C= {(x,y,z)∈ ℝ³: z∈ [0, 2], x²+ y²≤ z} \documentclass[12pt]{article} \usepackage{tikz,tikz-3dplot} \begin{document} \begin{center} \tdplotsetmaincoords{70}{130} \begin{tikzpicture}[tdplot_main_coords,scale=2.5] \pgfmathsetmacro{\h}{.6} \pgfmathsetmacro{\raggio}{sqrt(\h)} \draw[thick,->] (0,0,0) -- (1.5,0,0) node [below left] {$x$}; \draw[thick,->] (0,0,0) -- (0,1.5,0) node [right] {$y$}; \draw[thick,->] (0,0,0) -- (0,0,1.5) node [above] {$z$}; \draw[red,very thick] plot[domain=-1:1,smooth,variable=\t] (0,{\t},{\t*\t}); \draw[blue,fill=yellow,opacity=0.4] plot[domain=0:2*pi,smooth,variable=\t] ({\raggio*cos(\t r)},{\raggio*sin(\t r)},{\h}); \draw[fill=yellow,dashed,opacity=0.5] plot[domain=0:2*pi,smooth,variable=\t] ({\raggio*cos(\t r)},{\raggio*sin(\t r)},{0}) node [above] {\tiny $C(z)$}; \foreach \t in {0,10,...,350}{ \draw[gray, dashed, thin,opacity=0.4] ({\raggio*cos(\t)},{\raggio*sin(\t)},{\h}) -- ({\raggio*cos(\t)},{\raggio*sin(\t)},0); } \foreach \altura in {0.0125,0.025,...,1.0}{ \pgfmathsetmacro{\radio}{sqrt(\altura)} \draw[cyan,thick,opacity=0.5] plot[domain=0:2*pi,smooth,variable=\t] ({\radio*cos(\t r)},{\radio*sin(\t r)},{\altura}); } \fill[orange!30,opacity=0.4] (-1,-1,\h) -- (1,-1,\h) -- (1,1,\h) -- (-1,1,\h) -- cycle; \draw[blue,very thick] (0,0,\h) -- (0,{\raggio},\h); \node[black, above right] at (0,{\raggio/2},\h) {\tiny $\sqrt{z}$}; \draw[blue,fill=yellow,dotted,thick,opacity=0.4] plot[domain=0:360,smooth,variable=\t] ({\raggio*cos(\t)},{\raggio*sin(\t)},{\h}); \draw[blue!80,thick] plot[domain=0:2*pi,smooth,variable=\t] ({cos(\t r)},{sin(\t r)},{1.0}); \end{tikzpicture} \end{center} \end{document}
- How to plot y = x^{2/3} + 0.8 cos(kx) √(3-x²) in LaTeX TikZby hola on April 7, 2026 at 1:45 pm
I would like to plot the following function in LaTeX using TikZ or pgfplots: \[ y = x^{2/3} + 0.8 \cdot \cos(kx) \cdot \sqrt{3 - x^2} \] The domain is \( - \sqrt{3} \leq x \leq \sqrt{3} \). I need to create a nice graph where: The curve looks smooth I can easily change the value of \( k \) (number of oscillations) The modulated amplitude (the \( \sqrt{3-x^2} \) part) is clearly visible I have tried basic \addplot but I have problems with the fractional power \( x^{2/3} \) and with making the cosine oscillation look good. MWE (Minimal Working Example): \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis} \addplot {x^(2/3)}; % this part works, but adding the rest is difficult \end{axis} \end{tikzpicture} \end{document} pgfplots tikz-pgf plot functions graphics
- How to recreate a DuPont schemeby Dorian on November 22, 2025 at 1:30 pm
I'd like to recreate a DuPont scheme as the image below. I’m not necessarily asking for the exact code used to recreate the graphic, but rather for the packages and commands that would allow me to do it myself. Is there anything more “accessible” than TikZ? Thank you in advance 😉
- How to connect nodes in a flowchartby Fatma Belabed on January 31, 2025 at 11:56 am
I wanted to draw this flowchart, but I couldn't connect the nodes correctly. this is my code: \tikzset{ arr/.style={thick,-stealth}} %%%%%%%%%%%%%%%%%%%%%%%% \usetikzlibrary{ arrows.meta, shapes, positioning, calc, decorations.markings} \tikzset{ block2/.style={ rectangle, draw, fill=white, rounded corners, text centered, text width = 14em, minimum height = 2em}, line/.style={draw, -Latex}} %%%%%%%%%%%%%%%%%%%%%%% \tikzset{ block/.style={ rectangle, draw, fill=blue!10, rounded corners, text centered, text width = 9em, minimum height = 2em}, line/.style={draw, -Latex}} \tikzset{ blockxx/.style={ rectangle, draw, fill=blue!10, text centered, text width = 9em, minimum height = 2em}, line/.style={draw, -Latex}} \tikzset{ blockx/.style={ rectangle, draw, fill=blue!10, rounded corners, text centered, text width = 6em, minimum height = 2em}, line/.style={draw, -Latex}} \tikzset{ block3/.style={ rectangle, draw, fill=blue!20, rounded corners, text centered, text width = 9em, minimum height = 2em}, line/.style={draw, -Latex}} \tikzset{ block4/.style={ rectangle, draw, fill=blue!50, rounded corners, text centered, text width = 9em, minimum height = 2em}, line/.style={draw, -Latex}} \tikzset{ block44/.style={ rectangle, draw, fill=blue!50, rounded corners, text centered, text width = 3em, minimum height = 2em}, line/.style={draw, -Latex}} \tikzset{ block444/.style={ rectangle, draw, fill=blue!50, rounded corners, text centered, text width = 8em, minimum height = 2em}, line/.style={draw, -Latex}} \begin{document} \begin{tikzpicture}[every node/.style={block}] \node [ block2, node distance=2cm] (second) {Security attacks}; \node[block3, below left=1cm and 1cm of second](case one) {Physical}; \node[block4, below = 1cm of second](case two) {Data Link}; \node[below right = 1cm and 1cm of second](case three) {Network}; \node[below right = 1cm and 5.5cm of second](case forr) {Transport}; \node[block3, below = 0.7cm of case forr](case forr1){Dos}; \node[block3, below = 0.7cm of case forr1](case forr2){Session hijacking}; \node[block3, below = 0.7cm of case forr2](case forr3){Exhaustion}; \node[below right = 1cm and 10cm of second](case five) {Application}; \node[block3, below = 0.7cm of case five](case five1){Dos}; \node[block3, below = 0.7cm of case five1](case five2){Repudiation}; \node[block3, below = 0.7cm of case five2](case five3){Deluge}; \node[block3, below = 0.7cm of case one](no info){Dos}; \node[block3, below = 0.7cm of no info](no info1){Eavesdropping}; \node[block3, below = 0.7cm of no info1](no info2){Jamming}; \node[block444, on grid,below = 1.7cm of case two](aa){Dos}; \node[block444, on grid, below = 1.5cm of aa](aa1){Collision}; \node[block444, on grid,below = 1.5cm of aa1](aa2){Unfairness}; \node[block444, on grid,below = 1.5cm of aa2](aa3){Exhaustion}; \node[block444, on grid,below = 1.5cm of aa3](aa4){Traffic monitoring}; \node[blockxx, on grid,below = 1.5cm of case three](a){Dos}; \node[blockxx, on grid,below = 1.5cm of a](a1){Hole}; \node[blockxx, on grid,below = 1.5cm of a1](a2){Selective forwarding}; \node[blockxx, on grid,below = 1.5cm of a2](a3){Sybil}; \node[blockxx, on grid,below = 1.5cm of a3](a4){Eavesdropping}; \node[blockxx, on grid,below = 1.5cm of a4](a5){Spoofing}; \node[blockxx, on grid,below = 1.5cm of a5](a6){Traffic analysis}; \draw[arr] (second.south) --++ (0,-5pt) -| (case one); % physique \draw[arr] (case one.west) --++ (0,-5pt) -- (no info.west); \draw[arr] (case one.west) --++ (0,-5pt) -- (no info1.west); \draw[arr] (case one.west) --++ (0,-5pt) -- (no info2.west); \draw[arr] (second.south) --++ (0,-5pt) -| (case two); % data \draw[arr] (case two.west) --++ (0,-5pt) |- (aa.west); \draw[arr] (case two.west) --++ (0,-5pt) |- (aa1.west); \draw[arr] (case two.west) --++ (0,-5pt) |- (aa2.west); \draw[arr] (case two.west) --++ (0,-5pt) |- (aa3.west); \draw[arr] (case two.west) --++ (0,-5pt) |- (aa4.west); \draw[arr] (second.south) --++ (0,-5pt) -| (case three); % network \draw[arr] (case three.west) --++ (0,-5pt) |- (a.west); \draw[arr] (case three.west) --++ (0,-5pt) |- (a1.west); \draw[arr] (case three.west) --++ (0,-5pt) |- (a2.west); \draw[arr] (case three.west) --++ (0,-5pt) |- (a3.west); \draw[arr] (case three.west) --++ (0,-5pt) |- (a4.west); \draw[arr] (case three.west) --++ (0,-5pt) |- (a5.west); \draw[arr] (case three.west) --++ (0,-5pt) |- (a6.west); \draw[arr] (second.south) --++ (0,-5pt) -| (case forr); % Transport \draw[arr] (case forr.west) --++ (0,-5pt) |- (case forr1.west); \draw[arr] (case forr.west) --++ (0,-5pt) |- (case forr2.west); \draw[arr] (case forr.west) --++ (0,-5pt) |- (case forr3.west); \draw[arr] (second.south) --++ (0,-5pt) -| (case five); % Application \draw[arr] (case five.west) --++ (0,-5pt) |- (case five1.west); \draw[arr] (case five.west) --++ (0,-5pt) |- (case five2.west); \draw[arr] (case five.west) --++ (0,-5pt) |- (case five3.west); \end{tikzpicture} \end{figure} \end{document} Thanks
- How to Draw Gabriel's Hornby DDS on June 27, 2024 at 1:54 pm
Consider Gabriel's Horn: which, mathematically speaking, is the curve y=1/x over the interval [1,∞] revolved about the x-axis. It is interesting because though it contains a finite volume, its surface area is infinite. In an effort to draw it, I imported the image into Inkscape, traced a bitmap, and exported it to a tikzpath, which I incorporated into LaTeX as follows: \documentclass[12pt]{book} \usepackage{tikz} \begin{document} \thispagestyle{empty} \begin{tikzpicture} \path[fill=black] (6.8, 14.1).. controls (6.7, 14.1) and (6.7, 14.3) .. (6.6, 14.4).. controls (6.5, 14.6) and (6.5, 15.2) .. (6.5, 15.1).. controls (6.5, 15.1) and (6.7, 15.1) .. (6.9, 15.1) -- (7.3, 15.1) -- (7.3, 14.9).. controls (7.3, 14.7) and (7.2, 14.5) .. (7.0, 14.4).. controls (6.9, 14.4) and (6.8, 14.3) .. (6.8, 14.3).. controls (6.7, 14.2) and (6.7, 14.2) .. (6.8, 14.1).. controls (6.9, 14.0) and (6.9, 14.0) .. (6.8, 14.1) -- cycle(7.2, 14.9).. controls (7.3, 15.0) and (7.2, 15.1) .. (7.0, 15.0).. controls (6.9, 15.0) and (6.8, 14.9) .. (6.9, 14.8).. controls (6.9, 14.8) and (7.1, 14.8) .. (7.2, 14.9) -- cycle(7.0, 14.1).. controls (7.0, 14.1) and (7.1, 14.1) .. (7.2, 14.2).. controls (7.3, 14.2) and (7.3, 14.3) .. (7.2, 14.2).. controls (7.2, 14.2) and (7.1, 14.2) .. (7.1, 14.3).. controls (7.1, 14.3) and (7.2, 14.3) .. (7.3, 14.3).. controls (7.4, 14.3) and (7.4, 14.3) .. (7.4, 14.3).. controls (7.4, 14.4) and (7.4, 14.4) .. (7.4, 14.4).. controls (7.5, 14.4) and (7.5, 14.4) .. (7.5, 14.4).. controls (7.5, 14.4) and (7.5, 14.4) .. (7.5, 14.4).. controls (7.6, 14.4) and (7.6, 14.4) .. (7.5, 14.4).. controls (7.5, 14.5) and (7.5, 14.5) .. (7.5, 14.5).. controls (7.6, 14.4) and (7.6, 14.4) .. (7.3, 14.2).. controls (7.0, 14.0) and (7.0, 14.0) .. (7.0, 14.1) -- cycle(7.6, 14.5).. controls (7.6, 14.5) and (7.6, 14.5) .. (7.7, 14.5).. controls (7.7, 14.5) and (7.7, 14.5) .. (7.7, 14.5).. controls (7.7, 14.5) and (7.7, 14.5) .. (7.7, 14.5).. controls (7.8, 14.5) and (7.8, 14.5) .. (7.8, 14.5).. controls (7.7, 14.6) and (7.8, 14.6) .. (7.8, 14.6).. controls (7.8, 14.5) and (7.8, 14.5) .. (7.8, 14.5).. controls (7.7, 14.4) and (7.6, 14.4) .. (7.6, 14.5) -- cycle(7.8, 14.6).. controls (7.8, 14.6) and (7.8, 14.6) .. (7.9, 14.6).. controls (7.9, 14.6) and (8.0, 14.6) .. (7.9, 14.6).. controls (7.9, 14.6) and (7.9, 14.6) .. (8.0, 14.6).. controls (8.0, 14.6) and (8.1, 14.6) .. (8.0, 14.6).. controls (8.0, 14.7) and (8.0, 14.7) .. (8.1, 14.7).. controls (8.2, 14.6) and (8.2, 14.6) .. (8.1, 14.7).. controls (8.1, 14.7) and (8.2, 14.7) .. (8.2, 14.7).. controls (8.3, 14.7) and (8.2, 14.6) .. (8.1, 14.6).. controls (8.0, 14.6) and (8.0, 14.6) .. (7.9, 14.6).. controls (7.9, 14.5) and (7.9, 14.6) .. (7.8, 14.6) -- cycle(7.3, 14.7).. controls (7.3, 14.8) and (7.3, 14.8) .. (7.3, 14.8).. controls (7.3, 14.7) and (7.3, 14.7) .. (7.3, 14.7).. controls (7.3, 14.7) and (7.3, 14.7) .. (7.3, 14.7) -- cycle(8.3, 14.7).. controls (8.2, 14.8) and (8.3, 14.8) .. (8.4, 14.7).. controls (8.4, 14.7) and (8.4, 14.7) .. (8.4, 14.7).. controls (8.3, 14.7) and (8.3, 14.7) .. (8.3, 14.7) -- cycle(8.4, 14.8).. controls (8.4, 14.8) and (8.4, 14.8) .. (8.5, 14.8).. controls (8.6, 14.8) and (8.6, 14.8) .. (8.6, 14.8).. controls (8.5, 14.8) and (8.5, 14.8) .. (8.6, 14.8).. controls (8.6, 14.8) and (8.7, 14.8) .. (8.7, 14.8).. controls (8.7, 14.8) and (8.7, 14.8) .. (8.7, 14.8).. controls (8.5, 14.7) and (8.5, 14.7) .. (8.4, 14.8) -- cycle(8.7, 14.8).. controls (8.7, 14.8) and (8.7, 14.9) .. (8.8, 14.8).. controls (8.9, 14.8) and (8.9, 14.8) .. (8.9, 14.8).. controls (9.0, 14.8) and (8.8, 14.8) .. (8.7, 14.8) -- cycle(9.0, 14.8).. controls (9.1, 14.9) and (9.1, 14.9) .. (9.1, 14.8).. controls (9.1, 14.8) and (9.1, 14.8) .. (9.1, 14.8).. controls (9.0, 14.8) and (9.0, 14.8) .. (9.0, 14.8) -- cycle(7.3, 15.0).. controls (7.3, 15.4) and (7.3, 15.4) .. (7.0, 15.5) -- (6.7, 15.7) -- (6.7, 15.9).. controls (6.7, 16.0) and (6.7, 16.1) .. (6.7, 16.1).. controls (6.7, 16.1) and (6.6, 16.0) .. (6.6, 15.9).. controls (6.6, 15.9) and (6.6, 15.9) .. (6.6, 15.9).. controls (6.6, 15.9) and (6.6, 16.0) .. (6.6, 16.1).. controls (6.7, 16.2) and (6.7, 16.2) .. (6.7, 16.2).. controls (6.7, 16.1) and (6.7, 16.1) .. (6.8, 16.1).. controls (6.8, 16.2) and (6.8, 16.2) .. (6.8, 16.1).. controls (6.7, 15.9) and (6.7, 15.9) .. (7.0, 15.7).. controls (7.2, 15.6) and (7.3, 15.5) .. (7.3, 15.5).. controls (7.3, 15.4) and (7.3, 15.3) .. (7.3, 15.1).. controls (7.3, 14.9) and (7.3, 14.9) .. (7.3, 15.0) -- cycle(8.9, 14.9).. controls (8.9, 14.9) and (8.9, 14.9) .. (8.9, 14.9).. controls (8.9, 14.9) and (8.9, 14.9) .. (8.9, 14.9).. controls (8.8, 14.9) and (8.8, 14.9) .. (8.9, 14.9) -- cycle(9.2, 14.9).. controls (9.3, 14.9) and (9.3, 14.9) .. (9.4, 14.9).. controls (9.4, 14.9) and (9.4, 14.9) .. (9.3, 14.9).. controls (9.2, 14.9) and (9.2, 14.9) .. (9.2, 14.9) -- cycle(9.1, 14.9).. controls (9.1, 14.9) and (9.1, 14.9) .. (9.1, 14.9).. controls (9.2, 14.9) and (9.1, 14.9) .. (9.1, 14.9).. controls (9.1, 14.9) and (9.0, 14.9) .. (9.1, 14.9) -- cycle(9.5, 14.9).. controls (9.5, 14.9) and (9.6, 14.9) .. (9.6, 14.9).. controls (9.7, 14.9) and (9.6, 14.9) .. (9.6, 14.9).. controls (9.5, 14.9) and (9.5, 14.9) .. (9.5, 14.9) -- cycle(9.3, 15.0).. controls (9.3, 15.0) and (9.3, 15.0) .. (9.4, 15.0).. controls (9.4, 14.9) and (9.4, 14.9) .. (9.3, 14.9).. controls (9.3, 14.9) and (9.3, 14.9) .. (9.3, 15.0) -- cycle(9.8, 15.0).. controls (9.8, 15.0) and (9.9, 15.0) .. (10.0, 15.0).. controls (10.0, 14.9) and (10.0, 14.9) .. (9.9, 14.9).. controls (9.8, 14.9) and (9.7, 14.9) .. (9.8, 15.0) -- cycle(7.9, 15.0).. controls (7.6, 15.1) and (7.4, 15.3) .. (7.4, 15.7).. controls (7.3, 15.8) and (7.3, 15.9) .. (7.2, 16.1).. controls (7.1, 16.2) and (7.0, 16.3) .. (7.0, 16.3).. controls (7.0, 16.3) and (7.0, 16.3) .. (7.1, 16.2).. controls (7.1, 16.2) and (7.1, 16.2) .. (7.1, 16.2).. controls (7.1, 16.2) and (7.2, 16.1) .. (7.3, 16.1).. controls (7.9, 15.6) and (9.3, 15.3) .. (11.4, 15.2).. controls (11.8, 15.2) and (12.2, 15.2) .. (12.3, 15.2).. controls (12.4, 15.2) and (12.6, 15.2) .. (12.8, 15.2).. controls (12.9, 15.2) and (13.0, 15.2) .. (13.0, 15.1).. controls (13.0, 15.1) and (12.8, 15.1) .. (11.5, 15.0).. controls (11.1, 15.0) and (10.6, 15.0) .. (10.4, 15.0).. controls (10.2, 15.0) and (10.1, 15.0) .. (10.1, 15.0).. controls (10.1, 15.0) and (10.4, 15.0) .. (10.7, 15.0).. controls (11.9, 15.1) and (12.0, 15.1) .. (11.9, 15.1).. controls (11.9, 15.2) and (11.7, 15.2) .. (11.5, 15.2).. controls (9.7, 15.2) and (8.0, 15.5) .. (7.4, 15.9).. controls (7.4, 16.0) and (7.3, 16.0) .. (7.3, 16.0).. controls (7.3, 16.0) and (7.4, 15.9) .. (7.5, 15.8).. controls (7.6, 15.7) and (7.6, 15.7) .. (7.6, 15.6).. controls (7.6, 15.4) and (7.9, 15.2) .. (8.1, 15.2).. controls (8.2, 15.2) and (8.3, 15.2) .. (8.3, 15.1).. controls (8.3, 15.1) and (8.7, 15.1) .. (9.4, 15.1).. controls (10.1, 15.1) and (10.6, 15.1) .. (10.6, 15.1).. controls (10.6, 15.1) and (10.3, 15.0) .. (9.9, 15.0).. controls (9.8, 15.0) and (9.7, 15.0) .. (9.8, 15.0) -- (9.9, 15.1) -- (9.8, 15.1).. controls (9.7, 15.1) and (9.5, 15.1) .. (9.2, 15.0).. controls (8.5, 15.0) and (8.0, 15.0) .. (7.9, 15.0) -- cycle(7.3, 16.0).. controls (7.3, 16.0) and (7.2, 16.0) .. (7.2, 16.1) -- (7.1, 16.2) -- (7.2, 16.1).. controls (7.3, 16.0) and (7.3, 16.0) .. (7.3, 16.0) -- cycle(9.5, 15.0).. controls (9.5, 15.0) and (9.6, 15.0) .. (9.6, 15.0).. controls (9.7, 15.0) and (9.6, 15.0) .. (9.6, 15.0).. controls (9.5, 15.0) and (9.5, 15.0) .. (9.5, 15.0) -- cycle(6.5, 15.5).. controls (6.5, 15.5) and (6.5, 15.6) .. (6.5, 15.5).. controls (6.5, 15.5) and (6.5, 15.4) .. (6.5, 15.4).. controls (6.5, 15.4) and (6.5, 15.4) .. (6.5, 15.5) -- cycle; \end{tikzpicture} \end{document} Compiling it, I get Then, when I tried to add some color shading to get the horn to look more realistic, I got the following TikZ code which I cannot compile because the colorcodes (e.g., cb9b9b9) are not recognized by LaTeX. Moreover, I am not posting the code here because it is extremely long. QUESTION: How may I produce a reasonable facsimile of the above Wiki image with LaTeX code? From the colorized bitmap trace from Inkscape, I thought I had it, but LaTeX does not recognize Inkscape's color codes; for example, \path[fill=c767676] (-11.7, 7.6).. controls (-11.7, 7.6) and (-11.3, 8.0) ..
- Issue: Unable to Display Text Below TikZ Code in LyX"by Evya1 on January 20, 2024 at 10:35 am
I am currently facing a challenge in LyX where, after typing several lines of text, I insert TikZ code either inside a TeX box or directly into the apex preamble. However, I have observed that the text following the TikZ code is not visible. In the case of placing the code in the preamble, none of the text I have written in the document is visible. I am seeking assistance in resolving this issue and understanding how to ensure the proper display of text below inserted TikZ code in LyX. Any guidance or solutions would be greatly appreciated. LyX file: #LyX 2.3 created this file. For more info see http://www.lyx.org/ \lyxformat 544 \begin_document \begin_header ... \end_header \begin_body \begin_layout Standard Text here. 1 Algorithms - question 1 1 . ~~~Trying to show the figure here ~~~ ~~~ Text of the solution that isn't shown in rendered pdf~~~ \end_layout \end_body \end_document LaTeX preamble: \usepackage{autobreak} \usepackage{fontspec} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{autobreak} \usepackage{xcolor} \usepackage{amssymb} \usepackage{polyglossia} \usepackage{tikz} \setmainlanguage{hebrew} \setotherlanguage{english} \spaceskip=1\fontdimen2\font plus 1\fontdimen3\font minus 1.5\fontdimen4\font \everymath{\, } \usepackage{xcolor} \definecolor{blue}{RGB}{14,107,217} \definecolor{green}{RGB}{0,158,40} \definecolor{red}{RGB}{235,16,16} \definecolor{brown}{RGB}{164,66,0} \definecolor{orange}{RGB}{231,135,26} \definecolor{purple}{RGB}{94,53,177} \usepackage{amssymb} \renewcommand{\qedsymbol}{$\blacksquare$} \pagestyle{empty} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \begin{document} \begin{tikzpicture}[->,>=stealth',auto,node distance=2.5cm, thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries, minimum size=1cm}, align=center] \node[main node] (s) {$s$}; \node[main node] (v1) [below right=0.8cm and 1.8cm of s] {$v_1$}; \node[main node] (v2) [above right=0.8cm and 1.8cm of s] {$v_2$}; \node[main node] (vn-3) [right=1.2cm of v1] {$v_{n-3}$}; \node[main node] (vn-2) [right=1.2cm of v2] {$v_{n-2}$}; \node[main node] (t) [below right=0.8cm and 1.8cm of vn-2] {$t$}; \draw [->] (s) -- (v1); \draw [->] (s) -- (v2); \draw [->] (vn-3) -- (t); \draw [->] (vn-2) -- (t); \draw [dashed] [->,blue] (v1) -- (vn-2); \draw [dashed] [->,blue] (v2) -- (vn-3); \draw [dashed, ->, bend right] (v1.north) to (v2.south); \draw [dashed, ->, bend] (v2.south) to (v1.north); \draw [dashed, ->, bend right] (vn-3.north) to (vn-2.south); \draw [dashed, ->, bend] (vn-2.south) to (vn-3.north); % Add dashed lines to represent the cutted paths \draw [dashed] (s) -- (v1); \draw [dashed] (s) -- (v2); \draw [dashed] (v1) -- (vn-3); \draw [dashed] (v2) -- (vn-2); \draw [dashed] (vn-3) -- (t); \draw [dashed] (vn-2) -- (t); \end{tikzpicture} \end{document}
- Truncated parabolic cylinderby Alisson on October 16, 2023 at 2:48 am
I would like to know if it is possible to draw an image like this in 3D using tikz? Am not acquainted yet with 3D diagrams in TikZ and I would like to draw something like the picture attached. Does anybody have any helpful hints?
- Interesting weird TikZ behaviourby vishalpaudel on September 4, 2023 at 7:30 am
I was trying to draw a grid of points with the weights of the points as the average of x and y: \usepackage{tikz} ... \begin{center} \begin{tikzpicture} \foreach \x in {1,2,3,4,5,6} { \foreach \y in {1,2,3,4,5,6} { \fill (\x, \y) circle ({(\x + \y)/2}); } } \end{tikzpicture} \end{center} ... The output is unexpected(Screenshot attached)! Does anyone know what is happening? I am using Lualatex on overleaf. edit 1: Solved the original problem: but need an explanation of the earlier behaviour.
- How do I draw an anticlepsydra in LaTeX?by Cora Sanroman on August 25, 2021 at 12:48 am
I'd like to approach the sphere's volume by Cavalieri's principle, and so I want to give the students an anticlepsydra's drawing, to guide them to the sphere's formula. Something like this: The sphere I got right, but the area of the anticlepsydra that's equal to the sphere I'd like to be in a different color, and I don't quite know how to do it. Don't even know if it's best for me to use a 3d drawing or stick with 2d. Sugestions? Anyone's done that?
- How to put dashed lines between certain columns?by pixel on April 29, 2021 at 10:24 pm
I have a table in beamer frame and I want to put dashed lines between some columns. However, I have certain constraints. First, I want to make sure that the lines are disabled after certain transition, so they should work with visible for example. Next, I want to be able to write a text at the top or bottom of the dashed line. I tried to use the arydshln package, but it doesn't seem to offer the flexibility I need. \documentclass[aspectratio=169,xcolor=dvipsnames]{beamer} \usepackage{arydshln} \begin{document} \begin{frame}{Test} \begin{figure} \def\arraystretch{1.2} %\setlength{\tabcolsep}{0.2em} \begin{tabular}{ c : c c c : c } $e$ & $e+1$ & $e+2$ & $e+3$ & $e+4$ \\ \hline $k_{e}$ & $k_{e+1}$ & $k_{e+2}$ & $k_{e+3}$ & $k_{e+4}$ \\ $\Delta_{e}$ & $\Delta_{e+1}$ & $\Delta_{e+2}$ & $\Delta_{e+3}$ & $\Delta_{e+4}$\\ $\sigma_{e}$ & $\sigma_{e+1}$ & $\sigma_{e+2}$ & $\sigma_{e+3}$ & $\sigma_{e+4}$ \\ \end{tabular} \end{figure} \end{frame} \end{document} More precisely, I want to achieve what's shown below. Any ideas how to do that using table or TikZ?
- Make sphere look roundby Sat on April 12, 2021 at 10:59 am
\documentclass[tikz,border=5pt]{standalone} \usepackage{tikz-3dplot} \begin{document} \tdplotsetmaincoords{60}{150} \begin{tikzpicture} [scale=1.5, tdplot_main_coords, axis/.style={->,black,thick}, vector/.style={red,very thick}] %standard tikz coordinate definition using x, y, z coords %tikz-3dplot coordinate definition using x, y, z coords \pgfmathsetmacro{\ax}{0.5} \pgfmathsetmacro{\ay}{0.5} \pgfmathsetmacro{\az}{0.5} \pgfmathsetmacro{\bx}{0.25} \pgfmathsetmacro{\by}{1} \pgfmathsetmacro{\bz}{1} \coordinate (P) at (\ax,\ay,\az); \coordinate (Q) at (\bx,\by,\bz); %draw axes \draw[axis] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; \draw[axis] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; \draw[axis] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; %draw a vector from O to P \draw[vector] (P) -- (Q); \shade[ball color = gray!40, opacity = 0.4] (\ax,\ay,\az) circle (0.75); \draw (\ax,\ay,\az) circle (0.75); %draw guide lines to components \node[tdplot_main_coords,anchor=east] at (\ax,\ay,\az){$\left(a,b,c\right)$}; \node[tdplot_main_coords,anchor=south west] at (\bx,\by,\bz){$\left(x,y,z\right)$}; \node[tdplot_main_coords,anchor=south west] at (0.2,0.4,0.3){$r$}; \end{tikzpicture} \end{document} It has to do with that tdplotsetmaincoords, but how do I make this sphere look round? It's probably due to how I'm using a circle and it should be something that is actually 3D.
- Drawing a circle graph with TIKZ with foreach placement and paths, yet the inbound for edges is offby Tenaka on December 1, 2020 at 5:01 pm
I want to draw a circle using TIKZ and instead of manually placing the nodes and connecting the nodes I wanted to use loops as any sane person would. Now when I wrote these, the incoming edge seems to be going to some point slightly of the node instead of to its core. In the example, I included a version with the path manually written out. I am losing my sanity here 😀 Anyone got any idea as to what is happening here? Any style critique is also very welcome! \documentclass[margin=10pt]{standalone} \usepackage{tikz} \usetikzlibrary{automata} \begin{document} \begin{tikzpicture}[nodes=state] \def \number {8} \def \radius {2cm} \def \degree {360/\number} \foreach \s in {1,...,\number} { \node at ({\degree * (\s -1)}:\radius) (\s) {$u_\s$}; } \foreach \s in {1,...,\number} { \pgfmathsetmacro\result{Mod( (\s), \number)+1} \path (\s) edge[bend right = 15] (\result); } \end{tikzpicture} \begin{tikzpicture}[nodes=state] \def \number {8} \def \radius {2cm} \def \degree {360/\number} \foreach \s in {1,...,\number} { \node at ({\degree * (\s -1)}:\radius) (\s) {$u_\s$}; } \path (1) edge[bend right = 15] (2) % edge (5) (2) edge[bend right = 15] (3) % edge (6) (3) edge[bend right = 15] (4) % edge (7) (4) edge[bend right = 15] (5) % edge (8) (5) edge[bend right = 15] (6) (6) edge[bend right = 15] (7) (7) edge[bend right = 15] (8) (8) edge[bend right = 15] (1) ; \end{tikzpicture} \end{document}
- How to draw a pyramid like this in TikZ?by Amal on November 23, 2020 at 1:13 pm
I want to draw a pyramid like this using TikZ.
- Showing the overlap between a sphere and the volume insdie a solid angle with Tikzby Nownuri on November 3, 2020 at 1:59 pm
I want to describe how a line-of-sight integration of a 3D density function over a solid angle means using the pgf/Tikz package. The problem is to draw a sphere and then a solid angle that overlaps some part of the sphere. Unfortunately, I couldn't find the appropriate functions in the Tikz package for doing this job. Could you please help me by answering the following questions? Is it possible to make the dashed lines look like being behind the sphere? Is it also possible to make the volume inside the sphere and inside the solid angle darker than other regions? Are there better tricks of using Tikz to do the visualization intended here? Here are the codes used to generate the image. \documentclass[landscape]{article} \usepackage[utf8]{inputenc} \usepackage{tikz} \usepackage{tikz-3dplot} \begin{document} %set the plot display orientation %synatax: \tdplotsetdisplay{\theta_d}{\phi_d} %\tdplotsetmaincoords{65}{110} % Define variables and assign values to them. \pgfmathsetmacro{\rvec}{0.9} \begin{tikzpicture}[scale=3] \shade[ball color = white] (1.8,1.5) circle (\rvec); %Define a point. \coordinate (O) at (0,0,0); %draw the main coordinate system axes \draw[thick,->] (O) -- (1,0,0) node[anchor=north east]{$x$}; \draw[thick,->] (O) -- (0,1,0) node[anchor=north west]{$y$}; \draw[thick,->] (O) -- (0,0,1) node[anchor=south]{$z$}; \tdplotsetcoord{P1}{4}{90}{25} \tdplotsetcoord{P2}{4}{90}{30} \tdplotsetcoord{P3}{4}{83}{25} \tdplotsetcoord{P4}{4}{83}{30} \draw [-stealth, very thin, dashed] (O) -- (P1); \draw [-stealth, very thin, dashed] (O) -- (P2); \draw [-stealth, very thin, dashed] (O) -- (P3); \draw [-stealth, very thin, dashed] (O) -- (P4); \draw [thin] (P1) arc (25:30:4); \draw [thin] (P3) arc (25:30:4); \draw [thin] (P1) -- (P3); \draw [thin] (P2) -- (P4); \end{tikzpicture} \end{document}
- Matrix of bar chartsby Jitendra on April 16, 2018 at 7:09 am
I came across a post (https://peltiertech.com/stacked-bar-chart-alternatives/). I would like to draw a chart similar to last on mentioned in the post. The image of the chart is attached. Any help would be appreciated.
- Inspired beautiful box from Indesignby Educ on December 3, 2015 at 2:45 pm
I found these beautiful box in Math ebooks which is created by Adobe Indesign, I tired mdframed, tcolorbox but I didn't try Tikz. So could someone create them using LaTeX please? \documentclass[a4paper]{article} \usepackage{amsmath} \usepackage{amsmath,amsfonts,amssymb} \usepackage[svgnames]{xcolor} \usepackage[most]{tcolorbox} \tcbset{ lemmastyle/.style={enhanced, colback=white, colframe=blue!50, arc=0pt, fonttitle=\bfseries, description color=Maroon, colbacktitle=white, coltitle=DarkOliveGreen, top=\tcboxedtitleheight, boxed title style={arc=0pt}, attach boxed title to top right={yshift=-\tcboxedtitleheight/3, xshift=-2mm}% }, } \newtcbtheorem{myLemma}{Type Text Here Without counter }{lemmastyle}{thm} \usepackage{pifont} \begin{document} \begin{myLemma}{}{} \end{myLemma} \end{document} Update: Thanks, but when I use the code of @Alenanno, the equation doesn't fit the box. It's wider than it. Even when I put long text, the box is still too tight. I tired to fix it but with no luck. Could you please try? And could you make it breakable? (I mean by 'breakable' that the contents can be broken between two pages if the box contains long text.) \documentclass[a4paper]{article} \usepackage{amsmath} \usepackage{amsmath,amssymb}% pour les maths \usepackage{enumitem} \usepackage[svgnames]{xcolor} \usepackage[most]{tcolorbox} \usepackage{tikz} \tcbset{ lemmastyle/.style={enhanced, colback=white, colframe=blue!20, arc=0pt, fonttitle=\bfseries, description color=Maroon, colbacktitle=white, coltitle=DarkOliveGreen, top=\tcboxedtitleheight, boxed title style={arc=0pt}, attach boxed title to top left={yshift=-\tcboxedtitleheight/2, xshift=4mm}% }, } \newtcbtheorem{myLemma}{Long text here without counter }{lemmastyle}{thm} \usetikzlibrary{calc, fit} \newcommand{\mybox}[4][8cm]{ \begin{figure}[!h] \centering \begin{tikzpicture} \node[line width=0.5mm, rounded corners, text width=#1, draw=#2] (one) {\vspace{25pt}\\ #4}; \node[text=white,anchor=north east,align=center, minimum height=20pt] (two) at (one.north east) {#3}; \path[fill=#2] (one.north west|-two.west) -- ($(two.west)+(-1.5cm,0)$) to[out=0,in=180] (two.south west) -- (two.south east) [rounded corners] -- (one.north east) -- (one.north west) [sharp corners] -- cycle; \node[text=white,anchor=north east,align=center, minimum height=25pt, text height=2ex] (three) at (one.north east) {#3 \hspace*{.5mm}}; \end{tikzpicture} \end{figure} } \usepackage{pifont} \begin{document} \mybox[6cm]{green!70!black}{Long Fancy Title}{ \begin{enumerate} \item Show that ${\displaystyle D_2f(x,y) = \frac{\partial {}}{\partial{y}} \left ( \int_0^xg_1 (t,0) \ dt + \int_0^y g_2(x,s) \ ds \right)}$ \item prove that ${ \displaystyle \left(\forall x\in\mathbb{R} \right)\left(\forall y \in \mathbb{R} \right) x\neq y\, \text{and} \, x+y \neq 2 \implies x^{2}-2x \neq y^2-2y }$ \end{enumerate} } \begin{myLemma}{}{} \begin{enumerate} \item Show that ${\displaystyle D_2f(x,y) = \frac{\partial {}}{\partial{y}} \left ( \int_0^xg_1 (t,0) \ dt + \int_0^y g_2(x,s) \ ds \right)}$ \item prove that ${ \displaystyle \left(\forall x\in\mathbb{R} \right)\left(\forall y \in \mathbb{R} \right) x\neq y\, \text{and} \, x+y \neq 2 \implies x^{2}-2x \neq y^2-2y }$ \end{enumerate} \end{myLemma} \mybox[6cm]{blue!70!black}{Very Very Long Fancy Title}{Duis id dolor et ligula eleifend imperdiet. Mauris luctus, quam vitae viverra sagittis, dolor nibh imperdiet augue, eu venenatis eros augue et nisl. Vivamus nec fermentum est.} Nullam libero augue, luctus et est vitae, fermentum aliquet libero. Maecenas dictum placerat eros, eu fermentum sem fermentum dapibus. Quisque non tellus nec magna feugiat luctus. \end{document}
- TikZ- Draw a cooking potby Thanos on May 11, 2015 at 4:28 pm
I am trying to reproduce the following picture in tikz I am able to draw something that looks like that but it's not the same... Any chance to draw it or make it even more fancy? My code is \documentclass[demo]{standalone} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing} \usetikzlibrary{decorations.markings} \usetikzlibrary{% calc,% fadings,% shadings% } \usetikzlibrary{arrows,shapes} \usetikzlibrary{shapes.geometric,calc} \usetikzlibrary{backgrounds,fit} \usetikzlibrary{shadows} \usetikzlibrary{snakes} \usetikzlibrary{decorations.text} \usetikzlibrary{positioning} \usepackage{graphicx} \begin{document} \begin{tikzpicture} \draw[fill=black] (0,0) circle (1cm); \draw[fill=black] (0,0.75) ellipse (1cm and 0.25cm); \draw[fill=black] (0,-1) ellipse (0.6cm and 0.1cm); \draw[fill=gray] (0,0.75) ellipse (0.8cm and 0.15cm); \end{tikzpicture} \end{document} and my output is
- Is there a TikZ equivalent to the PSTricks \ncbar command?by Alan Munn on May 9, 2012 at 12:50 pm
Although I now use TikZ, every so often I find myself looking for very useful PSTricks commands which don't seem to exist in TikZ. The pst-node package has an \ncbar command which allows one to connect two nodes with arms dropping down, typically at a 90 degree angle. Here's an example: \documentclass{article} \usepackage{pst-node} \begin{document} \rput(0,0){\rnode{A}{\psframebox{A}}} \rput(2,0){\rnode{B}{\psframebox{B}}} \ncbar[angle=90]{A}{B} \end{document} Is there a TikZ equivalent to this useful command? If not, how easy would it be to create one?