• Elegant Visualizations for Volumes of Revolution in Calculus II Notes
    by Ahed on March 15, 2026 at 5:14 pm

    I’m preparing handwritten-style notes for my Calculus II class (topics like disk/washer method, shell method, etc.), and I would like to include nice visualizations of solids of revolution. Does anyone have suggestions for elegant ways to present volumes of revolution in lecture notes? For example: good diagrams or visualization tools, LaTeX/TikZ packages, Python/Matlab plots, interactive graphics (GeoGebra, Desmos, etc.). My goal is to make the geometry of the solid very clear for students (cross-sections, rotation around the axis, comparison of disk vs washer vs shell). Any suggestions or examples would be greatly appreciated. Thank you!

  • Drawing distorted circle
    by Miguel Forteza on March 14, 2026 at 12:14 pm

    I was trying to copy this figure (from Elementary Classic Analysis Marsden Hoffman): And I don't know how. I've already seen various posts about a distorted circles where they drawed it randomly and I tried it but the result I get it's not quite like I want. I want like it's a sketch of a set I could have drawn (like the picture), but I get a circle "that has random noise". I know that making figures can be hard (at least for me) so if someone could just give me some indications I'd be really grateful.

  • Comparing scope with on background layer versus pgfonlayer
    by D G on March 14, 2026 at 5:54 am

    I don't understand why the scope with on background layer option \begin{scope}{on background layer} \clip (bb.south west) rectangle (bb.north east) {[rotate=\myrot] (P) -- (Q) -- (R) -- (S) -- cycle}; \fill[lightgray!50] (bb.south west) rectangle (bb.north east); \end{scope} produces different result compared to the pgfonlayer. \begin{pgfonlayer}{background} \clip (bb.south west) rectangle (bb.north east) {[rotate=\myrot] (P) -- (Q) -- (R) -- (S) -- cycle}; \fill[lightgray!50] (bb.south west) rectangle (bb.north east); \end{pgfonlayer} Minimal Working Example \documentclass[tikz, border=1cm]{standalone} \usetikzlibrary{backgrounds} \begin{document} \begin{tikzpicture}[line width=2pt, dot/.style 2 args={circle,fill,inner sep=1pt, label={[black,transform shape=true]#1:{$#2$}}} ] \def\myrot{-45} \begin{scope}[rotate=\myrot,local bounding box=bb] \draw (0, 0) coordinate (P) -- ++(4, 0) coordinate (Q) -- ++(0, 3) coordinate (R) -- ++(-4, 0) coordinate (S) -- cycle; \path foreach \p/\d in {P/45,Q/135,R/-135,S/-45} {(\p)coordinate[dot={\d}{\p}]}; \end{scope} \def\selector{0}% odd for scoped on background layer, otherwise for pgfonlayer. \ifodd\selector \begin{scope}{on background layer} \else \begin{pgfonlayer}{background} \fi \clip (bb.south west) rectangle (bb.north east) {[rotate=\myrot] (P) -- (Q) -- (R) -- (S) -- cycle}; \fill[lightgray!50] (bb.south west) rectangle (bb.north east); \ifodd\selector \end{scope} \else \end{pgfonlayer} \fi \draw (bb.south west) rectangle (bb.north east); \end{tikzpicture} \end{document}

  • Trig label Issues on Graph
    by Nick B on March 13, 2026 at 1:07 pm

    I am trying to recreate this picture from the College Board. I am able to recreate the image with the x-axis labeled in fourths (pi). However, the original shows each label being 1/8 (pi). Each time I try to use specific xtick and xlabel, the spacing is incorrect. Is there an easier way I can do this? Here is my code: \documentclass[12pt]{article} \usepackage{fullpage,parskip,pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=middle, axis equal, clip=false, enlargelimits=false, xlabel={\(x\)}, ylabel={\(y\)}, title={Graph of \(f\)}, grid=major, grid style={black!75}, xmin=-2*pi/3,xmax=13*pi/6, ymin=-5,ymax=4, xtick={-0.75*pi, -0.5*pi, -0.25*pi, 0, 0.25*pi, 0.5*pi, 0.75*pi, pi, 1.25*pi, 1.5*pi, 1.75*pi, 2*pi, 2.25*pi}, xticklabels={, $-\frac{\pi}{2}$, , , , $\frac{\pi}{2}$, , $\pi$, , $\frac{3\pi}{2}$, , $2\pi$, }, ytick={-5, -4, -3, -2, -1, 0, 1, 2, 3, 4}, yticklabels={\(-5\), , \(-3\), , \(-1\), , \(1\), , \(3\)}, title style={ font=\Large, anchor=north, at={(rel axis cs: 0.5,0)}, yshift=-3mm, }, ticklabel style={fill=white}, axis line style={ thick,-{Triangle[length=3mm,width=2mm]},shorten >=-4mm,}, ticklabel style={fill=white, inner sep=1pt, font=\normalsize}, ] \addplot[samples=100,thick,domain=-2.09:6.54]{3*sin(deg(2*x-pi/2))}; \end{axis} \end{tikzpicture} \end{document} Any help would be appreciated. TYA

  • Drawing a Manifold in tikz
    by Hassium on March 12, 2026 at 8:21 pm

    I am trying to draw a manifold using tikz. The best way I can think of is to give several points and generates smooth lines connecting those points. Here is my draft: \documentclass{article} \usepackage{amsmath,amssymb,amsthm} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[thick] plot [smooth cycle, tension=1] coordinates { (-2.5,0) (-1.6,1) (0,0.55) (1.6,1) (2.5,0) (1.6,-1) (0,-0.55) (-1.6,-1) }; \draw[thick] (-1.85, -0.05) to[out=-30, in=210] (-0.95, -0.05); \draw[thick] (-1.7, -0.1) to[out=45, in=135] (-1.1, -0.1); \end{tikzpicture} \end{document} The lines are not very smooth. Is there a way to make the lines more smooth? Or is there a better strategy to draw this? Thanks in advance.

  • How to create lines perfectly lie on a circle shape with TikZ?
    by user516076 on March 12, 2026 at 6:49 am

    It's very difficult to make a perfect line that lies on exact circle. This is my full work: \documentclass[tikz,border=1pt]{standalone} \usepackage{tikz} \usepackage{calligra} \usepackage[T1]{fontenc} \begin{document} \begin{tikzpicture}[line width=1pt] \path[use as bounding box] (-5.6,-1.2) rectangle (6.4,7.2); % Circle \draw (2.6,3.0) circle (3.1); % Secant line P-T-U \draw (-5.0,0.1) -- (4.7,5.6); % Chords \draw (2.6,2.3) -- (1.2,1.7); % short chord near S \draw (1.2,1.7) -- (4.0,1.4); % S to V \draw (4.0,1.4) -- (4.7,5.6); % V to U % Angle at S \draw (1.2,1.7) ++(0.55,0) arc[start angle=0,end angle=123,radius=0.55]; % Angle at V \draw (4.0,1.4) ++(-0.55,0) arc[start angle=180,end angle=95,radius=0.55]; % Labels \node[font=\fontsize{34}{34}\selectfont] at (-5.0,-0.4) {$P$}; \node[font=\fontsize{34}{34}\selectfont] at (0.2,2.9) {$T$}; \node[font=\fontsize{34}{34}\selectfont] at (5.2,5.9) {$U$}; \node[font=\fontsize{34}{34}\selectfont] at (4.3,0.4) {$V$}; \node[font=\fontsize{34}{34}\selectfont] at (0.9,0.7) {$S$}; % Angle labels \node[font=\fontsize{28}{28}\selectfont] at (2.0,2.5) {$123^\circ$}; \node[font=\fontsize{28}{28}\selectfont] at (3.6,2.0) {$85^\circ$}; \end{tikzpicture} \end{document} and this is the result: What I want: Please along with full MWE ready to copy paste, could you explain, what the trick is and what to add and where to add, so that I can also learn? T.I.A.

  • how to trim inside TikZ?
    by user516076 on March 12, 2026 at 1:13 am

    MWE: \documentclass[tikz,border=1pt]{standalone} \usepackage{tikz} \usepackage{calligra} \usepackage[T1]{fontenc} \begin{document} \begin{tikzpicture}[line width=1pt] % \path[use as bounding box] (1,0) rectangle (12,7); % Outer rectangle \draw (0,0) rectangle (12,7); % Curvy E outside the box \node[anchor=center, font=\calligra\fontsize{38}{38}\selectfont] at (-1.5,6.75) {E}; % Left circle \draw (4.0,3.4) circle (2.75); % Right circle \draw (8.25,3.45) circle (2.2); % Labels \node[font=\fontsize{28}{28}\selectfont] at (1.8,5.8) {$P$}; \node[font=\fontsize{28}{28}\selectfont] at (9.4,5.9) {$Q$}; \end{tikzpicture} \end{document} This gives me this picture: There, you see a white space on the left that needs to be trimmed. My best knowledge is using: \path[use as bounding box] (1,0) rectangle (12,7); but it gives me: I want to control it like 1pt or 2pt or 1cm, 2cm to mean that I trim that much. How to do that? I tried to control (1,0), but it doesn't work as I expected. Also, if possible, I don't want to crop it outside, like using \includegraphs and trim it. It is saving time to trim it inside the TikZ, IMHO.

  • Fail to replicate a sloped node with label node
    by D G on March 10, 2026 at 8:13 am

    I want to replicate the black label with the red label created with label node. \documentclass[tikz,border=1cm,12pt]{standalone} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \draw (0,0) -- ++ ({sqrt(3)},{sqrt(11)}) node[pos=1/3,circle,fill,inner sep=1pt]{} % dot node[pos=1/3,label={[red,rotate={atan(sqrt(11/3))}]above:above}]{} % how can we make this label node[pos=1/3,above,sloped]{above}; % coincide with this label? \end{tikzpicture} \end{document} What am I missing here?

  • How to include standalone Tikz figure ready to move around in the main document without moving macros to the Main Document?
    by user516076 on March 10, 2026 at 12:27 am

    What I meant to ask is currently I have this Tikz: \documentclass[tikz,border=6pt]{standalone} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture}[line join=round, line cap=round] \newcommand{\singletick}[4]{% \path (#1) -- (#2) coordinate[pos=#3] (tickpos); \pgfmathanglebetweenpoints {\pgfpointanchor{#1}{center}} {\pgfpointanchor{#2}{center}} \let\ang\pgfmathresult \begin{scope}[shift={(tickpos)}, rotate=\ang+90] \draw[line width=0.8pt] (-#4,0) -- (#4,0); \end{scope} } \newcommand{\doubletick}[5]{% \path (#1) -- (#2) coordinate[pos=#3] (tickpos); \pgfmathanglebetweenpoints {\pgfpointanchor{#1}{center}} {\pgfpointanchor{#2}{center}} \let\ang\pgfmathresult \begin{scope}[shift={(tickpos)}, rotate=\ang+90] \draw[line width=0.8pt] (-#5,-#4) -- (#5,-#4); \draw[line width=0.8pt] (-#5, #4) -- (#5, #4); \end{scope} } \coordinate (A1) at (0,2.2); \coordinate (B1) at (3.2,5.7); \coordinate (C1) at (6.2,2.2); \coordinate (D1) at (3.2,-2.8); \fill[cyan!60] (A1)--(B1)--(C1)--(D1)--cycle; \draw[line width=1pt] (A1)--(B1)--(C1)--(D1)--cycle; \draw[line width=1pt] (B1)--(D1); \doubletick{A1}{B1}{0.47}{0.08}{0.12} \doubletick{B1}{C1}{0.47}{0.08}{0.12} \singletick{A1}{D1}{0.52}{0.12} \singletick{D1}{C1}{0.52}{0.12} \node[left,font=\LARGE] at (A1) {$A$}; \node[above,font=\LARGE] at (B1) {$B$}; \node[right,font=\LARGE] at (C1) {$C$}; \node[below,font=\LARGE] at (D1) {$D$}; \node[left,font=\LARGE] at (1.2,4.1) {$4\ \mathrm{cm}$}; \node[left,font=\LARGE] at (1,0.2) {$6\ \mathrm{cm}$}; \node[right,font=\LARGE] at (3.2,1.5) {$10\ \mathrm{cm}$}; \begin{scope}[shift={(-1.2cm,0)}] \coordinate (A2) at (8.8,1.4); \coordinate (B2) at (10.7,3.7); \coordinate (C2) at (12.5,1.4); \coordinate (D2) at (10.7,-1.8); \fill[cyan!60] (A2)--(B2)--(C2)--(D2)--cycle; \draw[line width=1pt] (A2)--(B2)--(C2)--(D2)--cycle; \draw[line width=1pt] (B2)--(D2); \doubletick{A2}{B2}{0.50}{0.07}{0.10} \doubletick{B2}{C2}{0.50}{0.07}{0.10} \singletick{A2}{D2}{0.53}{0.10} \singletick{D2}{C2}{0.53}{0.10} \node[left,font=\LARGE] at (A2) {$A$}; \node[above,font=\LARGE] at (B2) {$B$}; \node[right,font=\LARGE] at (C2) {$C$}; \node[below,font=\LARGE] at (D2) {$D$}; \node[font=\LARGE] at (10.9,1.0) {$b\ \mathrm{cm}$}; \node[right,font=\LARGE] at (12.0,2.8) {$2\ \mathrm{cm}$}; \node[right,font=\LARGE] at (11.5,-0.7) {$a\ \mathrm{cm}$}; \end{scope} \end{tikzpicture} \end{document} Suppose this is the main document: \documentclass[twoside]{article} \begin{document} \section{Introduction} Hello LaTeX %I want to add the figure here \end{document} I wish the figure within the article would be moveable by coordinate and any built-ins like h, t, b, p (Please teach me both, as to how to use them). By coordinate, if it's possible, I want something like (a, b). Or perhaps you have a better way to move the figure freely, please add it to your answer. I don't know where to start and what package I would need, if I need one. Also to make the main document to be cleaner, I don't want any macros from the Tikz. So just leave it there, but include them all. How to do that? T.I.A.

  • Fail to produce an octagon by repeating -- ([turn]45:{sqrt(2)}) 8 times with foreach [duplicate]
    by D G on March 9, 2026 at 3:58 pm

    The expected output is shown in the first two. \documentclass[tikz,border=1cm]{standalone} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \draw (0,0) foreach \a in {0,1,...,6}{-- ++({45*\a}:{sqrt(2)})} -- cycle; \end{tikzpicture} \begin{tikzpicture} \draw (0,0) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- cycle; \end{tikzpicture} \begin{tikzpicture} \draw (0,0) foreach \i in {0,...,6} {-- ([turn]45:{sqrt(2)})} -- cycle; \end{tikzpicture} \end{document} Why doesn't the last one produce the expected output?

  • Porting aligncolsatbottom.sty to TeX Live 2022+
    by ke. on March 9, 2026 at 1:22 pm

    I'm using this template to produce posters with columns that are aligned at the bottom. It seems to be based on this solution by Chris Le Sueur. My problem is that it works with Tex Live 2021, but not with 2022 and up. Here is a minimal example: simple-poster.tex \documentclass[a0paper,portrait,margin=0pt, colspace=24pt,subcolspace=0pt,blockverticalspace=36pt,innermargin=50pt]{tikzposter} \usepackage{lipsum} % Random Text \usepackage[colalign]{aligncolsatbottom} %To align columns at bottom (!! please run 2 times) \title{The Best Title Ever} \author{First Author\textsuperscript{1}, \underline{Presenting Author}\textsuperscript{1,2}, Second Author\textsuperscript{2}} \institute{ \textsuperscript{1}Your primary affiliation, City, Country.\\ \textsuperscript{2}Another affiliation, City, Country.} %.............................................................................................................................................................................................. \begin{document} % % % HEAD % %.................................................................................... % % Title % \maketitle[width=0.96\linewidth,titletoblockverticalspace=36pt,linewidth=0,roundedcorners=10] %.............................................................................................................................................................................................. % % LEFT COLUMN % \begin{columns} \column{0.5} %.................................................................................... % % Block % \block[titleleft,roundedcorners=16]{Introduction}{ \raggedright \lipsum[4] } %.............................................................................................................................................................................................. % % RIGHT COLUMN % \column{0.5} %.................................................................................... % % Block % \block[titleleft,roundedcorners=16]{Another Block}{ \raggedright \lipsum[13] } \end{columns} \end{document} aligncolsatbottom.sty \usepackage{letltxmacro} \usepackage{ifthen} \newif\ifmy@colalign \my@colalignfalse \DeclareOption{colalign}{ \my@colaligntrue } \ProcessOptions\relax \ifmy@colalign % Align the bottoms of columns % Declarations \newcounter{my@column} \newcounter{my@column@loop} \newcounter{my@block} \newdimen\my@columnextraspace \newdimen\my@maxcolheight \newdimen\my@colheight \newdimen\my@blocktopstart \newdimen\my@rounded % Store the natural height and number of blocks of the current column in the aux file \gdef\my@storecolheight{ \ifnum\value{my@column} > 0 % \expandafter\newdimen\csname my@colheight\alph{my@column}\endcsname \expandafter\setlength\csname my@colheight\alph{my@column}\endcsname{\my@colheight} \immediate\write\@auxout{\noexpand\newlabel{my@colheight\alph{my@column}}{{\the\my@colheight}{}}} \immediate\write\@auxout{\noexpand\newlabel{my@numblocks\alph{my@column}}{{\the\c@my@block}}} \fi } \LetLtxMacro{\orig@block}{\block} % Replace the \block command with a version that pads each block by \my@columnextraspace \renewcommand{\block}[3][]{% \ifTP@columnEnvironment \my@blocktopstart=0pt\relax \advance\my@blocktopstart-\TP@blocktop \fi \orig@block[{#1}]{#2}{\vspace*{-0.5\my@columnextraspace}#3\vspace*{-0.5\my@columnextraspace}} \ifTP@columnEnvironment % count number of blocks \stepcounter{my@block} % keep track of the height of the current column \advance\my@blocktopstart\TP@blocktop \advance\my@colheight\my@blocktopstart % don't add the padding to the height \advance\my@colheight-\my@columnextraspace \fi } % Store the maximum natural height of any column in the aux file \gdef\my@storemaxcolheight{ \ifnum\value{my@column} > 0 % \newdimen\my@maxcolheight \newdimen\my@colheight@loop \setcounter{my@column@loop}{0} \loop\ifnum\value{my@column@loop}<\value{my@column} \stepcounter{my@column@loop} \my@colheight@loop\csname my@colheight\alph{my@column@loop}\endcsname \ifnum\my@colheight@loop<\my@maxcolheight \my@maxcolheight\my@colheight@loop \fi \repeat \immediate\write\@auxout{\noexpand\newlabel{my@maxcolheight}{{\the\my@maxcolheight}{}}} \fi } % Read the column height information and calculate how much extra space the current column needs per block \gdef\my@calcextraspace{ \@ifundefined{r@my@maxcolheight}{% \my@columnextraspace=0pt\relax }{% \expandafter\my@maxcolheight\ref{my@maxcolheight} \expandafter\my@colheight\ref{my@colheight\alph{my@column}} \setcounter{my@block}{\ref{my@numblocks\alph{my@column}}} \my@columnextraspace\my@maxcolheight \advance\my@columnextraspace-\my@colheight \divide\my@columnextraspace by \value{my@block} } } % Replace \column command by a version which stores the height (of the previous column) and calls \my@calcextraspace \gdef\column#1{ % #1: relative width \ifTP@columnEnvironment \my@storecolheight \stepcounter{my@column} \my@calcextraspace \setcounter{my@block}{0} \my@blocktopstart0pt \my@colheight0pt % Now the normal \column command \normalsize \setlength{\TP@blocktop}{\TP@coltop} \setlength{\TP@colcenter}{\TP@colcenter+0.5\colwidth+\TP@colspace} \setlength{\colwidth}{#1\TP@visibletextwidth+#1\TP@colspace-\TP@colspace-\blocklinewidth} \setlength{\TP@colcenter}{\TP@colcenter+0.5\colwidth+\blocklinewidth} \fi } % Replace the columns environment with a version which stores the height of the final column and the max column \renewenvironment{columns}{ \TP@columnEnvironmenttrue \setlength{\TP@colcenter}{-0.5\TP@visibletextwidth-\TP@colspace-0.5\blocklinewidth} \global\TP@colcenter=\TP@colcenter \global\TP@coltop=\TP@blocktop \global\TP@colbottom=\TP@blocktop \colwidth=0pt }{ \my@storecolheight \my@storemaxcolheight \TP@columnEnvironmentfalse \global\TP@blocktop=\TP@colbottom } \fi With TeX Live 2021, this works and aligns the columns. With TeX Live 2022 and up, on the second run of pdflatex, I get this error: ! Missing number, treated as zero. <to be read again> \xparse function is not expandable l.29 \column{0.5} I don't understand what this means, but maybe something in the redefinition of \column in aligncolsatbottom.sty needs to be adjusted? I quote it here: % Replace \column command by a version which stores the height (of the previous column) and calls \my@calcextraspace \gdef\column#1{ % #1: relative width \ifTP@columnEnvironment \my@storecolheight \stepcounter{my@column} \my@calcextraspace \setcounter{my@block}{0} \my@blocktopstart0pt \my@colheight0pt % Now the normal \column command \normalsize \setlength{\TP@blocktop}{\TP@coltop} \setlength{\TP@colcenter}{\TP@colcenter+0.5\colwidth+\TP@colspace} \setlength{\colwidth}{#1\TP@visibletextwidth+#1\TP@colspace-\TP@colspace-\blocklinewidth} \setlength{\TP@colcenter}{\TP@colcenter+0.5\colwidth+\blocklinewidth} \fi } If I comment out this part: \my@storecolheight \stepcounter{my@column} \my@calcextraspace \setcounter{my@block}{0} \my@blocktopstart0pt \my@colheight0pt then it compiles - but doesn't align the columns, obviously.

  • Producing an Elliptical Ring of Images
    by DDS on March 8, 2026 at 8:34 pm

    Consider the code: \documentclass{book} \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \thispagestyle{empty} \begin{center} \begin{tikzpicture} \fill[red] rectangle (8,6); \foreach \k in {0,30,...,360} \node at ($(4,3)+(\k:2)$) {\includegraphics[width=1.7em]{example-image-a}}; \end{tikzpicture} \end{center} \end{document} which produces: QUESTION: How may I modify this code in order produce an ellipse (instead of circle) of images? Thank you.

  • How to correct for LaTeX and/or package changes affecting parsing of text in TikZ decoration for TL2020 vs TL2021 vs TL2022/3 vs TL2024 vs TL2025/6?
    by cfr on March 8, 2026 at 7:31 pm

    Consider the following code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{% decorations.text,% mindmap,% } \begin{document} \begin{tikzpicture} \path[ adddecrev/.style={% postaction={decorate, decoration={text along path, text={##1}, raise=3pt, }}}, small mindmap, ] node (norm) [root concept, concept, adddecrev={AAA AAA|\hskip 7.5pt| ||AAAAA AAA{\kern10ptA}A AA AA}] {AAAAAAAAA} [counterclockwise from=120] % removing this child eliminates the warnings child { node [concept, adddecrev={X{\kern-2ptX}{\kern-1ptX}{\kern4ptX}{\kern0ptX}X|\hskip8pt| ||X{\kern-2ptX}X{\kern-1ptX}{\kern-1ptX} X{\kern-3ptX}{\kern-1ptX}l{\kern-1ptX}|\hskip-2pt|X||{\kern-1ptX}|\hskip4pt|X||{\kern-2ptX}|\hskip-2pt|X|| }] {MMMMMMMM} } ; \end{tikzpicture} \end{document} In TL2020, this compiles without complaint for either pdfLaTeX or LuaLaTeX. In TL2025 or 2026, it complains Missing character: There is no A in font nullfont! In TL2024, the complaint is Missing character: There is no @ in font nullfont! In TL2022 and TL2023, the complaint is Missing character: There is no ? in font nullfont! In TL2021, the complaint is Missing character: There is no > in font nullfont! What causes these differences? Usually the nullfont warnings relate directly to problematic characters in the source. The A suggests that might be the case, except that removing the X line makes the problem disappear. Moreover, for earlier installations, the characters complained of bear no obvious relation to the input and I'm not sure where they are coming from or what the problem is. I also can't see anything obviously wrong with the code specifying the text for the decoration, despite rereading the relevant part of the manual. What is happening here? Is my code erroneous? If so, how can I correct it? In any case, is there a way to avoid the problem with a current TeX Live?

  • Drawing a topological surface of genus three
    by InsideOut on March 8, 2026 at 12:56 pm

    I would need your help to draw a surface of genus three like in the picture I attached. More specifically, I aim to draw a torus (surface of genus one) and below the surface of genus three realised by mean of some surgeries on the surface. I already drawn the torus by myself and I need help with the genus 3 surface. As you can see, the torus I drew is not exactly as on paper. Could help me? I also added some notes about colours of curves. Moreover, I'd like the surface is filled with the pattern [pattern=north west lines, pattern color=pallido], where pallido is just a colour I defined in RGB (it's already in the code). In the picture I do not need the names of colours, that's only for you. Thank you in advance! \documentclass[11pt,a4wide]{article} \usepackage[latin1]{inputenc} \usepackage{fancyhdr} \usepackage{indentfirst} \usepackage{graphicx} \usepackage{newlfont} \usepackage{amssymb} \usepackage{amsmath} \usepackage{latexsym} \usepackage{lscape} \usepackage{booktabs} \usepackage{amsthm} \usepackage{lscape} \usepackage{tikz} \usetikzlibrary{patterns,hobby} \usepackage{pgfplots} \pgfplotsset{compat=1.6} \usepackage{faktor} %\faktor{A}{B} %\usepackage{pictexwd,dcpic} \usepackage{pgf,tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usetikzlibrary{arrows.meta} \usetikzlibrary{decorations.markings} \usetikzlibrary{bending} \usetikzlibrary{patterns} \usetikzlibrary{intersections, calc} \usetikzlibrary{decorations.pathmorphing} \usepackage{soul} \usepackage{rotating} \usepackage[margin=3cm]{geometry} \usepackage{enumitem} \usepackage{color} \usepackage{hyperref} \definecolor{smoked}{RGB}{216, 212, 204} \definecolor{mauve}{RGB}{200, 55, 171} \definecolor{apricot}{RGB}{250, 144, 4} \definecolor{sky}{RGB}{66, 169, 244} \definecolor{plum}{RGB}{76, 0, 102} \definecolor{forest}{RGB}{90,145,120} \definecolor{sand}{RGB}{180,160,120} \begin{document} \begin{figure}[h!] \centering \begin{tikzpicture}[scale=2, every node/.style={scale=0.875}] \definecolor{pallido}{RGB}{221,227,227} \pattern [pattern=north west lines, pattern color=pallido] (0,0) ellipse (3cm and 2cm); \fill [white] (0,0) ellipse (1cm and 0.66cm); \draw[thin, black] (0,0) ellipse (3cm and 2cm) (0,0) ellipse (1cm and 0.66cm); \draw[orange] (0,0) ellipse (2cm and 1.25cm); %\draw[blue] (0,0) arc (030:060:2.5cm and 1.5cm); \draw[blue] (0,0) +(30:2.4 and 1.6) arc [start angle=30, end angle=60, x radius=2.4, y radius=1.6]; \draw[blue] (0,0) +(210:2.4 and 1.6) arc [start angle=210, end angle=240, x radius=2.4, y radius=1.6]; \draw[violet] (0,0) +(120:1.2 and 0.8) arc [start angle=120, end angle=150, x radius=1.2, y radius=0.8]; \draw[violet] (0,0) +(300:1.2 and 0.8) arc [start angle=300, end angle=330, x radius=1.2, y radius=0.8]; \draw[red ] (0 ,-0.66) to[bend left ] (0,-2); \draw[sky ] (0 , 0.66) to[bend left ] (0, 2); \draw[thin, red, dashed] (0 ,-0.66) to[bend right] (0,-2); \draw[thin, sky, dashed] (0 , 0.66) to[bend right] (0, 2); \fill ( 0.2,-1.25) circle (1pt); \fill (-0.2, 1.25) circle (1pt); \fill[violet] (0,0) +(120:1.2 and 0.8) circle (0.5pt); \fill[violet] (0,0) +(150:1.2 and 0.8) circle (0.5pt); \fill[violet] (0,0) +(300:1.2 and 0.8) circle (0.5pt); \fill[violet] (0,0) +(330:1.2 and 0.8) circle (0.5pt); \fill[blue] (0,0) +(030:2.4 and 1.6) circle (0.5pt); \fill[blue] (0,0) +(060:2.4 and 1.6) circle (0.5pt); \fill[blue] (0,0) +(210:2.4 and 1.6) circle (0.5pt); \fill[blue] (0,0) +(240:2.4 and 1.6) circle (0.5pt); \draw[black, thin] (0,0) +(030:2.4 and 1.6) circle (1pt); \draw[black, thin] (0,0) +(060:2.4 and 1.6) circle (1pt); \draw[black, thin] (0,0) +(210:2.4 and 1.6) circle (1pt); \draw[black, thin] (0,0) +(240:2.4 and 1.6) circle (1pt); \draw[violet] (0,0) +(120:1.2 and 0.8) circle (1pt); \draw[violet] (0,0) +(150:1.2 and 0.8) circle (1pt); \draw[violet] (0,0) +(300:1.2 and 0.8) circle (1pt); \draw[violet] (0,0) +(330:1.2 and 0.8) circle (1pt); \node at ( 1.75 , 1.25 ) {\(e_{1,1}\)}; \node at (-1.75 ,-1.25 ) {\(e_{1,2}\)}; \node at (-1.0625, 0.625) {\(e_{2,1}\)}; \node at ( 1.0625,-0.625) {\(e_{2,2}\)}; \end{tikzpicture} \caption{} \label{fig:hypermin} \end{figure} \end{document} My current result The picture I wish to draw:

  • Italian Parliament: semicircle and colored dots
    by Sebastiano on March 6, 2026 at 8:39 pm

    I am preparing a project that involves representing the Italian Parliament using a semicircle made of colored dots, as shown in the following image: I have tried to create something using the wheelchart package (page 19 of the manual), which allows generating similar charts. However, I am unable to automatically increase the number of dots per row. For example, in the figure there are 12 dots per row, but I would like a more customizable (for example 7 balls for every radius) and automatic solution to control this. I prefer big dots and not balls. \documentclass{article} \usepackage{tikz} \usepackage{wheelchart} \begin{document} \begin{tikzpicture} \pgfkeys{ /wheelchart, discrete, discrete pic={\shade[ball color=\WCvarB] (0,0) circle[radius=2pt];}, discrete sort=angle, discrete space at borders=false, start angle=180, total angle=180, value=\WCvarA } \wheelchart{ 120/blue/, 45/green/, 40/red/, 25/orange/, 10/purple/, 5/teal/ } \end{tikzpicture} \end{document}

  • Use a pattern in TikZ multipart node
    by Tobard on March 6, 2026 at 4:56 pm

    I would like to apply a pattern decoration in one part of a split node, in TikZ. See the following code: \documentclass[tikz]{standalone} \usetikzlibrary{shapes.multipart, patterns.meta} \begin{document} \begin{tikzpicture}[text width=3cm, draw, rounded corners] \node[draw, fill=yellow, postaction={pattern color=orange, pattern={Lines[distance=10mm,angle=45,line width=5mm]}} ] at (0,0) {Example}; \node[draw, rectangle split, rectangle split parts=2, rectangle split part fill={yellow,white}] at (0,-1) {Title\nodepart{second}Element content}; \end{tikzpicture} \end{document} I would like the "Title" part to look like the "Example" node. I have tried to replace the yellow,white instruction by {yellow, postaction={pattern color=orange, pattern={Lines[distance=10mm,angle=45,line width=5mm]}} },white But it dosn't work. Can you help me? Thanks.

  • TikZ: Projecting letter with a cm-matrix onto a 3D rectangular area
    by cis on March 6, 2026 at 2:44 pm

    I'm drawing a 3D rectangle (which should be a plane, represented by the letter "H"). At the top left corner, at 'C', I want to project a $H$ in mathematical font onto the plane. I've used a cm matrix for this. The position is correct, but I've noticed that the serifs of the 'H' are parallel, despite using $H$, so it doesn't look like mathematical font. What do I need to do? PS: I think, the $H$ should look something like this here: Unfortunately, I can't present it any better. \documentclass[margin=5pt, tikz]{standalone} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture}[ x={(-4.85mm,-4.85mm)}, y={(10mm,0mm)}, z={(0,10mm)}, font=\footnotesize, ] %\coordinate[label=below:$O$](O) at (0,0,0); \coordinate[label=right:A](A) at (0,2,0); \coordinate[label=B](B) at (0,2,2); \coordinate[label={[anchor=south west, inner sep=1pt]{C $H$ (as it should be)}}](C) at (-2.5,-1.5,2); \coordinate[label=left:D](D) at (-2.5,-1.5,0); \draw[] (A) -- (B) -- (C) -- (D) --cycle; \path let \p1 = ($(B)-(C)$), \p2 = ($(C)-(D)$), \n{len1} = {veclen(\x1,\y1)}, \n{len2} = {veclen(\x2,\y2)}, \n1 = {\x1/\n{len1}}, \n2 = {\y1/\n{len1}}, \n3 = {\x2/\n{len2}}, \n4 = {\y2/\n{len2}} in node[cm={\n1, \n2, \n3, \n4, (C)}, anchor=north west, inner sep=1pt, %transform shape, % no effect ]{H $H$ \mbox{$H$}}; % CoSy \begin{scope}[-latex, thick, shift={(0,-2,2)}] \foreach \P/\s/\Pos in {(1,0,0)/x/above, (0,1,0)/y/right, (0,0,1)/z/right} \draw[] (0,0,0) -- \P node[\Pos, pos=0.9,inner sep=3pt]{$\s$}; \end{scope} \end{tikzpicture} \end{document}

  • Using tikz's backgrounds library to draw something behind text
    by Werner on February 21, 2026 at 7:20 am

    Consider the following minimal example where I want to draw a rectangle behind a sequence of numbers (to highlight them): \documentclass{article} \usepackage{tikz} \usetikzlibrary{backgrounds,calc} \NewDocumentCommand{\tikzmark}{ m }{\tikz[overlay, remember picture] \node (#1) {};} \newcounter{seq} \NewDocumentCommand{\seqstart}{}{% \stepcounter{seq}% Start a new sequence \tikzmark{seq-start-\theseq}}% Set start marker \NewDocumentCommand{\seqend}{}{% \tikzmark{seq-end-\theseq}% Set end marker \tikz[remember picture, overlay] \scoped [on background layer] \fill [fill=blue!10!white] ($(seq-start-\theseq.south west) + (-0.5pt,1pt)$) rectangle ($(seq-end-\theseq.south east) + (0.5pt,1.1\normalbaselineskip)$);% } \begin{document} \[ 12, 15, 8, 11, 4, 7, 0, 3, 16, 19, 12, 15, 8, 11, 4, 7, 0, 3, \ldots \] \[ \seqstart{}12, 15, 8, 11, 4, 7, 0, 3, 16, 19\seqend{}, 12, 15, 8, 11, 4, 7, 0, 3, \ldots \] \end{document} The idea is that \seqstart would set a (counter-driven) \tikzmark representing the start of the sequence to be marked. Then \seqend would set a \tikzmark at the end and highlight it using the background layer. The counter allows for multiple such sequence marking within a larger document. However, the output shows that the rectangle highlighting a part of the sequence is not being drawn on background layer as requested. Why is that? How can I ensure the rectangle is drawn on the background layer behind document/text elements? The backgrounds library documentation (in the tikz documentation, section 45) mentions that on background layer can only be used inside a {scope} or \scoped, which is done above.

  • TiKZ: possibility of "average" blend mode?
    by putianyi888 on February 4, 2026 at 8:40 am

    I get that the screen mode basically adds the RGB values. Is it possible to take the average of the values instead, so that colors don't get lighter? Opacity trick doesn't seem to work because I want full opacity where the images don't overlap.

  • Segmented cake symbol
    by Sebastiano on October 26, 2025 at 9:50 pm

    Let's take as an example an old request of mine, where I asked to create small symbols (eyes) to indicate the difficulty of an exercise. TikZ or symbol eyes for difficulty of examples/exercises Since I can't find a symbol, among those available in the symbol manual, that represents 1/4 of a cake to indicate time (and that can be associated with 1/2, 3/4, and 4/4), I wonder if it's possible to adapt the Marsupilam code to use a symbol that can be found in an Italian national newspaper. I think that is an image and not a symbol. \documentclass[12pt]{standalone} \usepackage{tikz} \newcommand\straightEye[1][1.2ex] {% \begin{tikzpicture}[scale=#1/1cm] \draw (0,0) circle (.5); \fill (0,0) circle (.25); \end{tikzpicture}% } \newcommand\downwardsEye[1][1.2ex] {% \begin{tikzpicture}[scale=#1/1cm] \draw (0,0) circle (.5); \fill (0,-.25) circle (.25); \end{tikzpicture}% } \newcommand\rightEye[1][1.2ex] {% \begin{tikzpicture}[scale=#1/1cm] \draw (0,0) circle (.5); \fill (.25,0) circle (.25); \end{tikzpicture}% } \begin{document} \straightEye \downwardsEye \ look at me \rightEye\rightEye \end{document}

  • How to avoid duplicate chapter title and absolutely position chapter title with TikZ
    by Chen Mortenfeld on June 12, 2025 at 7:50 pm

    I'm customizing chapter titles in my book using the titlesec and tikz packages. For special chapters like the "Preface", I want to: Show a custom TikZ-styled title box that is positioned exactly \TitleBoxOffset below the top of the page (absolute positioning, not relative). Avoid having the chapter title (e.g., "Preface") appear twice on the page — once inside my TikZ box and once from LaTeX's default chapter title mechanism. So basically "Preface" appears twice, and the location is set manually. Here's my code in the .sty file: \usepackage[explicit]{titlesec} \usepackage{tikz} \usepackage{xcolor} \usepackage{etoolbox} % for \IfStrEq \newcommand{\CurrentChapterTitle}{} \newlength{\ChapterTopSkip} \newcommand{\ChapterHook}[1]{% \renewcommand{\CurrentChapterTitle}{#1}% \IfStrEq{#1}{Preface}{% \titleformat{\chapter} [block] {\centering} {} % no label {0pt} {% \begin{tikzpicture} \node[ draw=lightblue, line width=1pt, rounded corners=10pt, minimum width=0.8\linewidth, minimum height=2cm, align=center, fill=white, fill opacity=1, text opacity=1 ] {\scalebox{1.4}{\textcolor{lightblue}{\Huge{#1}}}}; \end{tikzpicture} } % \titlespacing*{\chapter}{0pt}{-\topskip}{20pt} \titlespacing*{\chapter}{0pt}{-95pt}{20pt} } {% \titleformat{\chapter}[block] {\normalfont\scshape\Huge\centering} {\fontsize{140pt}{140pt}\selectfont\thechapter\\} {0pt} {\normalfont\scshape\Huge\centering #1} }% } % % Patch \chapter to call ChapterHook \let\oldchapter\chapter \renewcommand{\chapter}[1]{% \ChapterHook{#1}% \oldchapter{#1}% } % Suppress LaTeX’s default \@makechapterhead \makeatletter \renewcommand{\@makechapterhead}[1]{} \makeatother Update: I updated the code block to include the packages. Thanks to the comments, I managed to make the word "Preface" appear only once, by using: \usepackage[explicit]{titlesec} see the update code. Now my only issue is the position of the title that I define manually — I want it to be at position 0 relative to the page boundaries, and then I’ll subtract a fixed predefined offset from it. Thank you!

  • pgfplot: Fill between while including decoration function
    by otiuuaugusto on January 11, 2023 at 10:43 pm

    I am trying to fill between area for a specific plot within a groupplot environment. I have already tried to follow the pgfplot manual which is pretty clear with respect to the name path abd \path[] ... but I just always get the same weird outcome (see picture below). Since I was using the x-axis as the delimitation for the fill between, I started trying to use something else to check if something would change. Below is my MWE: \usepackage{tikz} \usepackage{pgfplots} \usepgfplotslibrary{fillbetween} \usepackage{textcomp} \pgfplotsset{compat=1.18} \usepackage{siunitx} \usepackage{tikzscale} \usetikzlibrary{pgfplots.groupplots} \usetikzlibrary{decorations.markings} \begin{document} \begin{tikzpicture} \begin{groupplot}[ group style={ group name = 4L_keywaveform_sim_S6currentstress, group size = 1 by 1, vertical sep = 15pt }, clip=true, enlargelimits=false, height = 0.75\textwidth, width = \textwidth, axis x line = bottom, axis y line = left, xlabel={$t$}, xlabel style={align=right, anchor=west, xshift=5.8cm, yshift=0.6cm}, x axis line style={shorten >=-15pt}, xmin=0, xmax=12.5, ymajorgrids=true, yminorgrids = true, xmajorgrids=true, grid style={dashed}, set layers,cell picture=true, ] \nextgroupplot[ymin=0, %Position colunm 1 by row 1 ymax=15, ytick align = outside, ytick pos = left, axis y line = left, ylabel = {$y$}, legend columns=1, ] \addplot[color=blue, name path global = teste1, domain=0:15, postaction={decorate},% ------ decoration={markings, % ------ mark=between positions 0.05 and 1 step (1/10)*\pgfdecoratedpathlength with {\arrow{Latex}}, }, ] {x}; \label{test}; \addlegendentry{$x$}; \addplot[color=red, name path global = teste2, domain=0:15] {-3 + x^2}; \path[name path global = teste3] (axis cs:0,5) -- (axis cs:12.5,5); \addplot[blue, fill=blue, fill opacity=0.4] fill between[of= teste1 and teste3]; \end{groupplot} \end{tikzpicture} \end{document} The MWE consists of only 1by1 groupplot for simplificativo purpose. But the issue persists for n by m groupplot. EDIT/UPDATE: By investigating a bit further, it seems that the decoration arguments are messing up with the fill between. I do not know the reason for that, though. Thanks,

  • Subheadings for Pie charts
    by Waseem on June 15, 2021 at 8:03 am

    Can anyone help me for writing subheading on top each Pi chart with the following code. Please see the example picture \documentclass[border=5mm]{standalone} \usepackage{pgf-pie} % version: https://github.com/pgf-tikz/pgf-pie Dec 26, 2020 \usepackage{etoolbox} \makeatletter \pretocmd{\pgfpie@slice}{% define label text with percentages for small values \pgfmathparse{#3 > 5}% \ifnum\pgfmathresult=1 % \def\txtlabel{#4}% original label for large values \else% \def\txtlabel{#4 (#3\%)}% label with percentage for small values \fi% }{\message{define label patch ok}}{\message{define label patch failed}} \patchcmd{\pgfpie@slice}% use label text instead of original argument #4 {\pgfpie@text={\pgfpie@midangle:#4}}% {\pgfpie@text={\pgfpie@midangle:\txtlabel}}% {\message{add pct patch ok}}% {\message{add pct patch failed}}% \def\pgfpie@numbertext#1{% don't print percentage in slice for small values \pgfpie@ifhidenumber{}{% \pgfmathparse{#1 > 5}% \ifnum\pgfmathresult=1 % \pgfpie@beforenumber#1\pgfpie@afternumber% \fi }% } \makeatother \begin{document} \begin{subfigure} \footnotesize \begin{tikzpicture} %\begin{scope}[scale=0.7] \pie[before number =, after number = {\%},text=pin, ]{ 18.9/1-20 Employees, 29.2/21-100 Employees, 22.6/101-500 Employees, 7.5/501-1000 Employees, 21.7/Over 1000 Employees } %\end{scope} \end{tikzpicture} \end{subfigure} %\begin{tikzpicture} %\pie[before number =, after number = {\%},text=pin, ]{ %42.3/ Combination of DDD and business capability, %29.8/ Only business capability, %27.9/ only DDD %} %\end{tikzpicture} \begin{subfigure} \footnotesize \begin{tikzpicture} %\begin{scope}[scale=0.7] \pie[before number =, after number = {\%},text=pin, ]{ 5.7/1 Practitioners, 43.4/2-3 Practitioners, 27.4/4-5 Practitioners, 9.4/6-7 Practitioners, 6/8-10 Practitioners, 8.5/Over 10 Practitioners } %\end{scope} \end{tikzpicture} \end{subfigure} \end{document}

  • Beamer + TikZ-foreach: Every step a new frame on handout
    by synthax on June 21, 2018 at 10:08 pm

    I'm preparing a presentation with Beamer and TikZ to explain Dijkstra. The following graph is explored step by step and for each step there's a new frame. \tikzstyle{vertex}=[circle,fill=black!25,minimum size=20pt,inner sep=0pt] \tikzstyle{selected vertex} = [vertex, fill=red!24] \tikzstyle{edge} = [draw,thick,-] \tikzstyle{weight} = [font=\small] \tikzstyle{selected edge} = [draw,line width=5pt,-,red!50] \tikzstyle{ignored edge} = [draw,line width=5pt,-,black!20] \begin{figure} \begin{tikzpicture}[scale=1.8, auto,swap] \foreach \pos/\name in {{(0,2)/A}, {(2,1)/B}, {(4,1)/C}, {(0,0)/D}, {(3,0)/E}, {(2,-1)/F}, {(4,-1)/G}} \node[vertex] (\name) at \pos {$\name$}; \foreach \source/ \dest /\weight in {B/A/7, C/B/8,D/A/5,D/B/9, E/B/7, E/C/5,E/D/15, F/D/6,F/E/8, G/E/9,G/F/11} \path[edge] (\source) -- node[weight] {$\weight$} (\dest); \foreach \vertex / \fr in {A/2,D/3,B/4,F/5,E/6,C/7,G/8} \path<\fr-> node[selected vertex] at (\vertex) {$\vertex$}; \end{tikzpicture} \end{figure} Now I'm looking for the same behavior for particularly this part of the presentation with the handout-option turned on. Does anybody have an idea? Thanks a lot!

  • Horizontal Probability Tree using Forest with Edge Labels
    by Felix Jen on April 6, 2018 at 7:14 pm

    I’m trying to make a horizontal probability tree as pictured below using the Forest package. Currently, I am able to get a regular forest tree using the following code \usepackage{forest} \begin{document} \begin{forest} [A [B[D][E]] [C[F][G]] ] \end{forest} \end{document} I also know that you can add edge labels manually by specifying, for instance: [D;edge label = {node[midway,above]{$\frac{3}{5}$}}] However, since I will be making these trees quite frequently, I was hoping to have the edge labels automatically placed either above or below. As well, there may be more than two branches per node, in which the edge label should default to the top. I’ve seen code like: [D;$\frac{3}{5}$] But I’m not too sure how to achieve that.

  • Adding vertical hierarchy lines to a category column of a table
    by badroit on August 8, 2014 at 8:15 pm

    I often need to represent hierarchies within tables but I've yet to find an elegant way to do this. Oftentimes I do a variation on the following theme, with nested whitespace in the category column: \documentclass{article} \usepackage{booktabs} \newcommand{\lvl}{~~~} \begin{document} \begin{tabular}{lr} \toprule \textbf{Category} & \textbf{\%}\\ \midrule Animal & 100 \\ \lvl Human & 50 \\ \lvl\lvl Man & 20 \\ \lvl\lvl Woman & 30 \\ \lvl Fox & 30 \\ \lvl\lvl Vixen & 16 \\ \lvl\lvl Dog & 14 \\ \lvl Chicken & 20 \\ \lvl\lvl Cock & 8 \\ \lvl\lvl Hen & 12 \\ \bottomrule \end{tabular} \end{document} I might mix that up with midrules between categories and different fonts for different levels and so on. But the result can sometimes be very "busy", especially if there's a bunch of levels. Instead, I was playing around with the idea of adding lines to more elegantly represent the hierarchy, sketched as follows in red (a similar effect in the same spirit would also suffice): But I'm not sure how to realise this in LaTeX in an elegant way. I'm guessing I could somehow decorate a table with TikZ but I'd only know how to specify manual points (e.g., I'm not sure how to anchor rows in a table). Thus I'm looking for any suggestions of elegant solutions to achieve the above effect. (An ideal answer would avoid explicit coordinates/distances and would be "highly reusable".)

  • Moebius Strip using TikZ
    by Dox on June 10, 2013 at 11:19 pm

    I'm wondering whether is possible to draw a Moebius Strip using TikZ. The closest thing I've seen is in Texamples' page, but no luck so far! Do you have any ideas? I don't even have a MWE (sorry)

  • How can I draw an arc from point A -> B on a 3D sphere in TikZ?
    by mhk on March 5, 2012 at 9:46 am

    I'm basing myself on http://www.texample.net/tikz/examples/spherical-and-cartesian-grids/ and now I need to add a arc from point P to Q. What I was able to get so far: \begin{tikzpicture}[scale=1,every node/.style={minimum size=1cm}] %% some definitions \def\R{4} % sphere radius \def\angEl{25} % elevation angle \def\angAz{-100} % azimuth angle \def\angPhiOne{-110} % longitude of point P \def\angPhiTwo{-45} % longitude of point Q \def\angBeta{30} % latitude of point P and Q %% working planes \pgfmathsetmacro\H{\R*cos(\angEl)} % distance to north pole \LongitudePlane[xzplane]{\angEl}{\angAz} \LongitudePlane[pzplane]{\angEl}{\angPhiOne} \LongitudePlane[qzplane]{\angEl}{\angPhiTwo} \LongitudePlane[nzplane]{\angEl}{-86} \LatitudePlane[equator]{\angEl}{0} \fill[ball color=white!10] (0,0) circle (\R); % 3D lighting effect \coordinate (O) at (0,0); \coordinate[mark coordinate] (N) at (0,\H); \coordinate[mark coordinate] (S) at (0,-\H); \DrawLongitudeCircle[\R]{\angPhiOne} % pzplane \DrawLongitudeCircle[\R]{\angPhiTwo} % qzplane \DrawLatitudeCircle[\R]{\angBeta} \DrawLatitudeCircle[\R]{0} % equator %labelling north and south \node[above=8pt] at (N) {$\mathbf{N}$}; \node[below=8pt] at (S) {$\mathbf{S}$}; \draw[-,dashed, thick] (N) -- (S); %setup coordinates P and Q \path[pzplane] (0:\R) coordinate (P); \draw[->] (O) -- node[above=4pt] {$\overrightarrow{P}$} (P); \path[qzplane] (\angBeta:\R) coordinate (Q); \draw[->] (O) -- node[above=2pt] {$\overrightarrow{Q}$} (Q); \path[nzplane] (153:\R) coordinate (N); \draw[->,color=red] (O) -- node[right=2pt] {$\overrightarrow{N}$} (N); \draw (P) arc (-110:-45:\R) (Q); \end{tikzpicture} Is there a possibility to make an arc from P to Q with the center O? Upon request, the full compilable sourcecode: http://pastebin.com/m809Jwp7

  • Recursive method to build a tree with tikz
    by Alain Matthes on November 11, 2011 at 9:54 am

    I would like to translate the next example of a Bernoulli tree built with pst-tree with tikz but I don't know if it's possible : \documentclass{article} \usepackage{pstricks,pst-tree} \makeatletter \newcount\@Bernoudepth \newcount\@Bernoumaxdepth \newcommand\Bernoutree[8][treemode=R,nodesep=1ex,levelsep=12ex]{% % #2 = depth of tree % #3 = name for success % #4 = name for miss % #5 = probability of a success % #6 = position of #5 % #7 = probability of a miss % #8 = position of #7 \begingroup % initialize parameters \psset{treemode=R,nodesep=1ex,levelsep=12ex}% \psset{#1}% \@Bernoumaxdepth #2\relax \def\@Reussite{#3}% \def\@Echec{#4}% \def\@probareussite{#5}% \def\@Argreussite{#6}% % if no parameter of position % center position \ifx\empty\@Argreussite \def\@Argreussite{0.5}% \fi \def\@probaechec{#7}% \def\@Argechec{#8} \ifx\empty\@Argechec \def\@Argechec{0.5}% \fi % First call (empty root, level 1) \pstree{\TR{}}{\@Bernoutree{1}} \endgroup } \newcommand\@Bernoutree[1]{% % #1 = recursive depth % initialize the depth \@Bernoudepth #1\relax \ifnum\@Bernoudepth=\@Bernoumaxdepth % if depth max is reached % we place the two final nodes \TR{\@Reussite}\taput[tpos=\@Argreussite]{\@probareussite} \TR{\@Echec}\tbput[tpos=\@Argechec]{\@probaechec} % it's finished \else % else we build with a recursive method % the two branches of higher level \advance\@Bernoudepth \@ne \pstree{\TR{\@Reussite}\taput[tpos=\@Argreussite] {\@probareussite}}{\@Bernoutree{\the\@Bernoudepth}} \pstree{\TR{\@Echec}\tbput[tpos=\@Argechec] {\@probaechec}}{\@Bernoutree{\the\@Bernoudepth}} \fi } \makeatother \pagestyle{empty} \begin{document} \Bernoutree[levelsep=18ex,treenodesize=0pt]{4}{$R$}{$E$}{$p$}{}{$q$}{} \end{document} Actually I get the tree with the next method but it's not a recursive method. \documentclass{scrartcl} \usepackage{pgf,tikz} \usetikzlibrary{trees,arrows} \makeatletter \newcount\tkz@Berndepth \newdimen\tkz@BernLEN \tkz@BernLEN=24em \def\tkzBernTreeSet#{\pgfqkeys{/berntree}} \pgfqkeys{/berntree}{% success/.code = \def\tkz@bern@success{#1}, miss/.code = \def\tkz@bern@miss{#1}, p/.code = \def\tkz@bern@pbsuccess{#1}, q/.code = \def\tkz@bern@pbmiss{#1}, node success style/.style = {inner sep=2pt,outer sep=3pt}, node miss style/.style = {inner sep=2pt,outer sep=3pt}, edge style/.style = {->,>=latex',shorten <= 6pt}, root style/.style = {draw,circle}, success/.initial = S, miss/.initial = E, p/.initial = $p$, q/.initial = $1-p$, gap/.code = \def\tkz@bern@gap{#1}, length/.code = \def\tkz@bern@length{#1} } \def\tkz@brntree#1#2{% \node[/berntree/root style] {}; \global\advance\tkz@Berndepth 1\relax \begin{scope}[level distance=\tkz@bern@length, level 1/.style={sibling distance=#2}] \node[] (root) at (#1) {} [grow=right] child[/berntree/edge style] {% node[/berntree/node miss style](tkz@E\the\tkz@Berndepth) {\tkz@bern@miss} edge from parent node[fill=white] {\tkz@bern@pbmiss}} child [/berntree/edge style] {% node[/berntree/node success style] (tkz@S\the\tkz@Berndepth) {\tkz@bern@success} edge from parent node[fill=white] {\tkz@bern@pbsuccess} }; \end{scope}}% \def\tkzBernTree{\pgfutil@ifnextchar[{\tkz@BernTree}{\tkz@BernTree[]}} \def\tkz@BernTree[#1]#2{% \begingroup \pgfqkeys{/berntree}{% success = S, miss= E, node success style/.style = {inner sep=2pt,outer sep=3pt,draw,minimum width=1.5em,minimum height=1.5em}, node miss style/.style = {inner sep=2pt,outer sep=3pt,circle,draw,minimum width=1.5em}, p=$p$, q=$q$, gap=8cm, length=3cm} \pgfqkeys{/berntree}{#1} \tkz@BernLEN=\tkz@bern@gap\relax \tkz@Berndepth 0\relax \node (tkz@S0) at (0,0){}; \def\tkz@bn@level{#2} \ifcase\tkz@bn@level% \or% \tkz@brntree{tkz@S0}{\tkz@BernLEN} \or% \tkz@brntree{tkz@S0}{\tkz@BernLEN} \divide \tkz@BernLEN by 2 % \foreach \nd in {1}{ \tkz@brntree{tkz@S\nd}{\tkz@BernLEN} \tkz@brntree{tkz@E\nd}{\tkz@BernLEN}} \or% \tkz@brntree{tkz@S0}{\tkz@BernLEN} \divide \tkz@BernLEN by 2 % \foreach \nd in {1}{ \tkz@brntree{tkz@S\nd}{\tkz@BernLEN} \tkz@brntree{tkz@E\nd}{\tkz@BernLEN}} \divide \tkz@BernLEN by 2 % \foreach \nd in {2,3}{ \tkz@brntree{tkz@S\nd}{\tkz@BernLEN} \tkz@brntree{tkz@E\nd}{\tkz@BernLEN}} \or% \tkz@brntree{tkz@S0}{\tkz@BernLEN} \divide \tkz@BernLEN by 2 % \foreach \nd in {1}{ \tkz@brntree{tkz@S\nd}{\tkz@BernLEN} \tkz@brntree{tkz@E\nd}{\tkz@BernLEN}} \divide \tkz@BernLEN by 2 % \foreach \nd in {2,3}{ \tkz@brntree{tkz@S\nd}{\tkz@BernLEN} \tkz@brntree{tkz@E\nd}{\tkz@BernLEN}} \divide \tkz@BernLEN by 2 % \foreach \nd in {4,5,6,7}{ \tkz@brntree{tkz@S\nd}{\tkz@BernLEN} \tkz@brntree{tkz@E\nd}{\tkz@BernLEN}} \or% \tkz@brntree{tkz@S0}{\tkz@BernLEN} \divide \tkz@BernLEN by 2 % \foreach \nd in {1}{ \tkz@brntree{tkz@S\nd}{\tkz@BernLEN} \tkz@brntree{tkz@E\nd}{\tkz@BernLEN}} \divide \tkz@BernLEN by 2 % \foreach \nd in {2,3}{ \tkz@brntree{tkz@S\nd}{\tkz@BernLEN} \tkz@brntree{tkz@E\nd}{\tkz@BernLEN}} \divide \tkz@BernLEN by 2 % \foreach \nd in {4,...,7}{ \tkz@brntree{tkz@S\nd}{\tkz@BernLEN} \tkz@brntree{tkz@E\nd}{\tkz@BernLEN}} \divide \tkz@BernLEN by 2 % \foreach \nd in {8,...,15}{ \tkz@brntree{tkz@S\nd}{\tkz@BernLEN} \tkz@brntree{tkz@E\nd}{\tkz@BernLEN}} \fi \endgroup } \makeatother \begin{document} \begin{tikzpicture}[yscale=1.2] \tkzBernTree[root style/.style = {fill,circle,outer sep =1pt,inner sep=2pt}]{4} \end{tikzpicture} \end{document}

  • Probability tree using TikZ for Bernoulli experiments?
    by student on June 4, 2011 at 9:02 am

    Consider the tree below. Is there an easy way to label every left edge q, every right edge p, every left node f and every right node r, without doing it manually for every level? Second question: Is there a nice way to generalize this Bernoulli process tree example for n-levels? \documentclass{article} \usepackage{tikz} \usetikzlibrary{trees} \begin{document} \pagestyle{empty} \tikzstyle{level 1}=[level distance=3.5cm, sibling distance=6cm] \tikzstyle{level 2}=[level distance=3.5cm, sibling distance=3cm] \tikzstyle{level 3}=[level distance=3.5cm, sibling distance=2cm] \tikzstyle{bag} = [text centered,circle,draw,inner sep=0.3em] \tikzstyle{head} = [inner sep=0pt] \begin{tikzpicture} % \node[head] {} % child { % node[bag] {} % child{ % node[bag]{} child { % node[bag, label=below: % {$a$}] {} % } % child { % node[bag, label=below: % {$b$}] {} % } % }% child{ % node[bag]{} child { % node[bag, label=below: % {$c$}] {} % } % child { % node[bag, label=below: % {$d$}] {} % } % }% } child { % node[bag] {} % child{ % node[bag]{} child { % node[bag, label=below: % {$e$}] {} % } % child { % node[bag, label=below: % {$f$}] {} % } % }% child{ % node[bag]{} child { % node[bag, label=below: % {$g$}] {} % } % child { % node[bag, label=below: % {$h$}] {} % } % }% }; % % \end{tikzpicture} \end{document}