• Standard practices in label decluttering: overcoming overlapping label lines
    by Jasper on February 8, 2026 at 11:59 pm

    I have a situation where I want to lable the sample points of a line segment, and also label the smaller line segments connecting those sample points. My labels are really cluttered right now. How can I make this more proper? \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \draw[thick,->] (-1,0) -- (5,0) node[below left] {\(x\)}; \fill (0.5,0) circle[radius = 3pt] node[above] {point}; \fill[gray] (0.5,0) circle[radius = 1.5pt]; \draw[] (0.5,0) -- (0.5,-2) -- (5,-2) node[right] {individual sample point}; \draw[line width = 6pt] (2,0) -- (3.5,0) node[above,pos=0.5]{line segment}; \foreach[count = \c from 1] \x in {2,2.5,...,3.5} { \fill[gray] (\x,0) circle[radius = 1.5pt]; \draw[] (\x,0) -- (4,-1); \ifnum\c=4\else\draw[thick,gray] (\x,0) -- ++(0.5,0);\fi } \draw[](4,-1) -- (5,-1) node[right] {multiple sample points}; \foreach[count = \c from 1] \x in {2.25,2.75,...,3.25} { \draw[] (\x,0) -- (4,-1.5); } \draw[](4,-1.5) -- (5,-1.5) node[right] {one or more line segments}; \end{tikzpicture} \end{document}

  • pgfplots: axis-enlargement and visualizing of very small y-values at binomial distribution
    by cis on February 8, 2026 at 4:34 pm

    I wanted to adapt this nice solution for my purposes. • I want to extend the x- and y-axes a bit. But, when I set enlarge y limits={upper, abs=0.125} it creates a strange gap (ymin=0 is no longer respected, and restrict y to domain=0:1 seems to have no effect). • Secondly, what's the best way to configure it so that bars with very small y-values ​​are also visible here? • Unfortunately, I saw this too late: I would also like to eliminate this x-gap between the first bar and the y-axis! \documentclass[margin=5pt]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture}[font=\footnotesize, declare function={ binom(\n,\p,\k)=\n!/(\k!*(\n-\k)!)*\p^\k*(1-\p)^(\n-\k); } ] \begin{axis}[%y=8mm, no effect ymin=0, xmin=0, axis lines=left, axis line style={-latex}, xlabel={$k$}, ylabel={$P(X=k)$}, x label style={at={(axis description cs:1,0)}, anchor=south east, inner xsep=0pt }, y label style={at={(axis description cs:0,1)}, rotate = -90, anchor=north west, inner ysep=0pt, }, yticklabel style={ /pgf/number format/fixed, /pgf/number format/fixed zerofill, /pgf/number format/precision=2 }, ybar=0pt, bar width=1, bar shift=0pt, samples at={0,...,13}, variable=\k, enlarge x limits={upper, abs=0.785}, enlarge y limits={upper, abs=0.125}, %restrict y to domain=0:1,% no effect.... y= ] \addplot [fill=gray!25] {binom(13, 0.4, k)}; %\addplot [fill=orange, samples at={0,...,4}] {binom(12,0.4,k)}; %\addplot [fill=cyan, samples at={7}] {binom(12,0.4,k)}; \end{axis} \end{tikzpicture} \end{document}

  • How can I replicate this image using TikZ?
    by Bayaraa Surenjav on February 8, 2026 at 4:11 pm

    My code is: \documentclass[tikz,border=10pt]{standalone} \usepackage[utf8]{inputenc} \usepackage[mongolian]{babel} \usepackage{amsmath} \usetikzlibrary{calc, positioning, arrows.meta, backgrounds, shapes.geometric} \begin{document} \begin{tikzpicture}[ num node/.style={ font=\Large\bfseries\rmfamily, % Serif font, Bold anchor=east, inner sep=3pt, minimum height=0.65cm }, div node/.style={ font=\Large\rmfamily, anchor=east, inner sep=3pt }, arrow style/.style={ ->, >=latex, draw=cyan!80!blue, line width=0.8pt }, label text/.style={ text=cyan!80!blue, font=\itshape, align=right }, % Үйлдлийн тэмдэг (div 2) op label/.style={ text=cyan!80!blue, font=\large, anchor=west, xshift=2pt } ] \def\rowh{0.9} \node[div node] (d1) at (0,0) {2)}; \node[num node] (n1) at (1.8,0) {120}; \draw[thick] (d1.south east) -- (n1.south east); \node[div node] (d2) at (0,-\rowh) {2)}; \node[num node] (n2) at (1.8,-\rowh) {60}; \draw[thick] (d2.south east) -- (n2.south east); \node[div node] (d3) at (0,-2*\rowh) {2)}; \node[fill=cyan!25, inner sep=2pt, minimum height=0.6cm, minimum width=0.8cm, anchor=east] at (1.85,-2*\rowh) {}; \node[num node, text=magenta] (n3) at (1.8,-2*\rowh) {30}; \draw[thick] (d3.south east) -- (n3.south east); \node[div node] (d4) at (0,-3*\rowh) {3)}; \node[num node] (n4) at (1.8,-3*\rowh) {15}; \draw[thick] (d4.south east) -- (n4.south east); \node[num node] (n5) at (1.8,-4*\rowh) {5}; \begin{scope}[on background layer] % Зүүн талын босоо багана (Хуваагчдыг хамарсан) \fill[cyan!15] (-0.8, 0.4) rectangle (0.2, -4.5*\rowh); \fill[cyan!15] (-0.8, -3.65*\rowh) rectangle (2.2, -4.5*\rowh); \end{scope} \def\arm{0.5} \draw[arrow style] (n1.east) -- ++(\arm,0) |- node[pos=0.25, op label] {$\div 2$} (n2.east); \draw[arrow style] (n2.east) -- ++(\arm,0) |- node[pos=0.25, op label] {$\div 2$} (n3.east); \draw[arrow style] (n3.east) -- ++(\arm,0) |- node[pos=0.25, op label] {$\div 2$} (n4.east); \draw[arrow style] (n4.east) -- ++(\arm,0) |- node[pos=0.25, op label] {$\div 3$} (n5.east); \node[label text] (txt1) at (-3.5, 0) {анхны тоогоор хуваах}; \draw[arrow style] (txt1) -- (d1.west); \node[label text] (txt2) at (-4, -4*\rowh) {анхны тоо гартал үргэлжлүүлнэ}; \draw[arrow style] (txt2) -- (n5.west); \end{tikzpicture} \end{document} Current: Intended:

  • tikz euclides draw circle hung
    by Vuvi Numa on February 8, 2026 at 1:49 pm

    The MWE below freezes on the commented out line, until it is killed with Ctrl-C. This is a part of an old manuscript that was published, several years in the past, so at some point it did work. \documentclass{standalone} \usepackage{tikz} \usepackage{tkz-euclide} \begin{document} \begin{tikzpicture} \draw(-1,-1) rectangle(1,1); \tkzDefPoint(3,-1){A}; \tkzDefPoint(6,-1){B}; \tkzDefPoint(3,1){C}; %\tkzDrawCircle[in](A,B,C); \end{tikzpicture} \end{document} The last few lines of pdflatex output are: (/usr/share/texlive/texmf-dist/tex/latex/tkz-euclide/tkz-draw-eu-protractor.tex 2023/02/03 5.02c tkz-obj-eu-protractor.tex )) No file test.aux. (/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii [Loading MPS to PDF converter (version 2006.09.02).] ) (/usr/share/texlive/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty (/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)) Missing character: There is no ; in font nullfont! Missing character: There is no ; in font nullfont! Missing character: There is no ; in font nullfont! ^C! Interruption. \pgfkeys@parse ...uturelet \pgfkeys@possiblerelax \pgfkeys@parse@main l.12 \tkzDrawCircle[in](A,B,C) ; How can I fix the freeze and allow the arch to be drawn?

  • Best way to set pgf-grouplots and others inside a table
    by cis on February 8, 2026 at 1:21 pm

    I have a table, it looks like this: But I'm having a few problems. What's the best way to set the keys? The table contains a 2×2 groupplot and a formula next to another plot (this plot can be larger than the others). I want to use the entire width of the yellow box! What's the best way to set this up? (In the MWE, I only set it visually.) The formula should be vertically centered or top-centered, whichever is easier to set or looks better. The number of columns with the numbers (1111, 2222,...) is variable, but I don't think that matters because: The entire table should have the page width. Note: The reason I put everything in newcommands is that the original table is actually a pgfplotstable - I'm simulating it here. \documentclass[paper=a5]{scrartcl} \usepackage[margin=14mm, showframe=true]{geometry} \usepackage{amsmath} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepgfplotslibrary{groupplots} \usepackage{colortbl}% \rowcolor, \cellcolor \usepackage{diagbox}% \diagbox \usepackage{hhline}% \hhline{~|-------|} and so on \newcommand\Mydiagrams{ \begin{tikzpicture}[] \begin{groupplot}[group style={group size=2 by 2}, height=30mm,width=49mm, no marks, title style={inner sep=0pt} ] \nextgroupplot[title=plot 1] \addplot{x}; \nextgroupplot[title=plot 2] \addplot{x^2}; \nextgroupplot[title=plot 3] \addplot{x^3}; \nextgroupplot[title=plot 4] \addplot{x^4}; \end{groupplot} \end{tikzpicture}} \newcommand\Myheaddiagram{% \begin{tikzpicture}[] \begin{axis}[ height=30mm,width=49mm, no marks, title style={inner sep=0pt}, title=plot 0, ] \addplot{sin(deg(x))+2}; \end{axis} \end{tikzpicture}} \newcommand\Headformula{% $F(a,b,c) =\displaystyle\sum\limits_{v=0}^k \binom{a}{b} a^v (b+c)^{n-v}$ }% \newcommand\Myhead{% \begin{tabular}[t]{| @{}l@{} | @{}c@{} |}% tabular for linebreaks \arrayrulecolor{blue} \Headformula & \Myheaddiagram \\ \multicolumn{2}{|c|}{\Mydiagrams} \end{tabular} }% \begin{document} \section{Diagramms} \setlength\arrayrulewidth{2pt}% test: correctness of the rules \footnotesize\sffamily% wanted \noindent\begin{tabular}{c | c | *{7}{c} |c|} \hhline{~| *{8}{-} |} & \multicolumn{8}{l|}{\cellcolor{yellow}\Myhead} & \multicolumn{1}{c}{c'} \\ \hhline{-| *{8}{-} -|} \rowcolor{pink} aaa & bbb & 0.1111 & .2222 & .3333 & .4444 & .5555 & .6666 & .7777 & ccc \\ aaa & bbb & 0.1111 & .2222 & .3333 & .4444 & .5555 & .6666 & .7777 & ccc \\ aaa & bbb & 0.1111 & .2222 & .3333 & .4444 & .5555 & .6666 & .7777 & ccc \\ \hline aaa & \diagbox{p}{k} & 0.1111 & .2222 & .3333 & .4444 & .5555 & .6666 & .7777 & \diagbox{p}{k} \\ \end{tabular} \end{document}

  • Displaying equations involving TikZ graphics on a WordPress site with MathJax [closed]
    by abcdf on February 7, 2026 at 12:09 am

    I am writing a website using WordPress with MathJax. In my LaTeX documents, I use TikZ to construct equations that include graphics embedded in the math (for example, superscripts or subscripts connected by lines drawn with TikZ). I would like to display equations of this kind on my website as well. An example of the desired output is shown in the image below. While this works fine in LaTeX, I do not know how to achieve a similar result on a website using MathJax (or related tools such as tikzjax). Is this possible in principle? If so, what would be the recommended approach? Any help or pointers would be greatly appreciated. The following code produces the equation shown in the image in a LaTeX environment using TikZ. \documentclass[a4paper,15pt,riqno]{bxjsreport}%{bxjsarticle} \usepackage[ipa]{zxjafont} \usepackage{tikz-cd} \usetikzlibrary{calc} \usepackage{amsmath} \usetikzlibrary{tikzmark} \begin{document} \begin{align} a^{\tikzmarknode{X}{x}} +b^{\tikzmarknode{Y}{y}} =c^{\tikzmarknode{Z}{z}} \end{align} \tikz[remember picture,overlay]{ \coordinate (Xp) at ($(X.north)+(0,0.3ex)$); \coordinate (Yp) at ($(Y.north)+(0,0.3ex)$); \coordinate (Zp) at ($(Z.north)+(0,0.3ex)$); \path let \p1 = (Xp), \p2 = (Yp), \p3 = (Zp) in coordinate (TopX) at (\x1,{max(\y1,\y2,\y3)+2ex}) coordinate (TopY) at (\x2,{max(\y1,\y2,\y3)+2ex}) coordinate (TopZ) at (\x3,{max(\y1,\y2,\y3)+2ex}); \draw (Xp) -- (TopX); \draw (Yp) -- (TopY); \draw (Zp) -- (TopZ); \draw (TopX) -- (TopY) -- (TopZ); } \begin{align} d_{\tikzmarknode{X}{p}} +e_{\tikzmarknode{Y}{q}} =f_{\tikzmarknode{Z}{r}} \end{align} \tikz[remember picture,overlay]{ \coordinate (Xp) at ($(X.south)+(0,-0.3ex)$); \coordinate (Yp) at ($(Y.south)+(0,-0.3ex)$); \coordinate (Zp) at ($(Z.south)+(0,-0.3ex)$); \path let \p1 = (Xp), \p2 = (Yp), \p3 = (Zp) in coordinate (BottomX) at (\x1,{min(\y1,\y2,\y3)-2ex}) coordinate (BottomY) at (\x2,{min(\y1,\y2,\y3)-2ex}) coordinate (BottomZ) at (\x3,{min(\y1,\y2,\y3)-2ex}); \draw (Xp) -- (BottomX); \draw (Yp) -- (BottomY); \draw (Zp) -- (BottomZ); \draw (BottomX) -- (BottomY) -- (BottomZ); } \end{document}

  • Drawing diagrams in latex [duplicate]
    by Noah on February 6, 2026 at 4:43 pm

    I’m relatively new at diagram drawing in latex. How would I go about drawing an upper half sphere with an elliptic curve plotted along it (to resemble the real projective plane)? I want it to look something like this where you have the upper-half sphere drawn and shaded in a solid light grey, and the intersection of the equation X^3-3XZ^2+3Z^3-Y^2Z=0 with the upper-half sphere, the point (0,1,0) annotated with infinity, and the viewing angle rotated as in the image (and possibly the curve in another colour). I really don’t like the usual 3D look but prefer the way the following attached images look. I’d greatly appreciate your help!

  • Finding and displaying the intersection points of two surfaces
    by SH.Madadpour on February 6, 2026 at 10:23 am

    How can I display the intersection of the following two surfaces in LaTeX? I have used the following codes as a default but I am not getting acceptable output. Is it possible to create a form to find its intersection points in LaTeX? Thanks a lot. \documentclass[border=3.14mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.16} \begin{document} \begin{tikzpicture} \begin{axis}[domain=0.01:30,xlabel=$x$] \addplot3[surf,domain={0:1},color=green]{x^3+y^3}; \addplot3[surf,domain={0:1},color=red]{(x*(1-y^2)^(.5)+y*(1-x^2)^(.5))^3}; \end{axis} \end{tikzpicture} \end{document}

  • tikz / xint: Read out (and calc with) fractions from list (or array) with xint or pgfmath
    by cis on February 6, 2026 at 8:45 am

    How can I read out numbers from a list, say \def\pList{0.1, 1/6, 0.25, 0.4} (or array, say \def\pListArray{{\pList}}), with xint? Background: I want to keep fractions, like 1/6 in it's original form (not decimal value 0.1666 here). On the other hand, I need to calc 1-<value> too, and I want, in the case of 1/6 the value 5/6 (=1 - 1/6). I have a main document with a lot of xint content and calculations; therefore, for consistency reasons, it should be done with xint (it's clear that there are other packages or methods for this); and: There must be a method in the xint-package that I can't find in the manual. Does anybody know? \documentclass[margin=5pt, varwidth]{standalone} \usepackage{tikz} \usepackage{xintexpr} \begin{document} \def\pList{0.1, 1/6, 0.25, 0.4}% List \def\pListArray{{\pList}} \section{The pList} \pList \section{pgfmath-test for fraction-readout (bad)} p=\pgfmathprint{\pListArray[0]}, q=\pgfmathprint{1-\pListArray[0]} good. But p=\pgfmathprint{\pListArray[1]}, q=\pgfmathprint{1-\pListArray[1]} bad. \section{xint-test for fractions (good), but how to readout?} p=\xinteval{1/6}, q=\xinteval{1-1/6} \end{document}

  • using macros in coordinates is causing node names to be read as functions in tikz
    by Jasper on February 5, 2026 at 11:19 pm

    I'm trying to answer Animating light entry and radiation in a blackbody cavity, but am getting an error that I don't recognize. It's treating hit\hit as a function instead of a node name. It works if I just write it with numbers instead of with \hit. Yes, I know some of my conventions are wrong (e.g., by using one letter macro names). I would fix that after fixing my error which prompted this question. ! Package PGF Math Error: Unknown function `hit6' (in 'hit6'). % Source - https://tex.stackexchange.com/q/759283 % Posted by Sebastiano % Retrieved 2026-02-05, License - CC BY-SA 4.0 % Author: Izaak Neutelings (March 2019) % Inspiration: https://tex.stackexchange.com/questions/203597/automatically-generate-graphics-which-shows-light-diffusion-on-a-rough-surface \documentclass[border=3pt,tikz]{standalone} \usetikzlibrary{decorations.pathmorphing,decorations.markings,calc} % for random steps & snake \usetikzlibrary{arrows.meta} % for arrow size \tikzset{>=latex} % for LaTeX arrow head \tikzstyle{radiation}=[-{Latex[length=2,width=1.5]},red!95!black!50,opacity=0.7,very thin,decorate, decoration={snake,amplitude=0.7,segment length=2,post length=2}] \begin{document} \foreach \c[count = \i from 0] in {6,1,15,5,9,14,2,10,3,4,11,13,1,quack} { \pgfmathsetmacro{\flag}{\i == 0} \pgfmathsetmacro{\flagtwo}{\i == 13} \ifnum\flag=1 \xdef\mylist{\c} \else \ifnum\flagtwo=0 \xdef\mylist{\mylist,\c} \else % nothing \fi \fi \begin{tikzpicture}[scale=1.5,rotate=10] \useasboundingbox (-2,-2) rectangle (2,2); \shade[top color=black!60,bottom color=black!80,shading angle=10] (7:1) arc (7:355:1); \fill[thick,black,postaction=decorate, % rough inner surface decoration={markings,mark=between positions 0.55 and 1 step 0.03 with { \node[transform shape,inner sep=1pt] (hit\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) {}; }}] (7:1) arc (7:353:1) --++ (-7:-0.18) decorate[decoration={random steps,segment length=2,amplitude=1pt}] {arc (-7:-353:0.82)} -- cycle; \draw[yellow] (8:1.5) foreach \hit in {\mylist} { -- (hit\hit .center)}; \ifnum\flagtwo=1 \foreach \ang in {-35,-5,35}{ \draw[radiation] (1,0)++(\ang:0.1 and 0.2) --++ (\ang:0.35); }\fi \end{tikzpicture}} \end{document}

  • Animating light entry and radiation in a blackbody cavity
    by Sebastiano on February 5, 2026 at 9:04 pm

    I am using the code from https://tikz.net/blackbody/ by Izaak Neutelings, which draws a blackbody cavity with an incoming yellow light beam and wavy red arrows representing the emitted radiation. I would like to animate the yellow light beam to show that light enters the cavity, and only afterward make the wavy red arrows appear to represent the radiation. % Author: Izaak Neutelings (March 2019) % Inspiration: https://tex.stackexchange.com/questions/203597/automatically-generate-graphics-which-shows-light-diffusion-on-a-rough-surface \documentclass[border=3pt,tikz]{standalone} \usetikzlibrary{decorations.pathmorphing,decorations.markings,calc} % for random steps & snake \usetikzlibrary{arrows.meta} % for arrow size \tikzset{>=latex} % for LaTeX arrow head \tikzstyle{radiation}=[-{Latex[length=2,width=1.5]},red!95!black!50,opacity=0.7,very thin,decorate, decoration={snake,amplitude=0.7,segment length=2,post length=2}] \begin{document} % BLACK BODY \begin{tikzpicture}[scale=1,rotate=10] \shade[top color=black!60,bottom color=black!80,shading angle=10] % background (7:1) arc (7:355:1); \fill[thick,black,postaction=decorate, % rough inner surface decoration={markings,mark=between positions 0.55 and 1 step 0.03 with { \node[transform shape,inner sep=1pt] (hit\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) {}; }}] (7:1) arc (7:353:1) --++ (-7:-0.18) decorate[decoration={random steps,segment length=2,amplitude=1pt}] {arc (-7:-353:0.82)} -- cycle; \draw[yellow] % connect light ray to random points (8:1.5) -- (hit6.center) -- (hit1.center) -- (hit15.center) -- (hit5.center) -- (hit9.center) -- (hit14.center) -- (hit2.center) -- (hit10.center) -- (hit3.center) -- (hit4.center) -- (hit11.center) -- (hit13.center); \foreach \ang in {-35,-5,35}{ \draw[radiation] (1,0)++(\ang:0.1 and 0.2) --++ (\ang:0.35); } \end{tikzpicture} % BLACK BODY - without infalling light \begin{tikzpicture}[scale=1,rotate=10] \shade[top color=black!60,bottom color=black!80,shading angle=10] % background (7:1) arc (7:355:1); \fill[thick,black,postaction=decorate, % rough inner surface decoration={markings,mark=between positions 0.55 and 1 step 0.03 with { \node[transform shape,inner sep=1pt] (hit\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) {}; }}] (7:1) arc (7:353:1) --++ (-7:-0.18) decorate[decoration={random steps,segment length=2,amplitude=1pt}] {arc (-7:-353:0.82)} -- cycle; \foreach \ang [evaluate={\angin=\ang-180+10*rand; \r=0.76+0.05*rand; \l=0.4+0.02*rand}] in {10,45,100,140,190,240,290,330}{ \draw[radiation] (\ang:\r) --++ (\angin:\l); } \foreach \ang in {-30,0,30}{ \draw[radiation] (1,0)++(\ang:0.05 and 0.16) --++ (\ang:0.35); } \end{tikzpicture} \end{document}

  • Tikzcd's "crossing over" option and transparent backgrounds
    by Ben Steffan on February 5, 2026 at 8:55 pm

    I currently have the following simple setup for producing commutative diagrams using tikzcd and exporting them to .svg's, following the two most popular answers on this question: Put the code for the diagram in a standalone tex file. Compile. Convert to .svg using dvisvgm. This... works, mostly (better ideas are warmly welcome), but I'm running into one issue in particular that is slightly annoying. Consider the following example: \documentclass[crop,tikz]{standalone} \usetikzlibrary{cd} \begin{document} \begin{tikzcd} & & & \{1\} \ar[dd] \ar[dl] \\ \{0\} \ar[rr] \ar[dd] & & \{0, 1\} \\ & \{2\} \ar[dl] \ar[rr] & & \{1, 2\} \ar[dl] \\ \{0, 2\} \ar[rr] & & \{0, 1, 2\} \ar[from=uu, crossing over] \end{tikzcd} \end{document} If you compile this, the resulting pdf looks like this: Great, that looks fantastic. But if you now go and run dvisvgm yourfilenamehere.dvi and drop the resulting svg into something with a non-white background, you get this: This is bad for two obvious reasons: Text and background color are way too similar, and the crossing over arrow now lives on top of a white box. This box is an artifact of the way crossing over works, which simply adds a preaction to the arrow path that draws a background color colored rectangle. Consequently, both problems can be avoided by setting color and background color to something that works, see e.g. this answer. Suppose now, however, that I don't know what color the background of the document/website/etc. the svg will be embedded in has. Perhaps I know that it's going to be a dark background, so that setting the text color to white will take care of the first issue, but unless I know the precise shade of the background I can't set the crossing over box' color to perfectly match. My question, thus, is whether there is a (nice) way to solve this second issue when the final background color is not precisely known (if you have a way to dynamically alter the text color, I'd be happy to hear about it as well). (By "nice" here I mean that e.g. it's obviously possible to draw the two "pieces" of the arrow being crossed over separately and avoid crossing over entirely, but this seems to annoying to do in general unless there is some way to package it up into a flexible macro/tikz key).

  • Make perfect circular diagrams
    by Fran on February 5, 2026 at 12:23 pm

    I know that I can make circular diagrams with the nice smartdiagram package, but arrows do not fit perfectly in a imaginary circle. In fact, the diagram is far from a circle when there are only two or three nodes: \documentclass{standalone} \usepackage{smartdiagram} \begin{document} \smartdiagramset{ connection color=red, module shape= circle, circular distance=2cm, uniform color list=white for 6 items, uniform arrow color=true, arrow color=black} \smartdiagram[circular diagram:clockwise]{foo, bar} \end{document} I know also that there are several examples in this site about making circular diagrams without this package, but translating these examples to diagrams with a different numbers of nodes is complex, so I tried an automated solution with tikz (without really knowing what I was doing, I have to admit) so that I only have to modify a list of nodes in \mylist and little more to obtain the result: \documentclass[border=2mm]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture}[ > = Stealth, every node/.style = {circle, draw, thick, minimum width=1cm, align=center} ] \def\mylist{foo, bar, baz} % play with this \foreach \x [count=\i from 1] in \mylist {\xdef\n{\i}} \def\radio{2cm} % and this if needed \foreach \texto [count=\i from 0] in \mylist{ \pgfmathsetmacro\ang{-\i*360/\n} \node (n\i) at (\ang:\radio) {\texto}; } \foreach \dummy [count=\i from 0] in \mylist{ \pgfmathsetmacro\j{int(mod(\i+1,\n))} \pgfmathsetmacro\angini{-\i*360/\n} \pgfmathsetmacro\angfin{-\j*360/\n} \pgfmathsetmacro\outang{mod(\angini - 90 + 720, 360)} \pgfmathsetmacro\inang {mod(\angfin + 90 + 720, 360)} \draw[->, thick, line width=1.4pt] (n\i) to[out=\outang, in=\inang, looseness=.9] (n\j); % and with the looseness } \end{tikzpicture} \end{document} Mainly it works. The problem is that like in smartdiagram, the arrows don't perfectly follow an imaginary circle, that was the idea behind getting involved in this business. Playing with looseness is possible to correct a bit the curvature of the arrows, but it's tedious and the result is never perfect. So, the result should be ideally near to the image below (that I modified manually in Inkscape) and still require minimal settings to adapt the code to diagrams of n nodes. Fixes of the MWE as well as alternative approaches are welcome. Edit Thank you all for the excellent suggestions. This time, I am truly sorry I can only accept one.

  • Problem with the position of a graph (pgfplots)
    by Octavius on February 5, 2026 at 12:36 am

    in the following code and in the attached image, the graph becomes misaligned. Could you please give me an idea on how to fix it? \documentclass{article} \usepackage{graphicx} % Required for inserting images \newcommand{\ocultar}[1]{} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{pdfpages} \usepackage{hyperref} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage[utf8]{inputenc} \usepackage[spanish]{babel} \usetikzlibrary{angles, quotes} \usepackage{fancyhdr} \usepackage{graphicx} \usepackage{array} \begin{document} \begin{center} \begin{tabular}{>{\centering}m{5cm} >{\centering}m{5cm} >{\centering}m{5cm}} % CRECIENTE \begin{tikzpicture} \begin{axis}[ axis lines=middle, xmin=-3,xmax=6, ymin=-3,ymax=6, grid=both, width=5cm, height=5cm, ticks=none ] \addplot[red, thick] {x+1}; \end{axis} \end{tikzpicture} & % DECRECIENTE \begin{tikzpicture} \begin{axis}[ axis lines=middle, xmin=-3,xmax=6, ymin=-3,ymax=6, grid=both, width=5cm, height=5cm, ticks=none ] \addplot[blue, thick] {-x+3}; \end{axis} \end{tikzpicture} & % CONSTANTE \begin{tikzpicture} \begin{axis}[ axis lines=middle, xmin=-3,xmax=6, ymin=-3,ymax=6, grid=both, width=5cm, height=5cm, ticks=none ] \addplot[black, thick] {3}; \end{axis} \end{tikzpicture} \\[2mm] \fbox{\begin{minipage}{4.5cm} \centering \textbf{Creciente.}\\ En este caso su pendiente\\ es \textcolor{red}{\textbf{POSITIVA}.} \end{minipage}} & \fbox{\begin{minipage}{4.5cm} \centering \textbf{Decreciente.}\\ En este caso su pendiente\\ es \textcolor{blue}{\textbf{NEGATIVA}.} \end{minipage}} & \fbox{\begin{minipage}{4.5cm} \centering \textbf{Constante.}\\ En este caso su pendiente\\ es \textbf{CERO}. \end{minipage}} \end{tabular} \end{center} \end{document}

  • Unexpected “ccc” labels appearing in a pgfplots graph
    by Octavius on February 4, 2026 at 8:51 pm

    I have the following LaTeX code, and in the middle plot (the decreasing function) I cannot remove the letters “ccc” that appear on the graph. Does anyone have a suggestion on how to fix this? \documentclass{article} \usepackage{graphicx} % Required for inserting images \newcommand{\ocultar}[1]{} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{pdfpages} \usepackage{hyperref} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage[utf8]{inputenc} \usepackage[spanish]{babel} \usetikzlibrary{angles, quotes} \begin{document} \begin{center} \begin{tabular}{>{\centering}m{5cm} >{\centering}m{5cm} >{\centering}m{5cm}} % CRECIENTE \begin{tikzpicture} \begin{axis}[ axis lines=middle, xmin=-3,xmax=6, ymin=-3,ymax=6, grid=both, width=5cm, height=5cm, ticks=none ] \addplot[red, thick] {x+1}; \end{axis} \end{tikzpicture} & % DECRECIENTE \begin{tikzpicture} \begin{axis}[ axis lines=middle, xmin=-3,xmax=6, ymin=-3,ymax=6, grid=both, width=5cm, height=5cm, ticks=none ] \addplot[blue, thick] {-x+3}; \end{axis} \end{tikzpicture} & % CONSTANTE \begin{tikzpicture} \begin{axis}[ axis lines=middle, xmin=-3,xmax=6, ymin=-3,ymax=6, grid=both, width=5cm, height=5cm, ticks=none ] \addplot[black, thick] {3}; \end{axis} \end{tikzpicture} \end{document}

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

  • improve of solid effect of stack of unit cube legos: solid draw with hole, protruding elements
    by Epa on February 4, 2026 at 8:06 am

    How to make the solid effect view better, as shown in the photo attached? \documentclass[]{standalone} \usepackage{amsmath, amssymb, latexsym, amscd, amsthm} \usepackage{tikz} \newcommand{\drawboxa}[4]{ \pgfmathsetmacro \angle {30} \pgfmathsetmacro \xd {{2/3*cos(\angle)}} \pgfmathsetmacro \yd {{2/3*sin(\angle)}} \pgfmathsetmacro \x {{#1-1+(#2-1)*(\xd)}} \pgfmathsetmacro \y {{#3-1+(#2-1)*(\yd)}} \draw[fill=#4] (\x,\y) -- (\x+1,\y) -- (\x+1,\y+1) -- (\x,\y+1) -- cycle; \draw[fill=#4] (\x,\y+1) -- (\x+\xd,\y+1+\yd)coordinate[pos=.5](M) -- (\x+1+\xd,\y+1+\yd) -- (\x+1,\y+1) -- cycle; \draw[fill=#4] (\x+1,\y+1) -- (\x+1+\xd,\y+1+\yd) -- (\x+1+\xd,\y+\yd)coordinate[pos=.5](M2) -- (\x+1,\y)-- (\x+1,\y+1)coordinate[pos=.5](M3); \path(M2)--(M3)coordinate[pos=.5](M4); \draw[fill=#4] (M)++(.5,0)coordinate(T1)++(.15,0)arc(0:-180:.15cm and .06cm)--++(0,.1)arc(-180:0:.15cm and .06cm)coordinate(T2)--++(0,-.1) (T2)arc(0:180:.15cm and .06cm); \draw[fill=black,opacity=.1](M4)circle(.12cm and .15cm) (\x,\y)++(.5,.5)circle(.15); \draw(M4)circle(.12cm and .15cm) (\x,\y)++(.5,.5)circle(.15); } \newcommand{\drawboxb}[3]{ \pgfmathsetmacro \angle {30} \pgfmathsetmacro \xd {{2/3*cos(\angle)}} \pgfmathsetmacro \yd {{2/3*sin(\angle)}} \pgfmathsetmacro \x {{#1-1+(#2-1)*(\xd)}} \pgfmathsetmacro \y {{#3-1+(#2-1)*(\yd)}} \draw[fill=white] (\x,\y) -- (\x+1,\y) -- (\x+1,\y+1) -- (\x,\y+1) -- cycle; \draw[fill=white] (\x,\y+1) -- (\x+\xd,\y+1+\yd)coordinate[pos=.5](M) -- (\x+1+\xd,\y+1+\yd) -- (\x+1,\y+1) -- cycle; \draw[fill=white] (\x+1,\y+1) -- (\x+1+\xd,\y+1+\yd) -- (\x+1+\xd,\y+\yd)coordinate[pos=.5](M2) -- (\x+1,\y)-- (\x+1,\y+1)coordinate[pos=.5](M3); \path(M2)--(M3)coordinate[pos=.5](M4); \draw[fill=white] (M)++(.55,0)coordinate(T1)++(.15,0)arc(0:-180:.2cm and .07cm)--++(0,.1)arc(-180:0:.2cm and .07cm)coordinate(T2)--++(0,-.1) (T2)arc(0:180:.2cm and .07cm) (T2)++(-.2,0)circle(.16cm and .04cm); \draw(M4)circle(.15cm and .2cm)circle(.11cm and .16cm) (\x,\y)++(.5,.5)circle(.2)circle(.15); } \usepackage{tikzbricks} %\printanswers \newcommand{\drawboxc}[4]{ \pgfmathsetmacro \angle {30} \pgfmathsetmacro \xd {{2/3*cos(\angle)}} \pgfmathsetmacro \yd {{2/3*sin(\angle)}} \pgfmathsetmacro \x {{#1-1+(#2-1)*(\xd)}} \pgfmathsetmacro \y {{#3-1+(#2-1)*(\yd)}} \draw[fill=#4] (\x,\y) -- (\x+1,\y) -- (\x+1,\y+1) -- (\x,\y+1) -- cycle; \draw[fill=#4] (\x,\y+1) -- (\x+\xd,\y+1+\yd)coordinate[pos=.5](M) -- (\x+1+\xd,\y+1+\yd) -- (\x+1,\y+1) -- cycle; \draw[fill=#4] (\x+1,\y+1) -- (\x+1+\xd,\y+1+\yd) -- (\x+1+\xd,\y+\yd)coordinate[pos=.5](M2) -- (\x+1,\y)-- (\x+1,\y+1)coordinate[pos=.5](M3); \path(M2)--(M3)coordinate[pos=.5](M4)coordinate[pos=.4](M5); \draw[fill=#4](M4)circle(.12cm and .15cm)++(0,.15)coordinate(Y1)++(0,-.15)coordinate(Y2); \draw[fill=#4](M5)++(0,-.025)circle(.12cm and .15cm)++(0,.15)coordinate(Y3)++(0,-.3)coordinate(Y4) (Y3)--(Y1)arc(90:270:.12cm and .15cm)--(Y4)arc(270:90:.12cm and .15cm); \draw[fill=black,opacity=.1](\x,\y)++(.5,.5)circle(.15) (M)++(.5,0)coordinate(T1)circle(.15cm and .06cm); \draw(\x,\y)++(.5,.5)circle(.15) (T1)circle(.15cm and .06cm); } \begin{document} \begin{tikzpicture} \def\x{3} %so luong block \foreach\h in{1,...,\x}{ \drawboxa{1}{1}{\h}{blue!25} } \def\d{.3} \draw(1,-\d) node[scale=1.3]{3}; \draw(.8,\x+1.2*\d) node[scale=1.2, above]{three}; \begin{scope}[xshift=100] \def\x{2} %so luong block \foreach\h in{1,...,\x}{ \drawboxa{1}{1}{\h}{blue!25} } \draw(1,-\d) node[scale=1.3]{2}; \draw(.8,\x+1.2*\d) node[scale=1.2, above]{two}; \end{scope} \begin{scope}[xshift=200] \def\x{5} %so luong block \foreach\h in{1,...,\x}{ \drawboxa{1}{1}{\h}{blue!25} } \draw(1,-\d) node[scale=1.3]{5}; \draw(.8,\x+1.2*\d) node[scale=1.2, above]{five}; \end{scope} \end{tikzpicture} \vspace{1cm} \begin{tikzpicture} \def\x{5} %so luong block %drawbox{x}{z}{y} %x la toa do x %z la toa do lop tinh theo goc xien %y la toa do y \drawboxb{1}{0}{0} \end{tikzpicture} \begin{tikzpicture} \def\x{5} % so luong block xanh \def\v{2} % so luong block vang \def\b{1} % so luong block xanh duong \pgfmathtruncatemacro{\xx}{\x+1} \pgfmathtruncatemacro{\vv}{\x+\v} \pgfmathtruncatemacro{\vvv}{\vv+1} \pgfmathtruncatemacro{\bb}{\vv+\b} \ifnum\x>0 \foreach \h in {1,...,\x}{ \drawboxc{\h}{1}{1}{brown!35} } \fi \ifnum\v>0 \foreach \h in {\xx,...,\vv}{ \drawboxc{\h}{1}{1}{yellow!55} } \fi \ifnum\b>0 \foreach \h in {\vvv,...,\bb}{ \drawboxc{\h}{1}{1}{blue!25} } \fi \end{tikzpicture} \end{document} The code was from user 11232 How to draw stacked cubes of different sizes and colors?

  • Tikz feature `scope fading` only work for PDF but not the PNG format from screenshot tools on windows11?
    by Explorer on February 3, 2026 at 12:49 am

    This post originated from cfr's elegant solution here with scope fading: However, I found that it doesn't work with my bg.png, but work with bg.pdf: with bg.png: \documentclass[landscape]{article} \usepackage{tikz} \usetikzlibrary{fadings} \usepackage{kantlipsum} \begin{document} \AddToHook{shipout/background}{% \put (0pt,-\paperheight) {% \begin{tikzpicture}[baseline=(a.south),every node/.style={inner sep=0pt},] \node [anchor=south west] (a) {\includegraphics[width=.5\paperwidth]{bg.png}}; \node [anchor=west,scope fading=north] at (a.east) {\includegraphics[width=.5\paperwidth]{bg.png}}; \end{tikzpicture}% }% } \kant[1-2] \end{document} However, when I convert bg.png to bg.pdf, it works! with bg.pdf: \documentclass[landscape]{article} \usepackage{tikz} \usetikzlibrary{fadings} \usepackage{kantlipsum} \begin{document} \AddToHook{shipout/background}{% \put (0pt,-\paperheight) {% \begin{tikzpicture}[baseline=(a.south),every node/.style={inner sep=0pt},] \node [anchor=south west] (a) {\includegraphics[width=.5\paperwidth]{bg.pdf}}; \node [anchor=west,scope fading=north] at (a.east) {\includegraphics[width=.5\paperwidth]{bg.pdf}}; \end{tikzpicture}% }% } \kant[1-2] \end{document} In cfr's answer, it looks like .eps also works, I wonder why my bg.png failed, is that add .png can't work well with scope fadings, or just my specific bg.png that has something bad features inside? Edited The file information of my bg.png is as below: wsl file bg.png bg.png: PNG image data, 1534 x 1380, 8-bit/color RGBA, non-interlaced with Alpha Channel! Which the bg.png file could be downloaded from here(Thanks quark67's comment), which is accessed just a screenshot create by the default screenshot tool on my windows11 machine🤔...

  • Incorrect polar coordinate positions and changing color of marks
    by humanoferth on February 2, 2026 at 7:02 pm

    I've been trying to plot coordinates using the polar library of PGFplots, but the plot is just... wrong? Like the points are just not at the right position, and I'm not too sure what I'm missing. I'm pretty sure it may have something to do with using radians instead of degrees, but when I use radians to graph, they turn out fine. I would really prefer not to use degrees, but if it's the only solution, then I'll do the conversions. I'm also struggling to figure out how to change the actual infill color of the nodes. I've been referencing section 4.7.1, and in the code below I use fill, draw, and color, but the infill remains the same. Any help would be greatly appreciated. 🙂 \documentclass{report} \usepackage{amsmath} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepgfplotslibrary{polar} \begin{document} \[ \begin{array}{c|c} \text{Name}&(r,\theta)\\\hline A&(1,\dfrac{\pi}{3})\\ B&(2,\dfrac{3\pi}{4})\\ C&(3,\dfrac{7\pi}{6})\\ D&(-1,\dfrac{2\pi}{3})\\ \end{array}\implies\begin{tikzpicture}[baseline=(current bounding box.center)] \begin{polaraxis}[xticklabels={,0,$\frac{\pi}{6}$,$\frac{\pi}{3}$,$\frac{\pi}{2}$,$\frac{2\pi}{3}$,$\frac{5\pi}{6}$,$\pi$,$\frac{7\pi}{6}$,$\frac{4\pi}{3}$,$\frac{3\pi}{2}$,$\frac{5\pi}{3}$,$\frac{11\pi}{6}$}] \addplot+ [trig format plots=rad, data cs=polarrad,only marks,color=black, mark color=black,draw=black,fill=black,] coordinates {(1,pi/3)(2,3*pi/4)(3,7*pi/6)(-1,2*pi/3)}; \end{polaraxis} \end{tikzpicture} \] \end{document}

  • How to fade the background image with multiple opacity?
    by Explorer on February 2, 2026 at 5:58 pm

    I have the following code to add background for the document: \documentclass{article} \usepackage{lipsum} \usepackage{geometry} \usepackage{graphicx} \usepackage{tikz,tikzpagenodes} \usetikzlibrary{calc,fadings} \AddToHook{shipout/background}{ \begin{tikzpicture}[remember picture,overlay] \node[ % path fading=north, inner sep=0pt,outer sep=0pt, anchor=south,opacity=.3, ] at (current page.south) {\includegraphics[width=\paperwidth]{bg.png}}; % \path[path picture={ % \node[inner sep=0pt,outer sep=0pt,anchor=south,scope fading=south] at (current page.south) {\includegraphics[width=\paperwidth]{bg.png}}; % }]; \coordinate (L) at ($(current page.north west)!.5! (current page text area.north west)$); \coordinate (R) at ($(current page.south east)!.5! (current page text area.south east)$); \fill[white,opacity=.5] (L) rectangle (R); \end{tikzpicture} } \begin{document} \lipsum[1-6] \end{document} It produced: However, the intersection border's color transformation is too sharp! I want the image could smoothly fade to white, with multiple opacity, I have consulted this link, but it doesn't work. The bg.png could be accessed as below(maybe example-image is okay, but its background is pure gray, I would prefer to show that on bg.png):

  • Drawing a pulley system
    by Fatai Bakare on February 1, 2026 at 8:32 am

    I need to draw a pulley system as in the figure. How can I do that? Specific information about the figure: A block of mass Mo is on a horizontal surface and attached by a string to a hanging block, also of mass Mo , as shown in the figure. Friction between the block and the horizontal surface is negligible. The masses of the string and pulley are negligible, and the pulley can rotate with negligible friction around its axle.

  • Fraction Operations (Graphically - Area Model)
    by UberMorlock80 on October 11, 2025 at 3:03 pm

    I'm trying to divide the rectangle horizontally and vertically into parts without rotating it to create something similar to the image below and graphically display the sum, product, and division of fractions. I also want to create a macro to do this mechanically. Do you have an idea?

  • Incorrect spath3 "split at" method with a continued line?
    by Explorer on September 19, 2025 at 7:10 am

    Learning from this link: I have the following code: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{spath3} \begin{document} \begin{tikzpicture} \draw[spath/save=path,ultra thick,blue!30] (0,0) -- (4,2); \draw[spath/split at keep start={path}{1/3},spath/use=path]; \draw[spath/split at keep end={path}{2/3},spath/use=path]; \draw[spath/split at keep middle={path}{1/3}{2/3},spath/use=path,densely dashed]; \end{tikzpicture} \begin{tikzpicture} \draw[spath/save=path,ultra thick, red!30] (0,0) -- (1,1) -- (2,-1) -- (3,4) -- (4,0); \draw[spath/split at keep start={path}{1/3},spath/use=path]; \draw[spath/split at keep end={path}{2/3},spath/use=path]; \draw[spath/split at keep middle={path}{1/3}{2/3},spath/use=path,densely dashed]; \end{tikzpicture} \end{document} In the first figure, the "dashed" line shown exactly at 1/3 and 2/3. However, in the second, if the path is longer, it seemed not dealing right? Is that possible to fix that: for the whole path, only the middle "1/3" length's path is "dashed"?

  • Grid in LaTeX help
    by Amagoo on February 8, 2023 at 11:26 am

    Hi am new to latex and trying to recreate the grid as shown in the image, any help at all would be greatly appreciated

  • Drawing a simple Markov chain in a "triangle inequality" configuration
    by The Pointer on October 17, 2022 at 10:24 pm

    I'm trying to use Tikz to graph a simple Markov chain with three nodes. The first node is labelled s = 1, the second node is labelled s = 2, and the third node is labelled s = 3. All are connected via straight, undirected edges. But the problem is that I want the chain in a "triangle inequality" kind of shape, where node s = 2 is between s = 1 and s = 3, but off to the side a bit, so that it has a kind of triangle shape. This image from the Wikipedia article for triangle inequality illustrates what I mean: The nodes would be the vertices. I can't find any tutorials that show how to do such a thing. How is this done? EDIT The closest demonstrations I can find are things like this: (From https://ai.plainenglish.io/fraudulent-transaction-detection-using-markov-model-from-scratch-b26e6bf9bc0d) But I want a configuration like this: (From https://www.semanticscholar.org/paper/Inference-and-minimization-of-hidden-Markov-chains-Gillman-Sipser/88e08bd20b2ffc201eb92f3d073e06df92bb9fad) EDIT2 I tried the following, but it doesn't seem to compile: % Author: Till Tantau % Source: The PGF/TikZ manual \documentclass{article} \usepackage{pgf} \usepackage{tikz} \usetikzlibrary{arrows,automata} \usepackage[latin1]{inputenc} \begin{document} \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm, semithick] \tikzstyle{every state}=[fill=red,draw=none,text=white] \node[initial,state] (A) {$q_a$}; \node[state] (B) [above right of=A] {$q_b$}; \node[state] (C) [right of=A] {$q_c$}; \path (A) edge node (B) edge node (C) (B) edge node (C) \end{tikzpicture} \end{document} EDIT3 Got it: % Author: Till Tantau % Source: The PGF/TikZ manual \documentclass{article} \usepackage{pgf} \usepackage{tikz} \usetikzlibrary{arrows,automata} \usepackage[latin1]{inputenc} \begin{document} \begin{tikzpicture}[shorten >=1pt,auto,node distance=2.8cm, semithick] \tikzstyle{every state}=[fill=red,draw=none,text=white] \node[initial,state] (A) {$s = 1$}; \node[state] (B) [above right of=A] {$s = 2$}; \node[state] (C) [below right of=B] {$s = 3$}; \path (A) edge node {a1} (B) edge node {a2} (C) (B) edge node {a3} (C); \end{tikzpicture} \end{document} But for some reason it won't let me use a_1, a_2, a_3, so I have to use a1, a2, a3.

  • Absolute value of a function in tikz
    by UserA on December 2, 2021 at 2:27 pm

    Being a beginner, I'm having difficulty in plotting |sinx|. Can anyone help me with plotting y=|sinx| in [0,2pi] and y=0 elsewhere in tikz?

  • Draw a PhotoGate apparatus
    by Jorge on November 15, 2017 at 2:54 pm

    Is there a way to improve a schematic representation of PhotoGate apparatus? These instruments are widely used in Physics, so it would be interesting to get a good representation of it. I would like to ask for a Tikz solution and, if possible, for improvements in the artistic eye. My first code: \startMPcode path left_cell, right_cell, p, ball, texas; numeric u,v; u := 1cm; v:=.5cm; picture photogate, photogate_inactive; photogate := image ( texas := unitsquare xscaled 2v yscaled 2u shifted(4u,v); ball := fullcircle scaled 1.5cm; left_cell := unitsquare xscaled v yscaled u; right_cell := left_cell shifted (2.5u, .5v); p := (center left_cell) -- (center right_cell); draw left_cell; draw right_cell; draw p dashed evenly withcolor red; draw texas; draw urcorner left_cell .. urcorner left_cell + (0,2v) .. urcorner right_cell + (0,1.5v) .. center texas; draw urcorner right_cell .. center texas + (0,-.1u); fill ball shifted (center p + (0,3v)) withcolor red; draw ball shifted (center p + (0,3v)); ); photogate_inactive := image ( texas := unitsquare xscaled 2v yscaled 2u shifted(4u,v); ball := fullcircle scaled 1.5cm; left_cell := unitsquare xscaled v yscaled u; right_cell := left_cell shifted (2.5u, .5v); p := (center left_cell) -- (center right_cell); draw left_cell; draw right_cell; %draw p dashed evenly withcolor red; fill ball shifted center p withcolor red; draw ball shifted (center p); draw texas; draw urcorner left_cell .. urcorner left_cell + (0,2v) .. urcorner right_cell + (0,1.5v) .. center texas; draw urcorner right_cell .. center texas + (0,-.1u); ); draw photogate; draw photogate_inactive shifted (7cm , 0); \stopMPcode UPDATE (after Thurston suggestions) My new code: \startMPcode numeric u,v; u := 1cm; v:=.5cm; vardef photogate_base (expr ative) = path left_cell, right_cell, p, ball, texas; texas := unitsquare xscaled 2v yscaled 2u shifted(4u,v); ball := fullcircle scaled 1.5cm; left_cell := unitsquare xscaled v yscaled u; right_cell := left_cell shifted (2.5u, .5v); p := (center left_cell) -- (center right_cell); image ( draw left_cell; draw right_cell; draw urcorner left_cell .. urcorner left_cell + (-1u,3v) .. urcorner right_cell + (0,2v) .. center texas + (0,.6u) cutafter texas; draw urcorner right_cell .. urcorner right_cell + (0,.001v) .. center texas cutafter texas; if ative == 1: draw ball shifted (center p + (0,2.5v)); fill ball shifted (center p + (0,2.5v)) withcolor red; draw p dashed evenly withcolor red; else: fill ball shifted (center p + (0,.5v)) withcolor red; draw ball shifted (center p + (0,.5v)); fi; draw texas;) enddef; draw photogate_base(1); draw photogate_base(0) shifted (7cm , 0); \stopMPcode

  • How to color crossed out cell?
    by Katharina on May 23, 2017 at 8:24 am

    I crossed out the letter K using the answer given here... cross out arbitrary cells Then I colored the row using \cellcolor, but the cell, which is crossed out is only half filled... What do I need to change to color the whole cell...? This is my code... \documentclass[titlepage=true, 12pt]{scrartcl} \usepackage[ngerman]{babel} \usepackage[a4paper, text={16.5cm, 25.2cm}, centering]{geometry} \usepackage{newtxtext,newtxmath} \setkomafont{disposition}{\normalfont\bfseries} \usepackage[utf8]{inputenc} \setlength{\parskip}{1.2ex} \setlength{\parindent}{0em} \usepackage{fancyhdr} \pagestyle{fancy} \fancyhf{} \renewcommand{\headrulewidth}{0pt} \fancyhead[L]{Name} \fancyfoot[C]{\thepage} \usepackage{filecontents} \usepackage[autostyle]{csquotes} \usepackage{setspace} \usepackage{tabularx} \usepackage{adjustbox} \usepackage{zref-savepos} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{xcolor,stackengine} \newcommand\splat[3][white]{% \colorbox{#1}{~~\sffamily\stackon{\fbox{\makebox[3ex]{\large\strut #2}}}{#3}~~}% } \usepackage{colortbl} \newcounter{NoTableEntry} \renewcommand*{\theNoTableEntry}{NTE-\the\value{NoTableEntry}} \newcommand*{\strike}[2]{% \multicolumn{1}{#1}{% \stepcounter{NoTableEntry}% \vadjust pre{\zsavepos{\theNoTableEntry t}}% top \vadjust{\zsavepos{\theNoTableEntry b}}% bottom \zsavepos{\theNoTableEntry l}% left \hspace{0pt plus 1filll}% #2% content \hspace{0pt plus 1filll}% \zsavepos{\theNoTableEntry r}% right \tikz[overlay]{% \draw let \n{llx}={\zposx{\theNoTableEntry l}sp-\zposx{\theNoTableEntry r}sp-\tabcolsep}, \n{urx}={\tabcolsep}, \n{lly}={\zposy{\theNoTableEntry b}sp-\zposy{\theNoTableEntry r}sp}, \n{ury}={\zposy{\theNoTableEntry t}sp-\zposy{\theNoTableEntry r}sp} in (\n{llx}, \n{lly}) -- (\n{urx}, \n{ury}) ; }% }% } \begin{document} \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}} \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}} \setlength{\extrarowheight}{5pt} \setlength{\tabcolsep}{6pt} \adjustbox{valign=t}{\begin{minipage}[t]{0.63\textwidth} \begin{tabular}{|C{0.8cm}|L{8cm}|} \hline A & peu de cours \\ \hline B & la confiance en soi\\ \hline C & se trouve le village du Père Noël \\ \hline D & début de semestre\\ \hline E & à augmenter la fréquentation de la ville\\ \hline F & des ours polaires \\ \hline G & fin de semestre\\ \hline H & beaucoup de cours \\ \hline I & nous a permis de nous intégrer plus facilement \\ \hline J & une magnifique aurore boréale \\ \hline \strike{|c|}{\cellcolor{gray!30}K} &\cellcolor{gray!30} les gens sont quasiment tous bilingues en anglais \\ \hline \end{tabular} \end{minipage}} \adjustbox{valign=t}{\begin{minipage}[t]{0.36\textwidth} \Shortstack[l]{ \splat[gray!30]{K}{0}\splat{}{1}\splat{}{2}\splat{}{3} \splat{}{4}\splat{}{5}\splat{}{6}\splat{}{7} \splat{}{8}} \end{minipage}} \end{document}

  • How to draw stacked cubes of different sizes and colors?
    by benedito on January 25, 2015 at 1:26 pm

    I can (I learned here!) to draw, but I can't change the colors or make several distinct cells. \documentclass[12pt]{article} \usepackage{tikz} \usepackage{verbatim} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture}[on grid] \shade[yslant=-0.5,right color=gray!10, left color=black!50] (0,0) rectangle +(3,3); \draw[yslant=-0.5] (0,0) grid (3,3); \shade[yslant=0.5,right color=gray!70,left color=gray!10] (3,-3) rectangle +(3,3); \draw[yslant=0.5] (3,-3) grid (6,0); \shade[yslant=0.5,xslant=-1,bottom color=gray!10, top color=black!80] (6,3) rectangle +(-3,-3); \draw[yslant=0.5,xslant=-1] (3,0) grid (6,3); \end{tikzpicture} \end{document}

  • How to draw random simple closed smooth curves but with the same perimeter?
    by kiss my armpit on December 8, 2014 at 2:59 am

    I want to draw some random simple smooth closed curves. Each smooth curve must have the same perimeter but different area. See the following figure to illustrate what I meant clearly. Each smooth curve is assumed to have the same perimeter. How to do this with PSTricks (preferred) or TikZ or Metapost or Asymptote? The following template is provided to save your time. \documentclass{pstricks,border=12pt,12pt} \begin{document} \psLoop{10}{% \begin{pspicture}(-5,-5)(5,5) \end{pspicture}} \end{document}