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[french]{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}
- Canvas 3D effect for vectors flattened along an axis or planeby Sebastiano on July 15, 2026 at 7:39 pm
I would like to realize the following image in TikZ, which I had created very roughly in Adobe Illustrator. I am interested in understanding how to use TikZ 3d canvas to squash vectors along planes or lines. I would also like to see how it is used for labels. Here my attempt. See after the missing pieces. \documentclass{article} \usepackage{amsmath} \usepackage{bm} \usepackage{tikz} \usetikzlibrary{arrows.meta, angles, calc} \tikzset{rhtip/.tip={Triangle[line width=1pt, fill=white, length=9pt, width=9pt]}} \definecolor{vectorgreen}{RGB}{76, 181, 93} \definecolor{vectororange}{RGB}{235, 104, 38} \definecolor{vectorbrown}{RGB}{175, 110, 52} \definecolor{ellipseblue}{RGB}{112, 196, 172} \definecolor{spherepurple}{RGB}{155, 120, 200} \begin{document} \begin{tikzpicture}[>=latex] \coordinate (O) at (0,0); \draw[thin, black!70] (O) -- (0, 4.2) node[right, font=\Large] {$z$}; \draw[thin, black!70] (O) -- (5.5, -1.0) node[below right, font=\Large] {$y$}; \draw[thin, black!70] (O) -- (-4.8, -1.9) node[left, font=\Large] {$x$}; \coordinate (C) at (-2.2, -0.88); \fill[black] (C) circle (3.5pt) node[below=8pt, font=\Large] {$C$}; \begin{scope}[shift={(C)}, rotate=12] \draw[ellipseblue, line width=1.5pt] (0,0) ellipse (1.1 and 2.5); \draw[ellipseblue, line width=1.5pt, ->, >=latex] (131:1.1 and 2.5) -- (130:1.1 and 2.5); \draw[thin, black!60] (0,0) -- (225:1.1 and 2.5) node[midway, below right, font=\Large] {$r$}; \shade[ball color=spherepurple] (155:1.1 and 2.5) circle (0.18); \end{scope} \coordinate (P) at (4.0, 2.3); \coordinate (P_proj) at (4.0, -1.6); \draw[dashed, thick, black!80] (P) -- (P_proj); \draw[dashed, thick, black!80] (O) -- (P_proj); \draw[-rhtip, vectororange, line width=2pt] (O) -- (0, 1.9); \node[above right=2pt, font=\Large] at (0, 1.9) {$\bm{\beta}$}; \draw[-rhtip, vectorbrown, line width=2pt] (O) -- (-1.4, -0.56); \node[above=6pt, font=\Large] at (-0.7, -0.15) {$\mathbf{a}$}; \draw[-rhtip, vectorgreen, line width=2pt] (O) -- (3.9, 2.2); \node[below right=4pt, font=\Large] at (1.8, 1.1) {$\mathbf{R}$}; \fill[black] (P) circle (3.5pt) node[above right=4pt, font=\Large] {$P$}; \shade[ball color=spherepurple] (O) circle (0.22); \node[above left=6pt, font=\Large] at (O) {$q$}; \draw[<->, >=latex, semithick, black!80] (30:1.3) arc (30:90:1.3); \node[font=\Large] at (60:1.65) {$\theta$}; \node[font=\Large, below left=6pt] at (1, 0, 1) {$\varphi$}; \end{tikzpicture} \end{document}
- 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 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}
- How to draw the ribbon shape as decoration in TikZ?by Explorer on January 10, 2025 at 4:31 pm
What I want is to draw the following shape with TikZ and make it as a node, I have tred my attempt.And I have consulted some related tape link on TSE,but none of them satisfied my ideal result. I didn't find it in tikz.shapes, I wonder is there exists any wheels to achieve it as a node? My Final result is to draw a shape wrapped-tape as if the shapes in the tikz.shapes library, that means I can use SYNTAX like \node[shape=wrapped-tape,align=left] {\lipsum[2]}; to typeset the shape. My very first attempt is as below: \documentclass[tikz,border=3.14pt]{standalone} \begin{document} \begin{tikzpicture}[line cap=round] \node[ minimum size=1cm, inner sep=5pt, dashed,draw ] (O) {Hello, world!}; \foreach \side/\s in {west/1,east/-1} { \draw[cyan] (O.north) -- (O.north \side) arc (270:{270-180*\s}:.05cm) -- ([xshift=\s*.3cm,yshift=.1cm]O.north \side) arc (270:{270+180*\s}:.05cm) -- ++(-\s*1.5cm,0) -- ([xshift=-\s*.5cm,yshift=.1cm]O.\side) -- ([xshift=-\s*1.2cm,yshift=.1cm]O.south \side) -- ([xshift=-\s*.05cm,yshift=.1cm]O.south \side); \draw[magenta] ([yshift=.05cm,xshift=-\s*.05cm]O.north \side) -- ([xshift=-\s*.05cm]O.south \side) arc ({90+90*\s}:{90+180*\s}:.05cm) -- ([yshift=-.05cm]O.south); \filldraw[fill=gray!50,draw=cyan] ([yshift=.15cm,xshift=\s*.35cm]O.north \side) -- ++(0,-.15cm) -- ++(-\s*.35cm,0) arc (270:{270-180*\s}:.05cm) -- ([xshift=\s*.3cm,yshift=.1cm]O.north \side) arc (270:{270+90*\s}:.05cm); } \end{tikzpicture} \end{document} And it turn out to be as below: But there remains some flaws: some coordinates are fixed, and it's hard to be extended if the text in node is \lipsum but not Hello, world! the arc used maybe replaced by some control points, but it may make it hard to locate their exact coordiate for the latter points How can I make the style into tikz.shape(declare a new one style)? I want to know any possible thoughts, advise or tunning of the case. Best wishes! some maybe relative wrap-tape style in M$Office
- 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:
- Tikz library: what prevents this code from working? Unable to call the sin() functionby Adam Daniels on February 7, 2024 at 5:10 am
I've tried to call a mathematical function in the x-coordinate part of an (x,y) coordinate, to no avail. Strangely it works for the y-coordinate. Something must be wrong with the syntax but I can't figure it out. This code demonstrates the problem: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw (0,0) to [out=30,in=-120] (.5,{cos(60)}); % WORKS \draw (0,0) to [out=30,in=-120] ({.5},{cos(60)}); % WORKS \draw (0,0) to [out=30,in=-120] ({sin(30)},.5); % ATTEMPT 1: DOES NOT WORK \draw (0,0) to [out=30,in=-120] (sin(30),.5); % ATTEMPT 2: DOES NOT WORK \draw (0,0) to [out=30,in=-120] ({sin(30)},{.5}); % ATTEMPT 3: DOES NOT WORK \draw (0,0) to [out=30,in=-120] ({sin(30),.5}); % ATTEMPT 4: DOES NOT WORK \draw (0,0) to [out=30,in=-120] {(sin(30),.5)}; % ATTEMPT 5: DOES NOT WORK \draw (0,0) to [out=30,in=-120] ({{sin(30)},.5}); % ATTEMPT 6: DOES NOT WORK \draw (0,0) to [out=30,in=-120] {({sin(30)},.5)}; % ATTEMPT 7: DOES NOT WORK \end{tikzpicture} \end{document} Your help is greatly appreciated. Best regards,
- 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}
- Draw a unicorn in TikZ 🦄by Martin Thoma on March 31, 2023 at 2:42 pm
I'm currently reading Sparks of Artificial General Intelligence: Early experiments with GPT-4. This paper by Microsoft employees experiments with the capabilities of GPT-4, a successor of ChatGPT. One task is to draw a unicorn with tikz.ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ They claim: GPT-4 produces impressive outputs that are [...] at least comparable (if not superior) to what a human would do. Who wants to prove them wrong? 😄🦄🌈 edit: Please don't include PNG / JPG / other pixel image formats. MS-SPO is the only one allowed to do that (as a grandfathering-rule) - kudos for finding the loophole in this question and for thinking outside of the box 😁👍 edit: We now have 200 fun questions! 🥂🥳
- How to draw a chamfered triangle as a node in tikz?by Xiankai Pang on September 17, 2022 at 7:56 am
There are a lot of node shapes provided in the shape library, but I didn't find any chamfered triangles, as the picture shows below. Are there any libraries that provide such shape? Or how to define a new node shape in tikz? Yes it's possible to draw it as pic rather than a node, but it seems that the pic is not as convenient as node in drawing diagrams using tikz.
- 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}
- Conditionally emphasise / highlight matrix entriesby healyp on March 3, 2021 at 10:37 pm
I would like to successively emphasise / highlight matrix entries as specified in a provided list. Conceptually I'm hoping that I can change the style of the provided matrix cells on the overlays specified. The code below draws a box around the specified entries on the appropriate overlays but I would like, instead, to change the cell's style (to color blue, or face bold, or whatever). Is it even possible to "dynamically" change a cell's style in this way? It is certainly possible to set a single cell's style on matrix setup. Many thanks. \begin{tikzpicture} % \tikzstyle{unseen} = [] \tikzstyle{seen} = [color=blue!70] \matrix (m) [matrix of math nodes, nodes in empty cells, minimum size=7mm, ampersand replacement=\&, every node/.style={font={\large\ttfamily\bfseries}}] { 1 \& 0 \& 0 \& 0 \& 0 \& 0 \& 0 \\ 0 \& 1 \& 1 \& 1 \& 0 \& 0 \& 0 \\ 0 \& 1 \& 1 \& 0 \& 1 \& 1 \& 0 \\ 0 \& 0 \& 0 \& 1 \& 1 \& 1 \& 0 \\ 0 \& 0 \& 0 \& 0 \& 0 \& 0 \& 1 \\ }; \foreach \o/\r/\c in {1/2/1,2/3/1} { \draw<\o->[seen] (m-\r-\c.north west) rectangle (m-\r-\c.south east); } \end{tikzpicture}
- 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..
- 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.
- 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!
- Effectively, how to do "Underbrace" under two "Underbraces"?by wonderich on December 20, 2018 at 5:36 pm
Goal: I am trying to find a way to write an equation for: However, I fail, or at least so far could not find a way, to add the last layer in the bottom for "magnetic flux" using \underbrace. Here is what I have so far, $$ \overbrace{ \underbrace{S^1_A \times S^1_B}_{E} \times \underbrace{S^1_C \times \mathbb{R}}_{\mathbb{CP}^{N-1}} }^{\text{ABCDEFG}} $$ and my output is this: Could you find a better way to do it? Effectively, how to do "Underbrace" under two "Underbraces"? Or maybe we can also try to use TikZ instead? (i.e. I don't mind to try other methods) p.s. Another thing is that, in my case, the size of ABCDEFG is smaller than the S^1_A \times S^1_B \times S^1_C \times \mathbb{R} — is there a way to adjust the size of ABCDEFG and others? Thank you for your help!!!
- tikz diagram time lineby José on June 29, 2017 at 11:09 am
I am trying to make the following diagram with tikz but I have problems with the spikes. Any help would be appreciated. Thanks in advance!
- Hard time in plotting a figureby L.K. on May 9, 2017 at 12:01 pm
I have to plot the diagram shown in the following picture, but I couldn't find the way to do it in LaTeX. There should be three different types of networks (or step lines), green, blue and red. I need to write inside the diagram, as shown in the picture. I have to darken the places where they are very close. Code provided by @gernot: \documentclass[tikz,border=2mm]{standalone} \usetikzlibrary{calc} \newcommand\wireheight{2} % height of one segment \newcommand\wirewidth{1} % width of a segment \newcommand\wiredist{0.5} % distance between wires \pgfmathsetmacro\pairdist{2*(\wirewidth+\wiredist)} % distance between pairs of wires % \wire[options]{name}{start}{height}{width} \newcommand\wire[5][]% {\draw[#1] (#3) coordinate (#2-0) -- ++(0,#4) coordinate (#2-1) -- ++(#5,0) coordinate (#2-2) -- ++(0,#4) coordinate (#2-3) -- ++(-#5,0) coordinate (#2-4) -- ++(0,#4) coordinate (#2-5) -- ++(#5,0) coordinate (#2-6) -- ++(0,0.5*#4) coordinate (#2-7); } \begin{document} \begin{tikzpicture}[rounded corners,>=stealth,shorten >=1pt, shorten <=1pt] \foreach \i in {0,...,2}{ \wire[thick]{B-\i}{\i*\pairdist,0}{\wireheight}{\wirewidth} \wire[thick,green]{G-\i}{{(\i+1)*\pairdist-\wiredist},0}{\wireheight}{-\wirewidth} } \draw[<-] ($(B-0-2)!0.5!(B-0-3)$) -- +(-0.5,0); \draw[<-] ($(G-0-2)!0.5!(G-0-3)$) -- +(0.5,0) node[above]{5mm}; \draw[<-] ($(G-0-4)!0.5!(G-0-5)$) -- +(-0.5,0); \draw[<-] ($(B-1-4)!0.5!(B-1-5)$) -- +(0.5,0) node[above]{7mm}; \draw[<->] ($(B-1-0)!0.5!(B-1-1)$) -- node[above]{10mm} ($(G-1-0)!0.5!(G-1-1)$); \draw[<->] ($(G-1-2)!0.5!(G-1-3)$) -- node[above]{9mm} ($(B-2-2)!0.5!(B-2-3)$); \end{tikzpicture} \end{document} But this only gives two arrays. I don't know how to continue from there.
- 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}
- Beamer overlay specifications for a tikzpictureby XZS on November 25, 2013 at 9:07 pm
Overlay specifications can be added to the TikZ commands. \node<2> (a) {only visible on slide 2}; Is this also possible for the whole tikzpicture environment? \begin{tikzpicture}[<2>] \node (a) {only visible on slide 2}; \node (b) {also only visible on slide 2}; \end{tikzpicture} This can be emulated by enclosing the environment in \only<2>{ ... } but this is impossible when the tikzpicture is used in a \newenvironment.
- Different background for section page in Beamerby marczellm on November 25, 2013 at 11:27 am
On this picture you can see a titlepage, a section page and a content page done in Powerpoint: How to modify this code so that the section page has the background shown on the image? I can do the text positioning by myself later on. \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{tikz, datetime, textpos} \yyyymmdddate \renewcommand{\dateseparator}{.} \definecolor{MedianBrown}{RGB}{119,95,85} \definecolor{MedianLightBrown}{RGB}{235,221,195} \definecolor{MedianLightBlue}{RGB}{148,182,210} \definecolor{MedianOrange}{RGB}{221,128,71} \setbeamercolor*{title page header}{fg=white} \setbeamercolor*{title}{fg=MedianLightBrown} \setbeamercolor*{author}{fg=white} \setbeamercolor*{date}{fg=white} \setbeamercolor*{item}{fg=MedianOrange} \setbeamercolor*{frametitle}{fg=MedianBrown} \setbeamertemplate{navigation symbols}{} \setbeamertemplate{blocks}[rounded][shadow=true] \setbeamertemplate{background}{ \begin{tikzpicture} \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight); \ifnum\thepage>1\relax% Not the title page \fill[color=MedianOrange] (0,8) rectangle(0.8,8.3); \fill[color=MedianLightBlue] (0.9,8) rectangle(\the\paperwidth, 8.3); \else% Title page \fill[color=MedianBrown] (0,1.5) rectangle (\the\paperwidth,\the\paperheight); \fill[color=MedianOrange] (0,0.1) rectangle(3.45,1.4); \fill[color=MedianLightBlue] (3.55,0.1) rectangle(\the\paperwidth,1.4); \fi \end{tikzpicture} } \setbeamertemplate{title page} { \begin{textblock*}{12cm}(3cm,2.8cm) \begin{beamercolorbox}[wd=8cm]{title page header} \usebeamerfont{title}\usebeamercolor{title}\inserttitle% \end{beamercolorbox}% \end{textblock*} \begin{textblock*}{12cm}(-0.5cm,4.9cm) \begin{beamercolorbox}{date} \usebeamerfont{date}\insertdate% \end{beamercolorbox} \end{textblock*} \begin{textblock*}{9cm}(3cm,4.9cm) \begin{beamercolorbox}{author} \usebeamerfont{author}\insertauthor% \end{beamercolorbox} \end{textblock*} } \setbeamertemplate{frametitle} { \vskip0.3cm \begin{beamercolorbox}{frametitle} \insertframetitle \end{beamercolorbox} } \setbeamertemplate{items}[square] \setbeamertemplate{sections/subsections in toc}[square] \author{Author Name} \title{Quite A Long Title For A Simple Beamer Presentation} \date{\today} \begin{document} \frame{\maketitle} \section{Introduction} \frame{\sectionpage} \begin{frame}{My presentation is about\ldots} \begin{itemize} \item Some stuff \item And some other stuff \end{itemize} \end{frame} \end{document}