TikZ
- TikZ code, OK directly in a file, not OK in a standalone subfileby Denis Bitouzé on October 21, 2026 at 5:13 pm
The following file (which comes from an article in the TeXnische Komödie about the schulma-physik package), say subfile.tex, compiles like a charm: \documentclass{article} \usepackage[compatibility]{circuitikz} \usetikzlibrary{circuits.ee.IEC} \makeatletter % Ergänzungen von Schaltzeichenformen auf der Grundlage von pgflibraryshapes.gates.ee.IEC.code.tex \pgfdeclareshape{leere diode} {% \inheritsavedanchors[from=rectangle ee]% \inheritanchor[from=rectangle ee]{center}% \inheritanchor[from=rectangle ee]{north}% \inheritanchor[from=rectangle ee]{south}% \inheritanchor[from=rectangle ee]{east}% \inheritanchor[from=rectangle ee]{west}% \inheritanchor[from=rectangle ee]{north east}% \inheritanchor[from=rectangle ee]{north west}% \inheritanchor[from=rectangle ee]{south east}% \inheritanchor[from=rectangle ee]{south west}% \inheritanchor[from=rectangle ee]{input}% \inheritanchor[from=rectangle ee]{output}% \inheritanchorborder[from=rectangle ee]% % \backgroundpath{ \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}} \pgf@xa=\pgf@x \pgf@ya=\pgf@y \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} \pgf@xb=\pgf@x \pgf@yb=\pgf@y % Move tip back a little bit \advance\pgf@xb by-.5\pgflinewidth % Triangle triangle: \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}} \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}} \pgf@yc=.5\pgf@ya \advance\pgf@yc by .5\pgf@yb \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yc}} \pgfpathclose }% \beforebackgroundpath{ { \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}} \pgf@ya=\pgf@y \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}} \pgf@xb=\pgf@x \pgf@yb=\pgf@y \pgf@yc=.5\pgf@ya \advance\pgf@yc by.5\pgf@yb \pgfusepathqstroke \pgftransformshift{\pgfqpoint{\pgf@xb}{\pgf@yc}} \pgf@yc=.5\pgf@yb \advance\pgf@yc by-.5\pgf@ya \pgftransformscale{\pgf@sys@tonumber{\pgf@yc}} \pgfkeysvalueof{/pgf/generic diode IEC/before background} } }% } \makeatother \tikzset{ leere diode graphic/.style={ circuit symbol open, circuit symbol size=width 1.25 height 1.25, transform shape, shape=leere diode, /pgf/generic diode IEC/before background={ \pgfpathmoveto{\pgfqpoint{0pt}{-1pt}} \pgfpathlineto{\pgfqpoint{0pt}{1pt}} \pgfusepathqstroke }, }, } \begin{document} \begin{tikzpicture}[circuit ee IEC,circuit symbol unit=5.5pt] \tikzset{set diode graphic=leere diode graphic}\draw (0,0) to[diode] (1,0); \end{tikzpicture} \end{document} But if it is compiled via another file—say, mainfile.tex—using the standalone package: \documentclass{article} \usepackage[subpreambles]{standalone} \begin{document} \input{subfile.tex} \end{document} the second compilation fails with the following error: (./subfile.tex ! Undefined control sequence. \pgf@sh@bg@leere diode ->\pgf @process{\pgfpointadd {\southwest }{\pgfpoint ... l.77 ... diode graphic}\draw (0,0) to[diode] (1,0) ; ? Although the mainfile.sta file contains the entire preamble of the subfile.tex file—including the \makeatletter and \makeatother commands—it appears that the @ character is not treated as a letter. Do you understand why, and do you know how to solve this problem?
- How to make the `\ddots` centering of the bounding box?by Explorer on October 17, 2026 at 4:37 pm
This post is similar to this one, but not exactly the same... With the following code: \documentclass{article} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{matrix} \setlength{\fboxsep}{0pt} \begin{document} \[ \begin{tikzpicture} \matrix (magic) [ matrix of math nodes, nodes={circle,draw=magenta,minimum size=1cm}, left delimiter=(, right delimiter=) ] { 1 \\ & 1 \\ & & \ddots \\ & & & \fbox{$\ddots$} \\ & & & & 1 \\ }; \draw[teal,dashed] (magic-1-1.center) -- (magic-5-5.center); \end{tikzpicture} \] \end{document} What I want was the following: only typeset three dots, thus \Ddots with nicematrix was not so flexible; I want the "slope" of \ddots was parallel with the teal,dashed line; I want to ellnimate the extra height of the bounding box of \ddots(why?It looks not good...) It recalled the classical \rvdots here, and we know: $ latexdef \ddots \ddots: macro:->\protect \ddots \ddots : macro:->\mathinner {\mkern 1mu\raise 7\p@ \vbox {\kern 7\p@ \hbox {.}}\mkern 2mu \raise 4\p@ \hbox {.}\mkern 2mu\raise \p@ \hbox {.}\mkern 1mu} I guessed slightly modify the commands could help? Any suggestions? \makeatletter % \DeclareRobustCommand{\rvdots}{% % \vbox{ % \baselineskip4\p@\lineskiplimit\z@ % \kern-\p@ % \hbox{.}\hbox{.}\hbox{.} % }} \DeclareRobustCommand{\rddots}{% \mathinner {% \mkern 1mu\raise 7\p@% \vbox{\kern 1\p@ \hbox {.}}% \mkern 0.4mu \raise 4\p@ \hbox {.}% \mkern 0.4mu\raise \p@ \hbox {.}% \mkern 1mu% }% } \makeatother Edit1 If I zoomed in with with cfr's answer: \makeatletter \newcommand\exddots {% \mathinner {% \mkern 1mu\raise 3.5\p@ % 7 -> 3.5 \vbox {\kern 0\p@ \hbox {.}}% 7 -> 0 \mkern 2mu \raise -0.5\p@ \hbox{.}% 4 -> -0.5 \mkern 2mu \raise -4\p@ \hbox{.}% \p@ -> -4 \mkern 1mu }% } \makeatother Edit2 Just to show the example of cfr's comment: Is the content or, at least, the size of the content in the matrix fixed? because the angle of the diagonal obviously will vary if that varies. so unless you want this only as a one-off, you maybe need to think about how this should work. should \exddots really look different each time and different from any use in maths mode? or do you want to fix the matrix dimensions to keep the angle constant? or ...? I don't think it will look so good if the dots look different in different cases. at least, that is not how it usually would work in latex? \documentclass{article} \usepackage{amsmath} \usepackage{nicematrix} \usepackage{tikz} % \usepackage{kpfonts-otf} \begin{document} \[ \begin{pNiceMatrix} 3 & & & \\ & 555 & & \\ & & \ddots & \\ & & & 66666 \CodeAfter \tikz{ \draw[teal, ultra thin] (1-1.center) -- (4-4.center); \draw[magenta, ultra thin] (2-2.south east) -- (4-4.north west); } \end{pNiceMatrix}\qquad \begin{pNiceMatrix} 3 & & & \\ & 555 & & \\ & & \Ddots & \\ & & & 66666 \CodeAfter \tikz{ \draw[teal, ultra thin] (1-1.center) -- (4-4.center); \draw[magenta, ultra thin] (2-2.south east) -- (4-4.north west); } \end{pNiceMatrix} \] \[ \begin{pNiceMatrix} a & & & \\ & b & & \\ & & \ddots & \\ & & & d \CodeAfter \tikz{ \draw[teal, ultra thin] (1-1.center) -- (4-4.center); \draw[magenta, ultra thin] (2-2.south east) -- (4-4.north west); } \end{pNiceMatrix}\qquad \begin{pNiceMatrix} a & & & \\ & b & & \\ & & \Ddots & \\ & & & d \CodeAfter \tikz{ \draw[teal, ultra thin] (1-1.center) -- (4-4.center); \draw[magenta, ultra thin] (2-2.south east) -- (4-4.north west); } \end{pNiceMatrix} \] \[ \begin{pNiceMatrix} x & & & & \\ & x+y & & & \\ & & \ddots & & \\ & & & \sqrt{x-y} & \\ & & & & \dfrac{x}{y} \CodeAfter \tikz{ \draw[teal, ultra thin] (1-1.center) -- (4-4.center); \draw[magenta, ultra thin] (2-2.south east) -- (4-4.north west); } \end{pNiceMatrix}\qquad \begin{pNiceMatrix} x & & & & \\ & x+y & & & \\ & & \Ddots & & \\ & & & \sqrt{x-y} & \\ & & & & \dfrac{x}{y} \CodeAfter \tikz{ \draw[teal, ultra thin] (1-1.center) -- (4-4.center); \draw[magenta, ultra thin] (2-2.south east) -- (4-4.north west); } \end{pNiceMatrix} \] \end{document} With latin-modern-math: With kpfonts-otf:
- TikZ: good method to add dimension arrowsby cis on October 11, 2026 at 6:03 pm
I would like to add dimension arrows like the ones shown here. What is the most elegant way to do this in common? (Note that I am showing an example here; however, a good general method would be interesting.) So, for instance, the dimension arrows and labels should be placed evenly and systematically. Here is my own rather clumsy attempt: \documentclass[margin=5pt, tikz]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \begin{document} %% Values \pgfmathsetmacro{\R}{2.0} \pgfmathsetmacro{\a}{1.9} \pgfmathsetmacro{\b}{sqrt(\R^2 - \a^2) + \R} \pgfmathsetmacro{\x}{\R+(sqrt(2)*sqrt(\R*(2*\R-\b)) +\b -2*\R)-\b} \begin{tikzpicture}[scale=1.5, font=\footnotesize, >={Triangle[length=0pt 2*4,width=0pt 4]}, ] %% Coordinates on the main segment \coordinate[label=below:$M$] (M) at (0,0); \coordinate[label=below:$O$] (O) at (-\R,0); \coordinate[label=below:$A$] (A) at (\R,0); \coordinate[label=below:$C$] (C) at (\R-\b,0); %% Draw main segment OA \draw[] (O) -- (A); %% Solution elements on the main segment \coordinate[label=below:$X$] (X) at (\x,0); % Dimension arrows \foreach \P in {C,M,X,A}{%% \path[draw=none, shorten <=1em] (\P) -- +(0,-1.125) coordinate[pos=0.3] (\P-1) coordinate[pos=0.6] (\P-2) coordinate[pos=0.8] (\P-3) coordinate[pos=1.0] (\P-4); }%% \draw[shorten <=1em] (X) -- (X-2); \draw[<->] (C-1) -- (X-1) node[midway, fill=black!1]{$r$}; \draw[shorten <=0.25em] (M-1) -- (M-2); \draw[<->] ([yshift=0.5em]M-2) -- ([yshift=0.5em]X-2) node[midway, below]{$x$}; \draw[shorten <=1em] (C) -- (C-4); \draw[shorten <=1em] (A) -- (A-4); \draw[<->] (C-3) -- (A-3) node[midway, fill=black!1]{$b$}; %% Draw points on the axis (solution) \foreach \P in {A, X} \draw[fill=black!1] (\P) circle (1.5pt); %% Draw points on the axis (task) \foreach \P in {C, M} \draw[fill=black!1] (\P) circle (1.5pt); \draw[fill=black!1] (O) circle (1.5pt); \end{tikzpicture} \end{document}
- How to enlarge the bounding box of `tblr` with `tikz` if the `overlay` get out of the `tblr` itself?by Explorer on September 16, 2026 at 3:47 pm
Just for fun, I try to mimic this question with tikz-extension with tabularray: \documentclass{article} \usepackage{tabularray} \UseTblrLibrary{tikz} \begin{document} \begin{tblr}{ colspec={*{3}{Q[c,m,12mm]}}, hlines,vlines, } multiple lines & b & c \\ d & multiple lines & f \\ g & h & i \\ \end{tblr} \bigskip \begin{tblr}{ colspec={*{3}{Q[c,m,12mm]}}, % hlines,vlines, rows={rowsep=+5pt}, columns={colsep=+5pt}, } multiple lines & b & c \\ d & multiple lines & f \\ g & h & i \begin{tblrtikzabove}% \foreach \i in {1,...,\arabic{rowcount}}{ \foreach \j in {1,...,\arabic{colcount}}{ \coordinate (A) at ([xshift=+2pt,yshift=-2pt]h\i-|v\j); \coordinate (B) at ([xshift=-2pt,yshift=+2pt]h\inteval{\i+1}-|v\inteval{\j+1}); \draw[cyan] (A) rectangle (B); } } \draw[magenta] ([xshift=-1.5pt,yshift=+1.5pt]h1-|v1) rectangle ([xshift=+1.5pt,yshift=-1.5pt]h\inteval{\arabic{rowcount}+1}-|v\inteval{\arabic{colcount}+1}); \end{tblrtikzabove}% \end{tblr} \end{document} However, the bounding box was not enlarged with the overlay. It looks not a good idea to do so with tabularray...? Now I turn to focus, if we need to draw something outside the tblr, how to enlarge the corresponding bounding box? Edit Now let's only focues the bounding box, similar to this post(?), following example: \documentclass{article} \usepackage{showframe} \setlength{\parindent}{0pt} \usepackage{tabularray} \UseTblrLibrary{tikz} \usetikzlibrary{bending} \begin{document} \begin{tblr}{colspec={*{3}{Q[c,m,12mm]}},hlines,vlines} multiple lines & b & c \\ d & multiple lines & f \\ g & h & i \begin{tblrtikzabove}% \draw[ultra thick,cyan,-latex] (1-1.north west) to[bend right] (3-1.south west); \end{tblrtikzabove}% \end{tblr} \bigskip some text% \begin{tblr}{colspec={*{3}{Q[c,m,12mm]}},hlines,vlines} multiple lines & b & c \\ d & multiple lines & f \\ g & h & i \begin{tblrtikzabove}% \draw[ultra thick,cyan,-latex] (1-1.north west) to[bend right] (3-1.south west); \end{tblrtikzabove}% \end{tblr} \end{document} The "some text" was overlapped with the arrow outside the tblr, my focus here, was how to enlarge the bounding box of tblr in similar case?
- Hollowed-out sphere effectby Sebastiano on July 13, 2026 at 10:49 pm
How can I obtain the hollowed-out sphere effect? The drawing above is my original done many years before. \documentclass{article} \usepackage{tikz} \usetikzlibrary{arrows.meta, calc, positioning, shapes.geometric} \begin{document} \begin{tikzpicture}[ scale=1.2, axis/.style={thick, ->} ] \coordinate (O) at (0, 0); \coordinate (X) at (-2, -2.3); \coordinate (Y) at (5.5, 0); \coordinate (Z) at (0, 4); \coordinate (P) at (3.1, 1.3); \draw[axis] (O) -- (X) node[left, font=\large, xshift=-3pt] {$x$}; \draw[axis] (O) -- (Y) node[below, font=\large, yshift=-3pt] {$y$}; \draw[axis] (O) -- (Z) node[left, font=\large, xshift=-3pt] {$z$}; \begin{scope} \shade[ball color=gray!30!white, opacity=0.85] (O) circle (0.9); \draw[gray!60, thin] (O) circle (0.9); \fill[gray!60!black, opacity=0.9] plot[smooth cycle, tension=0.7] coordinates { ($(O)+(-0.2, 0.4)$) ($(O)+(0.5, 0.5)$) ($(O)+(0.6, -0.4)$) ($(O)+(0.1, -0.6)$) ($(O)+(-0.3, -0.3)$) }; \shade[inner color=black!80, outer color=gray!70!black, opacity=0.5] plot[smooth cycle, tension=0.7] coordinates { ($(O)+(-0.2, 0.4)$) ($(O)+(0.5, 0.5)$) ($(O)+(0.6, -0.4)$) ($(O)+(0.1, -0.6)$) ($(O)+(-0.3, -0.3)$) }; \end{scope} \fill[black] (O) circle (0.07) node[below, yshift=-4pt, font=\large] {$O$}; \draw[->, >=Stealth, shorten >= 2.5pt, shorten <= 2pt] (O) -- (P) node[midway, above, yshift=2pt, font=\large] {$r$}; \fill[black] (P) circle (0.08) node[above, yshift=3pt, font=\large] {$P$}; \node[right, font=\Large\itshape, xshift=2pt, yshift=-2pt] at (P) {$m$}; \node[below, font=\large] at (0.2, -0.95) {$M$}; \end{tikzpicture} \end{document}
- How to avoid code duplication in path along with patterns?by Explorer on May 21, 2026 at 1:06 pm
Here below is my original code: \documentclass[tikz,border=5pt]{standalone} \usepackage{fourier} \usetikzlibrary{bending,patterns.meta,angles,quotes} \begin{document} \begin{tikzpicture}[>=latex] \draw[thick,->] (0,0) -- (10,0) node[below] {$x$}; \draw[thick,->] (0,0) -- (0,-3) node[right] {$y$}; \draw[ultra thick] (7,2) -- (7,0) coordinate (A) -- (8,0) -- (8,-4) -- (7,-4) coordinate (B) -- (7,-6); %%%%%%%%%%%%%%%% path coordinate duplicated \fill[pattern={Lines[angle=-45,distance={5pt}]},preaction={fill=white}] (7,2) -- (7,0) -- (8,0) -- (8,-4) -- (7,-4) -- (7,-6) -- ++(.5,0) -- ++(0,+1.5) -- ++(1,0) -- ++(0,+5) -- ++(-1,0) -- ++(0,1.5) -- cycle; %%%%%%%%%%%%%%%% \draw(0,0) node[label={[label distance=-2.5mm]above left:$O$}] (O) {} -- (7,-4) pic[draw,<->,angle radius=2cm,angle eccentricity=1.15,"$\alpha$"] {angle = B--O--A}; \end{tikzpicture} \end{document} which gives: However, the path: (7,2) -- (7,0) -- (8,0) -- (8,-4) -- (7,-4) -- (7,-6) appeared twice, and I think that is duplicated. How to avoid and make the code more neater?
- nicematrix, \CodeAfter and overlappingby projetmbc on December 25, 2025 at 11:11 am
Is there an automatic way to avoid "TikZ code after" overlap the text? I give a real use case, and not a MWE. \documentclass[12pt]{scrartcl} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[top=1cm, bottom=1.95cm, left=.9cm, right=.9cm]{geometry} \usepackage{nicematrix} \usepackage[svgnames]{xcolor} \usepackage{tikz] \tikzset{ product/.style = { shorten > = 3.75mm, thick }, product-times/.style = { pos=0.5, circle, fill=white, inner sep=2pt }, arrow/.style = { ->, thick }, rounded-frame/.style = { draw, rounded corners, thick, inner sep = 5pt, anchor = west } } \begin{document} XXX $\begin{NiceArray}{*{9}{c}}[cell-space-limits=3pt] & & & & & & & & C_j^{\,\prime} \\ & & & & & & & & \phantom{X} \\ & & & & & & & & \Vdots[shorten-start=11pt] \\ & & & & & & & & \color{IndianRed}a[k]_{qj} \\ & & & & & & & & \Vdots \\ & & & & & & & & \color{ForestGreen} a[k]_{rj} \\ & & & & & & & & \Vdots[shorten-end=21pt] \\ & & \NotEmpty & & & & \NotEmpty & & \\ L_i & \hspace{3pt} & \Cdots[shorten-start=18pt] & \color{IndianRed} 1 & \Cdots & \color{ForestGreen} 0 & \Cdots[shorten-end=18pt] & \hspace{12.5pt} & a[k{+}1]_{ij} % \CodeAfter % Sous-matrices. \SubMatrix({3-9}{7-9})[slim] \SubMatrix({9-3}{9-7}) \SubMatrix({9-9}{9-9}) % Décorons... \begin{tikzpicture} % Indication pour la ligne et la colonne. \draw[ arrow, shorten > = 8mm, ] (1-9.south) to (4-9.north); \draw[ arrow, shorten < = 1mm, shorten > = 9.5mm, ] (9-1.east) to (9-4.west); % Flèches des produits. \draw[ product, IndianRed, ] (9-4.north) to [bend left] node[ product-times, draw = IndianRed, ] {$\times$} (4-9.west); \draw[ product, ForestGreen, ] (9-6.north) to [bend left] node[ product-times, draw = ForestGreen ] {$\times$} (6-9.west) ; % Signification des entrées. \draw[ arrow, ForestGreen, ] ([yshift=-5mm]9-6.south) to (9-6.south); \node[ rounded-frame, ForestGreen ] at ([yshift=-8.1mm, xshift=-2mm]9-6.south) {Pas de lien direct de $i$ à $r$.}; % \draw[ arrow, IndianRed, ] ([yshift=-13.5mm]9-4.south) to (9-4.south); \node[ rounded-frame, IndianRed ] at ([yshift=-17mm, xshift=-2mm]9-4.south) {Un lien direct de $i$ à $q$.}; % \draw[ arrow, IndianRed ] ([xshift=8.5mm] 4-9.east) to ([xshift=3.5mm] 4-9.east); \node[ rounded-frame, IndianRed, ] at ([xshift=8.5mm] 4-9.east) {Nombre de parcours de longueur $k$ de $q$ à $j$.}; % \draw[ arrow, ForestGreen, ] ([xshift=8.5mm] 6-9.east) to ([xshift=3.5mm] 6-9.east); \node[ rounded-frame, ForestGreen, ] at ([xshift=8.5mm] 6-9.east) {Nombre de parcours de longueur $k$ de $r$ à $j$.}; \end{tikzpicture} \end{NiceArray}$ XXX \end{document}
- How can I draw this box in 3D ? I am unhappy with that I haveby Shyamhs on September 22, 2025 at 12:57 am
I need to draw a 3D box comprising two half cylinders on either side attached to a cuboid with square holes. I have managed to accomplish this. But I am not happy with what I have now. For one, it does not look like a 3D picture. I would appreciate any pointers on a better version \documentclass[a4paper,12pt]{article} \usepackage{tikz} \usepackage{tikz-3dplot} \begin{document} \tdplotsetmaincoords{40}{20} \tdplotsetrotatedcoords{0}{15}{21} \begin{tikzpicture}[scale=0.85,tdplot_rotated_coords] % Draw the semicircle (opening to the left) \draw[very thick] (0,-1.5) arc (90:-90:-1.5); % Draw the semicircle for right semicircle (opening to the right) \draw[very thick] (4,1.5) arc (90:-90:1.5); % draw top and bottom lines connecting the two semicircles \draw[very thick] (0,1.5) -- (4,1.5); \draw[very thick] (0,-1.5) -- (4,-1.5); % Draw the below quarter circle (opening to the left) \draw[very thick] (0,-5.5) arc (90:0:-1.5); % Draw the below quarter circle (opening to the right) \draw[very thick] (5.5,-4) arc (0:-90:1.5); % draw bottom line connecting the two semicircles \draw[very thick] (0,-5.5) -- (4,-5.5); % Draw the left vertical line connecting the left upper % semicircle and the left lower quarter circle \draw[very thick] (-1.5,0) -- (-1.5,-4); % Draw the right vertical line connecting the right upper % semicircle and the right lower quarter circle \draw[very thick] (5.5,0) -- (5.5,-4); \draw[very thick,rotate=-9] (0,-3.5) rectangle (1,-2.5); \draw[very thick,rotate=-9] (1.5,-3.25) rectangle (2.5,-2.25); \draw[very thick,rotate=-9] (3,-3) rectangle (4,-2); \draw[very thick,rotate=-9] (4.5,-2.75) rectangle (5.5,-1.75); \end{tikzpicture} \end{document}
- genus-2 torus using tikz-3dplotby userא0 on March 12, 2025 at 12:41 pm
I'm attempting to create a 3D plot of a connected sum of two tori in LyX using the tikz-3dplot package, aiming for a visual representation similar to the image linked here Link Here. I have seen similar plots online, generated by Alternative packages (most of the are similar to the picture in Wikipedia under "Connected Sum"), In which I have no interest. Searching the internet and with the help of some AI engines, I was able to come up with this \documentclass[margin=5pt]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture}[] \begin{axis}[ hide axis, view={40}{60}, ] % Hyperboloid Tube (hyperboloid of one sheet) % Parameters: a = 1.5, c = 5*sqrt(2) % Here: the PGFPlots parameter "x" is used for t, and "y" for theta. \addplot3[ surf, faceted color=black, fill=none, samples=20, samples y=30, domain=-1:1, % t from -1 to 1 domain y=0:2*pi, % theta from 0 to 2pi z buffer=sort, ] ( { (1/(sqrt(2))) * ( 1.5*sqrt(1+x*x)*cos(deg(y)) + 4*sqrt(2)*x ) }, { (1/(sqrt(2))) * ( -1.5*sqrt(1+x*x)*cos(deg(y)) + 4*sqrt(2)*x ) }, { 1.5*sqrt(1+x*x)*sin(deg(y)) } ); % First Torus (centered at (-5,-5,0)) \addplot3[ surf, faceted color=black, fill=none, samples=22, samples y=30, domain=0:2*pi, domain y=0:2*pi, z buffer=sort, ] ({ (5+2*cos(deg(x)))*cos(deg(y))-7 }, { (5+2*cos(deg(x)))*sin(deg(y))-7 }, { sin(deg(x)) }); % Second Torus (centered at (5,5,0)) \addplot3[ surf, faceted color=black, fill=none, samples=22, samples y=30, domain=0:2*pi, domain y=0:2*pi, z buffer=sort, ] ({ (5+2*cos(deg(x)))*cos(deg(y))+7 }, { (5+2*cos(deg(x)))*sin(deg(y))+7 }, { sin(deg(x)) }); \end{axis} \end{tikzpicture} \end{document} which after compiling looks like this I'm not sure how to get these three surfaces to look like they're all part of one piece, besides maybe trying to plot the whole surface as a graph of a single function, which I also don't know how to do. Any help or ideas on either way would be awesome!. Thanks The full latex code: % Preview source code %% LyX 2.4.1 created this file. For more info, see https://www.lyx.org/. %% Do not edit unless you really know what you are doing. \documentclass[english,hebrew,no-math]{extarticle} \usepackage{amsmath} \usepackage{amsthm} \usepackage{fontspec} \setmainfont[Mapping=tex-text]{Hadasim CLM} \setsansfont[Mapping=tex-text]{FreeSerif} \setmonofont{FreeMono} \usepackage[a4paper]{geometry} \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2cm,rmargin=2cm,headheight=2cm,headsep=2cm} \usepackage{setspace} \doublespacing \usepackage[pdfusetitle, bookmarks=true,bookmarksnumbered=false,bookmarksopen=false, breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false] {hyperref} \makeatletter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands. \numberwithin{equation}{section} \@ifundefined{date}{}{\date{}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands. \PassOptionsToPackage{all,color}{xy} \usepackage{tikz} \usepackage{tikz-3dplot} \usetikzlibrary{shapes.geometric} \usetikzlibrary{3d,calc} \usetikzlibrary{matrix,shapes} \usetikzlibrary{arrows.meta} \usetikzlibrary{decorations.markings} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usepackage{faktor} \usepackage{graphicx, nicefrac} \usepackage[all]{xy} % Define a command to reflect box \let\rfb\reflectbox \newcommand{\uglyfrac}[2]{\scalebox{1.35}{\rfb{\nicefrac{\raisebox{0.7ex}{\rfb{#1}}}{\raisebox{-0.7ex}{\rfb{#2}}}}}} \newcommand{\muglyfrac}[2]{\uglyfrac{\ensuremath{#1}}{\ensuremath{#2}}} \usepackage{xcolor} \hypersetup{ colorlinks, linkcolor={red!24!blue}, citecolor={blue!75!black}, urlcolor={blue!75!black} } \usepackage{fancyhdr} \pagestyle{fancy} \usepackage{bbm} \usepackage{xfrac} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \newcommand\bquotient[2]{ \mathchoice {% \displaystyle \text{\lower1ex\hbox{$#2$}\Big/\raise1ex\hbox{$#1$}}% } {% \textstyle #1\,/\,#2 } {% \scriptstyle #1\,/\,#2 } {% \scriptscriptstyle #1\,/\,#2 } } \newcommand\Bquotient[2]{ \mathchoice {% \displaystyle \text{\lower1ex\hbox{$#2$}\Bigg/\raise1ex\hbox{$#1$}}% } {% \textstyle #1\,/\,#2 } {% \scriptstyle #1\,/\,#2 } {% \scriptscriptstyle #1\,/\,#2 } } \newcommand\Anquotient[3][-22]{% #1 is the optional angle, default is 45 \mathchoice {% \displaystyle \text{\lower0.8ex\hbox{$#3$}\rotatebox{#1}{$\big/$}\raise0.8ex\hbox{$#2$}}% } {% \textstyle #2\rotatebox{#1}{/}#3 } {% \scriptstyle #2\rotatebox{#1}{/}#3 } {% \scriptscriptstyle #2\rotatebox{#1}{/}#3 } } \newcommand\Abquotient[3][-22]{% #1 is the optional angle, default is 45 \mathchoice {% \displaystyle \text{\lower0.8ex\hbox{$#3$}\rotatebox{#1}{$\Big/$}\raise0.8ex\hbox{$#2$}}% } {% \textstyle #2\rotatebox{#1}{/}#3 } {% \scriptstyle #2\rotatebox{#1}{/}#3 } {% \scriptscriptstyle #2\rotatebox{#1}{/}#3 } } \newcommand\ABquotient[3][-22]{% #1 is the optional angle, default is 45 \mathchoice {% \displaystyle \text{\lower0.8ex\hbox{$#3$}\rotatebox{#1}{$\Bigg/$}\raise0.8ex\hbox{$#2$}}% } {% \textstyle #2\rotatebox{#1}{/}#3 } {% \scriptstyle #2\rotatebox{#1}{/}#3 } {% \scriptscriptstyle #2\rotatebox{#1}{/}#3 } } \newcommand\ABQuotient[3][-22]{% #1 is the optional angle, default is 45 \mathchoice {% \displaystyle \text{\lower0.8ex\hbox{$#3$}\rotatebox{#1}{\scalebox{1.5}{$\Bigg/$}}\raise0.8ex\hbox{$#2$}}% } {% \textstyle #2\rotatebox{#1}{/}#3 } {% \scriptstyle #2\rotatebox{#1}{/}#3 } {% \scriptscriptstyle #2\rotatebox{#1}{/}#3 } } \newcommand\fquotient[3][22]{% #1 is the optional angle, default is 22 \mathchoice {% \displaystyle \text{\raise1ex\hbox{\hspace{0.4em}$#3$\hspace{-0.4em}}\rotatebox{#1}{$\Big\backslash$}\lower0.8ex\hbox{\hspace{-0.3em}$#2$\hspace{0.3em}}}% } {% \textstyle \hspace{0.8em}#2\rotatebox{#1}{/}\hspace{-0.8em}#3 } {% \scriptstyle \hspace{0.8em}#2\rotatebox{#1}{/}\hspace{-0.8em}#3 } {% \scriptscriptstyle \hspace{0.8em}#2\rotatebox{#1}{/}\hspace{-0.8em}#3 } } \makeatother \usepackage{polyglossia} \setdefaultlanguage{hebrew} \setotherlanguage{english} \begin{document} \begin{center} \begin{tikzpicture} \begin{axis}[ hide axis, view={40}{60}, ] \addplot3[ surf, colormap name=viridis, faceted color=violet, fill=none, samples=22, samples y=30, domain=0:2*pi, domain y=0:2*pi, z buffer=sort, ] ({(3+cos(deg(x)))*cos(deg(y))}, {(3+cos(deg(x)))*sin(deg(y))}, {sin(deg(x))}); \end{axis} \end{tikzpicture} \end{center} \end{document}
- Draw a TikZ picture with forces and a ropeby selector on December 26, 2024 at 3:47 pm
I am trying to draw a TikZ picture of this screenshot. I was trying to adapt this template which I found when asking Google and which looks a lot like the picture I am aiming at. But I did not succeed. \documentclass[border=3pt,tikz]{standalone} \usepackage{physics} \usepackage{ifthen} \usepackage{tikz} \usetikzlibrary{patterns} \tikzset{>=latex} % for LaTeX arrow head \colorlet{myred}{red!65!black} \tikzstyle{ground}=[preaction={fill,top color=black!10,bottom color=black!5,shading angle=20}, pattern=north east lines,draw=none,minimum width=0.3,minimum height=0.6] \tikzstyle{mass}=[line width=0.6,red!30!black,fill=red!40!black!10,rounded corners=1, top color=red!40!black!20,bottom color=red!40!black!10,shading angle=20] \tikzstyle{rope}=[brown!70!black,line width=2] %very thick \def\rope#1{ \draw[black,line width=2.3] #1; \draw[rope] #1; } % FORCES SWITCH \tikzstyle{force}=[->,myred,thick,line cap=round] \newcommand{\vbF}{\vb{F}} \newcommand{\vbT}{\vb{T}} \newboolean{showforces} \setboolean{showforces}{true} \begin{document} % VERTICAL ceiling \def\h{0.6} % mass height \def\w{0.7} % mass width % VERTICAL ceiling 2 \begin{tikzpicture} \def\W{2.0} % ground width \def\D{0.2} % ground depth \def\H{1.5} % ground depth \def\y{0} % mass y coordinate \coordinate (M) at (0,0); \rope{(-0.4*\W,1.05*\H) -- (M) -- (0.4*\W,1.05*\H)} \draw[ground] (-\W/2,\H) rectangle++ (\W,\D); \draw (-\W/2,\H) --++ (\W,0); \draw[mass] (M)++(-\w/2,0) rectangle++ (\w,-\h) node[midway] {$m$}; \end{tikzpicture} \end{document} Do you see an easy way to adapt the template or to draw this picture otherwise?
- Custom Sidebar Table of Contents in Beamerby wrb98 on September 17, 2024 at 2:15 pm
I'm working with a blank Beamer presentation template and want to recreate a sidebar similar to one shown in the image below. Unlike typical Beamer sidebars that extend to the page's edge, this one is part of a custom frame. I'd like the sidebar to display boxed sections with sharp drop shadows. The current section should be highlighted by a red shadow, while the current subsection should be bolded and appear on a white horizontal strip. Subsections from other sections should remain hidden until the presentation reaches that specific section, at which point they should appear in a dropdown list in the sidebar (e.g. in the image, we're on SO so subsections of SO are shown in the sidebar, but subsections of Section Two and Section Three are not). Note: By 'subsection' I really mean slide titles. How can I implement this effect in LaTeX? Any help would be appreciated. \documentclass[11pt]{beamer} \usepackage{tikz} \usepackage{microtype} \usepackage{xcolor} \usepackage{soul} \usetikzlibrary{calc} \usepackage{ lmodern, babel, amsmath, eurosym } \definecolor{darkpastelgreen}{rgb}{0.01, 0.75, 0.24} \usepackage[default]{sourcesanspro} \usepackage[T1]{fontenc} \setbeamertemplate{navigation symbols}{} \setbeamertemplate{background}{% \begin{tikzpicture}[overlay,remember picture] \fill[sharp corners,fill=darkpastelgreen] ($ (current page.north west) + (0.4cm,-0.4cm) $) rectangle ($ (current page.south east) + (-0.4cm,0.4cm) $); \end{tikzpicture}% \begin{tikzpicture}[overlay,remember picture] \fill[sharp corners,color=white] ($ (current page.north west) + (0.5cm,-0.5cm) $) rectangle ($ (current page.south east) + (-2cm,0.5cm) $); \end{tikzpicture}% } \setbeamersize{text margin left=0.8cm, text margin right=0.85cm} % Reduce side margins \setbeamertemplate{frametitle}{\color{black}\bfseries\insertframetitle \nointerlineskip \bigskip } \addtobeamertemplate{frametitle}{\vspace*{0cm}}{\vspace*{-0.4cm}} \addtolength{\headsep}{0.6cm} \begin{document} \begin{frame}[t]{} \frametitle{A Subsection} Slide content goes here... \end{frame} \end{document}
- TikZ: Shapes with an angular colour gradientby StormyTeacup on April 18, 2024 at 2:05 pm
Cross-posting from Stack Overflow: https://stackoverflow.com/q/78347764/2777074 Good people! I'm trying to draw some shapes with an angular colour gradient, but I am unable to find the general syntax for how fill a shape like that. I'm going to need to draw an awful lot of these diagrams, but to give you an idea of the basic way I want these things to look like when they're finished, I am attaching this picture: So, what I want is something so that I can specify "the gradient starts with colour X at angle A, and ends with colour Y at angle B". Does TikZ picture have such a function, or is it necessary to define something on one's own? Look forward to your responses! The only thing I've been able to come up with would be to use the method described in this answer to create a circular shape as a background, then to "hide" most of it with white with a cut-out of my shape remaining, but the problem with this approach is not only that it's kind of inelegant, it also will not work if I need to have several shapes next to one another. https://stackoverflow.com/questions/72813749/tikz-fill-a-circle-with-shading-color-by-angle EDIT: It being requested that I add some code snippet, I have put together this one, which produces the figure I have in mind, albeit without the desired gradient: \begin{tikzpicture} \draw[thick, arrows=<->] (-5,0)--(5,0); \draw[thick, arrows=<->] (0,-5)--(0,5); \draw[fill=red, draw=none] (2.5,0) arc (0:225:2.5) -- (225:2.2) -- (243:3) -- (225:3.8)--(225:3.5) arc (225:0:3.5) -- cycle; \draw[fill=blue, draw=none] (290:2.5) arc (290:335:2.5) -- (335:2.2) -- (353:3) -- (335:3.8) -- (335:3.5) arc (335:290:3.5) -- cycle; \end{tikzpicture} The image produced looks as follows:
- 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}
- Plot differential equation trajectories of a 3-systemby Miguel Huaylla on April 3, 2022 at 10:19 pm
I was reading about drawing differential equation trajectories with latex, but I wonder... is there a way to graph this? Consider the system x'=-y+xz^2 y'=x+yz^2 z'=-z(x^2+y^2) The following image I have taken from Perko's book Differential Equations and Dynamical Systems
- Draw sphere and curved surface with TikZby Bahman Mirzakhani on March 7, 2021 at 10:54 am
I want to draw this picture, can anyone help me complete it? \documentclass[a4paper,11pt]{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \shade[ball color = brown, opacity=0.7] (0,0) circle (2cm); \draw (0,0) circle (2cm); \draw[thick, -latex] (-130:1cm) -- (-130:3.5cm) node [below] {$ x $}; % x axis \draw[thick, -latex] (-20:1cm) -- (-20:3.5cm) node [right] {$ y $}; % y axis \draw[thick, -latex] (90:1cm) -- (90:3.5cm) node [above] {$ z $}; % z axis \draw (60:1.5cm) -- (60:3.5cm) node [anchor=south west, xshift=-2em] {$ x^2 + y^2 + z^2 - a^2 = 0 $}; \end{tikzpicture} \end{document}
- Tikz drawing objects/figures on Pythagorean diagramsby Jon on June 17, 2020 at 1:52 pm
I am a mathematics teacher, and I have to make many tests using Pythagoras, kite in a tree, attached by string, a boat out to sea, etc. I would like to know the best ways of drawing these pictures do I need to learn another program? MWE. I have now tried inkscape obtained an SVG file, by using trace Bitmap, not a very good result, or I couldn't use it well. Tried Gimp 2.10.14 got a better result, was able to manipulate image. Would still like to know how these images are created.I have also got all the Tikz people, thank you Nils Fleischhacker. % !TeX spellcheck = en_GB \documentclass{article} \usepackage{graphicx} \usepackage{tikz} \usepackage{calc} \usetikzlibrary{shadows} \begin{document} \begin{figure} \sbox0{\includegraphics[width=0.5\textwidth]{Green_Tree}}% \begin{tikzpicture}[x=\wd0/400, y=\ht0/400] \node[anchor=south west,inner sep=0pt] {\usebox0}; \draw[blue, ultra thick, |-|] (275,0) -- (275,400); \draw[blue, ultra thick, |-|] (220,0) -- (-200,0); \draw[blue, ultra thick, |-|] (-210,30) -- (240,400); \node[below,font=\bfseries\LARGE] {$4m$}; \node[right,font=\bfseries\LARGE] at (300,150) {$13m$}; \node[left,font=\bfseries\LARGE] at (-25,220) {$x\,m$}; \end{tikzpicture} \end{figure} \end{document}
- Drawing Complicated geometry figures in tikzby furfur on April 13, 2020 at 9:49 am
I want to get this kind of figures in LaTeX: I am pretty sure these were not written manually in tikz, since it would take too much time. How can I draw hard geometry in tikz without needing to spend half an hour on each figure? I tried geogebra but the figures produced are horrible. Even by changing the software’s settings you still get ugly tikz figures and the nodes labels are placed incorrectly. Please help me, maybe with something like a WYSIWYG program for tikz, because it is not the best option to manually write the tikz code for 200 figures..
- Special table - rounded bordersby ez5653 on February 15, 2020 at 11:36 am
Can you help me with creating this type of table in Latex ? Thank you
- pgfgantt : progression is wrong when using `today offset=.5`?by Ripitchip on October 3, 2019 at 11:13 am
When I'm not using today offset=.5, I get this : So the progression in grey is right. Now if I add today offset=.5, I get this : The grey progression isn't 50% anymore. How can I do to nullify the offset on the progression ? Thanks in advance. Sample code (today offset=.5 is 8th rule in the options): \documentclass[tikz,border=5mm]{standalone} \usepackage[utf8]{inputenc} \usepackage[french]{babel} \usepackage[T1]{fontenc} \usepackage{pgfgantt} \begin{document} \definecolor{barblue}{RGB}{153,204,254} \definecolor{groupblue}{RGB}{51,102,254} \definecolor{linkred}{RGB}{165,0,33} \renewcommand\sfdefault{phv} \renewcommand\mddefault{mc} \renewcommand\bfdefault{bc} \sffamily \begin{ganttchart}[ x unit=0.4cm, y unit title=1.2cm, y unit chart=.6cm, canvas/.append style={fill=none, draw=black!30, line width=.75pt}, hgrid style/.style={draw=black!30, line width=.75pt}, vgrid={*1{draw=black!30, line width=.75pt}}, % Tell at which week we are right now & style of today line today=3, today offset=.5, today rule/.style={ draw=black!64, dash pattern=on 3.5pt off 4.5pt, line width=1.5pt }, today label font=\small\bfseries, today label=Current Week, % Title options title/.style={draw=none, fill=none}, title label font=\bfseries\footnotesize, title label node/.append style={below=7pt}, include title in canvas=false, % Style of ganttgroup's title bar label font=\mdseries\small\color{black!70}, bar label node/.append style={left=0.40cm}, % Style of bars bar/.append style={draw=none, fill=black!63}, bar incomplete/.append style={fill=barblue}, bar progress label font=\mdseries\footnotesize\color{black!70}, % Syle of groups group incomplete/.append style={fill=groupblue}, group left shift=0, group right shift=0, group height=.2, group peaks tip position=0, group label node/.append style={left=0.25cm}, group progress label font=\bfseries\small, % Syle of milestones milestone progress label text=, milestone label font=\mdseries\small\color{red!60}, milestone label node/.append style={left=0.40cm}, milestone/.append style={anchor=east,xshift=-1pt}, redMile/.style={milestone/.append style={fill=red}}, % Option red milestone ]{1}{18} % Gantt's title = Weeks \gantttitle[ title label node/.append style={below left=7pt and -3pt} ]{WEEKS:\quad1}{1} \gantttitlelist{2,...,18}{1} \\ % Indication of week's number % === Organisation du projet \ganttgroup[]{Organisation du projet}{2}{18} \\ \ganttbar[progress=50]{Ecrire le cahier des charges}{2}{3} \\ \ganttmilestone[redMile]{Rendu du cahier des charges}{4} \\ \ganttbar[progress=0]{Préparer la défense intermédiaire}{4}{4} \\ \ganttmilestone[redMile]{Défense intermédiaire}{5} \\ \ganttbar[progress=0]{Ecrire le rapport}{3}{17} \\ \ganttmilestone[redMile]{Rendu du projet}{17} \\ \ganttbar[progress=0]{Préparer la défense finale}{18}{18} \\ \ganttmilestone[redMile]{Défense finale}{18} \\ \end{ganttchart} \end{document}
- Densest sphere packingby Wokwok on June 16, 2019 at 5:38 pm
I would like to represent the densest sphere packing in dimension 3 as the following picture, for a beamer presentation. Is Tikz the way to go for it? It is not a real 3D drawing since I only want a fixed representation of the picture, right? Thank you for your help.
- Tikzlibrary package in the beamerby Lucas Sá on April 17, 2019 at 6:36 pm
I'm trying to use the tikz package in beamer, but the bug is appearing Missing \endcsname inserted The code of the diagram I'm drawing is \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage{utopia} \usepackage{tikz} \usetikzlibrary{shadows} \usetikzlibrary{arrows,shapes} \usetheme{Madrid} \usecolortheme{default} \begin{document} \begin{frame} \begin{equation*} \begin{tikzpicture} \matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em] { K_0(I) & K_0(A) & K_0(B) \\ K_1(B) & K_1(A) & K_1(I) \\}; \path[-stealth] (m-2-1) edge node [left] {$\delta_1$} (m-1-1) (m-1-1) edge node [above] {$K_0(\varphi)$} (m-1-2) (m-1-2) edge node [above] {$K_0(\psi)$} (m-1-3) (m-2-3) edge node [below] {$K_1(\varphi)$} (m-2-2) (m-2-2) edge node [below] {$K_1(\psi)$} (m-2-1); \end{tikzpicture} \end{equation*} \end{frame} \end{document} If I try this same code into a normal document (without the beamer) it works normally
- PGFplots - Imitate minimalistic styleby pogo-otter on April 8, 2019 at 5:38 pm
The style of plots, as shown in the example of a thesis I saw, can be found in literature of topics ranging from mechanical engineering to physics. I am primarily interested to know if this is a specific style option or package (like using colorbrewer sets for colours). (If it is none of this, I will try to re-imagine it myself.) So far, I have checked the TikZ Galery for any other examples of this and looked through math sans serif fonts, but it was not successful yet. Just as an addition, the reason I am searching for a package or something similar, is that this style of diagram is fairly widespread. And not only do the axes look differently than regular pgfplots (see the dimensions for the percentage on the y-axis), there's also the different fontand the arrows in the axis description. These characteristics are always the same when these diagrams can be found in books which makes me think that this is a fundamental design.
- I want to make a picture in physics with TikZ. Can you help me?by Hiếu Trần on March 30, 2019 at 2:06 am
A similar example: \documentclass[tikz]{standalone} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture}[ force/.style={>=latex,draw=blue,fill=blue}, axis/.style={densely dashed,gray,font=\small}, M/.style={rectangle,draw,fill=lightgray,minimum size=0.5cm,thin}, m/.style={rectangle,draw=black,fill=gray,minimum size=0.3cm,thin}, plane/.style={draw=black,fill=blue!10}, string/.style={draw=red, thick}, pulley/.style={draw, thick, circle}, ] %mainshape \filldraw[blue!30!white, draw=black] (0,0) coordinate (b) rectangle (3,1) coordinate (c); % \draw[pulley] (3.1,1.2) circle (0.25cm); \node (pulley) [pulley, minimum width=.5cm, anchor=south west] at (c) {}; \filldraw[gray!40!white, draw=black] (1.5,1.05) rectangle (2,1.55); \draw[red,thick] (2,1.2)--(pulley.west); \filldraw[gray, draw=black] (3.10, 0.1) rectangle (3.6, 0.6) coordinate (a); \draw[red,thick] (a -| pulley.south)--(pulley.south); %FBD1 \begin{scope}; \node[M, right=50pt of a](M){}; {[axis,->] \draw (0,-1) -- (0,2) node[right] {$+y$}; \draw (M) -- ++(2,0) node[right] {$+x$};} {[force,->] % Assuming that Mg = 1. The normal force will therefore be cos(alpha) \draw (M.center) -- ++(0,1) node[above right] {$F_N$}; \draw (M.west) -- ++(-1,0) node[left] {$F_f$}; \draw (M.east) -- ++(1,0) node[above] {$T$};} \draw[force,->] (M.center)-- ++(0,-1) node[below] {$Mg$}; \end{scope}; %FBD2 \node[m, left=25pt of b] (m) {}; \draw[axis,->] (m) -- ++(0,-2) node[left] {$+$}; {[force,->] \draw (m.north) -- ++(0,1) node[above] {$T'$}; \draw (m.south) -- ++(0,-1) node[right] {$mg$}; }; \end{tikzpicture} \end{document}
- Welcoming 2019 Pi day: How to draw the letter π?by user156344 on March 14, 2019 at 1:51 am
First of all: don't forget that exactly 140 years ago, Albert Einstein was born; but exactly one year ago, Stephen William Hawking passed away. What a special day for science! Question How to draw the letter π not in the standard way (i.e. \pi)? I mean "draw", not "type"! Today there will be no \pi, but there will be something like this \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture} \draw (0,2)--(3,2); \draw (1,0)--(1,2); \draw (2,0)--(2,2); \end{tikzpicture} \end{document} (inspired by David Carlisle – I draw this in TikZ just because I don't know how to use picture ;)) Or this \documentclass[tikz]{standalone} \usepackage{tikzducks} \begin{document} \begin{tikzpicture} \duck \duck[xshift=1cm,yshift=2cm] \duck[xshift=1cm,yshift=4cm] \duck[xshift=1cm,yshift=6cm] \duck[xshift=0cm,yshift=8cm] \duck[xshift=-2cm,yshift=7.5cm] \duck[xshift=2cm,yshift=8cm] \duck[xshift=4cm,yshift=8cm] \duck[xshift=6cm,yshift=8cm] \duck[xshift=8cm,yshift=8cm] \duck[xshift=5cm,yshift=6cm] \duck[xshift=5cm,yshift=4cm] \duck[xshift=5.5cm,yshift=2cm] \duck[xshift=6.5cm,yshift=0cm] \duck[xshift=8cm,yshift=1cm] \node[font=\huge] at (4,11) {Happy $\pi$ day with \verb|tikzducks|!}; \end{tikzpicture} \end{document} They are my proudest π drawings, and as today is Pi day, I'd like to see yours! Well, why didn't I delay the time of asking the question by 8 minutes? I asked this at 1:51:31 UTC time, and the "Pi second" of this year is at 1:59:26 today!
- Simple pulley free body diagramby user2175783 on September 26, 2018 at 12:58 pm
I would like to create the following image in tikz. I am completely new to it, so I tried to change the code at http://www.texample.net/tikz/examples/free-body-diagrams/ to \def\iangle{90} \def\down{-90} \def\arcr{0.5cm} \begin{tikzpicture}[ force/.style={>=latex,draw=blue,fill=blue}, axis/.style={densely dashed,gray,font=\small}, M/.style={rectangle,draw,fill=lightgray,minimum size=0.5cm,thin}, m/.style={rectangle,draw=black,fill=lightgray,minimum size=0.3cm,thin}, plane/.style={draw=black,fill=blue!10}, string/.style={draw=red, thick}, pulley/.style={thick}, ] \matrix[column sep=1cm] { \draw[plane] (0,-1) coordinate (base) -- coordinate[pos=0.5] (mid) ++(\iangle:3) coordinate (top) |- (base) -- cycle; \path (mid) node[M,rotate=\iangle,yshift=0.5cm] (M) {}; & %%% % Free body diagram of M2 pulley \draw[pulley] (top) -- ++(\iangle:0.25) circle (0.5cm) ++ (90-\iangle:0.5) coordinate (pulley); \draw[string] (M.east) -- ++(\iangle:2.0cm) arc (90+\iangle:0:0.25) -- ++(0,-1) node[m] {}; \\ }; \end{tikzpicture} but I am not close. Some basic pointers would be appreciated.
- How I can create a graph of forces - tikz?by user98690 on April 17, 2016 at 9:36 am
How can I create a graph of the forces acting on an object like the one in the picture? \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \end{tikzpicture} \end{document}
- Representing general transformations on a 3D grid using TikZby Sid on August 20, 2015 at 9:50 am
I have a cuboid made from unit squares which in 2D looks like the following: Considering a 3D version of this (i.e. a cuboid). I wanted to use Tikz to demonstrate some of the possible deformations that we can introduce to this 3D grid. I wanted to show arbitrary streching (in any direction), shearing (where one half is pulled in one direction and the other half is pulled in the other direction) and some general inhomogeneous deformation (a deformation which cannot be described by any of rotations, shearing, streching etc. It is a very general transformation). I would like each of the spheres shaded and shown in different colours for the different transformations. Many thanks for your help in advance!!!!
- How to create a text box using PGFby Arya Mz on December 24, 2014 at 12:59 pm
I'm styling my beamer presentation using PGF picture and I want to add a textbox with a specific width. The following line doesn't provide a width parameter. \pgftext[at=\pgfpoint{.05\paperwidth}{-.3\paperheight},left,base]{\inserttitle} Note: I strictly want to use PGF. Tikz is not an option.
- Table with alternating row colours and rounded cornersby sudosensei on June 9, 2014 at 10:54 pm
I am trying to create a table with alternating row colours and rounded corners. I combined two answers so far to achieve this: Thorsten Donnig's answer about alternating row colours. Jake's answer about adding rounded corners to a table. This works great in general, but the problem is that the alternating row colours method fills a proper square, not a rounded one, and the row colour "leaks" outside the table border. See the top left and bottom left corners of the image below. Is there an easy way to fix this? Maybe by using the named tikz node to clip everything outside it? Issue: MWE: \documentclass[border=10pt,10pt,table]{standalone} \usepackage{tikz} \usepackage{xcolor} \usepackage{array} \usepackage{booktabs} \usepackage{tabularx} \definecolor{tablerow1}{RGB}{225,217,205} \definecolor{tablerow2}{RGB}{236,229,221} \begin{document} \rowcolors{2}{tablerow1}{tablerow2} \begin{tikzpicture} \node (thetable) [inner sep=0pt] { \begin{tabularx}{\textwidth}{>{\raggedright\arraybackslash\hsize=1.4\hsize}X>{\raggedright\arraybackslash\hsize=0.6\hsize}X} \arrayrulecolor{white} \textbf{Column 1} & \textbf{Column 2} \\ \hline Some text. & Some text. \\ \hline Some text. & Some text. \end{tabularx} }; \draw [rounded corners=.5em] (thetable.north west) rectangle (thetable.south east); \end{tikzpicture} \end{document}
- Pascal's triangle in tikzby dalibor.zeleny on May 6, 2011 at 12:21 am
I would like to typeset the top part of Pascal's triangle. To get the triangle with the names of the binomial coefficients, i.e., {n \choose k}, I used the following code \begin{tikzpicture} \foreach \n in {0,...,4} { \foreach \k in {0,...,\n} { \node at (\k-\n/2,-\n) {${\n \choose \k}$}; } } \end{tikzpicture} The result is this Now I want to be equally lazy and do something like this for the values of the binomial coefficients, i.e., replace {\n \choose \k} in the node label with \CalculateBinomialCoefficient{\n}{\k} where \CalculateBinomialCoefficient is a hypothetical macro that calculates the binomial coefficient. Has anyone done something like that? The result should look like this: