• tikz, scaling widths of lines
    by Zarko on March 17, 2026 at 2:39 pm

    It seems (or is apparently) that thickness of lines is hart coded. Consequently at driving of an line, the use for example scale=2 make line only longer and its thickens is not changes, see MWE below: \documentclass[margin=3mm, varwidth]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \tikzset{LA/.style = {-Straight Barb, line width=1mm}} \begin{document} \begin{tikzpicture} \draw[LA] (0,0) -- ++ (2,0); \end{tikzpicture} \begin{tikzpicture}[scale=2] \draw[LA] (0,0) -- ++ (2,0); \end{tikzpicture} \end{document} Does exist some trick by which will be scaled thickness of line too? The best way would be as option of the line style, which will has effect just on this particular line. My quick search on site so far didn't give me any suggestion ...

  • TikZ / xint: break a loop at the second term, which is 1.0000
    by cis on March 17, 2026 at 11:34 am

    The following loop is an example of a loop that, starting from a certain sequence member, is rounded to 1.0000. How can I break the loop at the second term, which is 1.0000 (in this example, that's the 13th)? Note: I'm using TikZ and xint; both are possible options. \documentclass[margin=5pt, varwidth]{standalone} \usepackage{tikz} \usepackage{xintexpr} \begin{document} \foreach \x in {1,...,15}{%% \x: \xintround{4}{\xinteval{1-exp(-\x/1.2)}}\par }%% \end{document}

  • Is it possible to pass tikpicture as argument to chapter or section header
    by Dieter on March 17, 2026 at 9:57 am

    Complete rework of this question to better match my problem. My fist version was just not suitable I need to add margin notes to a two column environment. I am using a solution based on this question: Margin notes, multicols, tikz overlay Everything works fine, but I also need to add marginnotes to section headers. But I get Undefined control sequence. How can I avoid this error message? MWE \documentclass{scrbook} \usepackage{scrlayer-scrpage} \usepackage{babel} \babeltags{dutch=dutch} \babeltags{dan=danish} \babeltags{swed=swedish} \babeltags{brit=british} \babeltags{fren=french} \babeltags{ital=italian} \babeltags{espan=spanish} \babeltags{port=portuguese} \babeltags{german=german} \usepackage[no-math]{fontspec} \usepackage[babel=true,nopatch=footnote,letterspace=150,]{microtype} \usepackage[colaction]{multicol} \usepackage{ragged2e} \usepackage{rotating} \usepackage{enumitem} \newlist{LanguageEntry}{itemize}{1} \setlist[LanguageEntry]{ noitemsep,% partopsep=0pt,% topsep=0pt,% parsep=0.3\baselineskip,% labelindent=2em,% labelwidth=2.8em,% align=parleft,% leftmargin=!,% } \DeclareNewSectionCommand[% style=section,% level=2,% beforeskip=4pt,% afterskip=0pt,% runin=false,% font=\normalfont\Large,% tocindent=0pt,% tocnumwidth=0pt,% ]{dictionaryentry} \RenewCommandCopy{\raggedsection}{\RaggedRight} \newcommand{\entry}[3][]{\def\thedictionaryentry{#2}\dictionaryentry[#1]{#3}\allowbreak}%%edited here \newcommand{\entrygeneric}[3][]{% \begin{LanguageEntry}[#1] \item[\textit{#2}]{\RaggedRight #3} \end{LanguageEntry} }% \newcommand{\entrynl}[2][]{\entrygeneric[#1]{Holl.} {\begin{dutch} #2 \end{dutch}}} \newcommand{\entryda}[2][]{\entrygeneric[#1]{Dän.} {\begin{dan} #2 \end{dan}}} \newcommand{\entrysw}[2][]{\entrygeneric[#1]{Schw.} {\begin{swed} #2 \end{swed}}} \newcommand{\entryen}[2][]{\entrygeneric[#1]{Engl.} {\begin{brit} #2 \end{brit}}} \newcommand{\entryfr}[2][]{\entrygeneric[#1]{Franz.} {\begin{fren} #2 \end{fren}}} \newcommand{\entryit}[2][]{\entrygeneric[#1]{Ital.} {\begin{ital} #2 \end{ital}}} \newcommand{\entryes}[2][]{\entrygeneric[#1]{Span.} {\begin{espan} #2 \end{espan}}} \newcommand{\entrypt}[2][]{\entrygeneric[#1]{Port.} {\begin{port} #2 \end{port}}} % Based on % https://tex.stackexchange.com/questions/163567/margin-notes-multicols-tikz-overlay \usepackage{tikz} \newlength{\test} \def\Note#1{% \begin{tikzpicture}[remember picture,overlay] \coordinate (here) at (0,0); %compute horizontal offset from origin to center \pgfextractx{\test}{\pgfpointdiff{\pgfpointorigin} {\pgfpointanchor{current page}{center}}}% \ifdim\test < 0pt% \draw (current page.east |- here)+(-0.5in,0pt) node[anchor=text,align=left,text width=0.5in]{\strut #1}; \else \draw (current page.west |- here)+(0cm,0pt) node[anchor=text,align=right,text width=0.5in]{\strut #1}; \fi% \end{tikzpicture}% \ignorespaces% }% \begin{document} \begin{multicols}{2}\raggedcolumns%%Edited here % AAK \entry{AKK\Note{Note 1}}{Der Name eines Fahrzeugs für Rheinwein nach Holland gebracht wird.} \entrynl{Aak.} \entryda{Et Fartöj paa Rhinſtrömmen.} \entrysw{Et Farto̊g ſom nyttias på Rhinſtrömen.} \entryen{A ſort of flat bottomed lighter.} \entryfr{Aque, Acque.} \entryit{Un battello con fondo piano, di cui ſi ſervono ſopra il Reno.} \entryes{Una barca con fondo llano. ſobre el Reno.} \entrypt{Eſpecie de barca chata ſobre o Rheno.} Additional text for this dictionary entry.\Note{Note 2} % AAP. (Hochdeutſch Affe.) \entry{AAP.}{(Hochdeutſch Affe.)} \entrynl{Aap.} \entryda{Aben.} \entrysw{Apan.} \entryen{The mizen ſtay-ſail.} \entryfr{Voile d’etay d’artimon.} \entryit{La carbonera, o ſia la vela.} \entryes{Vela del humo, o vela.} \entrypt{Rabeca, ou vela do.} % ABAB \entry{ABAB.}{} \entrynl[beginpenalty=100000]{Een turkſch Matroos.} \entryda{En tyrkiſk Matros.} \entrysw{En tyrkiſk Matros.} \entryen{A turkiſh ſailor.} \entryfr{Un matelot turc.} \entryit{Un marinaro turco.} \entryes{Un marinero turco.} \entrypt{Hum marinheiro turco.} % AAPENFALL \entry{AAPENFALL.}{} \entrynl[beginpenalty=100000]{Aapenval.} \entryda{Abe-Fald.} \entrysw{Apan-eller Aben-Fall.} \entryen{The haliard of the mizen-ſtay-ſail.} \entryfr{La driſſe de la voile d’etay d’artimon.} \entryit{La drizza della carbonera.} \entryes{La driza de la vela del humo.} \entrypt{A driça da rabeca.} % ABAB \entry{ABAB.}{} \entrynl[beginpenalty=100000]{Een turkſch Matroos.} \entryda{En tyrkiſk Matros.} \entrysw{En tyrkiſk Matros.} \entryen{A turkiſh ſailor.} \entryfr{Un matelot turc.} \entryit{Un marinaro turco.} \entryes{Un marinero turco.} \entrypt{Hum marinheiro turco.} % ABANDONNEMENT \entry{ABANDONNEMENT.}{} \entrynl[beginpenalty=100000]{Het Abandoneeren van een Schip \&c. aan den Verzekeraar.} \entryda{En Afſtaaelſe og Overladelſe af Gods eller Skib til Aſſuradeuren.} \entrysw{Abandonera förſäkrade Skepp eller Gods til Aſſecuradeuren.} \entryen{The abandoning of a veſſel or goods to the inſurer for getting paid the inſured ſum.} \entryfr{Abandonnement.} \entryit{Abandonamento, ceſſione.} \entryes{Abandono.} \entrypt{Deixaçaõ, inteira ceſſaõ.} % ABANDONNEMENT \entry{ABANDONNEMENT.}{} \entrynl[beginpenalty=100000]{Het Abandoneeren van een Schip \&c. aan den Verzekeraar.} \entryda{En Afſtaaelſe og Overladelſe af Gods eller Skib til Aſſuradeuren.} \entrysw{Abandonera förſäkrade Skepp eller Gods til Aſſecuradeuren.} \entryen{The abandoning of a veſſel or goods to the inſurer for getting paid the inſured ſum.} \entryfr{Abandonnement.} \entryit{Abandonamento, ceſſione.} \entryes{Abandono.} \entrypt{Deixaçaõ, inteira ceſſaõ.} \end{multicols} \end{document}

  • How should (0,-1) -- +([turn]45:2) be interpreted?
    by D G on March 16, 2026 at 11:57 am

    How should I interprete the case B? Case A \documentclass[tikz,border=12pt,12pt]{standalone} \begin{document} \begin{tikzpicture}[dot/.append style={circle,fill,inner sep=3pt}] \draw (-3,-3) grid (3,3); \draw[line width=3pt] (-3,-1) coordinate[dot] -- (0,-1) coordinate[dot] -- ([turn]45:{sqrt(2)}) coordinate[dot]% turn 45 degrees relative to the previous segment direction -- ([turn]90:3) coordinate[dot]; \path (0,0) coordinate[dot,red]; \end{tikzpicture} \end{document} Case B \documentclass[tikz,border=12pt,12pt]{standalone} \begin{document} \begin{tikzpicture}[dot/.append style={circle,fill,inner sep=3pt}] \draw (-3,-3) grid (3,3); \draw[line width=3pt] (-3,-1) coordinate[dot] -- (0,-1) coordinate[dot] -- +([turn]45:{sqrt(2)}) coordinate[dot]% how should this line be interpreted? -- ([turn]90:3) coordinate[dot]; \path (0,0) coordinate[dot,red]; \end{tikzpicture} \end{document}

  • 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:

  • 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.

  • 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!

  • How to add space between x axis labels and draw a vertical line after a set of IDs?
    by Student on November 21, 2024 at 8:13 pm

    I'm trying to add space between x axis labels 10 Flows, 20 Flows, and 30 Flows and also properly draw a line after for every 1 to 8 IDs. Could someone help me with this problem? Code: % restructured data file: % - 'n' values are sorted ascending % - added column 'z' to know which data belong to which measurement % - added a dummy line at the end of each data set to produce an empty entry % for the separation of the blocks % - put all data in one file \begin{filecontents}{data.txt} z n pFA pFB 10 1 6 1 10 2 7 1 10 3 8 4 10 4 9 7 10 5 10 9 10 6 0 0 10 7 9 4 10 8 12 6 20 1 6 1 20 2 7 1 20 3 8 4 20 4 9 7 20 5 10 9 20 6 0 0 20 7 9 4 20 8 12 6 30 1 6 1 30 2 7 1 30 3 8 4 30 4 9 7 30 5 10 9 30 6 0 0 30 7 9 4 30 8 12 6 \end{filecontents} \documentclass[border=5pt]{standalone} \usepackage{pgfplots} \usetikzlibrary{patterns} \pgfplotsset{compat=1.3} \begin{document} \begin{tikzpicture} \begin{axis}[ footnotesize, % set the `width' of the plot to the maximum length ... width=\textwidth, % ... and use half this length for the `height' height=0.5\textwidth, ymin=0, ymax=100, %yticklabel=\pgfmathprintnumber{\tick}\,$\%$, % use `data' for the positioning of the `xticks' ... xtick=data, % ... and use table data for labeling the `xticks' xticklabels from table={data.txt}{n}, % add extra ticks "at the empty entries to add the vertical lines extra x ticks={8,16}, % this ticks shouldn't be labeled ... extra x tick labels={}, % ... but grid lines should be drawn without the tick lines extra x tick style={ grid=major, major tick length=0pt, }, xlabel={X Axis Label}, ylabel={Y Axis Label}, % because of the category labels, shift the `xlabel' a bit down xlabel style={ yshift=-4ex, }, legend pos=north west, legend entries={ {\color{black}{Algorithm A}}, {\color{red}{Algorithm B}}, }, area legend, % adjust `bar width' so it fits your needs ... bar width=10pt, % ... and with that you also have to adjust the x limits enlarge x limits=0.05, % set `clip mode' to `individual' so the category labels aren't clipped away clip mode=individual, ] % plot the "red" ybars \addplot [ ybar, draw=black, pattern color=black, pattern=dots, ] table [ % use just the `coordindex' as x coordinate, % the correct labeling is done with `xticklabels from table' x expr=\coordindex, y=pFA, ] {data.txt}; % plot the "blue" ybars \addplot [ ybar, draw=red, pattern color=red, pattern=north east lines, ] table [ x expr=\coordindex, y=pFB, ] {data.txt}; % add the category labels \begin{scope}[ % because the reference point will be the lower axis line the % labels have to be moved a bit more down to don't overlap with % the `xticklabels' every label/.append style={ label distance=2ex, }, ] \node [label=below:10 Flows] at (axis cs:4,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:20 Flows] at (axis cs:12,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:30 Flows] at (axis cs:20,\pgfkeysvalueof{/pgfplots/ymin}) {}; % \node [label=below:40 Flows] % at (axis cs:20,\pgfkeysvalueof{/pgfplots/ymin}) {}; %\node [label=below:50 Flows] % at (axis cs:26,\pgfkeysvalueof{/pgfplots/ymin}) {}; \end{scope} \end{axis} \end{tikzpicture} \end{document} Output:

  • 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,

  • Best matplotlib to Tikz conversion tool
    by rhz on September 16, 2019 at 9:13 pm

    What are some good, well-maintained packages for converting matplotlib plots to Tikz files for inclusion in latex documents?

  • Placing Image (Logo) over frametitle in Beamer (Metropolis Template Theme), it appears underneath
    by Alexis Drakopoulos on February 12, 2019 at 3:38 pm

    I am using the Metropolis theme, when I attempt to use logo{} or tikz or even manually place the image, it appears underneath the "banner" that contains frame titles. I cannot figure out how to bring the image to front (overlay it) on top of the frame title. M(N)WE: \documentclass{beamer} \usetheme{metropolis} \logo{\includegraphics[height=1cm]{example-image-duck}} \begin{document} \begin{frame} \frametitle{frame title} abc \end{frame} \end{document}

  • 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}