• I would like to create a graph paper document
    by Brion C on January 9, 2026 at 4:36 pm

    I'm trying to create a graph paper document and have the text align to the grid (Not just superimposed on it). The text should at least align with baseline of the grid, but better yet, each character should be placed inside the grid like if you were handwriting on graph paper.

  • Strange dot shown in `circuitikz` if `line cap=round` is set only in PDF-XChange Editor?
    by Explorer on January 9, 2026 at 2:32 pm

    I have the following code, with line cap=round: \documentclass[margin=5pt]{standalone} \usepackage{circuitikz} \begin{document} \begin{circuitikz}[ european, line cap=round, ] \draw (0,0) to [rmeter] (0,2) -- (1,2) |- (0,0); \end{circuitikz} \end{document} It shown as normal in "Adobe Acrobat Reader": However, with PDF-XChange Editor, the strange dot appeared by line cap=round... Edited: Mine PDF-XChange Editor's version is v10.5.2.

  • Simple way to show/hide controls points in a Tikz line?
    by YaGoi Root on January 9, 2026 at 2:18 pm

    In Tikz diagrams, one of the best ways to make controlled curved lines (such as pointing arrows in a flow chart) is using \draw with control points. For example, \documentclass{article} \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing} \usetikzlibrary{shapes.arrows, arrows.meta} \begin{document} \begin{figure} \begin{tikzpicture} \draw[thick,->,>=Stealth, show controls] (0,0) .. controls (0.5,3) and (4.5,0).. (5,5); \end{tikzpicture} \end{figure} \end{document} However, I feel like it ends up being a sort of guessing game when trying to determine where to actually place the control points, because I have a hard time visualizing where the points are and how their position affects the curved line. I understand how the points effect the line very intuitively, but moving said points to the desired location is easier when you can see the points as well. Is there any simple way to "toggle" on a display of the control points, so that you can see them while editing the diagram, and then hide them when you've got the line that you want?

  • circuitikz: how to get all in the same line width thickness
    by cis on January 9, 2026 at 1:37 pm

    Is there an easy way to get all in the same line width thickness? I tried to calc some things but I do not think this was correct: \pgfmathsetlengthmacro\lw{2.1pt}% wanted linewidth (circuitikz default 0.8pt) \pgfmathsetlengthmacro\lwc{0.8pt}% circuitikz default linewidth 0.8pt % ----> could this be read out somehow? \pgfmathsetmacro\th{\lwc/\lw}% needed bipoles/thickness % ---> do not think, this is correct \documentclass[margin=5pt]{standalone} \usepackage{tikz} \usepackage[]{circuitikz} %\ctikzset{bipoles/thickness=3} \pgfmathsetlengthmacro\lw{2.1pt}% wanted linewidth (circuitikz default 0.8pt) \pgfmathsetlengthmacro\lwc{0.8pt}% circuitikz default linewidth 0.8pt % ----> could this be read out somehow? \pgfmathsetmacro\th{\lwc/\lw}% needed bipoles/thickness % ---> do not think, this is correct \begin{document} \begin{tikzpicture}[european, line width=\lw, circuitikz/bipoles/thickness=\th,% default 2 %circuitikz/sources/symbol/thickness=\th,% default 1 ] \draw (0,3) to [sinusoidal voltage source, v=$u(t)$, ] (0,0); \draw (0,3) to[C=$C$] (4,3) to[resistor={$R$}] (4,0) to[battery1, invert] (0,0); \node[align=left, anchor=north west, fill=yellow!25] at (0,-1) { \textbf{Values}: \\ lw: \lw \\ th: \th \\ bipoles/thickness: \ctikzvalof{bipoles/thickness} \\ circuitikz/sources/symbol/thickness: \ctikzvalof{circuitikz/sources/symbol/thickness} ? \\ ...... }; \end{tikzpicture} \end{document}

  • TikZ overlay alignment issues in nested tcolorboxes: PDFLaTeX (LTR) vs XeLaTeX/Polyglossia (RTL)
    by Med Elhadi Kh on January 8, 2026 at 3:48 pm

    I am designing a complex lesson plan layout using tcolorbox. The design features specific vertical strips (margins) defined in the box's overlay. I use custom commands (\mrhala, \Time, \rems) based on TikZ to place content into these strips using absolute positioning relative to the page or box width. The Problem: The code works perfectly and aligns correctly when compiled with PDFLaTeX (LTR). However, my final document requires Arabic, so I must use XeLaTeX with polyglossia. When I switch to XeLaTeX, the horizontal positioning of these marginal notes breaks. They shift incorrectly or overlap, especially when used inside nested boxes. It seems that the coordinate calculations (e.g., \dimexpr, xshift) or the origin point (0,0) behave differently in the RTL context of XeLaTeX. Screenshots: Correct Output (PDFLaTeX): The marginal notes align perfectly with their columns. Incorrect Output (XeLaTeX with Polyglossia): The notes are shifted and misaligned. Minimal Working Example (MWE): \documentclass[a4paper]{article} \usepackage[margin=1cm]{geometry} \usepackage[most]{tcolorbox} \usepackage{amsmath,amssymb,mathtools,tikz,pifont,fontawesome,array,colortbl,varwidth,yagusylo,lipsum} \usetikzlibrary{calc,shapes.geometric,backgrounds} \renewcommand{\baselinestretch}{1.2} \pagestyle{empty} \parindent=0mm \newlength\BDmainW \newcommand\BDid{} % identifier of the current BoxDars \newlength\marahil \setlength\marahil{1.25cm} \newlength\modat \setlength\modat{1cm} \newlength\REMS \setlength\REMS{2.5cm} \newtcolorbox[auto counter]{BoxDars}{ enhanced,breakable, blanker,top=10mm, leftupper=\marahil+1mm, rightupper=\modat+\REMS+1mm, colback=white, bottom=3mm, before skip=3pt, after skip=10pt, parbox=false, before upper={% \edef\BDid{\thetcbcounter}% \setlength{\BDmainW}{\linewidth}% \tikz[remember picture,overlay]\coordinate (BDstart-\BDid) at (0,0);% }, overlay={ % Header background \draw[very thick,fill=orange!45] (interior.north west) rectangle ([yshift=-8mm]interior.north east); % Main Frame \draw[very thick,red!50!black] (interior.south west) rectangle (interior.north east); % --- Vertical Dividers --- % 1. Stages Divider (Left side) \draw[very thick,red!50!black] ([xshift=\marahil]interior.north west) -- ([xshift=\marahil]interior.south west); % 2. Remarks Divider (Right side) \draw[very thick,red!50!black] ([xshift={-\REMS}]interior.north east) -- ([xshift={-\REMS}]interior.south east); % 3. Time Divider (Right side, next to Remarks) \draw[very thick,red!50!black] ([xshift={-\modat - \REMS}]interior.north east) -- ([xshift={-\modat - \REMS}]interior.south east); % --- Header Labels --- % Stages Label (Left) \node[yshift=-4mm, font=\bfseries\small] at ([xshift=0.5*\marahil]interior.north west |- interior.north east) {Stages}; % Lesson Elements Label (Center) \node[yshift=-4mm, font=\bfseries\small] at ([xshift={0.5*\linewidth +\marahil - \modat-\REMS}]interior.north west |- interior.north east) {Lesson Elements}; % Time Label (Right) \node[yshift=-4mm, font=\bfseries\small] at ([xshift={ -(0.5*\modat+\REMS)}]interior.north east |- interior.north west) {Time}; % Remarks Label (Right) \node[yshift=-4mm, font=\bfseries\small] at ([xshift={-0.5*\REMS}]interior.north east |- interior.north west) {Notes}; }} \newcommand{\whichbox}{% \ifnum\value{tcblayer}=0 Outside any box% \else Box \Roman{tcblayer}% \fi } \newcommand{\Time}[2][0pt]{\leavevmode% \begin{tikzpicture}[remember picture,overlay] \coordinate (A) at (0,0); \coordinate (X) at ([xshift=\dimexpr\BDmainW+1mm+\modat/2\relax] BDstart-\BDid); \coordinate (target) at (X |- A); \node[anchor=base, text width=\modat, align=center] at ([yshift=#1]target) {% {\large\yagding[ifsymclock]{148}}\\#2% }; \end{tikzpicture}% } \newcommand{\rems}[2][0pt]{\leavevmode% \begin{tikzpicture}[remember picture,overlay] \coordinate (A) at (0,0); \coordinate (X) at ([xshift=\dimexpr\BDmainW+1mm+\modat+\REMS/2\relax] BDstart-\BDid); \coordinate (target) at (X |- A); \node[anchor=base, text width=\REMS, align=center, font=\small] at ([yshift=#1]target) {#2}; \end{tikzpicture}% } \newcommand{\mrhala}[2][0pt]{\leavevmode% \begin{tikzpicture}[remember picture,overlay] \coordinate (A) at (0,0); \coordinate (X) at ([xshift=\dimexpr-1mm-\marahil/2\relax] BDstart-\BDid); \coordinate (target) at (X |- A); \node[inner sep=0, rotate=90] at ([yshift=#1]target) {#2}; \end{tikzpicture}% } \newtcolorbox{box1}{ title=Title: \whichbox, colframe=blue!50!black, colback=blue!5 } \newtcolorbox{box2}{colframe=red!50!black, colback=red!5, title=Nested Box (Level 2)} \newtcolorbox{box3}{colframe=green!50!black, colback=green!5, title=Deep Nested Box (Level 3)} \begin{document} \begin{BoxDars} \section*{Main Lesson Content} This is the main text area. The margins are handled automatically. \mrhala{Start} \Time{10 min} \rems{Intro Note} \vspace{1cm} \begin{box2} We are now inside a nested box. Notice how the indentation changes for the text, but the margin notes below will still snap to the main columns. \mrhala{Step 2} \Time{30 min} \lipsum[1][1-2] \begin{box3} Inside a deeply nested box... Even here, the commands reference the physical page edge. \rems{Deep Note} \Time{15 min} \mrhala{Final} \end{box3} \end{box2} \rems[3mm]{Final remarks} \end{BoxDars} \end{document} Below is the code. If you run it with pdflatex, it works. If you uncomment the polyglossia lines and run with xelatex, it breaks. Question: How can I adapt the coordinate calculations (specifically \dimexpr logic inside \mrhala, \Time, and \rems) to be robust in XeLaTeX/RTL, so that the notes align to the physical columns of BoxDars regardless of the nesting level?

  • How to use turn coordinate specification in combination with global transforms like scale and shift?
    by dsacre on January 8, 2026 at 1:54 pm

    Scenario Consider the following: One needs to draw from a point on a curve following its tangent direction. TikZ provides for this scenario the ([turn]<ANGLE>:<DISTANCE>) syntax. As one continues the image, it becomes too big for the page layout. In order to prevent having to recreate the complete image with a smaller size, one tries to use the scale parameter (globally on the tikzpicture or via scope does not make a difference for this scenario). MWE \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} % DESCRIPTION: Plain, no modification % STATUS: WORKING \draw[black] (0,0) arc(0:90:-1.5 and 1.5) arc(90:135:-2.0 and 2.0) --([turn]0:0.5) node[below]{plain} ; % DESCRIPTION: Scale % STATUS: FAIL \begin{scope}[scale=0.5] \draw[red] (0,0) arc(0:90:-1.5 and 1.5) arc(90:135:-2.0 and 2.0) --([turn]0:0.5) node[below]{scale} ; \end{scope} % DESCRIPTION: Shift % STATUS: FAIL \begin{scope}[xshift=5cm] \draw[red] (0,0) arc(0:90:-1.5 and 1.5) arc(90:135:-2.0 and 2.0) --([turn]0:0.5) node[below]{xshift} ; \end{scope} \end{tikzpicture} \end{document} Result As soon as transformation are applied, the result of the ([turn]<ANGLE>:<DISTANCE>) specification is wrong. Research so far It was tried to encapsulate the \draw command into a TikZ pic, hoping that this might act as a wrapper, but the result was identical. The corresponding section 13.4.2: Rotational Relative Coordinates of the TikZ manual specifies: The effect of this key is to locally shift the coordinate system so that the last point reached is at the origin and the coordinate system is “turned” so that the (x)-axis points in the direction of a tangent entering the last point. From that, I would assume that certain global transforms cannot/will not be taken into account properly. Question Is it possible to use the ([turn]<ANGLE>:<DISTANCE>) syntax under (global) transformations? If not, is there another option to achieve the same functionality or an easy way to implement it?

  • TikZ overlay alignment issues in nested tcolorboxes using absolute page coordinates
    by Med Elhadi Kh on January 7, 2026 at 5:37 pm

    I am designing a complex document layout using tcolorbox. The main container (BoxDars) has specific vertical strips (margins) defined in its overlay. I have created custom commands (\mrhala, \Time, \rems) to place content into these specific strips using TikZ overlays. The Problem: These commands work fine in the main box. However, when I use them inside nested boxes (e.g., inside box2 or box3), the horizontal positioning shifts incorrectly. I tried to compensate for the nesting depth using \value{tcblayer}, but the alignment is still inconsistent. Goal: I want the content of \mrhala, \Time, and \rems to strictly stick to their respective vertical columns defined in the parent BoxDars, regardless of how deep the nesting is. Here is my MWE: \documentclass[a4paper]{article} \usepackage[margin=1cm]{geometry} \usepackage[most]{tcolorbox} \usepackage{amsmath,amssymb,mathtools,,tikz,pifont,fontawesome,array,colortbl,varwidth,yagusylo,lipsum} \usetikzlibrary{calc,shapes.geometric,backgrounds} \renewcommand{\baselinestretch}{1.2} \pagestyle{empty} \parindent=0mm \def\marahil{1.25cm} \def\modat{1cm} \def\REMS{2.5cm} \newtcolorbox{BoxDars}{ enhanced,breakable, blanker,top=10mm, leftupper=\marahil+1mm, rightupper=\modat+\REMS+1mm, colback=white, bottom=3mm, before skip=3pt, after skip=10pt, parbox=false, overlay={ \draw[very thick,fill=orange!45] (interior.north west) rectangle ([yshift=-8mm]interior.north east); \draw[very thick,red!50!black] (interior.south west) rectangle (interior.north east); % Vertical lines (from RIGHT to LEFT for RTL labeling) % Rightmost divider: stages | rest \draw[very thick,red!50!black] ([xshift=\marahil]interior.north west) -- ([xshift=\marahil]interior.south west); % Next: stages | elemes cours | rest \draw[very thick,red!50!black] ([xshift={-\REMS}]interior.north east) -- ([xshift={-\REMS}]interior.south east); % Next: stages | elemes cours | times | rems \draw[very thick,red!50!black] ([xshift={-\modat - \REMS}]interior.north east) -- ([xshift={-\modat - \REMS}]interior.south east); \node[yshift=-4mm] at ([xshift=0.5*\marahil]interior.north west |- interior.north east) {stages}; \node[yshift=-4mm] at ([xshift={0.5*\linewidth +\marahil - \modat-\REMS}]interior.north west |- interior.north east) {elemes cours}; \node[yshift=-4mm] at ([xshift={ -(0.5*\modat+\REMS)}]interior.north east |- interior.north west) {times}; \node[yshift=-4mm] at ([xshift={-0.5*\REMS}]interior.north east |- interior.north west) {rems}; }} \newcommand{\whichbox}{% \ifnum\value{tcblayer}=0 Outside any box% \else Box \Roman{tcblayer}% \fi } \newcommand{\Time}[2][0]{\leavevmode% \begin{tikzpicture}[remember picture,overlay] \def\baseDist{-5.3} \pgfmathsetmacro{\timeShift}{\baseDist - 0.65 * (\value{tcblayer} - 1)} \coordinate (A) at (0,0); \coordinate (Edge) at (current page.north east |- A); \node at ([xshift=\timeShift cm, yshift=#1]Edge) { \begin{minipage}{1cm}\centering {\large\yagding[ifsymclock]{148}}\\ \normalsize {#2} \end{minipage} }; \end{tikzpicture}% } \newcommand{\rems}[2][0]{\leavevmode% \begin{tikzpicture}[remember picture,overlay] \def\baseDist{-3.6} \pgfmathsetmacro{\timeShift}{\baseDist - 0.55 * (\value{tcblayer} - 1)} \coordinate (A) at (0,0); \coordinate (Edge) at (current page.north east |- A); \node at ([xshift=\timeShift cm, yshift=#1]Edge) { {\begin{minipage}{2cm}\small\centering #2 \end{minipage}} }; \end{tikzpicture}% } \newcommand{\mrhala}[2][0]{\leavevmode% \tikz[overlay,remember picture,baseline=0pt]{% \def\baseDist{0.3} \pgfmathsetmacro{\newX}{\baseDist - (\value{tcblayer}-1)*0.3} \coordinate (A) at (0,0); \ifnum\value{tcblayer}>0 \coordinate (Edge) at (current page.north west |- A); \node[inner sep=0] at ([xshift=\newX cm, yshift=#1 mm]Edge) {\rotatebox{90}{#2}}; \fi }% } \newtcolorbox{box1}{ title=Title: \whichbox, colframe=blue!50!black, colback=blue!5 } \newtcolorbox{box2}{ title=Title: \whichbox, colframe=red!50!black, colback=red!5 } \newtcolorbox{box3}{ title=Title: \whichbox, colframe=green!50!black, colback=green!5 } \begin{document} helow \begin{BoxDars} Inside box1: \whichbox \mrhala{arg2} \Time{20} \begin{box2} Inside box2: \whichbox \mrhala{arg2} Inside box2: \whichbox Inside box2: \whichbox Inside box2: \whichbox Inside box2: \whichbox Inside box2: \whichbox Inside box2: \whichbox \begin{box3} Inside box3: \whichbox \Time{20} \end{box3} \end{box2} \rems{text text text} \begin{box3} Inside box3: \whichbox \rems{text text text} \end{box3} \end{BoxDars} \end{document} Question: How can I define the coordinates in my custom commands so that they ignore the indentation of nested boxes and align perfectly with the BoxDars vertical strips?

  • How to correctly align a vertical margin note inside a complex tcolorbox layout with Arabic text?
    by Med Elhadi Kh on January 7, 2026 at 8:36 am

    I am designing a lesson plan layout using tcolorbox and TikZ in XeLaTeX with polyglossia (Arabic). The layout (BoxDars) has a specific right margin reserved for "Stages" (المراحل). I defined a command \mrhala to place vertical text in that specific strip. The Problem: The \mrhala command relies on current page coordinates and manual shifts, which makes it unstable. It does not land exactly in the reserved vertical strip defined in the BoxDars overlay, especially when I change nesting or margins. Goal: I want the vertical text generated by \mrhala to be absolutely positioned centered within the right margin strip (the white space between the red line and the right edge of the box), regardless of where the box is on the page. Here is a Minimal Working Example (MWE): \documentclass[a4paper]{article} \usepackage[margin=1cm]{geometry} \usepackage[most]{tcolorbox} \usepackage[explicit]{titlesec} \usepackage[tikz]{bclogo} \usepackage{amsmath,amssymb,mathtools,bidicontour,tikz,pifont,fontawesome,array,colortbl,varwidth,yagusylo} \usetikzlibrary{calc,shapes.geometric,backgrounds} \usepackage{polyglossia} \setdefaultlanguage[locale=algeria]{arabic} \setotherlanguage{english} \newfontfamily\arabicfont[Script=Arabic,Scale=1.1]{Amiri} \newfontfamily\arabicfontsf[Script=Arabic,Scale=1.2]{Sakkal Majalla} \newfontfamily\yot[Script=Arabic,Scale=1.4]{Arial} \def\EN#1{\textenglish{#1}} \def\AR#1{\textarabic{#1}} \renewcommand{\baselinestretch}{1.2} \pagestyle{empty} \parindent=0mm \def\marahil{1.25cm} \def\modat{1cm} \def\REMS{2.5cm} \newtcolorbox{BoxDars}{ enhanced,breakable, blanker,top=10mm, leftupper=\modat+\REMS+3mm, rightupper=\marahil+3mm, colback=white, bottom=3mm, before skip=3pt, after skip=10pt, parbox=false, overlay={ \draw[very thick,fill=orange!45] (interior.north west) rectangle ([yshift=-8mm]interior.north east); \draw[very thick,red!50!black] (interior.south west) rectangle (interior.north east); \draw[very thick,red!50!black] ([xshift=\REMS+\modat]interior.north west) -- ([xshift=\REMS+\modat]interior.south west); \draw[very thick,red!50!black] ([xshift=\REMS]interior.north west) -- ([xshift=\REMS]interior.south west); \draw[very thick,red!50!black] ([xshift=-\marahil]interior.north east) -- ([xshift=-\marahil]interior.south east); \node[white] at ($(interior.north east)!0.5!([shift={(-\marahil,-8mm)}]interior.north east)$) {\RL{\bf\Large{\resizebox {!}{0.3cm}{\textcolor{green!65!black}% {\bidicontour{yellow}{\RL{المراحل }}}}}}}; \node[white] at ($([shift={(-\marahil,0)}]interior.north east)!0.5!([shift={(\modat,-8mm)}]interior.north west)$) {\RL{\bf\Large{\resizebox {!}{0.4cm} {\textcolor{green!65!black}% {\bidicontour{yellow}{\RL{عناصر الدرس }}}}}}}; \node[white] at ($([shift={(\REMS+\modat,0)}]interior.north west)!0.5!([shift={(\REMS,-8mm)}]interior.north west)$) {\RL{\bf\Large{\resizebox {!}{0.4cm}{\textcolor{green!65!black}% {\bidicontour{yellow}{\RL{المدّة }}}}}}}; \node[white] at ($([shift={(\REMS,0)}]interior.north west)!0.5!([shift={(0,-8mm)}]interior.north west)$) {\RL{\bf\Large{\resizebox {!}{0.4cm} {\textcolor{green!65!black}% {\bidicontour{yellow}{\RL{ الملاحظات }}}}}}}; }} \newcommand{\ondor}[1]{ \LR{\tikzpicture \begin{scope}[rotate=-90,smooth cycle, line width=2.3pt, scale=0.3] \draw[line join=miter, color=#1!80] (0,0) -- ++ (0.7,-0.5) -- ++ (0.7,0.5); \draw[line join=miter, color=#1!68] (0,-0.5) -- ++ (0.7,-0.5) -- ++ (0.7,0.5); \draw[line join=miter, color=#1!58] (0,-1) -- ++ (0.7,-0.5) -- ++ (0.7,0.5); \draw[line join=miter, color=#1!38] (0,-1.5) -- ++ (0.7,-0.5) -- ++ (0.7,0.5); \end{scope} \endtikzpicture}} \newcommand\rqm[1]{\ifnum #1 < 10 0\fi #1} \newcounter{exo} \newenvironment{exe}[1][]{ \vglue7mm\begin{tcolorbox}[breakable,enhanced,detach title,blanker,title={\RL{تطبيق}},coltitle=black, boxsep=3mm,top=2mm,bottom=2mm, overlay={ \scoped[on background layer]{ \draw[fill=blue!60!black!1,draw=none](interior.north west)rectangle (interior.south east); \draw[draw=blue!60!black,line width=1.2pt](interior.north east)|- (interior.south west);} \node[anchor=north east,above left,font=\bf\sffamily ,inner xsep=7mm,inner ysep=2mm] (1) at (interior.north east){\tcbtitle}; \scoped[on background layer]{ \draw[fill=blue!60!black!10,draw=blue!60!black,line width=1.2pt](1.north west)--(1.north east)[sharp corners]--(1.south east)--(1.south west)--cycle; \fill[blue!60!black]([xshift=-4mm]1.north east)-|([yshift=-4mm]1.north east)--cycle; \fill[blue!60!black](interior.north east)rectangle([yshift=3pt]1.south west); \fill[blue!60!black](interior.south west)rectangle([yshift=0.5mm]interior.south east); \fill[blue!60!black]([xshift=-0.5mm]interior.south east)rectangle(interior.north east); \coordinate (A) at (1.north west); \coordinate (B) at (1.south west); \coordinate (C) at ($(1.north west)!0.5!(1.south west)$); \draw[draw=blue!60!black,line width=1.2pt,fill=white,rounded corners=2pt] ([yshift=0.7mm]1.north west)--([xshift=5.8mm]C)--([yshift=-0.7mm]1.south west)-- ([xshift=-5.8mm]C)--cycle node (K){}; } \node at ([xshift=-0.5mm]C) (M){ \stepcounter{exo} \bf\rqm{\theexo}}; \node[anchor=east,text=red!40!black] at (M.west)(N){\ondor{blue!60!black}}; \node[anchor=east,text=red!40!black] at (N.west)(N){\RL{\bf\sffamily #1}}; }] }{\end{tcolorbox}} \def\rosol{% \tikzpicture[transform shape,scale=0.5] \node [circle,scale=1.2,draw,fill=gray!25](1){}; \foreach \i in {0,2}{ \draw [line width=.4mm]([shift={(-0.\i,-.08)}]1.north east)arc(-40:-338:1.3mm and 5.3mm);} \endtikzpicture} \newtcolorbox{box1}[1][عنوان]{ enhanced,breakable, before skip=2mm,after skip=1cm,bottom=4mm, colback=white,colframe=black,boxrule=0.5mm, attach boxed title to top center={yshift*=1mm-\tcboxedtitleheight}, varwidth boxed title*=-3cm, boxed title style={frame code={ \path[fill=blue!30!black] ([yshift=-1mm,xshift=-1mm]frame.north west) arc[start angle=0,end angle=180,radius=1mm] ([yshift=-1mm,xshift=1mm]frame.north east) arc[start angle=180,end angle=0,radius=1mm]; \path[left color=blue!60!black,right color=blue!60!black, middle color=blue!40!white] ([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east) [rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east) -- (frame.south east)--(frame.south)[sharp corners]--([xshift=-1mm,yshift=-2mm]frame.south)[rounded corners=1mm]--([xshift=-2mm]frame.south)[rounded corners=1mm]--(frame.south west) --([xshift=-1mm,yshift=-1mm]frame.north west) [sharp corners]-- cycle; },interior engine=empty, },overlay unbroken and first={ \foreach \i in {0.1,0.2,...,0.9}{ \node at ($([yshift=-2.4mm,xshift=2mm]title.north east)!\i!([yshift=-1.4mm]frame.north east)$){\rosol}; } \foreach \i in {0.1,0.2,...,0.9}{ \node at ($([yshift=-2.4mm,xshift=-2mm]title.north west)!\i!([yshift=-1.4mm]frame.north west)$){\rosol}; } }, fonttitle=\bfseries, title={#1}} \newtcolorbox{BoxRafa}[2][red] {enhanced, before skip=2mm,after skip=2mm, colback=yellow!10!white,colframe=black!50,boxrule=0.2mm, attach boxed title to top right = {xshift=-0.6cm,yshift*=1mm-\tcboxedtitleheight}, varwidth boxed title*=-3cm, boxed title style={frame code={ \path[fill=tcbcolback!30!black] ([yshift=-1mm,xshift=-1mm]frame.north west) arc[start angle=0,end angle=180,radius=1mm] ([yshift=-1mm,xshift=1mm]frame.north east) arc[start angle=180,end angle=0,radius=1mm]; \path[left color=tcbcolback!60!black,right color = tcbcolback!60!black, middle color = tcbcolback!80!black] ([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east) [rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east) -- (frame.south east) -- (frame.south west) -- ([xshift=-1mm,yshift=-1mm]frame.north west) [sharp corners]-- cycle; },interior engine=empty, }, fonttitle=\bfseries, title={#2},colbacktitle = {#1}} \newcommand{\Time}[2][0]{% \begin{tikzpicture}[remember picture,overlay] \def\baseDist{0.2} \pgfmathsetmacro{\timeShift}{\baseDist - 0.55 * (\value{tcblayer} - 1)} \coordinate (A) at (0,0); \coordinate (Edge) at (current page.north west |- A); \node at ([xshift=\timeShift cm, yshift=#1]Edge) { \begin{minipage}{1cm}\centering {\large\yagding[ifsymclock]{148}}\\ \normalsize {{د \EN{#2} }} \end{minipage} }; \end{tikzpicture}% } \newcommand{\rems}[2][0]{% \begin{tikzpicture}[remember picture,overlay] \def\baseDist{-1.5} \pgfmathsetmacro{\timeShift}{\baseDist - 0.55 * (\value{tcblayer} - 1)} \coordinate (A) at (0,0); \coordinate (Edge) at (current page.north west |- A); \node at ([xshift=\timeShift cm, yshift=#1]Edge) { \RL{\begin{minipage}{2cm}\small\centering #2 \end{minipage}} }; \end{tikzpicture}% } \newcommand{\mrhala}[2][0]{% \tikz[overlay,remember picture,baseline=0pt]{% \def\baseDist{-5.45} \pgfmathsetmacro{\newX}{\baseDist - (\value{tcblayer}-1)*0.3} \coordinate (A) at (0,0); \ifnum\value{tcblayer}>0 \coordinate (Edge) at (current page.north east |- A); \node[inner sep=0] at ([xshift=\newX cm, yshift=#1 mm]Edge) {\rotatebox{90}{\RL{#2}}}; \fi }% } \newtcolorbox[auto counter]{box2}[1][]{enhanced,arc=1.5mm, before skip=2mm,after skip=2mm,right=1mm, colback=white,frame style={left color=white, right color=red!80!black,fill=none},boxrule=0.4mm, attach boxed title to top right= {xshift=-0.01cm,yshift*=-0.12mm-\tcboxedtitleheight}, boxed title style={frame code={ \path[draw=red!80!black, left color=tcbcolback!60!black,right color=tcbcolback!60!black, middle color=tcbcolback!80!black] ([xshift=-5mm]frame.north west) [rounded corners=1.5mm] -- (frame.north east) -- ([ yshift=-1mm]frame.south east) -- (frame.south east) -- ([xshift=-2mm]frame.south west) -- ([xshift=-4mm,yshift=-1mm]frame.north west)[sharp corners] -- cycle;},interior engine=empty,},colbacktitle=red, fonttitle=\bfseries,title={~~مثال~\thetcbcounter}, ,overlay unbroken and first={\node[anchor=west,color=green!55!black] at ([xshift=-4.5cm]title.west) {{\bfseries\small\RL{ #1}}};},} \newtcolorbox{proof 1}[1][]{ freelance,before skip=0mm,after skip=0pt, colback=white,title={\hspace*{-0.6cm}\bccrayon\ \bfseries \textcolor{red!90!black}{إثبـــات}}, bottomrule=0pt,top=-0cm,left=0mm,right=3mm,bottom=-1mm, boxrule=0pt,colframe=white, overlay unbroken and first={ \draw[red!40,line width=2.1pt,] ([xshift=-1.3mm,yshift=-8mm]frame.north east) -- ([xshift=-1.3mm,yshift=-8mm]frame.north east) -- ([xshift=-1.3mm,yshift=-0mm]frame.south east); \hfill \textcolor{red!70!black}{$\blacksquare$};}} \newtcolorbox[auto counter]{box3}[1][عنوان] {enhanced,arc=1.5mm, boxrule=2pt, breakable,colback=cyan!3,frame style={ left color=yellow!80, middle color=green!80, right color= cyan!80!blue, }, title=#1, attach boxed title to top right={xshift=-0.51cm,yshift*=-0.42cm}, coltitle=red, boxed title style={top=.5mm,bottom=+.5mm}, , underlay unbroken and first={ \fill[green!30,draw=cyan]([xshift=2pt,yshift=+2pt]title.north east) -- ([xshift=-8pt,yshift=+2pt]title.north west)--([xshift=-9pt]$(title.west)+(-0.3cm,0)$)-- ([xshift=-8pt,yshift=-2pt]title.south west) -- ([xshift=2pt,yshift=-2pt]title.south east)--cycle; % \draw[white,thick]([xshift=-1pt,yshift=+1pt]title.north west) -- ([xshift=+7pt,yshift=+1pt]title.north east)--([xshift=+8pt]$(title.east)+(0.3cm,0)$)-- ([xshift=+7pt,yshift=-1pt]title.south east) -- ([xshift=-1pt,yshift=-1pt]title.south west)--cycle; % \fill[cyan](title.north east) -- (title.north west)--($(title.west)+(-0.3cm,0)$)-- (title.south west) -- (title.south east)--cycle; \node[font=\bf] at(title.center){\textcolor{white}{#1}} ;} % } \begin{document} \begin{BoxDars} \section{عنوان} \mrhala{مرحلة الإنطلاق} \begin{box1}[نشاط مقترح] $f$ و $g$ دالتان معرفتان على $D_f$ و $D_g$ على الترتيب. مركب الدالة $f$ متبوعة بالدالة $g$ هي الدالة التي نرمز إليها بالرمز \{$g \circ f $ \} والمعرفة على $D_{ g \circ f} =\big\{ x ; f(x) \in D_g \wedge x\in D_f\big\}$ بــ \{{$(g \circ f )(x) = g \big( f(x)\big) $} \} \end{box1} \Time{20} \begin{box2}\mrhala{مرحلة} \textcolor{blue!85!black}{$z+z'=x+x'+i(y+y')$} جداء العددين $z$ و $z'$ هو العدد المركّب \textcolor{blue!85!black}{$z.z'=xx'-yy'+i(xy'+x'y)$} \end{box2} \begin{BoxRafa}[blue]{تعريف} لإثبات أن $f$ لا فردية ولا زوجيـة يكفي تقديم مثــال مضاد \end{BoxRafa} \begin{BoxRafa}{مــلاحظة} \mrhala{مرحلة} لإثبات أن $f$ لا فردية ولا زوجيـة يكفي تقديم مثــال مضاد \end{BoxRafa} \rems{ كتابة الملاحظة يكون هنا في هذه التعليمة } \begin{proof 1} \begin{enumerate} \item أي \item { $\dfrac{aZ_A+bZ_B}{a+b}$}. \end{enumerate} \end{proof 1} \begin{box3}[مبرهنــة] سسسسسسس \end{box3} \begin{exe} لتكن الدالة التالية يييسس \end{exe} \end{BoxDars} \end{document}

  • Tikz: how to fit a series of nodes determined at run-time
    by Guidone on January 6, 2026 at 7:15 pm

    My goal is to draw a brace under N nodes, like it is shown in the picture (nodes "G" and "H"): Looking at the second answer to this question I came out with this MWE: \begin{filecontents}[overwrite]{argumentmapp.cls} \NeedsTeXFormat{LaTeX2e} \ProvidesClass{argumap}[2026/01/03 v.0.0 Argument Mapping] \LoadClass[11pt]{extarticle} \RequirePackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \setmainfont{Brill} \RequirePackage{euler-math} \newfontfamily{\supscriptfont}{Euler Math}%[Scale=0.55] \RequirePackage{polyglossia} \setdefaultlanguage{italian} \setotherlanguage[hyphenation=liturgical, usej=true, prosodicshorthands=true]{latin} \RequirePackage{suffix} %=================% % Document layout % %=================% % Page \RequirePackage{geometry} \geometry{a4paper,margin=20mm} \pagestyle{plain} \setlength{\parindent}{0pt} % Line spacing: 1.3 \RequirePackage{setspace} \setstretch{1.2} % Two-column engine \RequirePackage{paracol} %=================% % Utilities % %=================% \RequirePackage{etoolbox} \RequirePackage{etextools} \RequirePackage{lipsum} %------------------ % Control Flow %------------------ \RequirePackage{xifthen} \RequirePackage{xstring}% used to operate on a string %------------------ % Graphics %------------------ \RequirePackage{graphicx} \RequirePackage{tikz} \usetikzlibrary{% calc,arrows.meta,% positioning,% decorations.pathreplacing,% fit,% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Main 2-column environment %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \NewDocumentEnvironment{argan}{ O{0.55} O{0.45} }{% \setcounter{ctrstmt}{0}% \columnratio{#1,#2}% \begin{paracol}{2}% \switchcolumn[0]% }{% \end{paracol}% } \newcommand{\TextCol}{\switchcolumn[0]} \newcommand{\AnalysisCol}{\switchcolumn[1]} \newcommand{\TextColStar}{\switchcolumn*[0]} \newcommand{\AnalysisColStar}{\switchcolumn*[1]} \newcommand{\TextColumn}{\switchcolumn[0]} \WithSuffix\newcommand\TextColumn*{\switchcolumn*[0]} \newcommand\AnalysisColumn{\switchcolumn[1]} \WithSuffix\newcommand\AnalysisColumn*{\switchcolumn*[0]} \newcounter{ctrstmt} \setcounter{ctrstmt}{0} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Right column macros %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%==============================%% %% Statement Graphic %% %%==============================%% % Styles \tikzset{ argStmnt/.style={ circle, draw, inner sep=0pt, minimum size=2.2em, font=\normalsize, }, arganDep/.style={ -{Latex[length=2.2mm,width=1.6mm]}, line width=0.4pt }, } \newrobustcmd{\emptyKey}{} \newrobustcmd{\elemPos}{} \pgfkeys{% /gstmnt/.is family, /gstmnt/.cd, name/.store in=\elemName, name/.default=, depend from/.store in=\dependFrom, % depend from/.initial={}, depend from/.default=, from/.store in=\dirFrom, from/.default=south, to/.store in=\dirTo, to/.default=north, element@pos/.style={}, south of/.code={\pgfqkeys{/gstmnt}{element@pos/.style={below=of #1}}}, north of/.code={\pgfqkeys{/gstmnt}{element@pos/.style={above=of #1}}}, west of/.code={\pgfqkeys{/gstmnt}{element@pos/.style={left=of #1}}}, east of/.code={\pgfqkeys{/gstmnt}{element@pos/.style={right=of #1}}},% name,depend from,from,to } \NewDocumentCommand{\graphStmnt}{O{} m}{% \pgfkeys{/gstmnt/.cd,% name,depend from,from,to,%, #1}% \node[argStmnt, /gstmnt/element@pos] (\elemName) {\supscriptfont#2};% \ifx\dependFrom\empty% \else \draw[arganDep] (\dependFrom.\dirFrom) -- (\elemName.\dirTo); \fi } %%==============================%% %% Coordinated Statement %% %%==============================%% \newif\ifispivot \newcounter{ctrelem} \setcounter{ctrelem}{0} \pgfkeys{% /coostmnt/.is family,% /coostmnt/.cd,% name/.store in=\elemName,% name/.default=,% pivot/.is if=ispivot,% element@pos/.style={}, pivot on/.store in=\pivotOn,% pivot on/.default=,% pivot below/.code={\pgfqkeys{/coostmnt}{element@pos/.style={below=of \pivotOn}}}, pivot below/.initial=, pivot above/.code={\pgfqkeys{/coostmnt}{element@pos/.style={above=of \pivotOn}}}, child of/.store in=\elemParent,% child of/.default=,% after/.code={\pgfqkeys{/coostmnt}{element@pos/.style={right=of \elemParent}}}, before/.code={\pgfqkeys{/coostmnt}{element@pos/.style={left=of \elemParent}}}, from/.store in=\dirFrom, from/.default=, to/.store in=\dirTo, to/.default=, name,pivot on, child of, from, to,% } \tikzset{ coordBrace/.style={ line width=0.4mm,% decorate,% decoration={amplitude=0.1cm,brace, mirror},% % blue } } \newcommand{\elemid}{} \newcommand{\elelist}{} \newcommand{\elements}{} \NewDocumentCommand{\coordielem}{O{} m}{ \refstepcounter{ctrelem} \pgfkeys{/coostmnt/.cd,% name,pivot=false, pivot on, child of,% #1 } \listadd{\elelist}{\elemName} \node[argStmnt, /coostmnt/element@pos] (\elemName) {\supscriptfont$#2\|$\thectrelem}; \ifx\pivotOn\empty \draw[arganDep] (\elemParent.\dirFrom) -- (\elemName.\dirTo); \else \draw[arganDep] (\pivotOn.\dirFrom) -- (\elemName.\dirTo); \fi } \newcounter{cntrbox} \setcounter{cntrbox}{0} \newcommand*{\boxname}{} \NewDocumentEnvironment{coordination}{+b}{% \stepcounter{cntrbox} \renewcommand*{\boxname}{coordbox\thecntrbox} \begin{scope}[local bounding box=\boxname] #1% \end{scope} \draw[color=red, coordBrace] (\boxname.south west) -- (\boxname.south east); } {\setcounter{ctrelem}{1}} % \NewDocumentEnvironment{argugraph}{O{12mm} +b}{ \par\centering% \begin{tikzpicture}[node distance=#1]% #2 }{% \end{tikzpicture}\par} \end{filecontents} \documentclass{argumentmapp} \begin{document} \begin{argan}[0.55][0.35] \AnalysisColumn \begin{argugraph} \graphStmnt[name=A]{A} \graphStmnt[name=B, south of=A, depend from=A, from=south, to=north]{1} \graphStmnt[name=C, north of=A, depend from=A, from=north, to=south]{C} \graphStmnt[name=D, west of=A, depend from=A, from=west, to=east]{D} \graphStmnt[name=E, east of=A, depend from=A, from=east, to=west]{E} \graphStmnt[name=F, south of=D, depend from=D, from=south, to=north]{F} \begin{coordination} \coordielem[name=G, pivot on=E, pivot above, from=north, to=south]{G} \coordielem[name=H, child of=G, after, from=east, to=west]{H} \end{coordination} \graphStmnt[name=L, south of=H, depend from=H, from=south, to=north]{L} \end{argugraph} \end{argan} \end{document} It compiles, but it is not what I am looking for. As a matter of fact, this is what I get: Which makes sense, since the scope also includes the connectors from "E" and "L". So, I decided to go along with the first answer to the same question, and modified the coordination environment to read like this: \newcounter{cntrbox} \setcounter{cntrbox}{0} \newcommand*{\boxname}{} \newcommand{\Loopx}{} \NewDocumentEnvironment{coordination}{+b}{% #1 % Converting the list obtained by each '\coordielem' \listtocsv[\elements]\elelist %suggested by https://tex.stackexchange.com/questions/173579/tikz-fit-variable-number-of-nodes \xdef\Loop{} \foreach \el in \elements {\xdef\Loop{\Loop(\el)} } \node[draw=red,fit=\Loop] {}; } {\setcounter{ctrelem}{1}}% Compiling it, I get the following message: ! Package pgf Error: No shape named `' is known. See the pgf package documentation for explanation. Type H <return> for immediate help. ... l.238 \end {argugraph} With this output: I think something is wrong with my use of the lists. My idea would be to build a list containing the names of \coordielem with etoolbox, convert it to a csvlist with etextools, then iterate over it with TikZ's \foreach method. But, clearly, I am missing something. Any idea?

  • circuitikz: width, height and pin-distance of a 'op amp'
    by cis on January 5, 2026 at 1:27 pm

    I want to create a breadboard whose x-slot spacing matches the pin spacing of a muxdemux (this was done here); and whose y-slot spacing matches the pin spacing of an op amp. An image for clarification: I can approximate the y-direction by trial and error, using \pgfmathsetlengthmacro\OApin{% 'op amp' pin width \bl*\ctikzvalof{tripoles/op amp/width}*0.3*0.5} But I would like to do this accurately and precisely. In short: I need height, width, and pin spacing of an op amp from the package-keys. (Unfortunately, these keys are usually well hidden and not very self-explanatory.) \documentclass[margin=5pt, multi=circuitikz]{standalone} \usepackage{circuitikz} \def\ShowBreadBoard{1} % Breadboard 1/2 ====================== % Default of bipoles/length ================= \pgfmathsetlengthmacro\bl{\UseName{pgf@circ@Rlen}}% default 1.4cm %%%%%%%%%% Problems here %%%%%%%%%%% % Breadboard y - measures of 'op amp' ================= \pgfmathsetlengthmacro\OApin{% 'op amp' pin width \bl*\ctikzvalof{tripoles/op amp/width}*0.3*0.5} \pgfmathsetlengthmacro\OAh{% 'op amp' height \bl*\ctikzvalof{tripoles/op amp/height}} \pgfmathsetlengthmacro\OAw{% 'op amp' width \bl*\ctikzvalof{tripoles/op amp/height}*5/6+0*\pgflinewidth/cos(45)} %%%%%%%%%%%%%%%%%%%%%%%%% % Breadboard x - measures of 'MuxDemux' ================= \pgfmathsetlengthmacro{\basemuxlen}{\bl *\ctikzvalof{multipoles/muxdemux/base len} *\ctikzvalof{muxdemuxes/scale}} \pgfmathsetlengthmacro{\MUXw}{\basemuxlen*6}%w=6, muxdemux-width %\pgfmathsetlengthmacro{\MUXh}{\basemuxlen*4}%Lh=4, muxdemux-height \pgfmathsetlengthmacro{\MUXp}{\MUXw/3}% bottom pin distance of muxdemux \begin{document} \begin{circuitikz}[] % Breadboard 2/2 ================ \begin{scope}[font=\footnotesize\ttfamily] \pgfmathsetlengthmacro\u{\MUXp/4}% x-unit-length \pgfmathsetlengthmacro\v{\OAh/4}% y-unit-length \def\X{x} \def\Y{y}% letters for coordinates \foreach \x in {0,...,26}{%% \foreach \y in {0,...,6}{% \ifnum\ShowBreadBoard=1 %%%%%%%%% \pgfmathtruncatemacro\Xt{mod(\x,2)==0 ? 1 : 0}% show x-coordinate test \pgfmathtruncatemacro\Yt{mod(\y,2)==0 ? 1 : 0}% show y-coordinate test \fill[gray] (\u*\x,-\y*\v) circle[radius=0.65pt] coordinate[label=](\X\x\Y\y); \ifnum\y=0 \node[above, red] at (\X\x\Y\y) {\ifnum\Xt=1 \x\fi};\fi \ifnum\x=0 \node[left, red] at (\X\x\Y\y) {\ifnum\Yt=1 \y\fi};\fi \draw[red, shorten <=2pt] (x0y0) -- +(135:0.75) node[midway, above]{x} node[near end, below]{y}; \else% \coordinate[](\X\x\Y\y) at (\u*\x,-\y*\v); \fi%%%%%%%%%%%%%% }}% %% %\node{\OAw, \OAh};% test %\draw (x0y0) circle(1mm); % test \end{scope}% ===================== \node[op amp](opamp) at (x8y3) {}; \draw (x15y3) to[L, color=pink] (x22y3); \end{circuitikz} \end{document}

  • circuitikz: potentiometer without pin on the right side
    by Explorer on January 5, 2026 at 7:45 am

    What I want to achieved is as below: I have the following code: \documentclass[border=5pt]{standalone} \usepackage{circuitikz} \begin{document} \begin{circuitikz}[european] \draw(0,0) to [rmeter,t=A] (0,2) to [R,l_=$R$](3,2) to [pR,l_=$R'$,n=pr] (4.1,2); \draw(0,0) to [normal open switch,l_=$S$] (6,0) |-(pr.wiper); \end{circuitikz} \end{document} it gives the similar result: However, the righthand of sliding rheostat's length is control in manual, but guess the coordinate (4.1,2), which is not elegant. I have consulted the manual, but found no similar components. Is that better method to achieve the desird result?

  • circuitikz: set 'rounded corners' of a 'oscopeshape' to a smaler value
    by cis on January 4, 2026 at 11:23 pm

    Due to a chat-talk with @Rmano, I asked myself wether there is a methode to set the rounded corners of a oscopeshape to 0pt or to a very small value. The rounded corners can become weird, if I set a small scale: \documentclass[margin=10pt]{standalone} \usepackage{circuitikz} \begin{document} \begin{circuitikz}[font=\footnotesize] \node[oscopeshape] (A){scale=1}; \node[oscopeshape, right of=A, scale=0.5](B) {scale=0.5}; \node[oscopeshape, right of=B, scale=0.35] {scale=0.35}; \end{circuitikz} \end{document}

  • circuitikz: width (height) and pin-distance of a 'muxdemux'
    by cis on January 4, 2026 at 4:48 pm

    How do I get these two lengths? By the way: a) I don't need the height right now, but I assume the extraction method would be the same; so it wouldn't hurt to have it... b) I know how to do it with the calc library. However, it would be better if I could get the dimensions directly from the circuitikz package, without having to measure them after drawing. \documentclass[margin=15pt]{standalone} \usepackage{circuitikz} \begin{document} \tikzset{ circuitikz/muxdemux/outer label font={\tiny\ttfamily\color{blue}}, mychip/.style={muxdemux,% ===================== muxdemux def={ Lh=4, Rh=4, w=6,% sizes NR=0, NL=5, NB=3, NT=3,}, muxdemux label={ %T1=T1, T2=T2, T3=T3, B1=B1, B2=B2, B3=B3, BR1=br1, BL1=bl1, BR2=br2, BL2=bl2, BR3=br3, BL3=bl3,% %TR1=tr1, TL1=tl1, TR2=tr2, TL2=tl2, TR3=tr3, TL3=tl3,% LU1=lu1, LD1=ld1, LU2=lu2, LD2=ld2, LU3=lu3, LD3=ld3, LU4=lu4, LD4=ld4, LU5=lu5, LD5=ld5, }, draw only top pins={}, append after command={ \pgfextra \def\fg{\tikzlastnode} % Contacts annotations ============== \foreach \x in {1,2,3}{%% \node[bnc, anchor=zero, rotate=-90](Contact\x) at (\fg.blpin 5 -| \fg.btpin \x) {}; \draw[] (Contact\x) -- (\fg.bbpin \x); }%% \endpgfextra }, },% ===================== } \begin{circuitikz}[>=latex] \node[mychip](FG){chip}; \draw[purple, <->] (FG.north west) -- (FG.north east) node[midway, fill=white, inner sep=0pt]{w=? pt}; \draw[orange, <->] (FG.bpin 1) -- (FG.bpin 2) node[midway, below]{p=? pt}; \end{circuitikz} \end{document}

  • How to test if a pgfkey is empty
    by Guidone on January 4, 2026 at 4:12 pm

    I have already checked the answers to a similar question, but it uses a pattern different from mine and, therefore, totally unfamiliar to me. Elaborating on the answers to a question of mine posted here, I came up with the following MWE: \NeedsTeXFormat{LaTeX2e} \ProvidesClass{argumap}[2026/01/03 v.0.0 Argument Mapping] \LoadClass[11pt]{extarticle} \RequirePackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \setmainfont{Brill} \RequirePackage{euler-math} \newfontfamily{\supscriptfont}{Euler Math}[Scale=0.55] \RequirePackage{polyglossia} \setdefaultlanguage{italian} \setotherlanguage[hyphenation=liturgical, usej=true, prosodicshorthands=true]{latin} %=================% % Document layout % %=================% % Page \RequirePackage{geometry} \geometry{a4paper,margin=20mm} \pagestyle{plain} \setlength{\parindent}{0pt} % Line spacing: 1.3 \RequirePackage{setspace} \setstretch{1.2} % Two-column engine \RequirePackage{paracol} %=================% % Utilities % %=================% %------------------ % Control Flow %------------------ \RequirePackage{xifthen} \RequirePackage{xstring}% used to operate on a string %------------------ % Graphics %------------------ \RequirePackage{graphicx} \RequirePackage{tikz} \usetikzlibrary{% calc,arrows.meta,% positioning,% decorations.pathreplacing} % Styles \tikzset{ argStmnt/.style={ circle, draw, inner sep=0pt, minimum size=2.2em, font=\normalsize, }, arganDep/.style={ -{Latex[length=2.2mm,width=1.6mm]}, line width=0.4pt }, } \newrobustcmd{\emptyKey}{} \newrobustcmd{\elemPos}{} \pgfkeys{% /gstmnt/.is family, /gstmnt/.cd, name/.store in=\elemName, depend from/.store in=\dependFrom, depend from/.default={}, from/.store in=\dirFrom, to/.store in=\dirTo, element@pos/.style={}, south of/.code={% \pgfqkeys{/gstmnt}{% element@pos/.style={below=of #1}, }% }, north of/.code={% \pgfqkeys{/gstmnt}{% element@pos/.style={above=of #1}, }% }, west of/.code={% \pgfqkeys{/gstmnt}{% element@pos/.style={left=of #1}, }% }, east of/.code={% \pgfqkeys{/gstmnt}{% element@pos/.style={right=of #1}, }% },% name,depend from,from,to } \NewDocumentCommand{\graphStmnt}{O{} m}{ \pgfkeys{/gstmnt/.cd, #1} \typeout{Node Name=[\elemName]} \typeout{First Call of Depend From=[\dependFrom]} \node[argStmnt, /gstmnt/element@pos,] (\elemName) {$#2$}; \ifthenelse{\isempty{\dependFrom}} {\typeout{Second Call of Depend From=[\dependFrom]}} {\draw[arganDep] (\dependFrom.\dirFrom) -- (\elemName.\dirTo);} % \IfStrEq{\dependFrom}{\emptyKey}% % {\typeout{Second Call of Depend From=[\dependFrom]}} % {\draw[arganDep] (\dependFrom.\dirFrom) -- (\elemName.\dirTo);} } \NewDocumentEnvironment{argugraph}{O{12mm} +b}{ \par\centering% \begin{tikzpicture}[node distance=#1]% #2 }{% \end{tikzpicture}\par} When I compile the following example: \documentclass{argumap} \begin{document} \begin{argugraph} \graphStmnt[name=A]{A} % \graphStmnt[name=A, depend from={}]{A}%same result as above \graphStmnt[name=B, south of=A, depend from=A, from=south, to=north]{B} \graphStmnt[name=C, north of=A, depend from=A, from=north, to=south]{C} \graphStmnt[name=D, west of=A, depend from=A, from=west, to=east]{D} \graphStmnt[name=E, east of=A, depend from=A, from=east, to=west]{E} \graphStmnt[name=F, south of=D, depend from=D, from=south, to=north]{F} \end{argugraph} \end{document} I get the following result: And compiling error: Node Name=[A] First Call of Depend From=[] ! Package pgf Error: No shape named `' is known. See the pgf package documentation for explanation. Type H <return> for immediate help. ... l.18 \end {argugraph} So, for some, to me, unknown reason, when I try to test if \dependFrom is empty, even if I haven't passed any value to the key, the test fails, meaning that it goes to the "else" statement, hence the failure to display the message «Second Call of Depend From=[\dependFrom]». Why? Any idea? These pgfkeys are very nice, but, for me, very challenging to handle, and the manual doesn't help me much.

  • How to use specific height in tikz tcolorbox
    by user386618 on January 4, 2026 at 9:53 am

    I wanted to set the coordinate that it's height is one third of a box that consists of 1 line, but tikz don't understand. What to do? \documentclass[10pt]{book} \usepackage[english]{babel} \usepackage[most]{tcolorbox} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tcolorbox}[enhanced, width=\linewidth, frame hidden, interior hidden, overlay={\draw[x=\dimexpr\ht\strutbox+\dp\strutbox\relax, y=\dimexpr\ht\strutbox+\dp\strutbox\relax] (1/3,0)--(0,1/3)--($(frame.north west)-(0,1/3)$)--($(frame.north west)+(1/3,0)$)--($(frame.north east)-(1/3,0)$)--($(frame.north east)-(0,1/3)$)--($(frame.south east)+(0,1/3)$)--($(frame.south east)-(1/3,0)$)--cycle;}] Smth \end{tcolorbox} \end{document} I want the shape to be like a part of regular octagon like below so for one line is more like a stretched regular octagon, i can approximate but want to be more precise

  • Space before grid [closed]
    by Тимур Черняев on January 4, 2026 at 1:17 am

    I'm trying to create a worksheet-like template, and I run into some issues with the grid. Really big space pops up, and I don't know how to get rid of it. I'm using tikz. Here's the screenshot of the problem and fragments of code I believe will be useful. Thanks in advance! % ========================================================= % ==================== GRID SETTINGS ====================== % ========================================================= \newlength{\gridsize} \setlength{\gridsize}{5mm} \newcommand{\gridcolor}{black!40} \newcommand{\gridlinewidth}{0.3pt} ... % ========================================================= % =================== PAGE GRID FILL ====================== % ========================================================= \newcommand{\gridblock}[1]{% \noindent \begin{tikzpicture} \pgfmathsetlengthmacro{\gridheight}{#1\textheight} \pgfmathsetlengthmacro{\gridwidth}{\textwidth} \pgfmathsetlengthmacro{\cell}{\gridsize} \pgfmathsetmacro{\Nx}{ceil(\gridwidth/\cell)} \pgfmathsetmacro{\Ny}{ceil(\gridheight/\cell)} % Горизонтальные линии \foreach \i in {0,...,\Ny} { \draw[color=\gridcolor, line width=\gridlinewidth] (0, \i*\cell) -- (\gridwidth, \i*\cell); } % Вертикальные линии \foreach \i in {0,...,\Nx} { \draw[color=\gridcolor, line width=\gridlinewidth] (\i*\cell, 0) -- (\i*\cell, \gridheight); } \end{tikzpicture}% } % ========================================================= % ====================== PROBLEM+GRID ===================== % ========================================================= \newlength{\problemgridsep} \setlength{\problemgridsep}{2pt} \newenvironment{problemwithgrid}[1]{ \def\currentgridfraction{#1} \begin{problem} }{ \end{problem} \vspace{2pt} \gridblock{\currentgridfraction} }

  • Are there any tikz library or TeX package to create maps?, with items like rivers, trees, level curves, similar to RPG maps? [closed]
    by Mika Ike on January 3, 2026 at 6:45 pm

    From time to time I search if there is a practical/eficient way to create maps, similar to the next ones, even with a terrain texture or even contour level. Are there any tikz library appropiate for this purpose? Images from https://rpgmapsforge.com/

  • How to pass relative coordinates to a \node via \pgfkeys
    by Guidone on January 3, 2026 at 3:20 pm

    What I am trying to achieve is to set a pgfkey (south of, for example), which would be a placeholder for the native option below=of <node> and to pass it to a custom command. Here is the working example: \NeedsTeXFormat{LaTeX2e} \ProvidesClass{argumap}[2026/01/03 v.0.0 Argument Mapping] \LoadClass[11pt]{extarticle} \RequirePackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \setmainfont{Brill} \RequirePackage{euler-math} \newfontfamily{\supscriptfont}{Euler Math}[Scale=0.55] \RequirePackage{polyglossia} \setdefaultlanguage{italian} \setotherlanguage[hyphenation=liturgical, usej=true, prosodicshorthands=true]{latin} %=================% % Document layout % %=================% % Page \RequirePackage{geometry} \geometry{a4paper,margin=20mm} \pagestyle{plain} \setlength{\parindent}{0pt} % Line spacing: 1.3 \RequirePackage{setspace} \setstretch{1.2} % Two-column engine \RequirePackage{paracol} %=================% % Utilities % %=================% %------------------ % Control Flow %------------------ \RequirePackage{xifthen} \RequirePackage{xstring}% used to operate on a string %------------------ % Graphics %------------------ \RequirePackage{graphics} \RequirePackage{tikz} \usetikzlibrary{% calc,arrows.meta,% positioning,% decorations.pathreplacing} % Styles \tikzset{ argStmnt/.style={ circle, draw, inner sep=0pt, minimum size=2.2em, font=\normalsize, }, arganDep/.style={ -{Latex[length=2.2mm,width=1.6mm]}, line width=0.4pt }, } \pgfkeys{% /argumap/.is family, /argumap/.cd, name/.store in=\elemName, position/.default={}, position/.store in=\elemPos, position,name } \NewDocumentCommand{\graphStmnt}{O{} m}{ \pgfkeys{/argumap/.cd, #1} \typeout{element name=[\elemName]} \ifthenelse{\isempty{\elemPos}} {\node[argStmnt] (\elemName) {$#2$};} { \typeout{element position=[\elemPos]} \node[argStmnt, \elemPos] (\elemName) {$#2$};} } \NewDocumentEnvironment{argugraph}{+b}{ \par\centering% \begin{tikzpicture}% #1 }{% \end{tikzpicture}\par} Here is the implementing example: \documentclass{argumap} \begin{document} \begin{argugraph} \graphStmnt[name=A]{A} \graphStmnt[name=B, position={below=of A}]{B} \end{argugraph} \end{document} When I compile it, I get the following error: element name=[A] element position=[] element name=[B] element position=[below=of A] ! Package pgfkeys Error: I do not know the key '/tikz/below=of A' and I am goin g to ignore it. Perhaps you misspelled it. See the pgfkeys package documentation for explanation. Type H <return> for immediate help. So, question is, how can I pass native /tikz options such as below=of to a custom document or environment with custom-defined options? Thanks for the help. Oh, and happy new year.

  • TikZ: dot-syntax for coordinates / anchors (.) [e.g. (Box.A)]
    by cis on January 3, 2026 at 12:25 pm

    If I set some coordinates inside a node named (Box) (with path picture), say (A),(B),(C). How can I get the (from other codes known) (Box.A) syntax? \documentclass[margin=5pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[ test/.style={minimum width=3cm, minimum height=2cm, fill=lightgray, draw, path picture={%% \draw[purple] (path picture bounding box.200) -- (path picture bounding box.-20) coordinate[pos=0.2, label=center:A](A) coordinate[pos=0.5, label=center:B](B) coordinate[pos=0.8, label=center:C](C); },%% }, ] \node[test](Box){}; \draw[red ,<-] (A) -- +(-135:1) node[right]{$\to$A}; % Needed: (Box.A), (Box.B), ... % \draw[red ,<-] (Box.A) -- +(-135:1) node[right]{$\to$A}; % \draw[red ,<-] (Box.B) -- +(-45:1) node[right]{$\to$B}; \end{tikzpicture} \end{document}

  • TikZ: overlay labels or nodes or unclip 'path picture'
    by cis on January 3, 2026 at 9:56 am

    Is there a way, to overlay labels or nodes inside a path picture, so that I can see the text? \documentclass[margin=5pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[ test/.style={minimum width=6cm, minimum height=4cm, fill=lightgray, path picture={%% \draw[blue] (path picture bounding box.west) -- (path picture bounding box.east) coordinate[pos=0.3, label=center:B1](B1) coordinate[pos=0.6, label=center:B2(all good)](B2) coordinate[pos=0.9, label=center:B2](B3); % How to overlay labels here? ============= \draw[red] (path picture bounding box.north west) -- (path picture bounding box.north east) coordinate[pos=0.3, label={[overlay]center:A1}](A1)% no effect coordinate[pos=0.6, label=center:A2(not good)](A2) coordinate[pos=0.9, label=center:A2](A3); },%% }, ] \node[test]{}; \end{tikzpicture} \end{document}

  • TikZ: grid at certain x- and y-positions
    by cis on January 3, 2026 at 9:45 am

    I want to create a 6x5 dotted grid over an area with clearly defined width and height (\w and \h). Can I configure the grid to only display points at the intersections of the horizontal and vertical lines? I only get that with dash pattern=on 0pt off \w/6, for the x-positions. What do I have to do? By the way: I'm wondering, as a task out of pure interest, how one can adjust the grid. It's clear how to manually create the image using foreach-loops. \documentclass[margin=5pt]{standalone} \usepackage{tikz} \pgfmathsetlengthmacro\w{2cm} \pgfmathsetlengthmacro\h{3.2cm} \begin{document} \begin{tikzpicture}[] \draw[] (0,0) rectangle (\w,\h) node[anchor=south east, align=center]{ Dots only at \\ all intersections \\ of the horizontals \\ and the verticals}; \draw[orange, xstep=\w/6, ystep=\h/5] (0,0) grid (\w,\h); \end{tikzpicture} \begin{tikzpicture}[] \draw[] (0,0) rectangle (\w,\h); \draw[orange, xstep=\w/6, ystep=0*\h/5, % Dotted Style: line width=1.0pt, dash pattern=on 0pt off \w/6, line cap=round, ] (0,0) grid (\w,\h); \end{tikzpicture} \end{document}

  • How to make title visible, tcolorbox
    by user386618 on January 2, 2026 at 10:04 pm

    I'm trying to create a hexagon frame, here what i did. \documentclass[12pt]{article} \usepackage[english, russian]{babel} \usepackage[most]{tcolorbox} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tcolorbox}[enhanced, width=\linewidth, attach boxed title to top left={xshift=5mm, yshift=-3.5mm, yshifttext=-1mm}, frame hidden, colback=white, coltitle=green, fonttitle=\large\bfseries\color{green}, boxed title style={frame hidden, colback=white}, title=Идея, underlay={ \draw[draw=green, line width=2pt, fill=green!20] (0.4,0)--(frame.west)--($(frame.north)+(frame.west)-(frame.center)+(0.4,0)$)--($(frame.north)+(frame.east)-(frame.center)-(0.4,0)$)--(frame.east)--($(frame.south)+(frame.east)-(frame.center)-(0.4,0)$)--cycle; \draw[draw=green, line width=2pt, fill=white] ($(title.south)+(title.west)-(title.center)+(0.4,0)$)--(title.west)--($(title.north)+(title.west)-(title.center)+(0.4,0)$)--($(title.north)+(title.east)-(title.center)-(0.4,0)$)--(title.east)--($(title.south)+(title.east)-(title.center)-(0.4,0)$)--cycle;}] Hexagon box Hexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon boxHexagon box \end{tcolorbox} \end{document} I'm quite fine with that, unless the title is below the figure. How to make it visible? Also i want to receive any advice from comunity how to make code from this particullar frame better

  • How to tweak this tikz code with `clip`?
    by Explorer on January 2, 2026 at 7:17 am

    I want to draw something like: \documentclass[tikz,border=5pt]{standalone} \begin{document} \begin{tikzpicture}[radius=4] % \draw[help lines] (-4,-4) grid (4,4); \begin{scope} \draw[clip] ({2*sqrt(2)},{-2*sqrt(2)}) arc [start angle=315,delta angle=90] arc [start angle=-45,delta angle=-90] arc [start angle=135,delta angle=90] arc [start angle=135,delta angle=-90] ; \fill[gray] ({4*sin(22.5)},-4) rectangle (4,4); \end{scope} \draw[dashed] ({2*sqrt(2)},{2*sqrt(2)}) arc [start angle=45,delta angle=90] ({2*sqrt(2)},{-2*sqrt(2)}) arc [start angle=-45,delta angle=-90] (0,{4-2*(4-2*sqrt(2))}) -- (0,{-(4-2*(4-2*sqrt(2)))}) ; \draw[thick] (4,0) -- (-4,0); \end{tikzpicture} \end{document} However, there are too many arcs and manually calculated coordinate and distance, I want to make good use of \clip, but it look a little bit hard than my expected, the border, is hard to control... Noted that the two code, I give, the parameter is not the same, that is not important. I want to focused on how to use clip magic to do so: what I have tried with \clip, the border is clipped in wrong... \documentclass[tikz,border=5pt]{standalone} \begin{document} \begin{tikzpicture}[radius=4] \clip circle[]; \draw[help lines] (-4,-4) grid (4,4); \draw[dashed,fill=gray] circle[]; \begin{scope} \clip (-4,-3) rectangle (4,3); \fill[white] (-4,-4) rectangle (1.5,4); \end{scope} \draw[fill=white] (0,6) circle[] (0,-6) circle[]; \end{tikzpicture} \end{document} If possible, I want to know the thought of how to design such proper drawing scheme.

  • Pic or Shape for collection of ready to use objects?
    by Sammy on December 31, 2025 at 2:25 pm

    For the graphics I use on my physics exercise sheets made with TikZ I often use the same objects (hooks, masses, carts, pulleys, force gauges,...). So instead of copy-pasting and modifying the code of these objects I think it makes sense to make them into a ready to use object. There are three ways I know of to make that happen: TeX macros, pics and shapes. There are some features I wish the implementation of these objects to have and need some advice on how to implement it in order to have those features: An object should have multiple anchors so I can easily use certain points for further construction and choose which anchor to use for the placement (so there is no need to calculate that stuff manually). The hook for example could be placed at it's base or the actual hook and either one should be available afterwards for further placement of objects or paths. A default style should be set, i.e. the fill color or shading of the mass body, that can be overwritten. If placed inside a scope that changes shift, rotation, scale, line width,... these changes should automatically also apply to the object as a whole. I want to be able to construct new objects from already existing objects, i.e. I want to be able to use the hook as part of the mass, force gauge and cart. Right now I'm leaning towards defining new shapes, even tho I haven't used low level pgf before. As far as I can see 1 and 3 are no problem with shapes. I feel like 2 could also be achieved (any hints are appreciated - maybe defining a new style that uses that shape?). I however have no Idea if or how to make 4 work in defining a new shape. Pics on the other hand would make 2 and 4 easy as far as I can imagine. But they don't respond to the settings of a scope (3). Also anchors (1) are not natively supported but using tikzmark one answer to this question Anchoring TiKZ pics suggests this could be achieved as well (although I imagine it to be not quite as powerful as a new shape and takes two compilation runs if I understood correctly). Any thoughts, hints or pieces of advice are very welcome. I hope I described the setting clear enough. Edit The following Example is not meant to be beautiful but hopefully helps to illustrate the issue: \documentclass[tikz]{standalone} \usetikzlibrary{calc} \usetikzlibrary{tikzmark} \begin{document} \tikzset{ hook/.pic={ \draw[double=gray!80, double distance=1.4pt] (0,0) .. controls (0,-1.5) and (0,{1/sin(45)-2.5}) .. ($(45:1)+(0,-2.5)$) arc(405:140:1); \node[inner sep=2mm] (-hole) at (0,-2.5) {}; } } \tikzset{ cart/.pic={ \shadedraw[left color=blue, right color=blue!50] (-3,0) rectangle (3,2); \shadedraw[left color=black, right color=gray] (2,-.8) circle (.8); \shadedraw[left color=black, right color=gray] (-2,-.8) circle (.8); \pic[transform shape,rotate=90,scale=.5] (h) at (3,1) {hook}; \coordinate (-front-wheel) at (2,-1.6); \coordinate (-back-wheel) at (-2,-1.6); \node[inner sep=2mm] (-hook) at (h-hole) {}; } } \begin{tikzpicture} \draw (0,0) -- (8,0) -- (8,2); \pic[pic anchor=(-back-wheel),scale=.5] (cart) at (.5,0) {cart}; \pic[rotate=270,xscale=-1,scale=.25] (hook) at (8,0|-cart-hook) {hook}; \draw[ultra thick, line cap=round] (cart-hook) -- (hook-hole); \end{tikzpicture} \end{document} So using a pic with tikzmark (and transform shape as I've discovered) seems to check all the requirements. Can this also be achieved with a custom shape? As in this solution I dislike a few things: tikzmark needs two compilation runs no border anchors can be defined (at least I don't know how) It seems to me all anchors are defined every time a pic is inserted and not calculated when needed as with shapes. I'm not sure about the impacts on compilation time.

  • How to draw a rectangle in tikz at scale 0.9 without broken line joins
    by msrd0 on November 15, 2025 at 10:28 am

    I have a tikz picture that I apply scale=0.9 to that \draws a rectangle, like this: \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=0.9] \draw[draw=red, fill=red, fill opacity=0.3, thick] (0.24999999999999997, 5.8) -| (0.44999999999999996, 6.2) -| cycle; \end{tikzpicture} \end{document} This results in one corner not having the correct line join: If I would remove the scale argument, the line joint would be correct, but the whole picture no longer fits on my page. I also would like to avoid having to manually multiply all coordinates with 0.9. As a workaround, I could draw a second rectangle over it, with the "missing" corner in a different location. Is there a better solution?

  • Adding a colormap to a solution curve of a vector field
    by Black Mild on October 7, 2025 at 8:29 pm

    Here the curve is drawn with a single color (red) It's easy to get the solution curve. The below figure is drawn in this app for y'=x^2+y^2-1, y(0)=1/2. As you can notice the color of the curve is varying from red (x<-1) to purple (-1<x<1) then to blue (x>1). It is not color set of the rainbow, so it is not synchronious to the Rainbow colormap. My question: How to add a given colormap (such as Rainbow) to a solution curve of a vector field? I guess this is a kind of popular, but can not find a way with Asymptote. I expect not only Asymptote code but also any others as TikZ, MetaPost, lua, etc. The code should be apply for any colormaps Please use my code here as MWE. Update: another MWE with AI and my poor Python import numpy as np import matplotlib.pyplot as plt from matplotlib.collections import LineCollection from matplotlib.colors import Normalize from scipy.integrate import solve_ivp # ============================================================ # 1. Configuration # ============================================================ x_min, x_max = -3, 3 y_min, y_max = -3, 3 density = 8 # Number of initial conditions per axis def ode_func(t, y): """ ODE: y' = x^2 + y^2 - 1 Here, t plays the role of x. """ return t**2 + y[0]**2 - 1 def exit_box(t, y): """ Event function: stop integration when the solution leaves the box |x| <= 3, |y| <= 3. """ return max(abs(t), abs(y[0])) - 3 exit_box.terminal = True # ============================================================ # 2. Figure setup # ============================================================ fig, ax = plt.subplots(figsize=(8, 8)) # Initial conditions x_inits = np.linspace(x_min, x_max, density) y_inits = np.linspace(y_min, y_max, density) manual_starts = [ (-2.7, 0), (-2.7, 1), (-2.7, 2), ( 2.7, 0), ( 2.7,-1), ( 2.7,-2), (-0.75, 2), (0.75, -2), (-1, 0), (1, 0) ] starts = [(x0, y0) for x0 in x_inits for y0 in y_inits] starts += manual_starts all_segments = [] all_values = [] print("Computing solution curves...") # ============================================================ # 3. Solve ODEs and collect line segments # ============================================================ for x0, y0 in starts: for direction in [1, -1]: t_span = [x0, direction * 3.2] sol = solve_ivp( ode_func, t_span, [y0], events=exit_box, max_step=0.05 ) x = sol.t y = sol.y[0] if len(x) > 1: points = np.array([x, y]).T.reshape(-1, 1, 2) segments = np.concatenate([points[:-1], points[1:]], axis=1) all_segments.extend(segments) slopes = x[:-1]**2 + y[:-1]**2 - 1 all_values.extend(slopes) all_values = np.array(all_values) # ============================================================ # 4. Background vector field (normalized) # ============================================================ X, Y = np.meshgrid( np.linspace(x_min, x_max, 20), np.linspace(y_min, y_max, 20) ) U = np.ones_like(X) V = X**2 + Y**2 - 1 N = np.sqrt(U**2 + V**2) ax.quiver( X, Y, U / N, V / N, color="gray", alpha=0.3, pivot="mid" ) # ============================================================ # 5. LineCollection with true rainbow colormap # ============================================================ norm = Normalize( vmin=np.percentile(all_values, 5), vmax=np.percentile(all_values, 95) ) lc = LineCollection( all_segments, cmap="rainbow", norm=norm, linewidth=1.5, alpha=0.85 ) lc.set_array(all_values) ax.add_collection(lc) # ============================================================ # 6. Axes styling and annotations # ============================================================ ax.set_xlim(x_min, x_max) ax.set_ylim(y_min, y_max) ax.set_aspect("equal", adjustable="box") ax.set_xlabel("x") ax.set_ylabel("y") ax.set_title(r"Solution curves for $y' = x^2 + y^2 - 1$") cbar = plt.colorbar(lc, ax=ax) cbar.set_label(r"Slope value $y' = x^2 + y^2 - 1$") ax.grid(True, linestyle=":", alpha=0.6) plt.tight_layout() plt.savefig("solution_curves_rainbow.png", dpi=200) plt.show()

  • Trouble with plot graphs
    by Alex on April 2, 2024 at 8:07 pm

    I try to compile this example for plotting graphs: https://texample.net/tikz/examples/drawing-graphs/ But, if I compile in TexWorks (pdfLatex or Overleaf) % Drawing a graph using the PG 3.0 graphdrawing library % Author: Mark Wibrow \documentclass[tikz,border=10pt]{standalone} \usetikzlibrary{graphdrawing} \usetikzlibrary{graphs} \usetikzlibrary{trees} \begin{document} \begin{tikzpicture}[>=stealth, every node/.style={circle, draw, minimum size=0.75cm}] \graph [tree layout, grow=down, fresh nodes, level distance=0.5in, sibling distance=0.5in] { 4 -> { 3 -> { 1 -> { 5, " " }, 2,2 }, 3 -> { 1, 2, 2 }, 3 -> { 1, 2, 2 } } }; \end{tikzpicture} \end{document} I get such errors: Package pgfkeys Error: I do not know the key '/tikz/graphs/grow', to which you passed 'down', and I am going to ignore it. Perhaps you misspelled it. Package pgfkeys Error: I do not know the key '/graph drawing/anchor at', to which you passed '(\tikz@lastx ,\tikz@lasty )', and I am going to ignore it. Perhaps you misspelled it. Package pgfkeys Error: I do not know the key '/tikz/graphs/sibling distance', to which you passed '0.5in', and I am going to ignore it. Perhaps you misspelled it. Package pgfkeys Error: I do not know the key '/tikz/graphs/tree layout' and I am going to ignore it. Perhaps you misspelled it. Package pgfkeys Error: I do not know the key '/tikz/graphs/level distance', to which you passed '0.5in', and I am going to ignore it. Perhaps you misspelled it. Graphs that I will expect see: But I get with errors: I assume that it is necessary to use LuaLatex, but the fact is that there are many good examples on the portal, and the layout is done using pdfLatex

  • Problem with of alignment with 4 tikzpictures in a figure environment
    by Matteo Bulgarelli on December 14, 2020 at 3:31 pm

    Good afternoon, I just to need to shift all of these for graphs a little bit more to the left, and spacing (vertically) the former two with respect to the latter. I tried with \hspace, but it produces the following: \documentclass{article} \linespread{1.3} \usepackage[margin=1.5in]{geometry} \usepackage{pgfplots} \usetikzlibrary{patterns} \begin{document}\pgfplotsset{compat=1.17} \begin{figure} \hspace{-2cm} \begin{tikzpicture} \begin{axis}[ compat=newest, axis lines = left, xlabel = {$\text{A\&D}/100k$}, ylabel = {$gp$}, xmin = 0, ymin = 0, xmax = 325, ymax = 325, xtick={0,80}, ytick={160+20/3,240+20/3}, title = {Tourists, Peak}, ] \addplot[ domain = 0:240, samples = 190, thick, ] {240 + 20/3 - x}; \draw [dotted] (0,160+20/3) -- (80,160+20/3) -- (80,0); \draw[pattern= north east lines,pattern color = green] (0,160+20/3) -- (0,240+20/3)-- (80,160+20/3); \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[ compat=newest, axis lines = left, xlabel = {$\text{A\&D}/100k$}, ylabel = {$gp$}, xmin = 0, ymin = 0, xmax = 325, ymax = 325, xtick={0,20}, ytick={120+10/3,180+10/3}, title = {Tourists, Off-Peak}, ] \addplot[ domain = 0:300, samples = 190, thick, ] {180 + 10/3 - 3*x}; \draw [dotted] (0,120+10/3) -- (20,120+10/3) -- (20,0); \draw[pattern= north east lines,pattern color = green] (0,120+10/3) -- (0,180+10/3)-- (20,120+10/3); \end{axis} \end{tikzpicture} \hspace{-2cm} \begin{tikzpicture} \begin{axis}[ compat=newest, axis lines = left, xlabel = {$\text{A\&D} / 100k$}, ylabel = {$gp$}, xmin = 0, ymin = 0, xmax = 60, ymax = 730, xtick={0,20}, ytick={40+20/3,160+20/3,560+20/3}, title = {Locals, Peak}, ] \addplot[ domain = 0:75, samples = 190, thick, ] {560 + 20/3 - 20*x}; \draw [dotted] (0,160+20/3) -- (20,160+20/3) -- (20,0); \draw [dotted] (0,40+20/3) -- (26, 40 + 20/3) -- (26,0); \draw [pattern = north east lines, pattern color = green](0, 40 + 20/3) -- (0,560 + 20/3) -- (20, 160 + 20/3) -- (20, 40 + 20/3); \draw [pattern = north east lines, pattern color = red](20, 40 + 20/3) -- (20, 160 + 20/3) -- (26,40 + 20/3); \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[ compat=newest, axis lines = left, xlabel = {$\text{A\&D} / 100k$}, ylabel = {$gp$}, xmin = 0, ymin = 0, xmax = 60, ymax = 730, xtick={0,30}, ytick={30+10/3,120+10/3,420+10/3}, title = {Locals, Off-Peak}, ] \addplot[ domain = 0:75, samples = 190, thick, ] {420 + 10/3 - 10*x}; \draw [dotted] (0,120+10/3) -- (30,120+20/3) -- (30,0); \draw [dotted] (0,30+10/3) -- (39, 30 + 10/3) -- (39,0); \draw [pattern = north east lines, pattern color = green](0, 30 + 10/3) -- (0,420 + 10/3) -- (30, 120 + 10/3) -- (30, 30 + 10/3); \draw [pattern = north east lines, pattern color = red](30, 30 + 10/3) -- (30, 120 + 10/3) -- (39,30 + 10/3); \end{axis} \end{tikzpicture} \end{figure} \end{document}

  • non-square picture dimensions for a LaTeXiT circle
    by user1337 on October 17, 2017 at 10:46 am

    Running the following in LaTeXiT preamble: \documentclass[10pt]{article} \usepackage[usenames]{color} %used for font color \usepackage{amssymb} %maths \usepackage{amsmath} %maths \usepackage[utf8]{inputenc} %useful to type directly diacritic characters \usepackage{tikz} body \begin{tikzpicture} \draw (1.5,1.5) circle [radius=1.5]; \end{tikzpicture} produced the following picture When I right-clicked on it, and chose "Get Info" it says that it has dimensions 618 × 620. My questions are: how come such a symmetric shape resulted in uneven dimensions? Is there a way to predict the image dimensions from the TikZ parameters (e.g. radius)? Is there a natural way to get a circle with equal dimensions in TikZ? Thanks.

  • Converting an SVG image to TikZ code
    by Hendrra on May 21, 2017 at 8:26 am

    I am to convert an SVG image to TikZ code. I have never done that before thus I have a few questions. First of all do I need Inkscape or any other program like this? Maybe there is a method using just Python? Have you ever done that before? Are there any typical errors or problems?