• Creating a tikz function for visualising a number in number systems with different bases
    by Damitr on July 12, 2025 at 6:02 am

    I am creating a table which shows the how different base number systems will show this number. As a visual aid I am adding "bundles" (whole number of base numbers possible) and "tokens" (carry over from the remaining number) for a given number. See the image below Right now I am using tikz nodes to draw this on a grid using mostly manual setting (with some loops at places) and placing this inside a tabular cell. I want to know is there anyway to automate this? For example we give the number, lets say 12, and the base of the number system, lets say 5, then the function automatically finds the bundles and tokens and draws them accordingly. Any other way to visualise this would also be appreciated. In the MWE below I am only reproducing the code for base-5 system. \documentclass{article} \usepackage{tikz} \usepackage{booktabs} \tikzset{bundle/.style={circle,fill,inner sep=0pt,minimum size=3mm}} \tikzset{token/.style={circle,draw,inner sep=0pt,minimum size=3mm}} \begin{document} \begin{tabular}{p{1.25cm}p{1.5cm}p{1.25cm}p{1.cm}p{3.cm}} \toprule \textbf{Bundles Of} & \textbf{No. of Bundles} & \textbf{No. of Tokens} & \textbf{Write as} & \textbf{Base/}\newline \textbf{Numerals} \\ \midrule Five & \textbf{2} bundles \newline \begin{tikzpicture}[scale=0.4] \foreach \x in {0,1,2} { \foreach \y in {0,1} { \ifnum\x=2 \ifnum\y=0 \else \node[bundle] at (\x*1, \y*1) {}; \fi \else \node[bundle] at (\x*1, \y*1) {}; \fi } } \begin{scope}[shift={(0,2.5)}] \foreach \x in {0,1,2} { \foreach \y in {0,1} { \ifnum\x=2 \ifnum\y=0 \else \node[bundle] at (\x*1, \y*1) {}; \fi \else \node[bundle] at (\x*1, \y*1) {}; \fi } } \end{scope} \end{tikzpicture} & \textbf{2} tokens \newline \begin{tikzpicture}[scale=0.4] \node[token] at (0,0) {}; \node[token] at (1,0) {}; \end{tikzpicture} & \textbf{22} & Base Five \newline Quinary System \newline Numerals\newline 0, 1, 2, 3, 4\\ \bottomrule \end{tabular} \end{document}

  • A TikZ node style with small caps
    by user50655 on July 11, 2025 at 10:02 pm

    Does anyone know how to define a node style with text that has small caps. I tried node[\scshape] as well as \textsc to no avail? Thanks Moustafa

  • Draw parabole and secant plane in perspective
    by graograman on July 11, 2025 at 7:36 pm

    I'd like to reproduce the following parabola in TeX but my approach is not working as I'd like it to. Because TeX doesn't have a 3D engine I drew the whole thing in Geogebra and then tried to reproduce it in code thus: \documentclass[12pt]{standalone} \usepackage{tikz} \usetikzlibrary{matrix, positioning, angles, decorations.pathreplacing, 3d, arrows.meta} \begin{document} \begin{tikzpicture}[parabola/.style={red}, scale=2] \draw [blue, dashed] (0,-1.5,0) -- (0,1.5,0); \draw (0.8,-1,0) arc (-10:-170:0.8cm and 0.3cm); \draw [dashed] (0.8,-1,0) arc (10:170:0.8cm and 0.3cm); \draw (0.8,1,0) arc (-10:-170:0.8cm and 0.3cm); \draw (0.8,1,0) arc (10:170:0.8cm and 0.3cm); \draw (0.8,1,0) -- (-0.78,-1,0); \draw (-0.78,1,0) -- (0.8,-1,0); \draw [fill, blue] (0,0,0) circle (0.5pt) node [left] {$S$}; \coordinate (a) at (-0.4,-0.8,0); \def\b{2} \def\h{1} \def\p{0.5} \pgfmathsetmacro{\rx}{\b/2} \pgfmathsetmacro{\ry}{\rx*\p} \pgfmathsetmacro{\ta}{90-atan2(\h,\ry)} \coordinate (parabend) at (-1*\ta:0.2*\rx-0 and \ry); \path (a) +(50+50*\p:\rx+0 and \ry) coordinate (tmp) +(-90+25*\p:\rx+0 and 0.9*\ry) coordinate (tmp2); \end{tikzpicture} \end{document} which renders the parabola bent like this: and I can't get the plane's edges straight or looking so at least. Maybe there's an easier way to draw the lines? I've looked at some examples but I can't make sense of them.

  • Is that possible to use Line Definition by one point and slope in tkz-elements?
    by Explorer on July 11, 2025 at 9:42 am

    I have the following code: \documentclass[border=4pt,tikz]{standalone} \usepackage{tkz-euclide,tkz-elements} \directlua{ init_elements() z.O = point(0, 0) z.F = point(1.5, 0) L.ab = line(point(-1.5, -1), point(-1.5, 1)) CO.PA = conic(z.F, L.ab, 1) PA.curve = CO.PA:points(-3.2, 4, 100) L.PF = line(z.F,point(2,2)) % I have to use dummy temp point(2,2) to determine the Line AB % Is that possible for tkz-elements to support Line Defined by (point, slope)? z.A, z.B = intersection(CO.PA,L.PF) } \begin{document} \begin{tikzpicture}[line cap=round] \tkzGetNodes \tkzInit[xmin=-2,xmax=3,ymin=-3.5,ymax=4] \tkzDrawX[noticks]\tkzDrawY[noticks] \tkzDrawCoordinates[smooth](PA.curve) \tkzDrawSegment[semithick](A,B) \tkzDrawPoints[blue](O,F,A,B) \tkzLabelPoints[blue,right](O,F,A,B) \end{tikzpicture} \end{document} I have to decide the LineAB's slope to determine the intersections, but I didn't found that tkz-elements support the method of define the Line with only one point and a slope but not line(<pointA>,<pointB>)? If I use line(z.F,point(2,2)), it's hard to dirctly control the slope as above; IMO, define a line by (<point>,<slope>) is a common requirement in geometry, is there better & elegant method to control the slope?

  • aligning tikz nodes to the left or right
    by Stefan Müller on July 11, 2025 at 9:04 am

    I want the nodes to be aligned right and left respectively. I did this with \hphantomand spaces, but I guess there is a proper way to do this within tikz. How can I reach this? \documentclass[border=0.2cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[remember picture] \node(c1) at (-3,2) {nicht weglassbar}; \node(c2) at (-3,1) {\hphantom{nicht~}weglassbar}; \node(c3) at (1,2) {Argument}; \node(c4) at (1,1) {Adjunkt~~~~}; \draw (c1) to (c3); \draw (c2.east) to (c3.west); \draw (c2) to (c4); \end{tikzpicture} \end{document}

  • Draw illustration (cylindric)
    by Alex on July 10, 2025 at 1:08 pm

    I have a such image And I try to draw this in Tikz, and have some troubles: how to set the correct viewing angle (as in the picture) for set the correct position of the plane at an angle of $2pi/3$? \documentclass[tikz,border=3.14mm]{standalone} \usepackage{amssymb} \usepackage{amsmath,amsthm} %\pdfpkresolution=2400 %\pdfpkmode={supre} %\usepackage[exscale]{ccfonts} \usepackage{tempora} \usepackage{newtxmath} \usepackage{tikz} \usepackage{pgfplots} \usepackage{tikz} \usepackage{tikz-cd} \usetikzlibrary{ arrows, matrix, arrows.meta, backgrounds, fit, matrix, positioning, calc, patterns, arrows.meta, graphs, shapes.misc, shadows.blur, shapes.geometric, decorations.pathmorphing } \newcommand{\myunit}{1 cm} \tikzset{ node style sp/.style={draw,circle,minimum size=\myunit}, node style ge/.style={circle,minimum size=\myunit}, arrow style mul/.style={draw,sloped,midway,fill=white}, arrow style plus/.style={midway,sloped,fill=white}, } \pgfplotsset{compat=1.18} \usepackage{tikz,tikz-3dplot} \begin{document} \tdplotsetmaincoords{70}{110} \begin{tikzpicture}[tdplot_main_coords,scale=0.8] \tikzstyle{every node}=[font=\small] % Define parameters \def\R{2.5} \def\zheight{4} \def\zbottom{-2.5} \def\phiangle{60} % Draw the complete cylinder (from bottom to top) % Bottom circle (hidden, at z = zbottom) \draw[thick,dashed] (0,0,\zbottom) circle (\R); % Circle at z = 0 \draw[thick] (0,0,0) circle (\R); % Top circle at z = z₀ \draw[thick] (0,0,\zheight) circle (\R); % Cylinder sides (visible parts) \draw[thick] (\R,0,\zbottom) -- (\R,0,\zheight); \draw[thick] (-\R,0,\zbottom) -- (-\R,0,\zheight); % Dashed lines for hidden parts \draw[thick,dashed] (0,\R,\zbottom) -- (0,\R,\zheight); \draw[thick,dashed] (0,-\R,\zbottom) -- (0,-\R,\zheight); % Draw coordinate planes % z = 0 plane (gray, transparent) \filldraw[fill=gray!20, draw=gray, opacity=0.3] (-4,-4,0) -- (4,-4,0) -- (4,4,0) -- (-4,4,0) -- cycle; % z = z₀ plane (gray, transparent) \filldraw[fill=gray!20, draw=gray, opacity=0.3] (-4,-4,\zheight) -- (4,-4,\zheight) -- (4,4,\zheight) -- (-4,4,\zheight) -- cycle; % φ = 2π/3 plane \tdplotsetrotatedcoords{0}{0}{\phiangle} \begin{scope}[tdplot_rotated_coords] \filldraw[fill=gray!10, draw=gray, opacity=0.4] (0,0,0) -- (4,0,0) -- (4,0,\zheight) -- (0,0,\zheight) -- cycle; \end{scope} % Mark important points and labels \node at (0,0,0) [below left] {$O$}; \node at (3.5,0,0) [below] {$\varphi_0$}; \node at (0,0,\zheight) [left] {$z = z_0$}; \node at (0,0,-0.3) [below] {$z = 0$}; \node at (\R,0,2) [right] {$r = R$}; % Draw angle arc for φ₀ = 2π/3 \tdplotdrawarc[thick,->]{(0,0,0)}{1.5}{0}{\phiangle}{anchor=north}{$\varphi_0 = \varphi = \frac{2\pi}{3}$} % Draw radial line \draw[thick] (0,0,0) -- ({\R*cos(\phiangle)},{\R*sin(\phiangle)},0); % Add "2" label inside cylinder \node at (0,0,2) [font=\large] {$2$}; % Add dimensional indicators \draw[<->] (\R+0.5,0,0) -- (\R+0.5,0,\zheight) node[midway,right] {$z_0$}; \draw[<->] (0,0,-0.7) -- (\R,0,-0.7) node[midway,below] {$R$}; % Mark the cylinder boundary at z = z₀ \draw[thick] (0,0,\zheight) circle (\R); % Draw dashed construction lines \draw[dashed] (0,0,\zbottom) -- ({\R*cos(\phiangle)},{\R*sin(\phiangle)},\zbottom); \draw[dashed] (0,0,0) -- ({\R*cos(\phiangle)},{\R*sin(\phiangle)},0); \draw[dashed] (0,0,\zheight) -- ({\R*cos(\phiangle)},{\R*sin(\phiangle)},\zheight); \draw[dashed] ({\R*cos(\phiangle)},{\R*sin(\phiangle)},\zbottom) -- ({\R*cos(\phiangle)},{\R*sin(\phiangle)},\zheight); % Draw coordinate axes (on top, black) \draw[thick,-latex] (0,0,0) -- (5,0,0) node[anchor=north east]{$x$}; \draw[thick,-latex] (0,0,0) -- (0,5,0) node[anchor=north west]{$y$}; \draw[thick,-latex] (0,0,\zbottom-0.5) -- (0,0,5) node[anchor=south]{$z$}; \end{tikzpicture} \end{document} Current result:

  • What are "best practices" for PGF/TikZ use of pgfmathparse and friends?
    by karlh on July 9, 2025 at 6:43 pm

    I have encountered (sporadically) comments to the effect that \pgfmathparse, \pgfmathsetlength, and so forth should not be used unless absolutely necessary. For example, it is (I am told) preferable to say \pgfmathmax@{{\pgfmath@tonumber{\pgf@xa}}{\pgfmath@tonumber{\pgf@xb}}} \pgf@xa=\pgfmathresult pt rather than \pgfmathsetlength{\pgf@xa}{max(\pgf@xa,\pgf@xb)}. Similarly, \pgfmathparse{sin(\pgf@xa)} should, in code written for others to use, be written as \pgfmathsin{\pgf@xa}} or even \pgfmathsin@{\pgf@xa}, and similar for operations such as addition, subtraction, multiplication, etc. What advice do others have on when to invoke the math parser and when to do it without? Also, is there a significant difference between \pgfmathadd and \pgfmathadd@ (and other similar variants)? If the answer is "it is faster," how much faster? Is there an example I can generate relatively easily and/or tinker with for which I could actually observe the difference (or do a timing test)? Edit/clarification: This is in the context of writing new shape definitions, extending shapes, and so forth (i.e., library/package code).

  • Which is faster to compile? Importing rendered images or rendering tikz codes together with the document
    by Liu Zhiyu on July 9, 2025 at 8:20 am

    I'm writing a huge document, which has many tikzpictures. I'm wondering which method is faster to compile? (1) Plain Tikz codes to compile with the document together. (2) Generating .pdf images in advance and importing the images. I think (2) is faster, which also has cleaner codes.

  • Using the distance between two points as the radius of an arc in TikZ
    by Lucy on July 8, 2025 at 4:23 pm

    I have two points defined, and I want to use the distance between them as the radius of an arc, but the vector (logically) does not work because it is not a number. \path let \p1 = (P), \p2 = (C) in \pgfextra{\pgfmathsetmacro{\r}{veclen(\x2-\x1,\y2-\y1)}}; % \draw[shift={(A)}] (34:{\r}) arc (34:75:{\r});

  • Adding annotations to polynomial long division using tikz
    by Damitr on July 8, 2025 at 12:26 pm

    I am typesetting a polynomial long division using polynom. I would like to add text annotations as shown in the figure. Right now I have manually adjusted the tikz nodes to approximately align where I want them after a bit of trial and error for each node. But is there a way to automagically to do this. As for other divisions I would have to manually adjust all 4 of them. MWE \documentclass{article} \usepackage{polynom} \usepackage{tikz} \begin{document} \begin{tikzpicture}[remember picture,overlay] \node at (0,0) { \polylongdiv[vars=a]{8a^3 + 16a^2 - 2a + 4}{4a^2 -2a +1} }; \node[anchor=west] at (-2,1.25) {Divisor}; \node[anchor=west] at (3.7,0.7) {Dividend}; \node[anchor=west] at (2,1.8) {Quotient}; \node[anchor=west] at (3.7,-1.2) {Remainder}; \end{tikzpicture} \end{document}

  • Clip bars for big values in bar chart
    by thinksolid on July 8, 2025 at 10:20 am

    I would like to display my bars fully in the range of 0-80. Above that I want to clip the bars and display the real value above. It should be displayed that it is easy to understand. It should look something like this: The problem is, that my clipped bars dont display the original value, but the value that I clipped the bars to. Why does the saving of the variable not work? This is my code right now. \documentclass[a4paper]{article} \usepackage[left=3cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry} \usepackage{pgfplots} \usepackage{siunitx} \pgfplotsset{compat=newest} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing} \begin{document} \pgfplotstableread{ Hersteller Delta1 Delta2 Delta3 Delta 25 125 48 Traco 46 49 75 Cosel 12 46 18 Meanwell 13 51 46 Cincon 50 50 50 Recom 27 75 51 Daitron 21 13 160 }\datatable \begin{figure}[htbp] \centering \begin{tikzpicture} \begin{axis}[ width=\textwidth, height=9cm, ybar=2pt, bar width=12pt, tick align=inside, xtick pos=lower, ytick pos=left, symbolic x coords={Delta, Traco, Cosel, Meanwell, Cincon, Recom, Daitron}, xtick=data, xticklabel style={rotate=45, anchor=east}, ylabel={Magnetfeld in \si{\milli\tesla}}, ymin=0, ymax=80, ymajorgrids, restrict y to domain*=0:85, visualization depends on=rawy\as\rawy, % Save the unclipped values after end axis/.code={ % Draw line indicating break \draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05); }, nodes near coords={% \pgfmathprintnumber{\rawy}% Print unclipped values }, axis lines*=left, clip=false, legend style={ /tikz/every even column/.append style={column sep=15pt}, at={(0.5,-0.2)}, anchor=north, legend columns=-1 }, legend image code/.code={ \draw[#1,draw=none] (0cm,-0.125cm) rectangle (0.25cm,0.175cm); }, nodes near coords, nodes near coords align={vertical}, ] \addplot+[fill=green, draw=none, nodes near coords style={color=green}] table [x=Hersteller, y=Delta1] {\datatable}; \addplot+[fill=red, draw=none, nodes near coords style={color=red}] table [x=Hersteller, y=Delta2] {\datatable}; \addplot+[fill=blue, draw=none, nodes near coords style={color=blue}] table [x=Hersteller, y=Delta3] {\datatable}; \legend{Richtung 1, Richtung 2, Richtung 3} \end{axis} \end{tikzpicture} \caption{YYY} \label{fig:YYY} \end{figure} \end{document}

  • TikZ pattern color not preserving CMYK values in PDF output (using pattern.meta) [duplicate]
    by Lucy on July 8, 2025 at 10:13 am

    I'm having trouble with TikZ patterns and CMYK colors in LaTeX. Specifically, when I use a pattern with pattern color=blue (or a custom CMYK blue color), the resulting PDF output shows about 52% cyan and 13% yellow instead of the expected pure blue. Also, when I try black defined as a composite of all four CMYK colors, the pattern color doesn’t appear correctly. I’m compiling with pdfLaTeX (not XeLaTeX or LuaLaTeX), and I’ve tried turning off PDF compression with \pdfcompresslevel=0, and also tried using the pdfx package for PDF/X compliance, but either the color model switches to RGB or the problem persists. Here is a minimal example: \documentclass{article} \pdfcompresslevel=0 \usepackage{xcolor} \definecolor{modra}{cmyk}{1,0,0,0} % custom CMYK blue \usepackage{tikz} \usetikzlibrary{patterns.meta} \begin{document} \begin{tikzpicture} \coordinate (I) at (0,0); \coordinate (S) at (4,0); \coordinate (J) at (2,3); \draw[pattern={Lines[angle=45, distance=5pt]}, pattern color=modra, draw=none] (I) -- (S) -- (J) --cycle; \end{tikzpicture} \end{document} My questions are: Why does the pattern color output as roughly 52% cyan and 13% yellow in the PDF instead of the expected CMYK blue? Is there a way to make the TikZ pattern lines fully opaque and preserve the exact CMYK color definitions in the output? Are there known workarounds to preserve CMYK colors and get correct pattern rendering without switching to RGB or using pdfx? Thanks in advance for any help! Lucy

  • tikzpicture in marginnote in lstlisting: extraneous character and alignment
    by user2926204 on July 7, 2025 at 10:32 pm

    I'm trying to write marginnotes attached to text in a lstlisting environment. Here's the output of a mwe: The macro mnote is for creating a margin note inside a tikzpicture with a red bounding box. Margin note B is attached to line in the main body near the call to mnote. This is correct and is included for comparison. Margin note C has three problems: (1) it is about 1 line below where mnote is called, (2) there are two extraneous vertical characters, one near the mnote call and one at the top of the mnote and (3) there's a blank line after the lstlisting environment. Here's the mwe: \documentclass[a4paper, openany, oneside, chapterprefix, 12pt, parskip=full]{scrbook} \setlength{\textwidth}{5in} \setlength{\hoffset}{-0.25in} \setlength{\marginparwidth}{2in} \usepackage{showframe} \usepackage{marginnote} \usepackage{tikz} \usepackage{listings} \begin{document} \newcommand\mnote[1] {\marginnote{\centering% \begin{tikzpicture}[overlay, baseline=(n.base)] \node[draw=red, text width=4cm, line width=0.1cm, inner sep=0.2cm] (n) {#1}; \end{tikzpicture}% }} A. Some text. \marginnote{margin note A} Some text. B. Some text. \mnote{margin note B} Some text. C. Some text. \lstset{ basicstyle=\ttfamily, breaklines=true, columns=fullflexible, keepspaces=true, frame=single, xleftmargin=3.4pt, xrightmargin=3.4pt } \begin{lstlisting}[escapeinside=||] Some text.|\mnote{margin note C}| Some text. \end{lstlisting}% Some text. \end{document} Thanks.

  • Draw variable curves in Tikz
    by liuzp on July 7, 2025 at 6:18 pm

    I'm trying to build a sample code that is able to reproduce the same curve multiple times, since I want to use it a few times but don't want to rewrite the full code every time. So, what I would like to define is a new square/.style curve that accepts two parameters #1 and #2, where #1 is a color and #2 is a number. From that it then draws a square colored #1 and with size #2, with black lines and grid on every unit interval up to #2. I tried the code bellow, but obviously it's missing the color part, and the grid part, while also not rendering the desired square. \tikzset{ square/.style args={1}{insert path={ (#1,0) -- (0,0) -- (0,#1) -- (#1,#1) -- cycle }} } Can you please, help me with this line of code? In a following matter, I would also like to define some cubes, is this possible in the same fashion way? Edit: I'm sorry if the question was unclear, I was lacking the proper vocabulary on the time, and could not explain in details what I wanted to do, but after your comments I think I can be. What I want to build is a tikz macro that can reproduce the drawing bellow passed the size and color As one can see, we have 3 progressive examples of grided and shaded squares, a 1x1 light blue square, a 2x2 light yellow square, and 3x3 light red square, that can be extended to an $$n \cross n$$ square of any color. As for the M (not) WE, what I can provide is this similar context of the whole document that spams dozens of other packages and features, and personal information. \documentclass[margin=5mm, varwidth]{standalone} \usepackage{tikz} \usepackage{multicol} \usetikzlibrary{ 3d, perspective, positioning, calc, arrows.meta, shapes } \tikzset{>={Stealth}} \tikzset{ square/.style args={1}{insert path={ (#1,0) -- (0,0) -- (0,#1) -- (#1,#1) -- cycle }} } \begin{document} \begin{enumerate} \item Item 1 \item Item 2 \begin{multicols}{3} \begin{enumerate} \item \tikz{\draw[style/.expanded=square 2]} \item Square 2 \item Square 3 \end{enumerate} \end{multicols} \item Item 3 \end{enumerate} \end{document} As for the cube case, I think that @cfr response should be sufficient for my purposes. Thanks in advance for all of your help.

  • Custom textbox title problem, TikZ
    by user386618 on July 7, 2025 at 6:05 am

    \documentclass[10pt]{book} \usepackage[papersize={148mm, 210mm}, inner=12.6mm, outer=5.4mm, top=5.4mm, textwidth=130mm, headheight=15pt, headsep=10pt, footskip=15mm, includehead]{geometry} \usepackage[english, russian]{babel} \usepackage{tikz} \usetikzlibrary{calc, backgrounds} \usepackage{pgffor} \usepackage{xparse} \usepackage{environ} \usepackage{fancyhdr} \usepackage{graphicx} \definecolor{V}{RGB}{54, 60, 124} \definecolor{O}{RGB}{238, 123, 96} \NewEnviron{fact}{ \vspace{5mm} \begin{tikzpicture} \node[draw=O, fill=O!20, line width=2pt, rounded corners=8pt, text width=0.955\textwidth, inner sep=10pt] (mainbox) at (0,0) {\BODY}; \node[fill=white, rounded corners=6pt, draw=O, line width=2pt, inner xsep=10pt, inner ysep=1.5pt] at ($(mainbox.north west)+(1.8cm, 7.5pt)$) {\textbf{\textcolor{O}{Интересный факт}}}; \end{tikzpicture} \vspace{1mm} } \pagestyle{fancy} \fancyhead{} \fancyhead\[RO,LE\]{Easy to Learn} \fancyhead\[C\]{\thepage} \fancyfoot{} \parindent=0pt \begin{document} \begin{fact} Пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то \end{fact} \newpage \begin{fact} Пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то пишу что-то \end{fact} \end{document}][1] I'm writing a book and i want to make custom textboxes like on the image but the title isn't in right place like in the first image. Please help

  • Half sphere - Tikz
    by Latexfan on July 6, 2025 at 7:27 pm

    I have tried to plot a half sphere as following: \documentclass[border=10pt]{standalone} \usepackage{pgfplots} \usepackage{tikz} \pgfplotsset{every axis/.style={scale only axis}} \begin{document} \begin{tikzpicture} \begin{axis}[ title={$f(x,y)=x^2-y^2$}, xlabel=$x$, ylabel=$y$, small, xmin=-1, xmax=1, ymin=-1, ymax=1, zmin=-1, zmax=1, 3d box=complete, unit vector ratio*=1 1 1, ] \addplot3[surf, domain=-1:1] {x^2-y^2}; \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[ title={$f(x,y)=\sqrt{4- (x^2+y^2)}$}, xlabel=$x$, ylabel=$y$, small, xmin=-2, xmax=2, ymin=-2, ymax=2, zmin=0, zmax=2, 3d box=complete, unit vector ratio*=1 1 1, ] \addplot3[surf, domain=-2:2] {sqrt{4- (x^2+y^2 }}; \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[ title={$f(x,y) = \sqrt{4 - (x^2 + y^2)}$}, xlabel=$x$, ylabel=$y$, zlabel={$z$}, view={120}{30}, domain=-1.9:1.9, y domain=-1.9:1.9, samples=60, ] \addplot3[surf, shader=interp, samples=60, domain=-1.9:1.9, y domain=-1.9:1.9] {sqrt(4 - (x^2 + y^2))}; \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[ title={$f(x,y) = \sqrt{4 - (x^2 + y^2)}$}, xlabel=$x$, ylabel=$y$, zlabel={$z$}, view={120}{30}, domain=-1.9:1.9, y domain=-1.9:1.9, samples=60, ] \addplot3[surf, domain=-1.9:1.9, y domain=-1.9:1.9] {sqrt(4 - (x^2 + y^2))}; \end{axis} \end{tikzpicture} \end{document} The first hyperbola is quite fine, but those 3 attempts does not give a good shaped half sphere. I wish to have something like hyperbola figur as nice as possible.

  • Custom command for creating grids of arbitrary sizes with filled discs as entries
    by ultralegend5385 on July 6, 2025 at 3:38 pm

    What I am doing involves a game which is played with stones on a rectangular grid that look like this: Just a rectangular grids with black stones as pieces. In the interface that I used to create this image, I just need to enter a command with "x.xxxx|.xx.x.|xx..xx" as input, and that would create the grid. (Here, x represents a stone, and . an empty space, and | indicates end of the row.) I want to recreate these with a command that takes a similar input and outputs the corresponding TikZ diagram. I can create a grid and fill it with circles manually, but I don't know how to make a custom command that can create any-sized grid with any configuration. Could someone give some ideas on how to do so? (If someone can edit the title and make the wording better, please do so.)

  • Using `evaluate` and `using` in nested Tikz-loop
    by Gerhard on July 5, 2025 at 7:40 pm

    How can I use \evaluate and using within a nested loop, where several loop indices are used? The following code does not work. \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \foreach \x in {0,1,...,9} \foreach \y [evaluate=\y as \p using {\x+\y*10}] in {0,1,...,9} \node [fill=red!\p!yellow, minimum size=0.65cm] at (\x,\y) {\p}; \end{tikzpicture} \end{document}

  • How do I add a second top element to my forest in latex
    by Zilore Mumba on July 5, 2025 at 7:34 pm

    In drawing of my directory structure, I am able to do what I want in tikz. However I would like to do the same using the forest package. As in the attached image, the forest output is ok, except I am not able to include the Build directory at the top. My code below. \documentclass[12pt,twoside,fleqn]{report} \usepackage{tikz} \usetikzlibrary{tikzmark} \usepackage{tikz-3dplot} \usepackage{tikz-3dplot} \usetikzlibrary{shapes.geometric, decorations.pathreplacing, matrix, angles, quotes, arrows, arrows.meta, datavisualization,cd} \usetikzlibrary{through,calc,intersections} \usepackage{forest} \begin{document} \begin{tikzpicture}[node distance=2cm, scale=0.5] \tikzstyle{process} = [rectangle, minimum width=2.0cm, minimum height=1cm, text centered, text width=2.0cm, draw=black, fill=orange!30] \node (proc0) [process, xshift=-8cm] {Build}; \node (proc1) [process, right of=proc0, xshift=1.0cm] {DA}; \node (proc2) [process, below of=proc1, yshift=-0.5cm] {WRF}; \node (proc3) [process, below of=proc2, xshift=-2.0cm,yshift=-1.0cm] {run}; \node (proc4) [process, right of=proc3, xshift=2.0cm] {test}; \node (proc5) [process, below of=proc3, xshift=4cm] {em\_real}; \node (proc6) [process, right of=proc2, xshift=1.0cm] {WPS}; \node (proc7) [process, right of=proc6, xshift=1.0cm] {WRFPLUS}; \node (proc8) [process, right of=proc7, xshift=1.0cm] {3DVAR}; \node (proc9) [process, right of=proc8, xshift=1.0cm] {4DVAR}; \draw [black,thick] (proc0) -- (proc1); \draw [black] (proc1) -- (proc2); \draw [black] (proc2) -- (-10,-11); \draw [black] (proc4) -- (proc5); \draw [black] (proc3) -- (proc4); \draw [black] (proc2) -- (proc6); \draw [black] (proc6) -- (proc7); \draw [black] (proc7) -- (proc8); \draw [black] (proc8) -- (proc9); \end{tikzpicture}\par \bigskip \begin{forest} for tree={ draw, font=\sffamily\bfseries, edge path={ \noexpand\path[draw, \forestoption{edge}] (!u.parent anchor) -- +(0,-5mm) -| (.child anchor)\forestoption{edge label}; }, parent anchor=south, child anchor=north, l sep=10mm, tier/.wrap pgfmath arg={tier #1}{level()}, edge={ultra thick, rounded corners=2pt}, ultra thick, inner color=blue, outer color=gray!20, rounded corners=2pt, s sep=1.0cm, minimum width=1.8cm, minimum height=0.6cm, } [DA [WPS] [WRF [\color{green}run] [\color{orange}test [\color{green}em\_real] ] ] [WRFPLUS] [3DVAR] [4DVAR] ] \end{forest} \end{document} Is it possible to include "Build" in the forest version? Help please.

  • pgfplots: Using set layers in an overlay picture
    by schtandard on July 5, 2025 at 1:58 pm

    Using pgfplots, I want to draw a plot as an overlay picture, making use of layers inside that plot. However, when I say \begin{tikzpicture} [overlay] \pgfplotsset{set layers} \begin{axis} \end{axis} \end{tikzpicture} I get two ! Dimension too large. errors. pgfplots seems to attempt to set both unit lengths (\pgf@x and \pgf@y) to -32000.0pt. Why is that and how can I avoid it? For tinkering, here is a slightly more useful MWE. Interestingly, the result looks fine in this example. (In larger pictures, the errors do cause havoc, though.) \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} [remember picture] \draw [green] coordinate (test) circle [radius=5cm]; \end{tikzpicture} \begin{tikzpicture} [remember picture, overlay] \pgfplotsset{set layers} \begin{axis} [at=(test), anchor=center, ymajorgrids] \addplot+ {x^2}; \begin{pgfonlayer}{axis grid} \fill [red] (axis cs:3,20) circle [radius=2cm]; \end{pgfonlayer} \end{axis} \end{tikzpicture} \end{document}

  • pgfplots: Math font for 'extra y tick labels'
    by cis on July 5, 2025 at 4:11 am

    What do I have to set so that the extra y tick labels are also set in math mode? Note: I left all other settings as they were. \documentclass[margin=5pt, tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \def\Ymin{-20} \def\Ymax{21} \pgfmathtruncatemacro\YminPre{\Ymin+5} \pgfmathsetlengthmacro\Yenlarge{3.25mm} \begin{tikzpicture}[] \begin{axis}[ xmin = -5, xmax=5, ymin =\Ymin, ymax = \Ymax, axis lines = middle, axis line style={->, >=latex}, xlabel={$x$}, ylabel={$y$}, x label style={at={(ticklabel* cs:1.00)}, inner sep=5pt, anchor=north}, y axis line style={shorten >=-\Yenlarge, shorten <=-\Yenlarge+1.5mm}, y label style={at={(ticklabel* cs:1.00)}, inner sep=2pt, anchor=east, yshift=\Yenlarge}, xtick={-5,-4,...,5}, enlarge x limits={0.075}, % y>0 ticks left ====================== ytick={20,15,...,-20}, yticklabel={\pgfmathprint{\tick>0 ? int(\tick) : {}} }, % y<0 ticks right =================== extra y ticks={\Ymin,\YminPre,...,-5}, extra y tick labels={\Ymin,\YminPre,...,-5}, extra y tick style = {tick label style={anchor=west, inner xsep=.5em}, /pgf/number format/assume math mode=true% no effect }, minor y tick num={4},% for complete y-axis! ] \addplot[red] {x}; \end{axis} \end{tikzpicture} \end{document}

  • How can I fix this beamer presentation error?
    by Oussama Taoussi on June 23, 2022 at 8:11 am

    I am making a beamer presentation that has some tikzpictures and pgfplots and I get this error : >Illegal parameter number in definition of \beamer@doifinframe. I tried adding fragile in \begin{frame} but the error still shows up, the pdf is still generated but when the presentation gets bigger(more tikzpictures and pgfplots} the output stops. %the error : <to be read again> 1 l.78 \end{figure}} You meant to type ## instead of #, right? Or maybe a } was forgotten somewhere earlier, and things are all screwed up? I'm going to assume that you meant ##. \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage{pgfplots} \usepackage{tikz} \usepackage{amsmath} \usetikzlibrary{positioning} \usetikzlibrary{calc} \pgfplotsset{width=10cm,compat=newest} \usetheme{Warsaw} \definecolor{mygreen}{rgb}{.125,.5,.25} \usecolortheme[named=mygreen]{structure} \begin{document} \begin{frame}[fragile,t]{La théorie des SVM}% \vspace{10pt} \only<1-3>{ \begin{block}{L'hyperplan optimale} L'hyperplan qui posséde une \alert{marge} maximale. \end{block}} \only<2-3>{ \begin{block}{La marge} Deux fois la \alert{distance minimale} entre l'hyperplan et les observations. \end{block}} \vspace{2pt} \only<3>{\begin{figure} \centering \begin{tikzpicture}[scale=0.6,marge/.style={<-,dashed,thick}, extended line/.style={shorten >=-#1,->}, extended line/.default=0.09cm] \begin{axis}[axis background/.style={fill=gray!10}, axis line style={->}, x label style={at={(axis description cs:0.5,-0.1)},very thick,anchor=north}, y label style={at={(axis description cs:-0.1,.5)},rotate=-90,thick,anchor=south},clip=false,xmin=0,xmax=10,ymin=1,ymax=8,axis lines=left,scatter/classes={ a={color=blue},b={color=red}}, xlabel=$x$, ylabel=$y$] %scatter \addplot+[ only marks,scatter src =explicit symbolic, scatter,mark size=2.9pt] coordinates{(3.67,1.47) [b] (6,2.5) [b] (6.2,3) [b] (5,2.55) [b] (4.89,3.22) [b] (2.8,1.5) [b] (2,2.071) [b]% (4,2) [b] (3.5,2.5) [b] (3,2) [b] (4.1,4.8) [a] (4.4,2.3) [b] (2.23,5.001) [a] (2.7,4.25) [a] (1.5,3.35) [a] (1.77,3.47) [a] (5,4.74) [a] % (3.45,5) [a] (2,4.2) [a] (2.6,5.3) [a] (2.4,4.6) [a] (3.24,4.47) [a]}; %hyperplanes \addplot[color=red, domain=0:7.5,left]{2/5*x + 2}; \addplot[color=red, domain=7.5:7.9,left]{2/5*x + 2}; \addplot[color=red, domain=9.44:10,left]{2/5*x + 2} node[sloped,pos=0.2](){$h(x)=0$}; \addplot[color=black,dashed, domain=0:10,left]{2/5*x + 1.26}; \addplot[color=black,dashed, domain=0:10,left]{2/5*x + 2.74}; %vecteur w \node (A) at (2,2/5*2+2) {}; \node (B) at (5,2/5*5+2) {}; \node (P) at (3.6,4.004) {}; \draw [extended line] ($(A)!(P)!(B)$) -- (P) node[sloped,above,pos=0.6](){$w$}; %marge \node (X) at (6,2/5*6+2.74) {}; \node (Y) at (9,2/5*9+2.74) {}; \node (T) at (6,2/5*6+1.26) {}; \node (Z) at (9,2/5*9+1.26) {}; \node (M) at (7.5,2/5*7.5+2) {}; \draw [marge] ($(X)!(M)!(Y)$) -- (M); \draw [marge] ($(T)!(M)!(Z)$) -- (M); %support vectors \end{axis} \end{tikzpicture} %\caption{Hyperplan optimale} \end{figure}} \only<3-5>{ \begin{block}{Normalisation} Pour les observations à limite de la marge on pose : $\arrowvert w\cdot x_{marge}+w_0\arrowvert=1$ , avec: $\begin{cases} w\cdot x_{marge+}+w_0=+1 \\ \ w\cdot x_{marge-}+w_0=-1 \end{cases}$ \end{block}} \only<5->{\begin{figure} \centering \begin{tikzpicture}[scale=0.6,marge/.style={<-,dashed,thick}, extended line/.style={shorten >=-#1,->}, extended line/.default=0.09cm] \begin{axis}[axis background/.style={fill=gray!10}, axis line style={->}, x label style={at={(axis description cs:0.5,-0.1)},very thick,anchor=north}, y label style={at={(axis description cs:-0.1,.5)},rotate=-90,thick,anchor=south},clip=false,xmin=0,xmax=10,ymin=1,ymax=8,axis lines=left,scatter/classes={ a={color=blue},b={color=red}}, xlabel=$x$, ylabel=$y$] %scatter \addplot+[ only marks,scatter src =explicit symbolic, scatter,mark size=2.9pt] coordinates{(3.67,1.47) [b] (6,2.5) [b] (6.2,3) [b] (5,2.55) [b] (4.89,3.22) [b] (2.8,1.5) [b] (2,2.071) [b]% (4,2) [b] (3.5,2.5) [b] (3,2) [b] (4.1,4.8) [a] (4.4,2.3) [b] (2.23,5.001) [a] (2.7,4.25) [a] (1.5,3.35) [a] (1.77,3.47) [a] (5,4.74) [a] % (3.45,5) [a] (2,4.2) [a] (2.6,5.3) [a] (2.4,4.6) [a] (3.24,4.47) [a]}; %hyperplanes \addplot[color=red, domain=0:7.5,left]{2/5*x + 2}; \addplot[color=red, domain=7.5:7.9,left]{2/5*x + 2}; \addplot[color=red, domain=9.44:10,left]{2/5*x + 2} node[sloped,pos=0.2](){$h(x)=0$}; \addplot[color=black,dashed, domain=0:10,left]{2/5*x + 1.26} node[sloped,below,pos=0.918](){$h(x)=-1$}; \addplot[color=black,dashed, domain=0:10,left]{2/5*x + 2.74} node[sloped,above,pos=0.85](){$h(x)=+1$}; %vector w \node (A) at (2,2/5*2+2) {}; \node (B) at (5,2/5*5+2) {}; \node (P) at (3.6,4.004) {}; \draw [extended line] ($(A)!(P)!(B)$) -- (P) node[sloped,above,pos=0.6](){$w$}; %marge \node (X) at (6,2/5*6+2.74) {}; \node (Y) at (9,2/5*9+2.74) {}; \node (T) at (6,2/5*6+1.26) {}; \node (Z) at (9,2/5*9+1.26) {}; \node (M) at (7.5,2/5*7.5+2) {}; \draw [marge] ($(X)!(M)!(Y)$) -- (M); \draw [marge] ($(T)!(M)!(Z)$) -- (M); %support vectors \node (svm) at (3.5,7) {Vecteurs de support}; \node (s1) at (5,4.74) {}; \node (s2) at (2,2.071) {}; \draw [->] (svm)--(s1); \draw [->] (svm)--(s2); \end{axis} \end{tikzpicture} %\caption{Hyperplan optimale} \end{figure}} \end{frame} \end{document}

  • pgfplot x axis ticks aligned with a matrix beneath |
    by Lawliet on September 29, 2020 at 6:09 am

    How can I make something like this as shown in the image using pgfplots in latex. I want the x-axis tick marks aligned with the other texts as shown in the image.

  • Tikz: positioning of circular framed photo in top right corner of paper, with control over the frame thickness and color, and x/y position
    by Hossein Rouhabadi on August 18, 2020 at 2:43 pm

    My question is about photo positioning in Tikz. I want to insert a photo on the top right corner, with a circular shape and a frame, thickness and color of which I can control. Can someone please guide me how I can bring the photo to the north east corner with the control inputs of color and thickness of the frame and the x and y shifts from paper edges? Thank you very much. \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc,arrows} \begin{document} \begin{tikzpicture}[remember picture,overlay] \draw[path picture={\node {\includegraphics[width=5.5cm]{example-image}}; } ] (0,0) circle [radius=2.5cm]; \end{tikzpicture} \end{document}

  • Chevron arrow shape in tikz
    by Peter on May 14, 2020 at 2:14 pm

    What is the best way to draw this in TIKZ? I was thinking I could define a custom shape with this "arrow" form, but did not really figure out how to achieve this. Maybe there are better solutions?

  • How to reproduce the beautiful LIB style box as in the tcolorbox document using mdframed package?
    by C. Davide on July 23, 2019 at 5:44 am

    I tried to reproduce the beautiful LIB type box as in tcolorbox document using mdframed package. But I failed, I don't know how to produce the clip effects using mdframed package. The rotated rectangle is somehow bigger than the background box... My code : % !Tex program = xelatex % !Tex encoding = UTF-8 Unicode \documentclass{article} \usepackage{xcolor} \usepackage{tikz} \usetikzlibrary{calc} \usepackage[absolute,overlay]{textpos} \usepackage[skins]{tcolorbox} \usepackage[framemethod=TikZ]{mdframed} %------------------------------- % Lib mdbox %------------------------------- \newmdenv[ skipabove =7pt, skipbelow =7pt, leftmargin =0cm, rightmargin =0cm, topline =true, bottomline =true, leftline =true, rightline =true, linewidth =.4pt, innertopmargin=4pt, innerbottommargin=4pt, innerleftmargin=4mm, innerrightmargin=4mm, roundcorner=1pt, linecolor=green!50!black, backgroundcolor=green!10!white, fontcolor =green!25!black, singleextra={% \path let \p1=(P), \p2=(O) in ($(\x2,0)+0.5*(0,\y1)$) node[ fill=green!75!blue!50!white, text=white, font=\sffamily\bfseries\tiny, rectangle, rounded corners=1pt, rotate=90 ] {REM}; \path let \p1=(P), \p2=(O) in ($(\x1,0)+0.5*(0,\y1)$) node[ fill=green!75!blue!50!white, text=white, font=\sffamily\bfseries\tiny, rectangle, rounded corners=1pt, rotate=90, ] {REM}; }, ]{mylibmd}% %------------------------------- % Lib tcbbox %------------------------------- \newtcolorbox{mylibtcb}{ enhanced, before skip=7pt, after skip =7pt, left skip=0pt, right skip=0pt, boxrule=0.4pt, top=0pt, bottom=0pt, left=4mm, right=4mm, arc=1pt, boxsep=4pt, %before upper={\vphantom{dlg}}, colframe=green!50!black, coltext=green!25!black, colback=green!10!white, overlay={\begin{tcbclipinterior} \fill[green!75!blue!50!white] (frame.south west) rectangle node[text=white, font=\sffamily\bfseries\tiny, %rectangle, rotate=90 ] {REM} ([xshift=4mm]frame.north west); \fill[green!75!blue!50!white] ([xshift=-4mm]frame.south east) rectangle node[text=white, font=\sffamily\bfseries\tiny, %rectangle, rotate=90 ] {REM} (frame.north east); \end{tcbclipinterior}; } } %----------------------------- % document %---------------------------- \begin{document} %\section{library} The following is \textbf{a mdbox}created by using \textbf{the mdframed package}: \begin{mylibmd} good good study day day up day day up \end{mylibmd} The following is a \textbf{a tcbbox} created by using \textbf{the tcolorbox package}: \begin{mylibtcb} good good study day day up day day up \end{mylibtcb} \end{document} % END The difference is shown in the picture

  • How can I use \\ with \texttt inside a node?
    by codeaviator on January 18, 2017 at 8:34 pm

    Take the following MWE: I made this node with tikz using the normal font: However, I need to use a monospaced font to get the following result: Since the node has two lines of text, I would normally do \texttt{line1\\line2}. However when I compile it I get lots of errors. If I do \texttt{line1}\\\texttt{line2} it compiles with no errors. Why can't I use \\ inside \texttt{}? Is there a solution to avoid putting \texttt{} on every line of text? \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node[draw,rectangle,align=center] {line1\\line2}; \end{tikzpicture} \end{document}

  • How to draw closed integration contours with conjugated poles using TikZ?
    by Jeremy on December 22, 2016 at 9:50 pm

    I would like to illustrate in my report integration contour with a cut and four poles (two of them located on another branch) what is demonstrated on the picture below. But I am having trouble finding a solution with TikZ. Where can I find the TikZ manuals? I would appreciate if you could indicate the code to draw this diagram.

  • "Logarithmic scale" for negative values
    by jazzpi on May 17, 2016 at 9:29 pm

    I have the following MWE: \documentclass{standalone} \usepackage{pgfplots} \usepackage{pgfplotstable} \usepackage{filecontents} \pgfplotsset{compat=1.12} \begin{filecontents}{data.dat} 4 -1e4 4 -1e3 4 -1e2 4 -10 4 -1 \end{filecontents} \begin{document} \begin{tikzpicture} \begin{axis}[ xmin=0, xmax=5 ] \addplot table {data.dat}; \end{axis} \end{tikzpicture} \end{document} This produces the following plot: Now I'd like to have ticks on the y axis at -1e0, -1e1, -1e2, -1e3 and -1e4 with even spacing. If my values are positive, I can achieve this by adding ymode=log to the axis options, but for negative values this just produces an error. So how can I produce a sort of logarithmic scale for negative values?

  • How do you draw the "snake" arrow for the connecting homomorphism in the snake lemma?
    by James Weigandt on October 8, 2010 at 4:32 am

    How does one draw the "snake" arrow for the connecting homomorphism when using the snake lemma? I'd also be interested in drawing similar arrows act as "carriage returns" when considering a long exact sequence of cohomology. I'm sorry if this is a little vague. I'm hoping that someone who's already done this might be willing to share a template. I'd prefer things in xy-pic, but would also be interested to see other ways it can be done.