TikZ
- How to draw realistic scientific calculator buttons and LCD screens in LaTeX? [duplicate]by user446526 on August 25, 2026 at 8:20 am
I am currently working on a mathematical document and I need to explain how to use a scientific calculator (specifically similar to Casio models) for operations like factorials, permutations, and combinations. I would like to recreate the calculator buttons and the LCD screen natively in LaTeX so that they blend perfectly with the text, rather than inserting external images. Here is a reference image (2875.jpg) showing exactly the style I want to achieve: Specifically, I am looking to create macros for: The Buttons: Rounded shapes with a slight 3D/shadow effect. Some buttons are dark blue (like SHIFT), others are dark grey or light grey. Secondary Labels: The ability to add small text above the buttons (like the yellow x! or nCr, and the red LCM). The LCD Screen: A box that mimics the calculator screen, showing the input expression on the left, the result on the bottom right, and tiny indicators at the top (like M, D, Math). I honestly don't know how to achieve this realistic look. I suspect it requires some advanced TikZ or tcolorbox styling, but I couldn't figure out where to start. Could someone provide a minimal working example or guide me on how to design these elements elegantly? Any help would be greatly appreciated!
- How to make two TikZ nodes have exactly the same height?by Marco Moldenhauer on August 25, 2026 at 7:03 am
I am defining custom keyboard-key commands using TikZ and the menukeys package. I defined two types of keystroke commands: one containing a normal letter and another containing a symbol such as \shift. The problem is that the \keystrokeSymbol node does not have the same height as the \keystrokeLetter node. I would like the symbol key to have exactly the same height as the letter key, while still allowing the symbol to be vertically centered. What would be the most elegant TikZ/LaTeX approach to achieve this? Note: I would prefer a solution using TikZ itself, without introducing additional packages, if possible. Code \documentclass{article} \usepackage{tikz} \usepackage{menukeys} \tikzset{ keystroke/.style={ draw=black!50, fill=yellow, %drop shadow={shadow xshift=0.15ex,shadow yshift=-0.15ex,fill=black,opacity=0.7}, rectangle, %rounded corners=0.8pt, inner xsep=0.8pt, inner ysep=0.8pt, line width=0.3pt, %minimum width=0.21cm, %minimum height=0.21cm, font=\sffamily\small, text=blue!75!black, %anchor=south } } \newcommand*\keystrokeLetter[1]{% \tikz[baseline=(key.base)] % \node[keystroke,fill=green!10](key) {#1} ;% } \newcommand*\keystrokeSymbol[1]{% \tikz[baseline=(key.base)] % \node[keystroke](key) {#1} ;% } \newcommand*\menubutton[1]{% \tikz[baseline=(key.base)] % \node[% keystroke, %signal, fill=black!8 ](key) {#1} ;% } \begin{document} first press \keystrokeLetter{A} and \keystrokeSymbol{\shift}\keystrokeLetter{R}, then click on \menubutton{FILE} \menubutton{EDIT}. \end{document} Output Desired Output
- tikz how to stop lines at shape edge when using plotted coordinatesby JKomp on August 23, 2026 at 10:49 pm
I'm writing a translator from OmniGraffle (left diagram) to tikz and I've run into a bit of a problem for translating lines (right diagram). Lines in OmniGraffle are specified as a start point, middle vertices and an ending point. I can replicate the exact shape of the line from the OmniGraffle points by using tikz plot/coordinates in a draw but I'm unsure how to change the code to end at the shape boundary. Here's my MWE \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw (36pt,-36pt) circle [radius=36pt ] node [] (S0) { S0}; \draw[red] plot [smooth, tension=1] coordinates { (S0) (-17.600000262260437pt, 3.89259546372341pt) (15.955999737740058pt, 28.233391483626292pt) (S0)}; \draw[red] plot [smooth, tension=1] coordinates { (36pt, -36pt) (87.40297565709261pt, 7.120001628994942pt) (57.999990582466125pt, 25.534386508502394pt) (36pt, -36pt)}; \draw[red] plot [smooth, tension=1] coordinates { (36pt, -36pt) (-15.128618137809553pt, -70.48571669739613pt) (10.699999623000622pt, -91.0802335745775pt) (36pt, -36pt)}; \end{tikzpicture} \end{document} Note, this is an early phase so things like line widths, arrowheads, text formatting, and converting out of pt coordinates are later tasks.
- Aligning a TikZ node with the text baseline and controlling surrounding spacingby Marco Moldenhauer on August 23, 2026 at 4:53 pm
I am creating a \keystroke command using TikZ to typeset keyboard keys as small boxes: Code \documentclass{article} \usepackage{xcolor} \usepackage{tikz} \usetikzlibrary{shadows} \newcommand*\keystroke[1]{% \tikz[baseline=(key.base)] \node[% draw, fill=black!10, drop shadow={shadow xshift=0.15ex,shadow yshift=-0.15ex,fill=black,opacity=0.7}, rectangle, rounded corners=1pt, inner xsep=1.5pt, inner ysep=1.5pt, line width=0.4pt, minimum width=0em, minimum height=0em, font=\ttfamily\small ](key) {#1} ; } \begin{document} Once Blender has started, press \keystroke{A} to select all existing \end{document} Output Questions I would like to solve two problems: Question Q1: Baseline alignment: How can I vertically position the Tikz node so that the box properly aligned with the baseline of the text outside that node? Question Q2: Horizontal spacing: Why is there apparently more horizontal space after the \keystroke node than before it? How can I make the spacing around the node consistent, so that press \keystroke{A} to has the same spacing before and after the key? Edit (my goal in detail)
- How to plot the graph with better curvature?by user1942348 on August 22, 2026 at 5:44 pm
I want to plot the above Fig. Using the code below, the curvature are not coming same as the Fig. Please help me get the exact Fig. \documentclass[12pt]{article} \usepackage{tikz} \begin{document} \begin{center} \begin{tikzpicture}[ scale=1.5, thick, vertex/.style={circle, draw=black, fill=white, inner sep=1.5pt, minimum size=6pt} ] % Coordinates \coordinate (v2) at (0, 0); \coordinate (v1) at (-1.5, 0.6); \coordinate (v3) at (1.5, 0.6); \coordinate (v7) at (-1.5, -0.6); \coordinate (v6) at (1.5, -0.6); \coordinate (v8) at (-2.5, 0); \coordinate (v5) at (2.5, 0); \coordinate (v0) at (-3.5, 1.8); \coordinate (v4) at (3.5, 1.8); \coordinate (v10) at (-3.5, -1.8); \coordinate (v9) at (3.5, -1.8); % Continuous Curves % Curve 1: Inner (v0 -> v1 -> v2 -> v3 -> v4) \draw (v0) to[out=-30, in=150] (v1) to[out=-30, in=180] (v2) to[out=0, in=210] (v3) to[out=30, in=210] (v4); % Curve 2: Inner (v10 -> v7 -> v2 -> v6 -> v9) \draw (v10) to[out=30, in=210] (v7) to[out=30, in=180] (v2) to[out=0, in=150] (v6) to[out=-30, in=150] (v9); % Curve 3: Top (v8 -> v1 -> v3 -> v5) \draw (v8) to[out=45, in=210] (v1) to[out=30, in=150] (v3) to[out=-30, in=135] (v5); % Curve 4: Bottom (v8 -> v7 -> v6 -> v5) \draw (v8) to[out=-45, in=150] (v7) to[out=-30, in=210] (v6) to[out=30, in=225] (v5); % Curve 5: Left Bow (v0 -> v8 -> v10) \draw (v0) to[out=-60, in=90] (v8) to[out=-90, in=60] (v10); % Curve 6: Right Bow (v4 -> v5 -> v9) \draw (v4) to[out=-120, in=90] (v5) to[out=-90, in=120] (v9); % 3. Hollow Nodes \node[vertex, label=left:$v_0$] at (v0) {}; \node[vertex, label=above:$v_1$] at (v1) {}; \node[vertex, label=above:$v_2$] at (v2) {}; \node[vertex, label=above:$v_3$] at (v3) {}; \node[vertex, label=right:$v_4$] at (v4) {}; \node[vertex, label=right:$v_5$] at (v5) {}; \node[vertex, label=below:$v_6$] at (v6) {}; \node[vertex, label=below:$v_7$] at (v7) {}; \node[vertex, label=left:$v_8$] at (v8) {}; \node[vertex, label=right:$v_9$] at (v9) {}; \node[vertex, label=left:$v_{10}$] at (v10) {}; \end{tikzpicture} \end{center} \end{document}
- Curve sketching in LaTeX documentby M.R. Yegan on August 21, 2026 at 4:13 pm
I wish to sketch a math graph in Latex Doc. my windows is 8.1 64 bit operating system. we need two packages tikz and pgf. I did not find these packages compatible with windows 8.1. Any help will be appreciated.
- How to create a macro to be concatenated?by D G on August 21, 2026 at 5:13 am
The macro \PointLabel is made to simplify creating label on a graph. \fill \PointLabel[above]{-2} \PointLabel[below]{-1} ; Here below is the full code: \documentclass[tikz,border=1cm,12pt]{standalone} \usepackage{amsmath} \usepackage{xintexpr} \newcommand\fx[1]{(#1)^2} \newcommand{\Rational}[1]{% \xintifboolexpr{\xinttheexpr (#1)<0\relax} {-\xintTeXFrac{\xinttheexpr reduce(-( #1 ))\relax}} {\xintTeXFrac{\xinttheexpr reduce(#1)\relax}} } \newcommand{\CoordLabel}[1]{$\left(\Rational{#1},\Rational{\fx{#1}}\right)$} \newcommand{\PointLabel}[2][]{(#2,{\fx{#2}}) circle (2pt) node[#1]{\CoordLabel{#2}}} \begin{document} \begin{tikzpicture}[scale=1.2] \draw[->] (-3.5,0)--(3.5,0) node[right] {$x$}; \draw[->] (0,-1)--(0,10) node[above] {$y$}; \draw[blue,thick,samples=20,domain=-3:3] plot(\x,{\fx{\x}}); \fill (0,{\fx{0}}) circle(2pt) node[below right,red]{\CoordLabel{0}} (1,{\fx{1}}) circle(2pt) node[right]{\CoordLabel{1}} (2,{\fx{2}}) circle(2pt) node[right]{\CoordLabel{2}} (2.5,{\fx{2.5}}) circle(2pt) node[right]{$y=f(x)$} ; % the following causes errors. \fill \PointLabel[above]{-2} \PointLabel[below]{-1} ; \end{tikzpicture} \end{document} However it produces errors: ! Package tikz Error: Giving up on this path. Did you forget a semicolon?. See the tikz package documentation for explanation. Type H <return> for immediate help. ... l.40 \PointLabel [above]{-2} ?
- How to create a dynamic fan in TikZ in LaTeX?by mathrm alpha on August 18, 2026 at 5:49 am
Although I've created a basic fan shape in TikZ, how do I make the center blade of the TikZ fan dynamic rotate? the value you enter determines exactly how fast the TikZ fan I created will spin. \documentclass{article} \usepackage{tikz} \usepackage[paperwidth=9cm, paperheight=9cm, margin=1.5cm]{geometry} \begin{document} \pagestyle{empty} \begin{figure}[htbp] \begin{tikzpicture} \filldraw[color=yellow!60, fill=orange!40, very thick](0,0) circle (3); \filldraw[color=yellow!60, fill=red!0, very thick](0,0) circle (2.5); \begin{scope}[rotate=0] \draw [line width=0.3cm] (0,0) -- (2,2); \draw [line width=0.3cm] (0,0) -- (0,3); \draw [line width=0.3cm] (0,0) -- (-2,2); \draw [line width=0.3cm] (0,0) -- (2,-2); \draw [line width=0.3cm] (0,0) -- (3,0); \draw [line width=0.3cm] (0,0) -- (-3,0); \draw [line width=0.3cm] (0,0) -- (0,-3); \draw [line width=0.3cm] (0,0) -- (-2,-2); \filldraw[orange] (0,0) circle (30pt) node[anchor=west]{}; \end{scope} \end{tikzpicture} \end{figure} \end{document}
- Showcase of beautiful 'electrical circuit diagrams' done in TeX & friendsby cis on January 27, 2026 at 7:03 am
When I saw this thread How to customize CircuiTikz ac - dc symbols or this one Showcase of beautiful typography done in TeX & friends, I had the idea to add a showcase for electrical circuit diagrams. The package would typically be circuitikz. Feel free to post your large, small, or elegant circuit diagrams here in the community wiki. (I will also add some examples occasionally.) Attach your codes (if possible); this would be a great opportunity to learn from your coding and your style. \documentclass[margin=5pt, multi=circuitikz]{standalone} \usepackage{circuitikz} \begin{document} \begin{circuitikz}[european resistors] \draw[] (0,0) to[R=$R_1$, a_=$1\Omega$, name=R1, invert] (3,0); \end{circuitikz} \end{document}
- Draw circumscribed sphere and inscribed sphere of regular tetrahedronby Stephen on October 7, 2025 at 11:07 am
I need to draw circumscribed and inscribed spheres of a regular tetrahedron. \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture}[x={(1mm,-3.5mm)},y={(1cm,0cm)},z={(0cm,1cm)}, contour/.style={gray,densely dashed},line width=0.8pt] % edge length \a \pgfmathsetmacro{\a}{4} \path (0,0,{sqrt(6)*\a/3}) coordinate (A) node[above] {$A$}; \path ({sqrt(3)*\a/6},-\a/2,0) coordinate (B) node[left] {$B$}; \path ({sqrt(3)*\a/6},\a/2,0) coordinate (C) node[right] {$C$}; \path ({-sqrt(3)*\a/3},0,0) coordinate (D) node[left] {$D$}; \path (0,0,0) coordinate (H) node[below] {$H$}; \path (0,0,{sqrt(6)*\a/12}) coordinate (O) node[above right] {$O$}; \fill (O) circle (1pt) (H) circle (1pt); \draw (A) -- (B) -- (C) -- cycle; \draw[dashed] (H) -- (A) -- (D) -- (B) (D) -- (C); % three contour lines \draw[contour] (A) -- ++ (0,2.2,0); \draw[contour] (H) -- ++ (0,2.2,0); \draw[contour] (O) -- ++ (0,2.2,0); % label the heights \draw[<->] ($(A)+(0,2,0)$) -- ($(O)+(0,2,0)$) node[midway,right] {$\frac{\sqrt{6}}{4}a$}; \draw[<->] ($(H)+(0,2,0)$) -- ($(O)+(0,2,0)$) node[midway,right] {$\frac{\sqrt{6}}{12}a$}; \end{tikzpicture} \end{document} If I use \shade[ball color=gray!20,opacity=0.3] (O) circle ({sqrt(6)*\a/4}); together with the shadings library, the result becomes which is abviously not that kind of sphere I want to see. Any ideas to draw?
- 3D rotation of nodes and shapesby Jellby on February 8, 2025 at 3:41 pm
Is there some way to create an image like the one below with TikZ, with the rotations being done right (instead of by manually slanting/scaling until it kind of looks okay-ish, as I did with inkscape)? I'd like to be able to apply an arbitrary 3D rotation to a node or planar shape. The closest I've found is Polar triangle in TiKz, but that addresses only the sphere part, and not the transformation. EDIT: OK, I figured out the canvas is * plane at * and transform shape keys, and I was able to reproduce the figure (based on the link above). Now I just need to express a rotation around an arbitrary axis as a sequence of x,y,z rotations, but that's a maths problem. \documentclass {standalone} \usepackage {tikz} \usetikzlibrary{3d} \usetikzlibrary{calc} \usetikzlibrary{math} % isometric axes \def\angi{35} \def\angii{45} \pgfmathsetmacro\xx{sin(\angii)} \pgfmathsetmacro\xy{-cos(\angii)*sin(\angi)} \pgfmathsetmacro\yx{sin(\angii-90)} \pgfmathsetmacro\yy{-cos(\angii-90)*sin(\angi)} \pgfmathsetmacro\zx{0} \pgfmathsetmacro\zy{cos(\angi)} % some functions (cross products) \tikzmath% {% function crossx(\mx,\my,\mz,\nx,\ny,\nz) {% cross product, x coordinate, normalized \pxx = \my*\nz-\mz*\ny; \pyy = \mz*\nx-\mx*\nz; \pzz = \mx*\ny-\my*\nx; return {\pxx/sqrt(\pxx*\pxx+\pyy*\pyy+\pzz*\pzz)}; }; function crossy(\mx,\my,\mz,\nx,\ny,\nz) {% cross product, y coordinate, normalized \pxx = \my*\nz-\mz*\ny; \pyy = \mz*\nx-\mx*\nz; \pzz = \mx*\ny-\my*\nx; return {\pyy/sqrt(\pxx*\pxx+\pyy*\pyy+\pzz*\pzz)}; }; function crossz(\mx,\my,\mz,\nx,\ny,\nz) {% cross product, z coordinate, normalized \pxx = \my*\nz-\mz*\ny; \pyy = \mz*\nx-\mx*\nz; \pzz = \mx*\ny-\my*\nx; return {\pzz/sqrt(\pxx*\pxx+\pyy*\pyy+\pzz*\pzz)}; }; } \newcommand{\greatcircle}[6] % pole x, y, z, color, two orientation factors (+1/-1) {% \coordinate (P) at (#1,#2,#3); % pole \coordinate (N) at ($(0,0,0)!#6*1.25cm!(P)$); % these points are \coordinate (S) at ($-1*(N)$); % used to clip the \coordinate (E) at ($(0,0,0)!-1.25cm!270:(P)$); % ellipses \coordinate (W) at ($-1*(E)$); % ... \coordinate (NW) at ($(N)+(W)$); \coordinate (NE) at ($(N)+(E)$); \coordinate (SW) at ($(S)+(W)$); \coordinate (SE) at ($(S)+(E)$); \pgfmathsetmacro\ptheta{atan2(#2,#1)} % pole, spherical coordinate theta \pgfmathsetmacro\pphi {#5*acos(#3)} % pole, spherical coordinate phi \begin{scope} \clip (W) -- (SW) -- (SE) -- (E) -- cycle; \draw[rotate around z=\ptheta,rotate around y=\pphi,% canvas is xy plane at z=0,#4] (0,0) circle (1); \end{scope} } \newcommand{\mylabel} {% \begin{scope}[canvas is xz plane at y=1] \node[draw,thick,inner sep=2pt,transform shape] at (0,0) {\sffamily\bfseries R}; \end{scope} } \begin{document} \begin{tikzpicture}[line cap=round,line join=round,scale=2,% x={({\xx cm,\xy cm})},y={(\yx cm,\yy cm)},z={(\zx cm,\zy cm)}] % points A, B, C in spherical coordinates \def\atheta{0} \def\aphi {0} \def\btheta{0} \def\bphi {90} \def\ctheta{90} \def\cphi {90} % points A, B, C in cartesian coordinates \pgfmathsetmacro\ax{cos(\atheta)*sin(\aphi)} \pgfmathsetmacro\ay{sin(\atheta)*sin(\aphi)} \pgfmathsetmacro\az{cos(\aphi)}); \pgfmathsetmacro\bx{cos(\btheta)*sin(\bphi)} \pgfmathsetmacro\by{sin(\btheta)*sin(\bphi)} \pgfmathsetmacro\bz{cos(\bphi)}); \pgfmathsetmacro\cx{cos(\ctheta)*sin(\cphi)} \pgfmathsetmacro\cy{sin(\ctheta)*sin(\cphi)} \pgfmathsetmacro\cz{cos(\cphi)}); % polar points P, Q, R in cartesian coordinates \pgfmathsetmacro\px{crossx(\ax,\ay,\az,\bx,\by,\bz)} \pgfmathsetmacro\py{crossy(\ax,\ay,\az,\bx,\by,\bz)} \pgfmathsetmacro\pz{crossz(\ax,\ay,\az,\bx,\by,\bz)} \pgfmathsetmacro\qx{crossx(\cx,\cy,\cz,\ax,\ay,\az)} \pgfmathsetmacro\qy{crossy(\cx,\cy,\cz,\ax,\ay,\az)} \pgfmathsetmacro\qz{crossz(\cx,\cy,\cz,\ax,\ay,\az)} \pgfmathsetmacro\rx{crossx(\bx,\by,\bz,\cx,\cy,\cz)} \pgfmathsetmacro\ry{crossy(\bx,\by,\bz,\cx,\cy,\cz)} \pgfmathsetmacro\rz{crossz(\bx,\by,\bz,\cx,\cy,\cz)} % triangles \greatcircle{\px}{\py}{\pz}{black}{-1}{1} \greatcircle{\qx}{\qy}{\qz}{black}{ 1}{1} \greatcircle{\rx}{\ry}{\rz}{black}{-1}{1} % sphere and axes \draw (0,0,0) circle (1 cm); % labels \mylabel \begin{scope}[rotate around z=-90] \mylabel \end{scope} \begin{scope}[rotate around x=90] \mylabel \end{scope} \begin{scope}[rotate around z=\angii-90]\begin{scope}[rotate around x=\angi] \mylabel \end{scope}\end{scope} \end{tikzpicture} \end{document}
- How to tune the TikZ marking code more elegant?by Explorer on December 11, 2024 at 9:54 am
I use the following TikZ commands to draw the followng figure: \documentclass[margin=2cm]{standalone} \usepackage{tikz,xfp} \usetikzlibrary{arrows.meta,decorations.markings} \pgfmathtruncatemacro{\NN}{9} \begin{document} \begin{tikzpicture}[ ->-/.style = { decoration={ markings,% \fpeval here is not so elegant mark=between positions \fpeval{.55*{#1}/(2*{#1}+1)} and \fpeval{{#1}/(2*{#1}+1)} step \fpeval{{#1}/(2*{#1}+1)} with {\arrow{Stealth[scale=1.2]}}, mark=between positions \fpeval{1.58*{#1}/(2*{#1}+1)} and \fpeval{(2*{#1})/(2*{#1}+1)} step \fpeval{{#1}/(2*{#1}+1)} with {\arrow{Stealth[scale=1.2]}}, mark=between positions \fpeval{(2*{#1}+.63)/(2*{#1}+1)} and 1 step \fpeval{1/2*(2*{#1}+1)} with {\arrow{Stealth[scale=1.2]}}, },postaction={decorate},semithick }, ->-end/.style = { decoration={ markings, mark=between positions .25 and .78 step .8 with {\arrow{Stealth[scale=1.2]}}, mark=between positions .78 and 1 step .8 with {\arrow{Stealth[scale=1.2]}}, },postaction={decorate},semithick },line cap=round,line join=round, ] \draw (-.21,-.21) node {$O$}; \draw[->] (-.5,0) -- (\fpeval{\NN+.5},0) node[anchor=north west] {$x$}; \draw[->] (0,-.5) -- (0,\fpeval{\NN+.5}) node[anchor=south east] {$y$ }; \foreach \x in {1,...,\NN} \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {$\x$}; \foreach \y in {1,...,\NN} \draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east] {$\y$}; \pgfmathtruncatemacro{\nowx}{0} \pgfmathtruncatemacro{\nowy}{1} \foreach \t in {1,...,\NN}{ \ifnum\t=\NN\relax \ifodd\t\relax \path[draw=magenta,->-end] (\nowx,\nowy) -- ++(\t,0) -- ++(0,-\t); % \pgfmathsetmacro\tmpx{\nowx+\t+1} % \pgfmathsetmacro\tmpy{\nowy-\t} \else \path[draw=cyan,->-end] (\nowx,\nowy) -- ++(0,\t) -- ++(-\t,0); % \pgfmathsetmacro\tmpx{\nowx-\t} % \pgfmathsetmacro\tmpy{\nowy+\t+1} \fi \else \ifodd\t\relax \path[draw=magenta,->-=\t] (\nowx,\nowy) -- ++(\t,0) -- ++(0,-\t) -- ++(1,0); \pgfmathsetmacro\tmpx{\nowx+\t+1} \pgfmathsetmacro\tmpy{\nowy-\t} \else \path[draw=cyan,->-=\t] (\nowx,\nowy) -- ++(0,\t) -- ++(-\t,0) -- ++(0,1); \pgfmathsetmacro\tmpx{\nowx-\t} \pgfmathsetmacro\tmpy{\nowy+\t+1} \fi \fi \global\let\nowx\tmpx \global\let\nowy\tmpy } \end{tikzpicture} \end{document} Howevet there remains some question I think that can be tuned: the setting of mark=between positions #1 and #2 step #3 with {\arrow{Stealth[scale=1.2]}} in my case is not precise and not elegant, I want command like \draw[->-] (A) -- ++(1,0) --++(0,1) --++(3,4) could produce only one centered arrow in each sub part, but I fould that difficult to control in my example, is there any advice? In my case I don't want the LAST loop(i.e. \t=\NN in \ifnum logic) to draw the third path, with \ifnum I succeed, but it cause plenty of dummy code, is there good method to solve the problem like the special case in the Last Or Fisrt in TikZ? The global varible \nowx and \nowy consulting the link, I think because the group inside the \foreach, we can fix it via \global\let\nowx\tmpx, but if with a lot of situation in the code I need the variable in forloop to be global, it's not convient. Is there any better choice? thanks!
- Shading young tableauby nick hristov on December 11, 2024 at 4:44 am
EDIT: Following Jasper Habicht's answer https://tex.stackexchange.com/a/732655/308324 , This code works well for all cells (you may need to fine tune the varuiables, which is annoying but doable) \newcommand{\shadehalf}[3]{% \raisebox{0pt}[0pt][0pt]{% \begin{tikzpicture}[baseline=1, scale=0.8] % Hardcoded coordinates \def\leng{0.65} % Rectangle side length \def\xone{0} % Rectangle x1 \def\yone{-0.16} % Rectangle y1 % Use \pgfmathsetmacro for calculating \xtwo and \ytwo \pgfmathsetmacro{\xtwo}{\xone + \leng} % Rectangle x2 \pgfmathsetmacro{\ytwo}{\yone + \leng} % Rectangle y2 % Draw the shapes \fill[#1] (\xone,\yone) rectangle (\xtwo,\ytwo); % Full square with first color \fill[#2] (\xone,\yone) -- (\xtwo,\yone) -- (\xtwo,\ytwo) -- cycle; % Half-shading triangle % Centered text \node at ({(\xtwo+\xone)/2},{(\yone+\ytwo)*0.6}) {#3}; \end{tikzpicture}% } } I am struggling to make a diagonal shading in Young tableaux. For example in the following: \documentclass{article} \usepackage{ytableau} \usepackage{graphicx} % For \scalebox \begin{document} \begin{ytableau} % line 1 *(green) 1 & *(red) 1& *(green) 1 \\ % line 2 \none& *(green) 1 & *(red) 1\\ % line 3 \none & \none & *(green) 1 \end{ytableau} \end{document} which produces I want to have diagonal shading in each boxes as in 1. TikZ: Rectangle with diagonal fill (two colors) \documentclass[tikz, margin=3mm]{standalone} \usetikzlibrary{shadows,shadings,shapes.symbols} \tikzset{ double color fill/.code 2 args={ \pgfdeclareverticalshading[% tikz@axis@top,tikz@axis@middle,tikz@axis@bottom% ]{diagonalfill}{100bp}{% color(0bp)=(tikz@axis@bottom); color(50bp)=(tikz@axis@bottom); color(50bp)=(tikz@axis@middle); color(50bp)=(tikz@axis@top); color(100bp)=(tikz@axis@top) } \tikzset{shade, left color=#1, right color=#2, shading=diagonalfill} } } \begin{document} \begin{tikzpicture}[my node/.style={ double color fill={green}{blue}}] \node[my node, shading angle=45]{}; \end{tikzpicture} \end{document} I think Staircase paths through young tableaux should be helpful but I fail to do what I want. I will appreciate any help. Thank you
- Nested tableauxby eti902 on February 1, 2024 at 5:32 am
EDIT : I added some examples to illustrate what I want to do. I would like to be able to draw nested Young tableaux. For a definition of Young tableaux, see https://en.wikipedia.org/wiki/Young_tableau. What I mean by nested is that the content of a cell of a tableau is itself a tableau. For example, my result should look like this : In general, rows and columns can be of any length. Here is another example to illustrate what I want to be able to do: Because I also want tabloids and column-tabloids, I draw my tableaux using the method in this answer (instead of the packages ytableau or genyoungtabtikz) : column tabloids versus row tabloids However, I am not used to tikz, and it does not work as I would like. There is a minimal code for my first example (I used \Tableau and \PTableau so that the computer does not confuse both methods): \documentclass{article} \usepackage{tikz} \newcount\tableauRow\newcount\tableauCol \newcommand\Tableau[2]{% \begin{tikzpicture}[scale=#2,draw/.append style={thick,black},baseline=-4mm] \tableauRow=0 \foreach \Row in {#1} { \tableauCol=1 \foreach\k in \Row { \draw(\the\tableauCol,\the\tableauRow)+(-.5,-.5)rectangle++(.5,.5); \draw(\the\tableauCol,\the\tableauRow)node{\k}; \global\advance\tableauCol by 1 } \global\advance\tableauRow by -1 } \end{tikzpicture} } \newcommand\PTableau[2]{% \begin{tikzpicture}[scale=#2,draw/.append style={thick,black},baseline=-4mm] \tableauRow=0 \foreach \Row in {#1} { \tableauCol=1 \foreach\k in \Row { \draw(\the\tableauCol,\the\tableauRow)+(-.5,-.5)rectangle++(.5,.5); \draw(\the\tableauCol,\the\tableauRow)node{\k}; \global\advance\tableauCol by 1 } \global\advance\tableauRow by -1 } \end{tikzpicture} } \begin{document} \[ \PTableau{{\Tableau{{1,2},{3,4}}{0.5},\Tableau{{5,6},{7,8}}{0.5}}}{1.5} \] \end{document} With this code, the result looks like this instead of what I want (I drew it because of computer problem, but it illustrates the problem): What should I modify to \PTableau so that I obtain the result I want? And mostly, why?
- 3D view of a 2D rectangleby Diaa on November 12, 2023 at 11:34 pm
I would be grateful to know how to: fix the code to make it work be able to control the viewing angle so that I can see the rectangle like the top surface of this image \documentclass{article} \usepackage{tikz-3dplot} \usetikzlibrary{perspective,calc,3d,arrows} \begin{document} \tdplotsetmaincoords{70}{110} % Set the view angles \begin{tikzpicture}[scale=2, transform shape, tdplot_main_coords] % Define the coordinates of the rectangle corners with labels \coordinate (A) at (0,0,0); \coordinate (B) at (4,0,0); \coordinate (C) at (4,1,0); \coordinate (D) at (0,1,0); % Draw the rectangle \draw (A) -- (B) -- (C) -- (D) -- cycle; % Draw x-axis \draw[->] (0,0,0) -- (2,0,0) node[anchor=north east]{$x$}; % Draw y-axis \draw[->] (0,0,0) -- (0,2,0) node[anchor=north west]{$y$}; % Draw z-axis \draw[->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; % Add labels to coordinates \node[above right] at (A) {$A$}; \node[above right] at (B) {$B$}; \node[above right] at (C) {$C$}; \node[above right] at (D) {$D$}; \end{tikzpicture} \end{document}
- TikZ fill behavior depends on perspective (tikz-3dplot)by Leyna Shackleton on August 11, 2023 at 10:25 pm
Here is my MWE: \documentclass{minimal} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usepackage{tikz-3dplot} \tdplotsetmaincoords{80}{-5} \begin{document} \begin{tikzpicture} \draw[fill=gray] (1.66, -2, 0) -- (1.33, -2, 0) .. controls (1.33, -0.5, -1) .. (1.33, 1, 0) -- (1.66, 1, 0) .. controls (1.66, -0.5, -1) .. (1.66, -2, 0); \end{tikzpicture} \begin{tikzpicture}[tdplot_main_coords] \draw[fill=gray] (1.66, -2, 0) -- (1.33, -2, 0) .. controls (1.33, -0.5, -1) .. (1.33, 1, 0) -- (1.66, 1, 0) .. controls (1.66, -0.5, -1) .. (1.66, -2, 0); \end{tikzpicture} \end{document} which outputs the following: I'm drawing a curved sheet for which the interior should be filled in, but precisely how this is filled in depends on the coordinate system - the first one is how it should be shaded, but it seems like if I change the perspective, TikZ gets confused and doesn't shade it in properly. Is there any way to fix this?
- Filling in capped off torus in tikz 3dby heervande on July 7, 2023 at 1:28 pm
I am trying to draw a capped off torus in tikz 3d, see MWE below. I'd like the surface to be colored in gray for the first picture, and everything below the blue line to be colored in gray for the second one. Is it possible to do this and changing as little as possible about the picture (so it will still be in the same style with some other pictures I made)? Thanks in advance \documentclass[tikz,border=1.618mm]{standalone} \usepackage{tikz} \usepackage{tikz-3dplot} \usepackage{tikz-cd} \usepackage[]{calc} \begin{document} \tdplotsetmaincoords{80}{0} \begin{tikzpicture}[scale=5,tdplot_main_coords] \coordinate (O) at (0,0,0); \tdplotsetrotatedcoords{90}{90}{0} \tdplotdrawarc[bottom color= gray, top color= gray!40, tdplot_main_coords]{(0,-0.08,0.76604444311)}{0.64278760968}{0}{360}{}{} \tdplotdrawarc[tdplot_rotated_coords]{(O)}{1}{-140.5}{140.5}{}{} \tdplotdrawarc[tdplot_rotated_coords]{(O)}{.25}{0}{360}{}{} \end{tikzpicture} \tdplotsetmaincoords{80}{0} \begin{tikzpicture}[scale=5,tdplot_main_coords] \coordinate (O) at (0,0,0); \tdplotsetrotatedcoords{90}{90}{0} \tdplotdrawarc[tdplot_main_coords,color=blue, dashed]{(0,-0.08,0.76604444311)}{0.64278760968}{0}{180}{}{} \tdplotdrawarc[tdplot_main_coords,color=blue]{(0,-0.08,0.76604444311)}{0.64278760968}{180}{360}{}{} \tdplotdrawarc[tdplot_rotated_coords]{(O)}{1}{-140.5}{140.5}{}{} \tdplotdrawarc[tdplot_rotated_coords]{(O)}{.25}{0}{360}{}{} \tdplotsetrotatedcoords{90}{-90}{0} \tdplotdrawarc[tdplot_rotated_coords, color=blue]{(O)}{1}{-39.5}{39.5}{}{} \end{tikzpicture} \end{document}
- Trouble drawing a staircase tableby Rodrigo on October 17, 2022 at 10:50 pm
I know there are multiple posts on the forum related to staircase tables. Altought, I couldn't find one that fits my idea, mainly because the headers of each row / column are too small for what I want. My desired output is exactly the picture below, but without the vertical lines that aren't being used, i.e., to only have the saircase design (as shown in this post). Thanks for any help in advance.
- Tikz 3D plot of poles zerosby Raja Ali Riaz on September 18, 2021 at 4:43 pm
I need to make a 3D plot in tikz of the form as in the picture. It's the magnitude plot of transfer function H(s)= (s+1)(s+2)/(s+3)(s+1+j)(s+1-j) I am sorry, I have not shared any attempt because I am ignorant in tikz 3d plotting. If somebody provide the solution, it will be kick start for me and then I build up on it. Thanks in advance. My Attempt and still few things to rectify. I have plotted the graph with online help of different resources (code and picture attached). Now the problems are It is not correcting plotting the curve in y-z plane the red line and give this error message Package pgfplots Error: Sorry, you can't use 'y' in this context. PGFPlots expected to sample a line, not a mesh. Please use the [mesh] option combined with [samples y>0] and [domain y!=0:0] to indicate a twodimensional input domain. Labels are too small and not placed properly. If somebody can set view angles so it looks like the picture of the book. If somebody can help in that regard. \documentclass[border=1cm]{standalone} \usepackage{pgfplots} \usetikzlibrary{calc,math} \pgfplotsset{compat=newest} \pgfkeys{/pgf/declare function={H(\x,\y) = 3*((((((\x)^2-(\y)^2+3*(\x)+2)^2+((2*\x*\y)+3*\y)^2)+2.2204e-16)^(1/2))/(((((\x)^3+5*(\x)^2-3*\x*(\y)^2+8*x-5*(\y)^2+6)^2+(3*(\x)^2*y+10*\x*\y-(\y)^3+8*y)^2)+2.2204e-16)^(1/2)));}} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=middle, axis on top, axis equal image, width=50cm, view={30}{10}, xmin=-4, xmax=0, ymin=-2, ymax=2, zmin=0, zmax=5, miter limit=1, xlabel=$\sigma$, xlabel style={anchor=east,xshift=-5pt,at={(xticklabel* cs:.95)}}, ylabel=$j\Omega$, zlabel=$\mathopen| H(s)\mathclose|$, zlabel style={anchor=north east}, xtick = {-3,-2,-1,0}, hide obscured x ticks=false, ytick = {-1,0,1}, ztick = {2,4}, ] \addplot3[ smooth, surf, faceted color=gray, line width=0.1pt, fill=white, domain=-4:0, y domain = -2:2, samples = 50, samples y = 50, restrict z to domain*=0:5] {H(\x,\y)}; \addplot3[domain=-2:2,samples=70, samples y = 0,red, thick] ({0},{x},{H(0,x)}); \end{axis} \end{tikzpicture} \end{document}
- Problem whit TikZ 3D graphby Magform on May 16, 2021 at 2:08 pm
I want to draw a 3D graph in tikz; something like z=x/y, this is the code that I've written: \documentclass[tikz,border=5pt]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} [ title = {Campo in funzione della forza e della carica}, xtick = {-12,-9,...,12}, ytick = {-9,-6,...,12}, xlabel = $\vec{F}$, ylabel = $q$, ticklabel style = {font = \scriptsize}, grid ] \addplot3 [surf, domain=-12:12, samples=50] { x/y }; \end{axis} \end{tikzpicture} \end{document} The problem is that where the graph shouldn't exist anyway it exists, I tried to solve the problem, maybe using asymptote instead of tikz but I still can't draw it.
- Code highlighting drawn under tcolorbox and not displayedby Zoefschildpad on March 10, 2020 at 10:07 am
I am looking to add highlighting to listings. I have tried to adept the techniques given by https://tex.stackexchange.com/users/23765/siracusa in the question Highlight text in code listing while also keeping syntax highlighting However I have run into a problem, which is demonstrated in the example below. I want my listing to be inside a tcolorbox. When it isn't in a tcolorbox, the highlighting works as expected. When it is inside the box, the highlighting is rendered properly and in the right place, but it isn't displayed because the tcolorbox seems to be drawn on top of it. Is there a way to draw the highlighting on top of the box (but still under the text) instead? I would really like to keep the core of the highlighting solution, because it plays really nicely with the listings package. Also note that any solution that involves manually adjustments to individual codeblocks is not an option. Their contents are generated by another program, and there are thousands. \LoadClass[10pt]{book} \RequirePackage{fontspec} \RequirePackage{listings} \RequirePackage{xcolor} \RequirePackage{atbegshi} \RequirePackage{ifthen} \RequirePackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{fit} \RequirePackage[breakable]{tcolorbox} % HIGHLIGHTING \makeatletter \newcommand\if@empty[1]{% \if\relax\detokenize{#1}\relax \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi } \newcommand\ifthen[2]{\ifthenelse{#1}{#2}{}} \newcommand\ifelse[2]{\ifthenelse{#1}{}{#2}} % Is highlighting currently active in the listings environment? \newif\ifhl@active % Material executed at each page shipout \newtoks\hl@shipout % Extra styling parameters for the currently active highlight \newtoks\hl@parameters % Inline highlight style. This does not break across line ends \newcommand\hl[2][]{\begingroup\hlstyle@start{#1}#2\endgroup} % The highlight style for listings environments \newcommand\hlstyle[1][]{\hlstyle@start{#1}} \newcommand\hlstyle@start[1]{% \global\hl@activetrue \aftergroup\hlstyle@end \write\@auxout{\noexpand\hl@setparameters{#1}}% \hl@mark{S}% } \newcommand\hlstyle@end{% \hl@mark{E}% \global\hl@activefalse } % Sets the current highlight parameters \newcommand\hl@setparameters[1]{% \global\hl@parameters={#1}% } % Writes a new node marker with the current position and page number to the .aux file \newcommand\hl@mark[1]{% \ensuremath{\vcenter{\hbox{\pdfsavepos}}}% \write\@auxout{\noexpand\hl@processmark{#1}{\the\pdflastxpos}{\the\pdflastypos}{\arabic{page}}}% } % Writes the current page origin to the .aux file, and issues the current \hl@shipout material % to be processed \AtBeginShipout{\AtBeginShipoutUpperLeft{% \pdfsavepos \write\@auxout{\noexpand\hl@processmark{Z}{\the\pdflastxpos}{\the\pdflastypos}{\arabic{page}}}% \hl@doshipout }} % Maintains the current first and last node positions, checks whether a node marker should be used % for the current highlighting segment, and issues a \hl@draw call if necessary. % #1 is either 'S' (start node), 'M' (intermediate node), 'E' (end node), or 'Z' (page origin) % #2/#3 are the x/y-coordinates, #4 is the page number \newcommand\hl@processmark[4]{% \if#1S% \xdef\hl@firstx{#2}% \xdef\hl@firsty{#3}% \xdef\hl@firstp{#4}% \else\if#1M% \ifthenelse{\hl@firsty=#3}{% % Still on same line \xdef\hl@lastx{#2}% \xdef\hl@lasty{#3}% }{% \ifelse{\hl@firstx=\hl@lastx \and \hl@firsty=\hl@lasty}{% % Last highlight part is not empty \expandafter\hl@draw\expandafter{\the\hl@parameters}% }% \xdef\hl@firstx{#2}% \xdef\hl@firsty{#3}% \xdef\hl@firstp{#4}% }% \else\if#1E% \ifthen{\hl@firsty=#3}{% % Still on same line \xdef\hl@lastx{#2}% \xdef\hl@lasty{#3}% \ifelse{\hl@firstx=#2}{% % Last highlight part is not empty \expandafter\hl@draw\expandafter{\the\hl@parameters}% }% }% \else\if#1Z% \xdef\hl@zerox{#2}% \xdef\hl@zeroy{#3}% \fi\fi\fi\fi } % Add a new highlight segment to \hl@shipout to be processed on every shipout. % #1 is the styling command used to draw the segment within a properly positioned \tikz call. % If #1 is empty, \hldefaultstyle is used as a default. Every styling command can take % arbitrary parameters, only the last four are mandatory (x_first, y_first, x_last, y_last) \newcommand\hl@draw[1]{% \edef\@temp{{\noexpand\tikz [ overlay, shift = {(-\hl@zerox sp, -\hl@zeroy sp)} ] {\if@empty{#1}{\noexpand\hldefaultstyle}{\unexpanded{#1}}% {\hl@firstx sp}{\hl@firsty sp}{\hl@lastx sp}{\hl@lasty sp}}}% {\hl@firstp}% }% \expandafter\global\expandafter\addto@hook\expandafter\hl@shipout\expandafter{\@temp}% } % Processes the current \hl@shipout material. The material is a sequence of % {TikZ commands}{page number} pairs \def\hl@doshipout{% \expandafter\hl@doshipout@\the\hl@shipout{}{}\@end } \def\hl@doshipout@#1#2#3\@end{% \if@empty{#2}{}{% \ifthen{\arabic{page}=#2}{#1}% \hl@doshipout@#3\@end }% } % Hook into listings' discretionary breaks \let\orig@lst@discretionary=\lst@discretionary \gdef\lst@discretionary{% \ifhl@active \hl@mark{M}% \fi \orig@lst@discretionary \ifhl@active \hl@mark{M}% \fi } % Styling command for a simple marker highlights \newcommand\hlmarkerstyle[5][yellow]{% \draw [ line width = \baselineskip, #1 ] (#2, #3) -- (#4, #5); } % Default styling command \let\hldefaultstyle=\hlmarkerstyle \makeatother \newcommand\delimstyleB{\hlstyle} %ENDHIGHLIGHTING %% Define custom verbatim as listing allowing background color and mark notation \let\verbatim\someundefinedcommand \lstnewenvironment{CustomVerbatim}[1][name=main] { \lstset{ basicstyle=\fontsize{8}{8}\ttfamily, moredelim=**[is][\delimstyleB]{`}{`}, aboveskip=3mm, breaklines=true, breakatwhitespace=false, keepspaces=true, extendedchars=true, xleftmargin=8pt, xrightmargin=8pt, framextopmargin=3pt, framexbottommargin=3pt, frame=tb, framerule=0pt, escapeinside={¬}{¬}, postbreak=\mbox{\textcolor{blue}{$\hookrightarrow$}\space}, #1 } } {} \newtcolorbox{codebox}[1][] { #1, breakable, size=fbox, arc=0mm, colback=red, colframe=red, } \begin{document} \begin{codebox}\begin{CustomVerbatim}% The text of this `codeblock should be partially highlighted. However, the red box is blocking the highlighting.` \end{CustomVerbatim}\end{codebox} \begin{CustomVerbatim}% The text of `this codeblock is properly partially highlighted, even across multiple lines because it` isn't in a tcolorbox \end{CustomVerbatim} \end{document}
- Tikz pictures inside Tikz pictures: typesetting failing in lattice subgraph with edgesby hhh on April 16, 2016 at 11:29 am
I define Tikz pictures within each other. The typesetting fails in a way that the edges are not drawn properly: the edges are not drawn from the centers of vertices in the lattice subgraph structure, instead on the side of the vertices like below and the lattice subgraph structure is in 2. MWE while simplified example without the issue in 1. MWE: the issue somehow occurs only when having many tikz environments. 1. MWE draws the edges nicely between the centers of vertices \begin{tikzpicture} \tikzstyle{every node}=[draw, circle, fill=black, inner sep=4pt,minimum size=3pt] \draw (0,0)node{}; \draw (1,0)node{}; \draw (0.5,1)node{}; \draw (0,0)--(1,0); \end{tikzpicture} 2. MWE not drawing the edges nicely between the centers of vertices, why? \begin{tikzpicture}[scale=1.2] \tikzstyle{every node}=[draw, circle] \node(0) { \begin{tikzpicture} \tikzstyle{every node}=[draw, circle, fill=black, inner sep=0pt,minimum size=3pt] \draw (0,0)node{}; \draw (1,0)node{}; \draw (0.5,1)node{}; \end{tikzpicture} }; \node[above =of 0](1){ \begin{tikzpicture} \tikzstyle{every node}=[draw, circle, fill=black, inner sep=1pt,minimum size=3pt] \draw (0,0)node{} -- (1,0)node{}; \draw (0.5,1)node{}; \end{tikzpicture} }; \node[above right =of 1](21){ \begin{tikzpicture} \tikzstyle{every node}=[draw, circle, fill=black, inner sep=1pt,minimum size=3pt] \draw (0,0)node{} -- (1,0)node{} -- (0.5,1)node{}; \end{tikzpicture} }; \node[above left =of 1](22){ \begin{tikzpicture} \tikzstyle{every node}=[draw, circle, fill=black, inner sep=1pt,minimum size=3pt] \draw (0,0)node{} -- (0.5,1)node{} -- (1,0)node{}; \end{tikzpicture} }; \node[above left =of 21](30){ \begin{tikzpicture} \tikzstyle{every node}=[draw, circle, fill=black, inner sep=1pt,minimum size=3pt] \draw (0,0)node{} -- (1,0)node{} -- (0.5,1)node{}; \draw (0,0)node{} -- (0.5,1)node{}; \end{tikzpicture} }; \draw (0) -- (1); \draw (1) -- (21); \draw (1) -- (22); \draw (21) -- (30); \draw (22) -- (30); %\draw (21) -- (31); %\draw (21) -- (32); %\draw (21) -- (33); %\draw (31) -- (41); %\draw (31) -- (42); %\draw (32) -- (42); %\draw (33) -- (41); %\draw (22) -- (32); \end{tikzpicture} where the lattice subgraph picture has the failed typesetting, the edges not drawn between the centers. So How to draw edges properly from the centers of vertices in the lattice subgraph with many tikz environments? Perhaps relevant Nesting tikz pictures Joining different TikZ pictures What are most important variables set at the beginning of a tikzpicture? of a scope?
- Sphere Intersection using Tikzby Relative0 on November 14, 2015 at 10:42 pm
I found this example here of two intersecting spheres, have reproduced a couple Tikz spheres that I found here which is the code below. I however would like to know how to get these two spheres to intersect - but also to embed them in/draw a larger sphere around both that is just big enough in the XY plane to house the two. I am thinking more general - that somehow maybe I could just create a general "Sphere" and instantiate 3 spheres of different sizes and move them around until they look correct. That might be the good way to go. Thanks for your insights. \documentclass[tikz,border=10pt]{standalone} \usepackage{tikz-3dplot} \begin{document} \tdplotsetmaincoords{55}{5} \begin{tikzpicture} [scale=3,tdplot_main_coords,curve/.style={black}] \coordinate (O) at (0,0,0); \foreach \angle in {-90,-75,...,90} { %calculate the sine and cosine of the angle \tdplotsinandcos{\sintheta}{\costheta}{\angle}% %define a point along the z-axis through which to draw %a circle in the xy-plane \coordinate (P) at (0,0,\sintheta); %draw the circle in the main frame \tdplotdrawarc[curve]{(P)}{\costheta}{0}{360}{}{} %define the rotated coordinate frame based on the angle %\tdplotsetthetaplanecoords{\angle} %draw the circle in the rotated frame %\tdplotdrawarc[curve,tdplot_rotated_coords]{(O)}{1}{0}{360}{}{} } \end{tikzpicture} \tdplotsetmaincoords{30}{5} \begin{tikzpicture} [scale=2, tdplot_main_coords, curve/.style={black}] \coordinate (O) at (-130,0,0); \foreach \angle in {-90,-75,...,90} { %calculate the sine and cosine of the angle \tdplotsinandcos{\sintheta}{\costheta}{\angle}% %define a point along the z-axis through which to draw %a circle in the xy-plane \coordinate (P) at (0,0,\sintheta); %draw the circle in the main frame \tdplotdrawarc[curve]{(P)}{\costheta}{0}{360}{}{} %define the rotated coordinate frame based on the angle %\tdplotsetthetaplanecoords{\angle} %draw the circle in the rotated frame %\tdplotdrawarc[curve,tdplot_rotated_coords]{(O)}{1}{0}{360}{}{} } \end{tikzpicture} \end{document}
- Spiral on a truncated coneby Dinis Nunes on September 1, 2015 at 2:33 pm
I need to plot a spiral around an inverted truncated cone, starting and ending at the centre of both bases. Something like this: I've searched and found a similar solution, but for cylinders only: Helix on a cylinder I couldn't adapt it to my geometric shape in question, so any help would be appreciated. The code for the cone only: \documentclass[border=0.125cm]{standalone} \usepackage{tikz} \usetikzlibrary{3d,calc} \begin{document} \begin{tikzpicture} \draw (-1,0) arc (180:370:2cm and 1cm); \draw (-1,0) arc (180:10:2cm and 1cm); \draw (0,-3) arc (180:360:1cm and 0.5cm); \draw[dashed] (0,-3) arc (180:0:1cm and 0.5cm); \draw(0,-3) -- (-0.97,-0.18); \draw(2,-3) -- (2.97,-0.18); \shade[left color=blue!5!white,right color=blue!60!white,opacity=0.3] (-0.97,-0.18) arc (190:350:2 and 1) -- (2,-3) arc (360:180:1cm and 0.5cm) -- cycle; \shade[left color=blue!5!white,right color=blue!60!white,opacity=0.3] (1,0) ellipse (2cm and 1cm); \draw[dashed] (0.7,-3) arc (180:0:0.3cm and 0.15cm); \draw[dashed] (0.7,-3) arc (180:360:0.3cm and 0.15cm); \end{tikzpicture} \end{document} Thanks in advance, Dinis Nunes EDIT: Following Ignasi suggestion, I've added a spiral function, but my goal was making the line follow closely the wall of the cone. Code: \node[xshift=1cm,yshift=-3cm] (dummy) {}; \draw[densely dotted,scale=0.09,variable=\x,shift=(dummy)] plot[domain = 0:10*pi, samples = 400] ({\x*0.6*sin(0.3*pi*deg(\x))},{\x},{\x*0.6*cos(0.3*pi*deg(\x)});
- draw round/rectangular bracket embracing nodes in tikzby Jack Cheng on September 30, 2014 at 3:57 am
I know how to draw a curly bracket with the following code: \draw[decorate,decoration={brace,amplitude=5},-] (0.8,-0.75) -- (0.8,0.75); But now I want to draw a round bracket, or a rectangular one. Can anyone tell how can I do this? Is it possible to do this by changing "brace" to some other values? The result should look like: (some pictures) but not {some pictures}
- How can I draw a 3D, three-sided 5-7-9 triangle with TikZ or PSTricks?by minthao_2011 on March 29, 2014 at 11:23 pm
I want to draw a triangle with three sides 5, 7, 9 and its incircle in geometry 3D. I used GeospacW. I tried Draw a circle (T) has center origin and has radius r=15/sqrt(11). Take a point A on (T) and draw a circle (C1) has center A and has radius r=5. Find the intersection of points between (T) and (C1), say one of them is B. Draw a circle (C2) has center B and has radius 7. Find the intersection of points between (T) and (C2), say one of them is C. Draw the triangle ABC and its incircle. After drawing the triangle, I draw a pyramid DABC with DC perpendicular to the plane (ABC) and DC=\sqrt{33}/2.
- Rectangles around cells in tableby James on October 23, 2013 at 6:48 am
I asked a question here but, rather stupidly, added extra information after it had been answered. My additional question is this: I have a table with varying lengths of words. I want to encircle different groups of cells, including diagonals. If possible, it would be great if the rectangles don't overlap each other where possible. I looked at the answer here, which, whilst tedious, worked except for the overlap. This is where I've got to so far: \documentclass[fleqn,12pt,a4paper,landscape]{article} \usepackage{tikz} \usepackage{tabularx} \begin{document} % Introduce a new counter for counting the nodes needed for circling \newcounter{nodecount} % Command for making a new node and naming it according to the nodecount counter \newcommand\tabnode[1]{\addtocounter{nodecount}{1} \tikz \node (\arabic{nodecount}) {#1};} % Some options common to all the nodes and paths \tikzstyle{every picture}+=[remember picture,baseline] \tikzstyle{every node}+=[inner sep=0pt,anchor=base, minimum width=1.8cm,align=center,text depth=.25ex,outer sep=1.5pt] \tikzstyle{every path}+=[thick, rounded corners] \begin{table}[ht] \begin{minipage}[b]{1 \linewidth}\centering \begin{tabular}{cccccc} % Turn the cells needed for defining the circling paths into nodes with our custom command \tabnode{Long ago}& \tabnode{A few days ago}& \tabnode{Day before yesterday}& \tabnode{Yesterday} & & \\ & & & & \tabnode{Today} & \tabnode{Now}\\ \tabnode{Long time in the future}& \tabnode{A few days on}& \tabnode{Day after tomorrow}& \tabnode{Tomorrow} & & \\ \end{tabular} \end{minipage} \begin{tikzpicture}[overlay] % Define the circle paths \draw [blue](1.north west) -- (1.north east) -| (7.north east) |- (7.south west) |- (1.north west); \draw [red](8.south west) -| (2.north east) -| (2.south west) |- (8.south west); \draw [yellow](9.south west) -| (3.north east) -| (3.south west) |- (9.south west); \draw [green](8.south west) -| (3.north east) -| (2.south west) |- (8.south west); \end{tikzpicture} \end{table} \end{document} %%% Local Variables: %%% mode: latex %%% TeX-master: t %%% End:
- Manual/automatic line breaks and text alignment in TikZ nodesby Jake on July 11, 2013 at 11:04 pm
How can I insert a line break in a TikZ node? Simply putting \\ where I want the break doesn't work (see MWE). Is there a way to make lines break automatically at some specified width? And can I control the alignment of the text (left, right, centered, justified)? \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node {First line\\second line}; \end{tikzpicture} \end{document}
- Creating a staircase shaped tableauby utdiscant on September 16, 2012 at 11:37 pm
I want to create a tableau of vectors in LaTeX, like the one seen on Slide 7 in these slides. But unlike in the slides, I want to have vectors like the one given by the code below \begin{pmatrix} 1\\ 0\\ -1 \end{pmatrix} placed inside the cells. Is there an elegant way to do this, using either TikZ or tables?
- 3D bodies in TikZby azetina on January 30, 2012 at 4:35 pm
Is there like a library that has default geometric figures like the ones shown below. Am not acquainted yet with 3D diagrams in TikZ.