TikZ
- 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 surfacesby 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 pgfmathby 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 tikzby 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 cavityby 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 backgroundsby 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 diagramsby 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 graphby 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 elementsby 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 marksby 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):
- How to transform canvas with `grid` and not to affect the `node`'s content at the same time?by Explorer on February 1, 2026 at 5:24 pm
Description As the successor of my prevoius not-supported l3draw attempt, I try with plain-tikz: \documentclass[tikz,border=5pt]{standalone} \usepackage{mathpazo} \usepackage{amsmath} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture}[line cap=round] \clip (-.5,-.5) rectangle (4.5,4.5); \begin{scope}[ x={(1.5cm,0.5cm)}, y={(0.5cm,2cm)}, ] \fill[orange!10] (-2,-2) rectangle (5,5); \draw[orange] (-2,-2) grid (5,5); \draw[orange,ultra thick,-Stealth] (0,0) -- +(1,0) node[below] {$\mathbf{b_1}$}; \draw[orange,ultra thick,-Stealth] (0,0) -- +(0,1) node[below left] {$\mathbf{b_2}$}; \draw[black,ultra thick,-Stealth] (0,0) -- +(1,1) node[right] {$\mathbf{x}$}; \end{scope} \end{tikzpicture} \begin{tikzpicture}[line cap=round] \clip (-.5,-.5) rectangle (4.5,4.5); \begin{scope}[x={(1.5cm,0.5cm)}, y={(0.5cm,2cm)}] \fill[orange!10] (-2,-2) rectangle (5,5); % \draw[orange] (-2,-2) grid (5,5); \foreach \i in {-2,-1,...,5} {\draw[orange] (\i,-2) -- ++(0,7) (-2,\i) -- ++(7,0);} \draw[orange,ultra thick,-Stealth] (0,0) -- +(1,0) node[below] {$\mathbf{b_1}$}; \draw[orange,ultra thick,-Stealth] (0,0) -- +(0,1) node[below left] {$\mathbf{b_2}$}; \draw[black,ultra thick,-Stealth] (0,0) -- +(1,1) node[right] {$\mathbf{x}$}; \end{scope} \end{tikzpicture} \begin{tikzpicture}[line cap=round] \clip (-.5,-.5) rectangle (4.5,4.5); \begin{scope}[ transform canvas={cm={1.5, 0.5, 0.5, 2, (0,0)}} ] \fill[orange!10] (-2,-2) rectangle (5,5); \draw[orange] (-2,-2) grid (5,5); \draw[orange,ultra thick,-Stealth] (0,0) -- +(1,0) node[below] {$\mathbf{b_1}$}; \draw[orange,ultra thick,-Stealth] (0,0) -- +(0,1) node[below left] {$\mathbf{b_2}$}; \draw[black,ultra thick,-Stealth] (0,0) -- +(1,1) node[right] {$\mathbf{x}$}; \end{scope} \end{tikzpicture} \end{document} Here, I have three proposals: FIRST: the grid doesn't transform by x={(1.5cm,0.5cm)}, y={(0.5cm,2cm)}. SECOND: the manual \foreach gives what I want, but I don't think manually mimic what feature grid do is the best practice. THIRD: with transform canvas, it affected the grid, but all on the canvas, the text and arrow are both sheared, that is not I want. Question: Is there better approach without manually plot the grid? I would make good use of feature grid in my case as possible.
- Drawing a pulley systemby 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.
- Wrapping a circle on a torusby M. Al Jumaily on February 1, 2026 at 4:19 am
I have used the sample code from latexdraw that draws a torus. I am trying to draw a filled circle and a dashed circle where they should be wrap around the torus instead of being drawn uniformly at z=0. I am looking for a TikZ solution. The closest I have seen is this solution but it is too difficult for me to decipher. Any help would be appreciated! \documentclass[margin=4pt]{standalone} \usepackage{tikz} \usepackage{pgfplots} \usepackage{tikz-3dplot} \usepgfplotslibrary{colormaps} \pgfplotsset{ compat=newest, colormap={manifoldmap}{color=(lightgray) color=(white) color=(lightgray)} } \begin{document} \begin{tikzpicture} \def\R{2.75} % Major radius (distance from torus centre to tube centre) \def\offset{0.5} % Radial displacement from the torus centre circle \def\thetaB{2.5} % Angular position (in radians) for highlighted point \begin{axis}[ width=12cm, axis equal image, hide axis, z buffer=sort, view={125}{35}, clip=false ] % Parametric torus equations: % x = (R + cos(x)) cos(y) % y = (R + cos(x)) sin(y) % z = sin(x) \addplot3[ surf, shader = faceted interp, samples = 30, samples y = 40, domain = 0:2*pi, domain y = 0:2*pi, colormap name = manifoldmap, thin, opacity=0.75 ] ( {(\R + cos(deg(x))) * cos(deg(y))}, {(\R + cos(deg(x))) * sin(deg(y))}, {sin(deg(x))} ); \begin{scope}[canvas is xy plane at z=0, transform shape] \coordinate (p) at ({(\R + \offset) * cos(deg(\thetaB))}, {(\R + \offset) * sin(deg(\thetaB))}); \draw[fill=red, draw=none] (p) circle (4pt); \draw[blue, dashed, thick] (p) circle (16pt); \end{scope} \end{axis} \end{tikzpicture} \end{document}
- How to draw a figure (horizontal and diagonal ines) with numbers / variables within (easy) [closed]by Justin Eaves on January 31, 2026 at 6:56 pm
I am looking to draw diagrams similar to this many times over the course of a document, and fill in all (6) of the negative spaces (top, bottom, top left, top right, bottom left, bottom right). The numbers in each diagram will vary. The center of the diagram need not be hollow as in the photo below, that was just sloppy line drawing. Just an "X" with a horizontal line through it, and a way to add numbers in each negative space. I'm sure this is easy, but I have zero experience with tikz. Anyone have an easy solution? Thanks in advance!
- Putting two flowcharts on the same page side by side in Latexby Destr on January 31, 2026 at 12:27 pm
So i have the following code in latex and i'm trying to put these two flowcharts side by side, for some reason i cant do that and instead one is on top of the other , i can't understand what i do wrong. Below is the code and here is the resulting image https://i.sstatic.net/kHcPDRb8.png \documentclass{article} \usepackage[dvipsnames]{xcolor} \usepackage{tikz} \usetikzlibrary{arrows.meta, positioning, calc} \usepackage{xcolor} \usepackage{graphicx} \usetikzlibrary{shapes.geometric, arrows.meta, positioning,calc} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{figure}[ht] \centering % ================= LEFT DIAGRAM ================= \begin{minipage}[t]{0.30\textwidth} \centering \begin{tikzpicture}[ scale=0.75, transform shape, node distance=1cm, every node/.style={font=\scriptsize}, block/.style={rectangle, draw, rounded corners, minimum width=2.6cm, minimum height=0.7cm, align=center}, adder/.style={circle, draw, minimum size=0.45cm, inner sep=0pt}, arrow/.style={->, thick} ] \tikzset{ inputoutput/.style={block, fill=cyan!40}, linear/.style={block, fill=green!40}, mixup/.style={block, fill=BrickRed!40}, penc/.style={block, fill=purple!40}, cmamba/.style={block, fill=red!40}, rms/.style={block, fill=yellow!40} } \node[inputoutput] (input) {Input}; \node[mixup, above=of input] (mixup) {Channel Mixup}; \node[linear, above=of mixup] (lin1) {Linear}; \node[penc, above=of lin1] (penc) {Positional Encoding}; \node[adder, above=of penc] (add) {$+$}; \node[cmamba, above=of add] (cmamba) {CMamba}; \node[rms, above=of cmamba] (rms) {RMS Norm}; \node[linear, above=of rms] (lin2) {Linear}; \node[inputoutput, above=of lin2] (output) {Output}; \draw[arrow] (input) -- (mixup); \draw[arrow] (mixup) -- (lin1); \draw[arrow] (lin1) -- (penc); \draw[arrow] (penc) -- (add); \draw[arrow] (add) -- (cmamba); \draw[arrow] (cmamba) -- (rms); \draw[arrow] (rms) -- (lin2); \draw[arrow] (lin2) -- (output); \draw[arrow] (input.east) -- ++(1.2,0) |- (add.east); \end{tikzpicture} \caption*{(a) Overall Architecture} \end{minipage} \hfill % ================= RIGHT DIAGRAM ================= \begin{minipage}[t]{0.30\textwidth} \centering \begin{tikzpicture}[ scale=0.7, transform shape, node distance=0.45cm, every node/.style={font=\scriptsize}, block/.style={rectangle, draw, rounded corners, minimum width=3.2cm, minimum height=0.7cm, align=center}, mult/.style={circle, draw, minimum size=0.45cm, inner sep=0pt}, arrow/.style={->, thick} ] \node[block, fill=green!40] (linL) {Linear}; \node[block, fill=RoyalBlue!40, above=of linL] (conv) {Conv1D}; \node[block, fill=magenta!40, above=of conv] (siluL) {SiLU}; \node[block, fill=red!40, above=of siluL] (ssm) {SSM}; \node[block, fill=green!40, right=0.8cm of linL] (linR) {Linear}; \node[block, fill=magenta!40, above=of linR] (siluR) {SiLU}; \node[mult] (mult) at ($(ssm.north)!0.5!(siluR.north) + (0,2cm)$) {$\times$}; \draw[arrow] (linL) -- (conv); \draw[arrow] (conv) -- (siluL); \draw[arrow] (siluL) -- (ssm); \draw[arrow] (linR) -- (siluR); \draw[arrow] (ssm.north) |- (mult.west); \draw[arrow] (siluR.north) |- (mult.east); \node[block, fill=yellow!40, above=0.4cm of mult] (rms2) {RMS Norm}; \draw[arrow] (mult) -- (rms2); \end{tikzpicture} \caption*{(b) CMamba Block (Expanded)} \end{minipage} \caption{Overview of the model architecture and the internal structure of the CMamba block.} \label{fig:cmamba_combined} \end{figure} \end{document}
- 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?
- Drawing a simple Markov chain in a "triangle inequality" configurationby 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.
- How to get set the precision of the PGFPLOTS?by user266771 on March 20, 2022 at 1:56 pm
I want to plot the a strange function which is the 'InterpolatingPolynomial' of the tanh(x): (40*x*tanh(1/2))/11-(698249*x^3*tanh(1/2))/87318+(2517135701*x^5*tanh(1/2))/392931000-(8990599279*x^7*tanh(1/2))/3536379000+(666523661*x^9*tanh(1/2))/1178793000-(87882491*x^11*tanh(1/2))/1178793000+(2616454*x^13*tanh(1/2))/442047375-(40708*x^15*tanh(1/2))/147349125+(1024*x^17*tanh(1/2))/147349125-(32*x^19*tanh(1/2))/442047375-(15*x*tanh(1))/11+(1650809*x^3*tanh(1))/232848-(7656977201*x^5*tanh(1))/1047816000+(15347344853*x^7*tanh(1))/4715172000-(269158459*x^9*tanh(1))/349272000+(82887751*x^11*tanh(1))/785862000-(2527141*x^13*tanh(1))/294698250+(6658*x^15*tanh(1))/16372125-(508*x^17*tanh(1))/49116375+(16*x^19*tanh(1))/147349125+(80*x*tanh(3/2))/143-(1827209*x^3*tanh(3/2))/567567+(11431199701*x^5*tanh(3/2))/2554051500-(5986965079*x^7*tanh(3/2))/2554051500+(39926233*x^9*tanh(3/2))/65488500-(17379821*x^11*tanh(3/2))/196465500+(4771412*x^13*tanh(3/2))/638512875-(77416*x^15*tanh(3/2))/212837625+(6016*x^17*tanh(3/2))/638512875-(64*x^19*tanh(3/2))/638512875-(30*x*tanh(2))/143+(1888949*x^3*tanh(2))/1513512-(3240137519*x^5*tanh(2))/1702701000+(17611561711*x^7*tanh(2))/15324309000-(130451323*x^9*tanh(2))/392931000+(1695689*x^11*tanh(2))/32744250-(8810596*x^13*tanh(2))/1915538625+(148112*x^15*tanh(2))/638512875-(1312*x^17*tanh(2))/212837625+(128*x^19*tanh(2))/1915538625+(48*x*tanh(5/2))/715-(9587629*x^3*tanh(5/2))/23648625+(109639993*x^5*tanh(5/2))/170270100-(3194891431*x^7*tanh(5/2))/7662154500+(5165621*x^9*tanh(5/2))/39293100-(1447093*x^11*tanh(5/2))/65488500+(796564*x^13*tanh(5/2))/383107725-(69928*x^15*tanh(5/2))/638512875+(128*x^17*tanh(5/2))/42567525-(64*x^19*tanh(5/2))/1915538625-(5*x*tanh(3))/286+(1933049*x^3*tanh(3))/18162144-(14119093201*x^5*tanh(3))/81729648000+(4749355073*x^7*tanh(3))/40864824000-(81091903*x^9*tanh(3))/2095632000+(10896041*x^11*tanh(3))/1571724000-(1767109*x^13*tanh(3))/2554051500+(8147*x^15*tanh(3))/212837625-(698*x^17*tanh(3))/638512875+(8*x^19*tanh(3))/638512875+(60*x*tanh(7/2))/17017-(5663*x^3*tanh(7/2))/262548+(2464771*x^5*tanh(7/2))/69498000-(106900847*x^7*tanh(7/2))/4378374000+(44989*x^9*tanh(7/2))/5346000-(25313*x^11*tanh(7/2))/16038000+(45439*x^13*tanh(7/2))/273648375-(14*x^15*tanh(7/2))/1447875+(64*x^17*tanh(7/2))/221524875-(16*x^19*tanh(7/2))/4652022375-(5*x*tanh(4))/9724+(487121*x^3*tanh(4))/154378224-(53447083*x^5*tanh(4))/10216206000+(336140003*x^7*tanh(4))/91945854000-(3039931*x^9*tanh(4))/2357586000+(147211*x^11*tanh(4))/589396500-(157426*x^13*tanh(4))/5746615875+(3208*x^15*tanh(4))/1915538625-(1712*x^17*tanh(4))/32564156625+(64*x^19*tanh(4))/97692469875+(20*x*tanh(9/2))/415701-(11419*x^3*tanh(9/2))/38594556+(5040143*x^5*tanh(9/2))/10216206000-(3558293*x^7*tanh(9/2))/10216206000+(32699*x^9*tanh(9/2))/261954000-(19447*x^11*tanh(9/2))/785862000+(1789*x^13*tanh(9/2))/638512875-(38*x^15*tanh(9/2))/212837625+(64*x^17*tanh(9/2))/10854718875-(16*x^19*tanh(9/2))/206239658625-(x*tanh(5))/461890+(514639*x^3*tanh(5))/38594556000-(364919*x^5*tanh(5))/16345929600+(5839219*x^7*tanh(5))/367783416000-(21713*x^9*tanh(5))/3772137600+(5473*x^11*tanh(5))/4715172000-(619*x^13*tanh(5))/4597292700+(17*x^15*tanh(5))/1915538625-(2*x^17*tanh(5))/6512831325+(8*x^19*tanh(5))/1856156927625 It's very scary lmao but, I try to trans it into 0.9979114*x-0.3195393*x^3+0.1056912*x^5-0.02658724*x^7+0.004606668*x^9-0.0005249908*x^11+0.00003808077*x^13-0.000001675943*x^15+0.0000000405108*x^17-0.000000000410371*x^19 and put it in 'PGFPLOTS': \documentclass{ctexart}\usepackage{tikz}\usepackage{pgfplots,xfp}\begin{figure}[h] \centering \pgfplotsset{width=12cm,height=7cm} \begin{tikzpicture} \begin{axis}[ title={The Runge phenomenon of the function $\tanh x$}, xlabel={$x$}, ylabel={$y$}, axis x line=center, axis y line=center, every inner x axis line/.append style={->}, every inner y axis line/.append style={->}, xmin=-6,xmax=6 ] \addplot[domain=-5:5, samples=800, color=gray,smooth,]{0.9979114*x-0.3195393*x^3+0.1056912*x^5-0.02658724*x^7+0.004606668*x^9-0.0005249908*x^11+0.00003808077*x^13-0.000001675943*x^15+0.0000000405108*x^17-0.000000000410371*x^19}; \addplot[domain=-5.2:5.2,color=black, samples=400,very thick]{tanh(x)}; \end{axis} \end{tikzpicture} \end{figure} and get the figure and this annoying 'saw' if I use the scary one: \documentclass{ctexart}\usepackage{tikz}\usepackage{pgfplots,xfp}\begin{figure}[h] \centering \pgfplotsset{width=12cm,height=7cm} \begin{tikzpicture} \begin{axis}[ title={The Runge phenomenon of the function $\tanh x$}, xlabel={$x$},legend pos = north west, ylabel={$y$}, axis x line=center, axis y line=center, every inner x axis line/.append style={->}, every inner y axis line/.append style={->}, xmin=-6,xmax=6 ] \addplot[domain=-5:5, samples=800, color=gray,smooth,]{(40*x*tanh(1/2))/11-(698249*x^3*tanh(1/2))/87318+(2517135701*x^5*tanh(1/2))/392931000-(8990599279*x^7*tanh(1/2))/3536379000+(666523661*x^9*tanh(1/2))/1178793000-(87882491*x^11*tanh(1/2))/1178793000+(2616454*x^13*tanh(1/2))/442047375-(40708*x^15*tanh(1/2))/147349125+(1024*x^17*tanh(1/2))/147349125-(32*x^19*tanh(1/2))/442047375-(15*x*tanh(1))/11+(1650809*x^3*tanh(1))/232848-(7656977201*x^5*tanh(1))/1047816000+(15347344853*x^7*tanh(1))/4715172000-(269158459*x^9*tanh(1))/349272000+(82887751*x^11*tanh(1))/785862000-(2527141*x^13*tanh(1))/294698250+(6658*x^15*tanh(1))/16372125-(508*x^17*tanh(1))/49116375+(16*x^19*tanh(1))/147349125+(80*x*tanh(3/2))/143-(1827209*x^3*tanh(3/2))/567567+(11431199701*x^5*tanh(3/2))/2554051500-(5986965079*x^7*tanh(3/2))/2554051500+(39926233*x^9*tanh(3/2))/65488500-(17379821*x^11*tanh(3/2))/196465500+(4771412*x^13*tanh(3/2))/638512875-(77416*x^15*tanh(3/2))/212837625+(6016*x^17*tanh(3/2))/638512875-(64*x^19*tanh(3/2))/638512875-(30*x*tanh(2))/143+(1888949*x^3*tanh(2))/1513512-(3240137519*x^5*tanh(2))/1702701000+(17611561711*x^7*tanh(2))/15324309000-(130451323*x^9*tanh(2))/392931000+(1695689*x^11*tanh(2))/32744250-(8810596*x^13*tanh(2))/1915538625+(148112*x^15*tanh(2))/638512875-(1312*x^17*tanh(2))/212837625+(128*x^19*tanh(2))/1915538625+(48*x*tanh(5/2))/715-(9587629*x^3*tanh(5/2))/23648625+(109639993*x^5*tanh(5/2))/170270100-(3194891431*x^7*tanh(5/2))/7662154500+(5165621*x^9*tanh(5/2))/39293100-(1447093*x^11*tanh(5/2))/65488500+(796564*x^13*tanh(5/2))/383107725-(69928*x^15*tanh(5/2))/638512875+(128*x^17*tanh(5/2))/42567525-(64*x^19*tanh(5/2))/1915538625-(5*x*tanh(3))/286+(1933049*x^3*tanh(3))/18162144-(14119093201*x^5*tanh(3))/81729648000+(4749355073*x^7*tanh(3))/40864824000-(81091903*x^9*tanh(3))/2095632000+(10896041*x^11*tanh(3))/1571724000-(1767109*x^13*tanh(3))/2554051500+(8147*x^15*tanh(3))/212837625-(698*x^17*tanh(3))/638512875+(8*x^19*tanh(3))/638512875+(60*x*tanh(7/2))/17017-(5663*x^3*tanh(7/2))/262548+(2464771*x^5*tanh(7/2))/69498000-(106900847*x^7*tanh(7/2))/4378374000+(44989*x^9*tanh(7/2))/5346000-(25313*x^11*tanh(7/2))/16038000+(45439*x^13*tanh(7/2))/273648375-(14*x^15*tanh(7/2))/1447875+(64*x^17*tanh(7/2))/221524875-(16*x^19*tanh(7/2))/4652022375-(5*x*tanh(4))/9724+(487121*x^3*tanh(4))/154378224-(53447083*x^5*tanh(4))/10216206000+(336140003*x^7*tanh(4))/91945854000-(3039931*x^9*tanh(4))/2357586000+(147211*x^11*tanh(4))/589396500-(157426*x^13*tanh(4))/5746615875+(3208*x^15*tanh(4))/1915538625-(1712*x^17*tanh(4))/32564156625+(64*x^19*tanh(4))/97692469875+(20*x*tanh(9/2))/415701-(11419*x^3*tanh(9/2))/38594556+(5040143*x^5*tanh(9/2))/10216206000-(3558293*x^7*tanh(9/2))/10216206000+(32699*x^9*tanh(9/2))/261954000-(19447*x^11*tanh(9/2))/785862000+(1789*x^13*tanh(9/2))/638512875-(38*x^15*tanh(9/2))/212837625+(64*x^17*tanh(9/2))/10854718875-(16*x^19*tanh(9/2))/206239658625-(x*tanh(5))/461890+(514639*x^3*tanh(5))/38594556000-(364919*x^5*tanh(5))/16345929600+(5839219*x^7*tanh(5))/367783416000-(21713*x^9*tanh(5))/3772137600+(5473*x^11*tanh(5))/4715172000-(619*x^13*tanh(5))/4597292700+(17*x^15*tanh(5))/1915538625-(2*x^17*tanh(5))/6512831325+(8*x^19*tanh(5))/1856156927625}; \addplot[domain=-5.2:5.2,color=black, samples=400,very thick]{tanh(x)}; \end{axis} \end{tikzpicture}\end{figure} I get I thaught that it's the precision of PGFPLOTS made this, and how to fix them?
- Absolute value of a function in tikzby 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 apparatusby 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}
- Sieve of Eratosthenes in tikzby azetina on February 15, 2012 at 7:42 pm
I am writing notes for my students under the topic of prime factorization and I needed to illustrate the Sieve of Eratosthenes and this is what I came up with in tikz: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=0.65] \draw[very thick,red] (3,9)--(4,10); \draw[very thick,red] (3,10)--(4,9); \draw[very thick,red] (5,9)--(6,10); \draw[very thick,red] (5,10)--(6,9); \draw[very thick,red] (7,9)--(8,10); \draw[very thick,red] (7,10)--(8,9); \draw[very thick,red] (8,9)--(9,10); \draw[very thick,red] (8,10)--(9,9); \draw[very thick,red] (9,9)--(10,10); \draw[very thick,red] (9,10)--(10,9); %------------------------------------ \draw[very thick,red] (1,8)--(2,9); \draw[very thick,red] (2,8)--(1,9); \draw[very thick,red] (3,8)--(4,9); \draw[very thick,red] (4,8)--(3,9); \draw[very thick,red] (4,8)--(5,9); \draw[very thick,red] (5,8)--(4,9); \draw[very thick,red] (5,8)--(6,9); \draw[very thick,red] (6,8)--(5,9); \draw[very thick,red] (7,8)--(8,9); \draw[very thick,red] (8,8)--(7,9); \draw[very thick,red] (9,8)--(10,9); \draw[very thick,red] (10,8)--(9,9); %------------------------------------ \draw[very thick,red] (0,7)--(1,8); \draw[very thick,red] (1,7)--(0,8); \draw[very thick,red] (1,7)--(2,8); \draw[very thick,red] (2,7)--(1,8); \draw[very thick,red] (3,7)--(4,8); \draw[very thick,red] (4,7)--(3,8); \draw[very thick,red] (4,7)--(5,8); \draw[very thick,red] (5,7)--(4,8); \draw[very thick,red] (5,7)--(6,8); \draw[very thick,red] (6,7)--(5,8); \draw[very thick,red] (6,7)--(7,8); \draw[very thick,red] (7,7)--(6,8); \draw[very thick,red] (7,7)--(8,8); \draw[very thick,red] (8,7)--(7,8); \draw[very thick,red] (9,7)--(10,8); \draw[very thick,red] (10,7)--(9,8); %------------------------------------ \draw[very thick,red] (1,6)--(2,7); \draw[very thick,red] (2,6)--(1,7); \draw[very thick,red] (2,6)--(3,7); \draw[very thick,red] (3,6)--(2,7); \draw[very thick,red] (3,6)--(4,7); \draw[very thick,red] (4,6)--(3,7); \draw[very thick,red] (4,6)--(5,7); \draw[very thick,red] (5,6)--(4,7); \draw[very thick,red] (5,6)--(6,7); \draw[very thick,red] (6,6)--(5,7); \draw[very thick,red] (7,6)--(8,7); \draw[very thick,red] (8,6)--(7,7); \draw[very thick,red] (8,6)--(9,7); \draw[very thick,red] (9,6)--(8,7); \draw[very thick,red] (9,6)--(10,7); \draw[very thick,red] (10,6)--(9,7); %------------------------------------ \draw[very thick,red] (1,5)--(2,6); \draw[very thick,red] (2,5)--(1,6); \draw[very thick,red] (3,5)--(4,6); \draw[very thick,red] (4,5)--(3,6); \draw[very thick,red] (4,5)--(5,6); \draw[very thick,red] (5,5)--(4,6); \draw[very thick,red] (5,5)--(6,6); \draw[very thick,red] (6,5)--(5,6); \draw[very thick,red] (7,5)--(8,6); \draw[very thick,red] (8,5)--(7,6); \draw[very thick,red] (8,5)--(9,6); \draw[very thick,red] (9,5)--(8,6); \draw[very thick,red] (9,5)--(10,6); \draw[very thick,red] (10,5)--(9,6); %------------------------------------ \draw[very thick,red] (0,4)--(1,5); \draw[very thick,red] (1,4)--(0,5); \draw[very thick,red] (1,4)--(2,5); \draw[very thick,red] (2,4)--(1,5); \draw[very thick,red] (3,4)--(4,5); \draw[very thick,red] (4,4)--(3,5); \draw[very thick,red] (4,4)--(5,5); \draw[very thick,red] (5,4)--(4,5); \draw[very thick,red] (5,4)--(6,5); \draw[very thick,red] (6,4)--(5,5); \draw[very thick,red] (6,4)--(7,5); \draw[very thick,red] (7,4)--(6,5); \draw[very thick,red] (7,4)--(8,5); \draw[very thick,red] (8,4)--(7,5); \draw[very thick,red] (9,4)--(10,5); \draw[very thick,red] (10,4)--(9,5); %------------------------------------ \draw[very thick,red] (1,3)--(2,4); \draw[very thick,red] (2,3)--(1,4); \draw[very thick,red] (2,3)--(3,4); \draw[very thick,red] (3,3)--(2,4); \draw[very thick,red] (3,3)--(4,4); \draw[very thick,red] (4,3)--(3,4); \draw[very thick,red] (4,3)--(5,4); \draw[very thick,red] (5,3)--(4,4); \draw[very thick,red] (5,3)--(6,4); \draw[very thick,red] (6,3)--(5,4); \draw[very thick,red] (7,3)--(8,4); \draw[very thick,red] (8,3)--(7,4); \draw[very thick,red] (8,3)--(9,4); \draw[very thick,red] (9,3)--(8,4); \draw[very thick,red] (9,3)--(10,4); \draw[very thick,red] (10,3)--(9,4); %------------------------------------ \draw[very thick,red] (1,2)--(2,3); \draw[very thick,red] (2,2)--(1,3); \draw[very thick,red] (3,2)--(4,3); \draw[very thick,red] (4,2)--(3,3); \draw[very thick,red] (4,2)--(5,3); \draw[very thick,red] (5,2)--(4,3); \draw[very thick,red] (5,2)--(6,3); \draw[very thick,red] (6,2)--(5,3); \draw[very thick,red] (6,2)--(7,3); \draw[very thick,red] (7,2)--(6,3); \draw[very thick,red] (7,2)--(8,3); \draw[very thick,red] (8,2)--(7,3); \draw[very thick,red] (9,2)--(10,3); \draw[very thick,red] (10,2)--(9,3); %------------------------------------ \draw[very thick,red] (0,1)--(1,2); \draw[very thick,red] (1,1)--(0,2); \draw[very thick,red] (1,1)--(2,2); \draw[very thick,red] (2,1)--(1,2); \draw[very thick,red] (3,1)--(4,2); \draw[very thick,red] (4,1)--(3,2); \draw[very thick,red] (4,1)--(5,2); \draw[very thick,red] (5,1)--(4,2); \draw[very thick,red] (5,1)--(6,2); \draw[very thick,red] (6,1)--(5,2); \draw[very thick,red] (6,1)--(7,2); \draw[very thick,red] (7,1)--(6,2); \draw[very thick,red] (7,1)--(8,2); \draw[very thick,red] (8,1)--(7,2); \draw[very thick,red] (9,1)--(10,2); \draw[very thick,red] (10,1)--(9,2); %------------------------------------ \draw[very thick,red] (0,0)--(1,1); \draw[very thick,red] (1,0)--(0,1); \draw[very thick,red] (1,0)--(2,1); \draw[very thick,red] (2,0)--(1,1); \draw[very thick,red] (2,0)--(3,1); \draw[very thick,red] (3,0)--(2,1); \draw[very thick,red] (3,0)--(4,1); \draw[very thick,red] (4,0)--(3,1); \draw[very thick,red] (4,0)--(5,1); \draw[very thick,red] (5,0)--(4,1); \draw[very thick,red] (5,0)--(6,1); \draw[very thick,red] (6,0)--(5,1); \draw[very thick,red] (7,0)--(8,1); \draw[very thick,red] (8,0)--(7,1); \draw[very thick,red] (8,0)--(9,1); \draw[very thick,red] (9,0)--(8,1); \draw[very thick,red] (9,0)--(10,1); \draw[very thick,red] (10,0)--(9,1); %------------------------------------ \draw (0,0) grid (10,10); \draw (0.5,9.5) node {}; \draw (1.5,9.5) node {2}; \draw (2.5,9.5) node {3}; \draw (3.5,9.5) node {4}; \draw (4.5,9.5) node {5}; \draw (5.5,9.5) node {6}; \draw (6.5,9.5) node {7}; \draw (7.5,9.5) node {8}; \draw (8.5,9.5) node {9}; \draw (9.5,9.5) node {10}; %-------------------------- \draw (0.5,8.5) node {11}; \draw (1.5,8.5) node {12}; \draw (2.5,8.5) node {13}; \draw (3.5,8.5) node {14}; \draw (4.5,8.5) node {15}; \draw (5.5,8.5) node {16}; \draw (6.5,8.5) node {17}; \draw (7.5,8.5) node {18}; \draw (8.5,8.5) node {19}; \draw (9.5,8.5) node {20}; %-------------------------- \draw (0.5,7.5) node {21}; \draw (1.5,7.5) node {22}; \draw (2.5,7.5) node {23}; \draw (3.5,7.5) node {24}; \draw (4.5,7.5) node {25}; \draw (5.5,7.5) node {26}; \draw (6.5,7.5) node {27}; \draw (7.5,7.5) node {28}; \draw (8.5,7.5) node {29}; \draw (9.5,7.5) node {30}; %-------------------------- \draw (0.5,6.5) node {31}; \draw (1.5,6.5) node {32}; \draw (2.5,6.5) node {33}; \draw (3.5,6.5) node {34}; \draw (4.5,6.5) node {35}; \draw (5.5,6.5) node {36}; \draw (6.5,6.5) node {37}; \draw (7.5,6.5) node {38}; \draw (8.5,6.5) node {39}; \draw (9.5,6.5) node {40}; %-------------------------- \draw (0.5,5.5) node {41}; \draw (1.5,5.5) node {42}; \draw (2.5,5.5) node {43}; \draw (3.5,5.5) node {44}; \draw (4.5,5.5) node {45}; \draw (5.5,5.5) node {46}; \draw (6.5,5.5) node {47}; \draw (7.5,5.5) node {48}; \draw (8.5,5.5) node {49}; \draw (9.5,5.5) node {50}; %-------------------------- \draw (0.5,4.5) node {51}; \draw (1.5,4.5) node {52}; \draw (2.5,4.5) node {53}; \draw (3.5,4.5) node {54}; \draw (4.5,4.5) node {55}; \draw (5.5,4.5) node {56}; \draw (6.5,4.5) node {57}; \draw (7.5,4.5) node {58}; \draw (8.5,4.5) node {59}; \draw (9.5,4.5) node {60}; %-------------------------- \draw (0.5,3.5) node {61}; \draw (1.5,3.5) node {62}; \draw (2.5,3.5) node {63}; \draw (3.5,3.5) node {64}; \draw (4.5,3.5) node {65}; \draw (5.5,3.5) node {66}; \draw (6.5,3.5) node {67}; \draw (7.5,3.5) node {68}; \draw (8.5,3.5) node {69}; \draw (9.5,3.5) node {60}; %-------------------------- \draw (0.5,2.5) node {71}; \draw (1.5,2.5) node {72}; \draw (2.5,2.5) node {73}; \draw (3.5,2.5) node {74}; \draw (4.5,2.5) node {75}; \draw (5.5,2.5) node {76}; \draw (6.5,2.5) node {77}; \draw (7.5,2.5) node {78}; \draw (8.5,2.5) node {79}; \draw (9.5,2.5) node {80}; %-------------------------- \draw (0.5,1.5) node {81}; \draw (1.5,1.5) node {82}; \draw (2.5,1.5) node {83}; \draw (3.5,1.5) node {84}; \draw (4.5,1.5) node {85}; \draw (5.5,1.5) node {86}; \draw (6.5,1.5) node {87}; \draw (7.5,1.5) node {88}; \draw (8.5,1.5) node {89}; \draw (9.5,1.5) node {90}; %-------------------------- \draw (0.5,0.5) node {91}; \draw (1.5,0.5) node {92}; \draw (2.5,0.5) node {93}; \draw (3.5,0.5) node {94}; \draw (4.5,0.5) node {95}; \draw (5.5,0.5) node {96}; \draw (6.5,0.5) node {97}; \draw (7.5,0.5) node {98}; \draw (8.5,0.5) node {99}; \draw (9.5,0.5) node {100}; \end{tikzpicture} \end{document} This is what results: Evidently it is not the most suitable way and it took me a while to get it right. I know there is a less tedious way of doing it but for the moment this is what I have to deal with. If anyone can assist me with the matter I would appreciate it. Something tells me that a \foreach would suffice but I still don't know its implementation.
- How to use every plot with TikZby Alain Matthes on January 2, 2012 at 6:15 pm
In the paragraph about gnuplot in the pgfmanual, I read this : The following styles influence the plot: /tikz/every plot (style, initially empty) This style is installed in each plot, that is, as if you always said plot[every plot,...] This is most useful for globally setting a prefix for all plots by saying: \tikzset{every plot/.style={prefix=plots/}} I try this with no succes. \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[domain=0:4,every plot/.style={green,ultra thick}] \draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9); \draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$}; \draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$}; \draw plot[id=x] function{x} node[right] {$f(x) =x$}; \draw plot[id=sin] function{sin(x)} node[right] {$f(x) = \sin x$}; \draw plot[id=exp] function{0.05*exp(x)} node[right] {$f(x) = \frac{1}{20} \mathrm e^x$}; \end{tikzpicture} \end{document}