TikZ
- How to include a white background photo (jpg) in a 10% gray background?by Learner on May 31, 2026 at 11:20 am
I am using \includegraphics{photo.jpg} to upload a photo in a 10% gray background. For 10% gray background INSIDE border \fill[gray!10] ($(current page.north west) + (1cm,-1cm)$) rectangle ($(current page.south east) + (-1cm,1cm)$); To upload the photo (with white background, I used \node at ($(current page.south)+( 6cm,5.2cm)$) { \includegraphics{sig_digital.jpg} }; This produced the following photo: We can see the background is not matching, the photo has white background. I have one option, I can make the background to be white. But I want to keep the background gray while adjust the photo background. Edit: I am adding the full latex code: \documentclass[12pt,reqno]{amsart} %\documentclass [border = .2cm] {standalone} \usepackage{pgfplots} \usepackage{tikz} \pgfplotsset{compat=newest} \topmargin=0.02cm \textwidth = 17cm \textheight = 23cm \baselineskip=11pt \usepackage{color} \makeatletter \renewcommand*{\@cite}[2]{\fcolorbox{black}{white}{#1\if@tempswa, #2\fi}} %\renewcommand*{\@cite}[2]{\fcolorbox{green}{white}{#1, #2}} \renewcommand*{\@biblabel}[1]{{\fcolorbox{green}{white}{#1}}\hfill} \makeatother \setlength{\oddsidemargin}{0.01 pt} \setlength{\evensidemargin}{0.01 pt} \renewcommand{\baselinestretch}{1.4} \usepackage{amsmath,amsfonts,amssymb,amsthm} \usepackage{graphicx} \graphicspath{ } \usetikzlibrary{intersections} \usetikzlibrary{patterns} \usepackage{dsfont} \usepackage{amssymb} \usepackage{relsize} \usepackage{soul} \usepackage{exercise} \usepackage{lipsum} \usepackage{epstopdf} \usepackage{pdflscape} \usepackage{csquotes} \usepackage{wrapfig} \usepackage{accents} \usepackage{adjustbox} \usepackage{tikz-3dplot} \usepackage{caption} \usepackage{subcaption} \usepackage{calligra} \usepackage[colorlinks]{hyperref} \hypersetup{citecolor=black} \newtheorem{fig}{figure}[section] \numberwithin{figure}{section} \newcommand\norm[1]{\left\lVert#1\right\rVert} \theoremstyle{plain} \newtheorem{thm}{Theorem}[section] \newtheorem*{thm*}{Theorem} \newtheorem{lem}[thm]{Lemma} \newtheorem{prop}[thm]{Proposition} \newtheorem{cor}{Corollary}[thm] \theoremstyle{definition} \newtheorem{defn}{Definition}[section] \newtheorem{conj}{Conjecture}[section] \newtheorem{exmp}{Example}[section] \theoremstyle{remark} \newtheorem{rem}{Remark} \newtheorem*{note}{Note} \usepackage{mathtools} \makeatletter \@namedef{subjclassname@2020}{% \textup{2020} Mathematics Subject Classification} \makeatother \renewcommand\ExerciseName{Question~} \renewcommand\ExerciseHeader{% \noindent\parbox[t]{.18\textwidth}{% \bfseries\large\ExerciseName\ExerciseHeaderNB\hfill}% \parbox[t]{.72\textwidth}{% \centering\bfseries\large% \ExerciseHeaderTitle\ExerciseHeaderOrigin}% \par\medskip } \newcommand{\md}[1]{\hfill\makebox[0pt][r]{[#1]}} %md=mark distribution \begin{document} \thispagestyle{empty} \begin{tikzpicture}[remember picture,overlay] % Light gray background INSIDE border \fill[gray!10] ($(current page.north west) + (1cm,-1cm)$) rectangle ($(current page.south east) + (-1cm,1cm)$); % Border \draw[line width=3pt] ($(current page.north west) + (1cm,-1cm)$) rectangle ($(current page.south east) + (-1cm,1cm)$); \draw[line width=1pt] ($(current page.north west) + (1.2cm,-1.2cm)$) rectangle ($(current page.south east) + (-1.2cm,1.2cm)$); % Title % Title (no node name needed) \node at ($(current page.north)+(0,-2.5cm)$) { {\Huge \bfseries Certificate of Presentation} }; % Main underline \draw[line width=1.3pt, color=blue] ($(current page.north)+(-4.7cm,-3.35cm)$) -- ($(current page.north)+(4.7cm,-3.35cm)$); % End dots \fill[color=blue] ($(current page.north)+(-4.9cm,-3.35cm)$) circle (2.2pt); \fill[color=blue] ($(current page.north)+(4.9cm,-3.35cm)$) circle (2.2pt); % Left stem \draw[line width=0.7pt, color=blue] ($(current page.north)+(-5.05cm,-3.35cm)$) -- ($(current page.north)+(-5.22cm,-3.35cm)$); % Left upper leaf \draw[line width=0.7pt, color=blue] ($(current page.north)+(-5.22cm,-3.35cm)$) .. controls +(-0.14,0.14) and +(0.14,0.11) .. ($(current page.north)+(-5.72cm,-3.16cm)$) .. controls +(-0.14,-0.11) and +(-0.10,0.00) .. ($(current page.north)+(-5.22cm,-3.35cm)$); % Left lower leaf \draw[line width=0.7pt, color=green] ($(current page.north)+(-5.22cm,-3.35cm)$) .. controls +(-0.14,-0.14) and +(0.14,-0.11) .. ($(current page.north)+(-5.72cm,-3.54cm)$) .. controls +(-0.14,0.11) and +(-0.10,0.00) .. ($(current page.north)+(-5.22cm,-3.35cm)$); % Right stem \draw[line width=0.7pt, color=blue] ($(current page.north)+(5.05cm,-3.35cm)$) -- ($(current page.north)+(5.22cm,-3.35cm)$); % Right upper leaf \draw[line width=0.7pt, color=blue] ($(current page.north)+(5.22cm,-3.35cm)$) .. controls +(0.14,0.14) and +(-0.14,0.11) .. ($(current page.north)+(5.72cm,-3.16cm)$) .. controls +(0.14,-0.11) and +(0.10,0.00) .. ($(current page.north)+(5.22cm,-3.35cm)$); % Right lower leaf \draw[line width=0.7pt, color=green] ($(current page.north)+(5.22cm,-3.35cm)$) .. controls +(0.14,-0.14) and +(-0.14,-0.11) .. ($(current page.north)+(5.72cm,-3.54cm)$) .. controls +(0.14,0.11) and +(0.10,0.00) .. ($(current page.north)+(5.22cm,-3.35cm)$); \node at ($(current page.north west)+(10.7cm,-5.6cm)$) { \includegraphics[width=4cm]{DHU_logo.png} }; % Body Text (for presenters) \node[align=center, text width=21cm] at ($(current page.center)+(0,0.1cm)$) { \large This is to certify that \\[0.5cm] {\LARGE \textbf{Participant Name}} \\[0.3cm] {\large (Affiliated to XYZ University)} \\[0.3cm] has presented a research paper titled \\[0.3cm] {\large \bfseries ``Title of the Research Paper''} \\[0.3cm] at the \\[0.1cm] { \color{blue!60!black}{{ $\mathbb{T}\mathbb{W}\mathbb{O}-$$\mathbb{DAY}$ $\mathbb{WORKSHOP}$ $\mathbb{AND}$ $\mathbb{CONFERENCE}$ $\mathbb{IN}$ $\mathbb{MATHEMATICS}$}\\[0.25cm] $\mathbb{HONORING}$ $\mathbb{SRINIVASA}$ $\mathbb{RAMANUJAN}$}}\\[0.6cm] held at Darjeeling Hills University from 2--3 July 2026.\\[0.4cm] We appreciate his/her valuable contribution to the conference. }; % Signature Lines \node at ($(current page.south)+( 6cm,3.5cm)$) { \begin{tabular}{c} \rule{5cm}{0.4pt}\\ (Organizer Name) \\ Affiliation \end{tabular} }; %add digital signature \node[scale=0.9] at ($(current page.south)+( 6cm,5.2cm)$) { \includegraphics{sig_digital.jpg} }; \end{tikzpicture} \end{document} The output is as follows: Here is the photo link
- Automatically shift arrow heads in TikZ for piecewise defined functions or gapsby CampanIgnis on May 30, 2026 at 7:40 pm
The tip of arrow heads in TikZ usually extends on exactly the specified coordinate, for example in \draw[->] (0,0) -- (1,1);. Is it possible to align the center of the end mark automatically at the specified coordinate? This is useful for plotting piecewise defined functions using * or o as arrow heads such as in https://commons.wikimedia.org/wiki/File:Discontinuity_jump.eps.png. Another way to achieve a similar result is by calculating the coordinates of the points and adding the points manually by \filldraw[fill=white] (1,0.5) circle (0.75pt);. To illustrate what I would like to have: The center of the two circles should be in the middle of the two blue lines of the MWE. It would also be great if we could define certain x-values to set marks at exactly desired points. MWE \documentclass{article} \usepackage{tikz} \usetikzlibrary{arrows} \begin{document} \begin{tikzpicture}[scale=3] \draw[blue!25,line width=4.80pt] (0,-0.25) -- ++(0,1.25) (1,-0.25) -- ++(0,1.25) ; \draw[domain=0:1, smooth, variable=\x, samples=4, *-o] plot ({\x}, {0.55}); \draw[->] (0,0) -- (1,0); \end{tikzpicture} \end{document}
- How to make the double arrow style more like the `single arrow` in `shapes.arrows`?by Explorer on May 29, 2026 at 10:30 am
What I want to replicate originally is something as below: Now my key point is the arrow of the following style, similar to the single arrow shape in shapes.arrows: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{arrows.meta,positioning,shapes.arrows,decorations.markings} \begin{document} \begin{tikzpicture}[ node distance=2cm and 1cm, shrink/.style={shorten >=#1cm,shorten <=#1cm}, myarrow/.style={ shrink=.75,thick,-Stealth, postaction=decorate, decoration={ markings,mark=at position .5 with { \draw[shrink=0,-] (-10pt,-10pt) -- (10pt,10pt); } } }, mysinglearrow/.style={ shape=single arrow,minimum height=1.5cm,inner sep=3pt,draw,line width=1.2pt, } ] \node[draw] (betaII) {AAAAAAAA}; \node[draw] (betaI)[below left=of betaII]{BBBBBBBBB}; \node[draw] (normal)[below right=of betaII]{CCCCCCCCC}; \draw[myarrow] (betaII.west) -- (betaI.north); \draw[myarrow] (normal.north) -- (betaII.east); \draw[myarrow] (betaI) -- (normal); \node[mysinglearrow,rotate=45] at (-1.75,-1.5) {}; \end{tikzpicture} \end{document} However, that is not behave as a "arrow", but a shape. I dislike the syntax: \node[mysinglearrow,rotate=45] at (-1.75,-1.5) {}; Here below is the simplified version, based on the similar solution code here: % Source - https://tex.stackexchange.com/a/662285 \documentclass[tikz,margin=1cm]{standalone} \usetikzlibrary{arrows.meta} \tikzset{ doubleTriangle/.style args={#1 and #2 colored by #3 and #4}{ -Triangle, line width=#1,#3, postaction={ draw, -Triangle,#4, line width=#2, /utils/exec=\pgfmathsetlengthmacro{\doubleTriangleShortenStart}{((#1)-(#2))/2}, /utils/exec=\pgfmathsetlengthmacro{\doubleTriangleShortenEnd}{1.2*(sqrt(3))*((#1)-(#2))}, shorten <=\doubleTriangleShortenStart, shorten >=\doubleTriangleShortenEnd, }, }, } \begin{document} \begin{tikzpicture} \node[draw,below left] at (0,0) {A}; \node[draw,above right] at (5,5) {B}; \draw[doubleTriangle=1cm and 0.7cm colored by black and white] (0,0) -- (5,5); % \draw[doubleTriangle=1cm and 0.7cm colored by black and white,shorten >=.5cm,shorten <=.5cm] (0,0) -- (5,5); \end{tikzpicture} \end{document} which gives: Noted that the arrow's width is not the same. What I was after as an arrow style, is something as below: Any suggestions on how to make more elegant syntax of this arrow style?
- How could make inkscape input path as single path but not filled area?by Explorer on May 28, 2026 at 5:10 am
The question is similar to this classical one. I followed the following instructions with inkscape and svg2tikz: Procedure: import your bitmap image. vectorize it by Inkscape (potrace algorithm). delete bitmap image. adjust document to content. export it by inkscape2tikz extension. Then, export the svg figure with svg2tikz, it give me the following: \documentclass[tikz]{standalone} \begin{document} \def \globalscale {1.000000} \begin{tikzpicture}[y=1cm, x=1cm, yscale=-\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[fill=black] (8.9, 20.3).. controls (8.8, 20.3) and (8.7, 20.2) .. (8.6, 20.2).. controls (8.6, 20.2) and (8.4, 20.2) .. (8.2, 20.2).. controls (8.1, 20.2) and (7.9, 20.1) .. (7.9, 20.1).. controls (7.8, 20.1) and (7.6, 20.0) .. (7.5, 20.0).. controls (7.4, 20.0) and (7.3, 20.0) .. (7.2, 20.0).. controls (7.2, 19.9) and (7.1, 19.9) .. (7.0, 19.9).. controls (6.8, 19.8) and (6.2, 19.5) .. (6.1, 19.5).. controls (6.1, 19.4) and (6.0, 19.4) .. (6.0, 19.4).. controls (5.9, 19.4) and (5.9, 19.3) .. (5.8, 19.3).. controls (5.8, 19.3) and (5.8, 19.3) .. (5.7, 19.2).. controls (5.7, 19.2) and (5.6, 19.2) .. (5.5, 19.1).. controls (5.4, 19.0) and (5.3, 19.0) .. (5.3, 18.9).. controls (5.1, 18.8) and (4.3, 18.1) .. (4.2, 18.0).. controls (4.2, 18.0) and (4.1, 17.9) .. (4.0, 17.8).. controls (3.9, 17.8) and (3.8, 17.6) .. (3.7, 17.6).. controls (3.6, 17.5) and (3.4, 17.3) .. (3.3, 17.2).. controls (2.7, 16.6) and (2.2, 16.1) .. (1.8, 15.5).. controls (1.7, 15.5) and (1.7, 15.4) .. (1.7, 15.3).. controls (1.6, 15.3) and (1.6, 15.2) .. (1.6, 15.2).. controls (1.5, 15.2) and (1.3, 14.6) .. (1.3, 14.4).. controls (1.3, 14.4) and (1.3, 14.3) .. (1.3, 14.2).. controls (1.2, 14.1) and (1.2, 13.9) .. (1.2, 13.7).. controls (1.2, 13.6) and (1.1, 13.3) .. (1.1, 13.2).. controls (1.1, 13.0) and (1.0, 12.7) .. (1.0, 12.3).. controls (1.0, 12.0) and (1.0, 11.7) .. (1.0, 11.6).. controls (0.9, 10.9) and (1.0, 9.6) .. (1.1, 9.3).. controls (1.1, 9.2) and (1.2, 9.1) .. (1.2, 8.9).. controls (1.2, 8.8) and (1.3, 8.7) .. (1.3, 8.6).. controls (1.3, 8.6) and (1.3, 8.5) .. (1.3, 8.4).. controls (1.4, 8.3) and (1.4, 8.3) .. (1.4, 8.2).. controls (1.4, 8.2) and (1.5, 8.1) .. (1.5, 8.0).. controls (1.5, 7.9) and (1.6, 7.8) .. (1.6, 7.8).. controls (1.6, 7.8) and (1.7, 7.7) .. (1.7, 7.7).. controls (1.7, 7.7) and (1.8, 7.4) .. (1.9, 7.3).. controls (1.9, 7.3) and (2.0, 7.2) .. (2.0, 7.1).. controls (2.1, 7.0) and (2.1, 6.9) .. (2.3, 6.8).. controls (2.4, 6.6) and (2.7, 6.2) .. (2.7, 6.2).. controls (2.8, 6.1) and (2.8, 6.1) .. (2.8, 6.1).. controls (2.8, 6.1) and (3.0, 5.8) .. (3.0, 5.7).. controls (3.1, 5.7) and (3.1, 5.6) .. (3.2, 5.5).. controls (3.3, 5.4) and (3.3, 5.4) .. (3.6, 5.0).. controls (3.7, 4.9) and (3.8, 4.7) .. (3.9, 4.6).. controls (4.0, 4.5) and (4.2, 4.4) .. (4.2, 4.3).. controls (4.4, 4.0) and (4.9, 3.5) .. (5.4, 3.1).. controls (5.5, 3.0) and (5.7, 2.9) .. (5.7, 2.8).. controls (5.9, 2.7) and (6.0, 2.6) .. (6.2, 2.5).. controls (6.2, 2.5) and (6.3, 2.4) .. (6.3, 2.4).. controls (6.3, 2.4) and (6.6, 2.2) .. (6.7, 2.2).. controls (6.7, 2.2) and (6.8, 2.1) .. (6.8, 2.1).. controls (6.8, 2.1) and (6.9, 2.1) .. (7.0, 2.0).. controls (7.1, 2.0) and (7.2, 2.0) .. (7.2, 1.9).. controls (7.3, 1.9) and (7.3, 1.9) .. (7.4, 1.9).. controls (7.4, 1.8) and (7.5, 1.8) .. (7.6, 1.8).. controls (7.6, 1.7) and (7.7, 1.7) .. (7.7, 1.7).. controls (7.7, 1.7) and (7.8, 1.7) .. (7.9, 1.6).. controls (8.0, 1.6) and (8.1, 1.6) .. (8.2, 1.5).. controls (8.3, 1.5) and (8.4, 1.5) .. (8.4, 1.5).. controls (8.4, 1.4) and (8.6, 1.4) .. (8.7, 1.4).. controls (8.9, 1.4) and (9.1, 1.3) .. (9.2, 1.3).. controls (9.3, 1.3) and (9.5, 1.2) .. (9.8, 1.2).. controls (10.0, 1.2) and (10.3, 1.2) .. (10.5, 1.1).. controls (10.8, 1.1) and (11.6, 1.1) .. (12.0, 1.1).. controls (12.2, 1.2) and (12.4, 1.2) .. (12.5, 1.2).. controls (12.6, 1.2) and (12.7, 1.3) .. (12.8, 1.3).. controls (12.8, 1.3) and (12.9, 1.4) .. (13.0, 1.4).. controls (13.1, 1.4) and (13.2, 1.4) .. (13.3, 1.5).. controls (13.3, 1.5) and (13.4, 1.5) .. (13.5, 1.5).. controls (13.6, 1.6) and (13.7, 1.6) .. (13.8, 1.6).. controls (13.8, 1.7) and (13.9, 1.7) .. (14.0, 1.8).. controls (14.4, 1.9) and (14.7, 2.1) .. (14.7, 2.1).. controls (14.7, 2.1) and (14.8, 2.2) .. (14.8, 2.2).. controls (14.9, 2.2) and (15.1, 2.4) .. (15.4, 2.6).. controls (15.6, 2.8) and (16.3, 3.6) .. (16.4, 3.7).. controls (16.5, 3.8) and (16.5, 3.9) .. (16.6, 3.9).. controls (16.7, 4.0) and (16.8, 4.1) .. (16.8, 4.2).. controls (16.8, 4.2) and (16.9, 4.3) .. (16.9, 4.3).. controls (16.9, 4.3) and (16.9, 4.3) .. (16.9, 4.3).. controls (16.9, 4.4) and (17.0, 4.5) .. (17.1, 4.6).. controls (17.1, 4.6) and (17.2, 4.8) .. (17.2, 4.8).. controls (17.3, 4.9) and (17.3, 5.0) .. (17.4, 5.1).. controls (17.5, 5.3) and (17.8, 5.9) .. (17.9, 6.0).. controls (17.9, 6.1) and (17.9, 6.2) .. (18.0, 6.3).. controls (18.0, 6.4) and (18.0, 6.4) .. (18.0, 6.5).. controls (18.0, 6.5) and (18.1, 6.6) .. (18.1, 6.8).. controls (18.2, 6.9) and (18.2, 7.0) .. (18.2, 7.1).. controls (18.2, 7.2) and (18.3, 7.3) .. (18.3, 7.3).. controls (18.3, 7.4) and (18.3, 7.5) .. (18.4, 7.6).. controls (18.4, 7.7) and (18.4, 7.9) .. (18.4, 8.0).. controls (18.6, 8.4) and (18.6, 10.2) .. (18.5, 10.9).. controls (18.4, 11.3) and (18.4, 11.5) .. (18.4, 12.2).. controls (18.3, 12.5) and (18.3, 12.9) .. (18.3, 13.1).. controls (18.3, 13.3) and (18.2, 13.6) .. (18.2, 13.7).. controls (18.2, 13.9) and (18.2, 14.1) .. (18.1, 14.2).. controls (18.1, 14.4) and (18.1, 14.5) .. (18.1, 14.6).. controls (18.0, 14.7) and (18.0, 14.8) .. (18.0, 14.9).. controls (17.9, 15.0) and (17.9, 15.1) .. (17.9, 15.2).. controls (17.9, 15.3) and (17.8, 15.4) .. (17.8, 15.5).. controls (17.8, 15.5) and (17.7, 15.6) .. (17.7, 15.6).. controls (17.7, 15.7) and (17.7, 15.8) .. (17.7, 15.8).. controls (17.6, 15.9) and (17.6, 16.0) .. (17.6, 16.0).. controls (17.6, 16.1) and (17.5, 16.2) .. (17.5, 16.2).. controls (17.5, 16.2) and (17.4, 16.3) .. (17.4, 16.4).. controls (17.4, 16.5) and (17.3, 16.6) .. (17.3, 16.6).. controls (17.3, 16.7) and (17.2, 16.7) .. (17.2, 16.8).. controls (17.2, 16.8) and (17.2, 16.9) .. (17.2, 16.9).. controls (17.1, 17.0) and (17.0, 17.1) .. (17.0, 17.2).. controls (16.9, 17.3) and (16.8, 17.4) .. (16.8, 17.4).. controls (16.8, 17.4) and (16.8, 17.5) .. (16.7, 17.6).. controls (16.6, 17.7) and (16.1, 18.2) .. (16.1, 18.2).. controls (16.0, 18.2) and (16.0, 18.3) .. (15.9, 18.3).. controls (15.9, 18.4) and (15.8, 18.4) .. (15.8, 18.4).. controls (15.7, 18.5) and (15.7, 18.5) .. (15.6, 18.5).. controls (15.6, 18.5) and (15.6, 18.6) .. (15.5, 18.6).. controls (15.5, 18.6) and (15.4, 18.7) .. (15.4, 18.7).. controls (15.4, 18.7) and (15.3, 18.8) .. (15.1, 18.8).. controls (15.0, 18.9) and (14.9, 18.9) .. (14.8, 19.0).. controls (14.6, 19.0) and (14.5, 19.1) .. (14.5, 19.1).. controls (14.5, 19.1) and (14.4, 19.1) .. (14.3, 19.2).. controls (14.3, 19.2) and (14.2, 19.2) .. (14.2, 19.2).. controls (14.1, 19.2) and (14.1, 19.3) .. (14.0, 19.3).. controls (13.9, 19.3) and (13.8, 19.4) .. (13.7, 19.4).. controls (13.6, 19.4) and (13.6, 19.4) .. (13.5, 19.5).. controls (13.5, 19.5) and (13.4, 19.5) .. (13.3, 19.5).. controls (13.3, 19.6) and (13.2, 19.6) .. (13.1, 19.6).. controls (13.1, 19.6) and (13.0, 19.7) .. (12.8, 19.7).. controls (12.7, 19.7) and (12.6, 19.8) .. (12.5, 19.8).. controls (12.1, 19.9) and (11.9, 20.0) .. (11.7, 20.0).. controls (11.6, 20.0) and (11.5, 20.1) .. (11.4, 20.1).. controls (11.3, 20.1) and (11.2, 20.2) .. (10.9, 20.2).. controls (10.7, 20.2) and (10.4, 20.2) .. (10.2, 20.3).. controls (10.0, 20.3) and (9.3, 20.3) .. (8.9, 20.3) -- cycle(10.4, 20.0).. controls (10.6, 19.9) and (10.8, 19.9) .. (10.9, 19.9).. controls (11.0, 19.9) and (11.2, 19.8) .. (11.3, 19.8).. controls (11.4, 19.8) and (11.6, 19.8) .. (11.7, 19.7).. controls (11.7, 19.7) and (11.9, 19.7) .. (12.0, 19.7).. controls (12.1, 19.7) and (12.2, 19.6) .. (12.3, 19.6).. controls (12.4, 19.5) and (12.5, 19.5) .. (12.6, 19.5).. controls (12.7, 19.5) and (12.8, 19.4) .. (12.8, 19.4).. controls (12.9, 19.4) and (13.0, 19.3) .. (13.1, 19.3).. controls (13.2, 19.3) and (13.3, 19.3) .. (13.3, 19.2).. controls (13.4, 19.2) and (13.5, 19.2) .. (13.5, 19.2).. controls (13.6, 19.1) and (13.7, 19.1) .. (13.8, 19.1).. controls (13.8, 19.1) and (13.9, 19.0) .. (14.0, 19.0).. controls (14.0, 19.0) and (14.1, 19.0) .. (14.1, 18.9).. controls (14.1, 18.9) and (14.2, 18.9) .. (14.3, 18.9).. controls (14.4, 18.8) and (14.5, 18.8) .. (14.6, 18.8).. controls (14.6, 18.7) and (14.7, 18.7) .. (14.7, 18.7).. controls (14.7, 18.7) and (15.2, 18.5) .. (15.2, 18.4).. controls (15.2, 18.4) and (15.3, 18.4) .. (15.3, 18.4).. controls (15.6, 18.3) and (16.4, 17.6) .. (16.6, 17.2).. controls (16.7, 17.0) and (16.8, 16.9) .. (16.8, 16.9).. controls (16.8, 16.9) and (17.2, 16.2) .. (17.2, 16.2).. controls (17.2, 16.1) and (17.3, 16.0) .. (17.3, 16.0).. controls (17.3, 15.9) and (17.4, 15.8) .. (17.4, 15.8).. controls (17.4, 15.7) and (17.4, 15.7) .. (17.4, 15.6).. controls (17.5, 15.6) and (17.5, 15.5) .. (17.5, 15.4).. controls (17.5, 15.4) and (17.6, 15.2) .. (17.6, 15.1).. controls (17.6, 15.0) and (17.7, 14.9) .. (17.7, 14.8).. controls (17.7, 14.8) and (17.7, 14.6) .. (17.8, 14.5).. controls (17.8, 14.4) and (17.8, 14.3) .. (17.8, 14.3).. controls (17.8, 14.2) and (17.9, 13.9) .. (17.9, 13.7).. controls (18.0, 13.6) and (18.0, 13.3) .. (18.0, 12.8).. controls (18.0, 12.5) and (18.1, 12.1) .. (18.1, 12.0).. controls (18.1, 11.9) and (18.1, 11.7) .. (18.1, 11.4).. controls (18.2, 10.8) and (18.2, 10.1) .. (18.3, 10.0).. controls (18.3, 9.9) and (18.3, 8.8) .. (18.3, 8.7).. controls (18.2, 8.7) and (18.2, 8.5) .. (18.2, 8.2).. controls (18.1, 7.8) and (18.1, 7.5) .. (17.9, 7.2).. controls (17.9, 7.1) and (17.9, 7.0) .. (17.8, 6.9).. controls (17.8, 6.8) and (17.8, 6.7) .. (17.8, 6.6).. controls (17.7, 6.6) and (17.7, 6.5) .. (17.7, 6.4).. controls (17.6, 6.2) and (17.5, 5.9) .. (17.4, 5.7).. controls (17.3, 5.6) and (17.3, 5.4) .. (17.2, 5.3).. controls (17.2, 5.3) and (17.1, 5.1) .. (17.0, 5.1).. controls (17.0, 5.0) and (16.9, 4.9) .. (16.9, 4.8).. controls (16.9, 4.8) and (16.8, 4.7) .. (16.7, 4.6).. controls (16.7, 4.5) and (16.6, 4.4) .. (16.6, 4.4).. controls (16.5, 4.1) and (15.7, 3.3) .. (15.2, 2.9).. controls (14.9, 2.6) and (14.9, 2.6) .. (14.6, 2.4).. controls (14.4, 2.2) and (14.1, 2.1) .. (14.0, 2.1).. controls (14.0, 2.1) and (13.9, 2.0) .. (13.9, 2.0).. controls (13.8, 2.0) and (13.7, 1.9) .. (13.6, 1.9).. controls (13.5, 1.9) and (13.5, 1.8) .. (13.5, 1.8).. controls (13.5, 1.8) and (13.4, 1.8) .. (13.3, 1.8).. controls (13.2, 1.7) and (13.1, 1.7) .. (13.0, 1.7).. controls (13.0, 1.6) and (12.9, 1.6) .. (12.8, 1.6).. controls (12.6, 1.6) and (12.5, 1.5) .. (12.5, 1.5).. controls (12.2, 1.4) and (10.2, 1.4) .. (10.0, 1.5).. controls (10.0, 1.5) and (9.8, 1.5) .. (9.6, 1.5).. controls (9.0, 1.6) and (8.5, 1.7) .. (8.2, 1.8).. controls (8.2, 1.8) and (8.1, 1.9) .. (8.0, 1.9).. controls (8.0, 1.9) and (7.8, 2.0) .. (7.7, 2.0).. controls (7.6, 2.1) and (7.5, 2.1) .. (7.4, 2.2).. controls (6.8, 2.4) and (6.4, 2.7) .. (5.9, 3.1).. controls (5.7, 3.2) and (5.5, 3.4) .. (5.4, 3.5).. controls (5.1, 3.7) and (5.0, 3.9) .. (4.8, 4.1).. controls (4.7, 4.2) and (4.5, 4.4) .. (4.4, 4.5).. controls (4.2, 4.7) and (4.1, 4.8) .. (4.1, 4.8).. controls (4.1, 4.8) and (4.1, 4.9) .. (4.0, 4.9).. controls (4.0, 5.0) and (3.9, 5.1) .. (3.9, 5.1).. controls (3.8, 5.2) and (3.8, 5.3) .. (3.7, 5.3).. controls (3.7, 5.4) and (3.6, 5.4) .. (3.6, 5.5).. controls (3.6, 5.5) and (3.5, 5.6) .. (3.5, 5.7).. controls (3.3, 5.8) and (3.2, 5.9) .. (3.2, 6.0).. controls (3.1, 6.1) and (3.1, 6.1) .. (3.1, 6.2).. controls (3.0, 6.3) and (3.0, 6.3) .. (2.9, 6.4).. controls (2.9, 6.5) and (2.8, 6.5) .. (2.8, 6.6).. controls (2.8, 6.6) and (2.7, 6.7) .. (2.7, 6.7).. controls (2.7, 6.8) and (2.6, 6.8) .. (2.6, 6.9).. controls (2.5, 6.9) and (2.5, 7.0) .. (2.4, 7.1).. controls (2.4, 7.1) and (2.3, 7.2) .. (2.3, 7.3).. controls (2.3, 7.3) and (2.2, 7.4) .. (2.2, 7.4).. controls (2.2, 7.5) and (2.1, 7.5) .. (2.1, 7.5).. controls (2.1, 7.5) and (2.1, 7.6) .. (2.0, 7.7).. controls (2.0, 7.7) and (1.9, 7.9) .. (1.9, 7.9).. controls (1.8, 8.0) and (1.7, 8.2) .. (1.7, 8.2).. controls (1.7, 8.3) and (1.7, 8.4) .. (1.6, 8.5).. controls (1.6, 8.5) and (1.6, 8.7) .. (1.5, 8.8).. controls (1.5, 8.9) and (1.5, 9.0) .. (1.5, 9.1).. controls (1.4, 9.1) and (1.4, 9.3) .. (1.4, 9.4).. controls (1.4, 9.6) and (1.3, 9.8) .. (1.3, 9.9).. controls (1.2, 10.2) and (1.2, 11.6) .. (1.3, 12.2).. controls (1.3, 12.3) and (1.4, 12.6) .. (1.4, 12.8).. controls (1.4, 13.3) and (1.4, 13.5) .. (1.5, 13.7).. controls (1.5, 13.8) and (1.5, 14.0) .. (1.6, 14.1).. controls (1.6, 14.3) and (1.6, 14.4) .. (1.6, 14.5).. controls (1.7, 14.5) and (1.7, 14.6) .. (1.7, 14.7).. controls (1.8, 14.9) and (2.0, 15.3) .. (2.1, 15.5).. controls (2.2, 15.6) and (2.7, 16.2) .. (2.8, 16.3).. controls (2.8, 16.3) and (2.9, 16.4) .. (3.0, 16.5).. controls (3.2, 16.7) and (3.5, 17.0) .. (3.9, 17.3).. controls (4.0, 17.4) and (4.1, 17.5) .. (4.1, 17.5).. controls (4.2, 17.6) and (5.0, 18.3) .. (5.2, 18.5).. controls (5.2, 18.5) and (5.3, 18.6) .. (5.4, 18.6).. controls (5.6, 18.8) and (5.9, 19.0) .. (6.0, 19.0).. controls (6.0, 19.0) and (6.0, 19.1) .. (6.1, 19.1).. controls (6.1, 19.1) and (6.2, 19.2) .. (6.2, 19.2).. controls (6.2, 19.2) and (6.3, 19.2) .. (6.3, 19.2).. controls (6.4, 19.3) and (6.5, 19.3) .. (6.5, 19.3).. controls (6.6, 19.3) and (6.6, 19.4) .. (6.7, 19.4).. controls (6.7, 19.4) and (6.8, 19.5) .. (6.9, 19.5).. controls (6.9, 19.5) and (7.0, 19.5) .. (7.1, 19.6).. controls (7.2, 19.6) and (7.3, 19.6) .. (7.3, 19.7).. controls (7.4, 19.7) and (7.5, 19.7) .. (7.6, 19.7).. controls (7.7, 19.8) and (7.8, 19.8) .. (7.9, 19.8).. controls (8.0, 19.8) and (8.1, 19.9) .. (8.2, 19.9).. controls (8.5, 20.0) and (9.7, 20.0) .. (10.4, 20.0) -- cycle; \end{tikzpicture} \end{document} which give me a filled area, but not a path. I would prefer a path with the same line width in my actual case. Here below is the original blurry image: Says that I want a closed and smooth path, any suggestion on the process above? Edited: I try with Gemini-3.5-Flash with the following prompt: Identify the path and return to me a smooth TikZ Bezier closed curve. Which give the code: \documentclass[tikz,border=10pt]{standalone} \begin{document} \begin{tikzpicture} \draw [ line width=1.5pt, color=black!80, line cap=round, line join=round ] (0.2, 2.2) .. controls (1.0, 2.2) and (1.5, 1.9) .. (1.8, 1.3) .. controls (2.1, 0.7) and (2.2, -0.2) .. (1.9, -0.9) .. controls (1.6, -1.6) and (0.9, -2.1) .. (0.0, -2.1) .. controls (-0.9, -2.1) and (-1.6, -1.7) .. (-2.0, -0.9) .. controls (-2.4, -0.1) and (-2.4, 0.8) .. (-1.8, 1.5) .. controls (-1.2, 2.2) and (-0.6, 2.2) .. (0.2, 2.2) -- cycle; \end{tikzpicture} \end{document} But the details is NOT what the original image is, and the output code is unstable(due to LLM's randomness limitation): The LLM solution is probably not what I was after here.
- Draw balls in Galton boardby Stephen on May 26, 2026 at 9:06 am
I need to draw some balls at the entrance (and if possible at the bottom) of the Galton board like the following picture: Code: \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture} \def\distance{0.3cm} \def\layer{10} \def\radius{2pt} % draw the nails \foreach \i in {0,...,\layer} { \foreach \j in {0,...,\numexpr\i+1\relax} { \draw ({-\distance*\i/2 + \distance*\j}, {-sqrt(3)*\distance*\i/2}) circle[radius=\radius]; } } % draw the slant board on both sides \draw ({-\layer*\distance/2-sqrt(3)*\radius}, {-sqrt(3)*\distance*\layer/2-\radius}) -- (0,2*\radius) -- +(-4pt,4pt); \draw ({-\layer*\distance/2+\distance*(\layer+1)+sqrt(3)*\radius}, {-sqrt(3)*\distance*\layer/2-\radius}) -- (\distance,2*\radius) -- +(4pt,4pt); % draw the separator plates \foreach \i in {0,...,\numexpr\layer+1\relax} { \draw ({-\layer*\distance/2 + \i*\distance}, {-sqrt(3)*\layer*\distance/2 - \radius}) -- ++ (0,-0.5cm); } % draw the bottom line \draw ({-\layer*\distance/2},{-sqrt(3)*\layer*\distance/2 - \radius - 0.5cm}) -- ++ ({(\layer+1)*\distance},0); % number the separated areas \foreach \i in {0,...,\numexpr\layer\relax} { \node at ({-\layer*\distance/2 + \distance*(\i+0.5)},{-sqrt(3)*\layer*\distance/2 - \radius - 0.7cm}) {\footnotesize\i}; } \end{tikzpicture} \end{document}
- How to make 3D axes pass above/below a surface in pgfplotsby UnknownW on May 25, 2026 at 11:54 pm
I am trying to draw a 3D graph that looks like the attached picture. However, I cannot make the axes behave in the same way. In the picture, some intervals of the axes appear on top of the surface, while on other intervals the surface appears above the axes. I would also like the axis labels to stay outside the arrow tips. What I have tried so far is shown below, together with the attached picture. I would like a solution that works for arbitrary functions, not only for this particular example. \documentclass[tikz,border=5pt]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ view={45}{20}, axis lines=center, %axis on top, axis line style={-latex}, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}, ticks=none, xmin=-5, xmax=5, ymin=-5, ymax=5, zmin=-4, zmax=4, width=7cm, height=7cm, colormap/jet, declare function={ f(\x,\y)=10*\y/((\x^2 + 1)*(\y^2 + 2*\y + 4)); }, ] \addplot3[ surf, opacity=0.6, faceted color=black!80, samples=60, samples y=60, domain=-4:4, y domain=-4:4, line width=0.01pt, ] (({x},{y},{f(x,y)}); \end{axis} \end{tikzpicture} \end{document}
- Help sketching the polarity of HCl, H₂O, and CO₂ in LaTeXby Abdelhalim AANIBA on May 24, 2026 at 3:25 pm
I’m trying to create professional-looking molecular polarity diagrams in LaTeX (using TikZ or chemfig if possible). I need help sketching the partial charges cloud distribution for the following molecules: HCl H₂O CO₂ Moved from a non-answer (it's no solution, just problem description), and adding missing lines to make the posted code compile by MS-SPO this is so far my code, but I don't know how to connect all the clouds to give me a similar figure like the image \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} % Source - https://tex.stackexchange.com/a/763072 % Posted by Abdelhalim AANIBA, modified by community. See post 'Timeline' for change history % Retrieved 2026-05-25, License - CC BY-SA 4.0 \begin{tikzpicture}[scale=1.5] % Couleurs pour les nuages de charges \definecolor{negColor}{RGB}{255,100,100} % Rouge pour δ- \definecolor{posColor}{RGB}{100,100,255} % Bleu pour δ+ % Atomes \node[draw, circle, minimum size=0.6cm, fill=gray!30] (O) at (0,0) {O}; \node[draw, circle, minimum size=0.5cm, fill=gray!20] (H1) at (-0.8,-0.6) {H}; \node[draw, circle, minimum size=0.5cm, fill=gray!20] (H2) at (0.8,-0.6) {H}; % Liaisons \draw[thick] (O) -- (H1); \draw[thick] (O) -- (H2); % ===== NUAGE DE CHARGE NÉGATIVE (δ-) autour de l'oxygène ===== % Utilisation d'un shading radial pour un dégradé continu du centre vers l'extérieur \shade[inner color=negColor, outer color=negColor!10, opacity=0.3] (O) circle (0.8cm); % ===== NUAGES DE CHARGE POSITIVE (δ+) autour des hydrogènes ===== \shade[inner color=posColor, outer color=posColor!10, opacity=0.3] (H1) circle (0.5cm); \shade[inner color=posColor, outer color=posColor!10, opacity=0.3] (H2) circle (0.5cm); % Petits symboles δ- et δ+ (optionnels, très discrets) \node[red] at ($(O)+(0.08,1)$) {$2\delta^-$}; \node[blue] at ($(H1)+(0.05,-0.7)$) {$\delta^+$}; \node[blue] at ($(H2)+(0.05,-0.7)$) {$\delta^+$}; \end{tikzpicture} \end{document}
- White halo around black & transparent image in tikzby aky-her on May 24, 2026 at 12:36 pm
I have a png image that contains pure black crosshatching and the rest is fully transparent. I added that to a tikz image, but against a black background, a fine white line is added (see the picture) around the edges of the hatching. Why is the white line there and how can I get rid of it? Is this an issue with the image or with how I am using tikz? edit: here is a link to the file: https://limewire.com/d/47cga#KK6HtC3jAV (I am using an external file sharing site, because pasting the file here as an image actually removed the issue. My problem is solved, but I still don't know what was wrong or how to fix this outside of making an SO question, pasting the image there, downloading a second copy and discarding the question without posting it. At least this confirms that the issue was with the image.) Edit: I am using the default Ubuntu Document Viewer. I also tried several free online pdf viewers, all had the same issue. Here is my code: \documentclass{article} \usepackage[paperheight=8cm, paperwidth=6cm, left=0pt, top=0pt, right=0pt, bottom=0pt]{geometry} \usepackage{tikz} \begin{document} \begin{tikzpicture}[remember picture, overlay, shift = {(current page.south west)}] \node at (current page.center) [] {\includegraphics[height=\paperheight]{example-image-a.png}}; \node at (current page.center) [] {\includegraphics[height=\paperheight, width=\paperwidth]{ims/border_pure_black.png}}; \end{tikzpicture} \end{document}
- Sequence of functions: easing packageby Sebastiano on May 23, 2026 at 8:20 pm
I was trying to understand how the easing package works and whether it can be useful for plotting a sequence of functions in order to study uniform convergence. I am not sure whether the package only allows plotting a set of predefined functions, or whether it also enables the representation of arbitrary sequences of functions. In particular, I would like to know whether there is a way to use this package (or other similar LaTeX packages) to effectively visualize any sequence of functions. If there is a more suitable tool, I would appreciate it if you could suggest it. Additionally I not understand the reason of a ugly graph for $n=1, 2$. Here an example: \documentclass{article} \usepackage{pgfplots} \usepgflibrary{easing} \pgfplotsset{compat=1.18} \begin{document} \begin{center} \begin{tikzpicture} \begin{axis}[ width=12cm, height=7cm, domain=0:1, axis equal image, samples=300, xmin=0, xmax=1, ymin=0, ymax=1.05, axis lines=left, xlabel={$x$}, ylabel={$x^n$}, legend pos=north west, thick ] \pgfkeys{/easing/pow/exponent=1} \addplot[blue] {poweasein(0,1,x)}; \addlegendentry{$n=1$} \pgfkeys{/easing/pow/exponent=2} \addplot[red] {poweasein(0,1,x)}; \addlegendentry{$n=2$} \pgfkeys{/easing/pow/exponent=4} \addplot[green!60!black] {poweasein(0,1,x)}; \addlegendentry{$n=4$} \pgfkeys{/easing/pow/exponent=8} \addplot[orange] {poweasein(0,1,x)}; \addlegendentry{$n=8$} \addplot[black, dotted] { (x==1 ? 1 : 0) }; \addlegendentry{$\lim f_n$} \end{axis} \end{tikzpicture} \end{center} \end{document}
- How can I automatically align circuitikz voltage labels with rotated bipoles?by Evelyn Walker on May 23, 2026 at 5:40 am
I am drawing a large electrical schematic using circuitikz and noticed that voltage labels attached to rotated bipoles are not always visually aligned with the component orientation. For example, in the following code: \documentclass{article} \usepackage[american]{circuitikz} \begin{document} \begin{circuitikz} \draw (0,0) to[R, v=$v_R$] (4,0) to[V, rotate=90, v=$v_s$] (4,4); \end{circuitikz} \end{document} the voltage label orientation and positioning seem inconsistent once the bipole is rotated. I would like the labels to: automatically follow the component rotation, preserve readable text orientation, and maintain consistent spacing relative to the symbol. Is there a recommended way to redefine the voltage label placement behavior globally for rotated bipoles in circuitikz?
- How to extend the decoration path with multiple arrows?by Explorer on May 22, 2026 at 2:05 pm
What I want is the arrow path patterns as below, but not only work for straight line, but ployline, curve, as path style/decoration: \documentclass[tikz,border=6pt]{standalone} \begin{document} \begin{tikzpicture} \foreach \i in {1,...,5} \draw[-latex,shorten >=2pt, shorten <=2pt] (\i,0) -- ({\i+1},0); \end{tikzpicture} \begin{tikzpicture} \draw[-latex,shorten >=2pt, shorten <=2pt] (0.5,0) -- (1,0); \foreach \i in {1,...,5} \draw[-latex,shorten >=2pt, shorten <=2pt] (\i,0) -- ({\i+1},0); \node[text width=5.5cm,align=left,anchor=north] at (3,-.25) {If the length is not exactly N cm, then I hope the starting point could be shortened. For instance, the 5.5cm here, I want the first arrow to start at 0.5cm, then follows five 1cm arrows.}; \end{tikzpicture} \end{document} I don't think the following is the same as my case: Draw consecutive arrows with TikZ Generating Multiple Arrow Decorations in Series Here below is my attempt with decoration, but not what I want: \documentclass[tikz,border=6pt]{standalone} \usetikzlibrary{decorations.markings,arrows.meta} \tikzset{ multiarrow/.style={ decoration={ markings, mark=between positions 0.1 and 0.9 step 0.2 with { \draw[-Stealth,shorten >=1pt, shorten <=1pt] (-10pt,0) -- (10pt,0); % the gap here not what I want... and hard to control the `0.1 and 0.9 step 0.2' } }, postaction=decorate } } \begin{document} \begin{tikzpicture} \path[multiarrow] (-2,-3) -- (2,-3); % good! \path[multiarrow,yshift=-1cm] (-2,-3) -- (2,-3)-- (5,-2); % not good! % \draw[multiarrow] plot[ % domain=-5:5, % samples=160, % smooth, % variable=\x % ] ({\x},{sin(\x r)}) % -- (5,-2) % -- (-5,-2) % -- cycle; \end{tikzpicture} \end{document} I want every arrow to be, says, fixed, 1cm length, shorten 1pt of both sides, for example of the closed path, I want something as below: (Quite sure that may be duplicated post, but I can't find that...) More information of the original purpose: \documentclass[tikz,border=5pt]{standalone} \usepackage{fourier} \usetikzlibrary{bending,decorations.pathmorphing} \begin{document} \begin{tikzpicture}[>=latex,line join=round,line cap=round] \draw[semithick,->] (0,0) -- (-1,0) node[below] {$y$}; \draw[semithick,->] (0,0) -- (0,-3) node[right] {$x$}; \draw[thick] (-110:2.5) -- node[left=5pt] {$q$} (0,0) node[above] {$O$} -- node[right=5pt] {$q$} (-70:2.5); \def\tmp{\fpeval{2.5*sind(20)}} \draw[thick, decorate, decoration={random steps, segment length=1pt, amplitude=.75pt}] (-110:2.5) arc[start angle=-110, end angle=-70, radius=2.5]; \foreach \i in {1,...,5}{ \draw[->,shorten <=1.5pt] (-.1,0) ++(-110:{(\i-1)*0.5}) -- ++(-110:0.5); \draw[->,shorten <=1.5pt] (+.1,0) ++(-70:{(\i-1)*0.5}) -- ++(-70:0.5); } \end{tikzpicture} \end{document} I use the code above to plot the following: I found that quite difficult to decide the (-.1,0) and ++(-110:{(\i-1)*0.5}) -- ++(-110:0.5) here, I want "extend the decoration path with multiple arrows" and put it together with the offset trick...
- Is that possible to extend the path pattern decoration solution with `nfold` and `offset`?by Explorer on May 21, 2026 at 5:18 pm
This post is partly the follow-up of my previous question and the samcarter's excellent answer based on the "wheel". However, I came across a more easy solution with nfolds and offset here. Unfortunely, I found it only work with closed path, but not an open one: % Source - https://tex.stackexchange.com/a/738063 \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{patterns,nfold} \makeatletter \tikzset{ remove inside/.code={% \tikzset{even odd rule}% \tikz@addmode{\pgfsyssoftpath@getcurrentpath\tikz@temp \pgfoffsetpath\tikz@temp{#1}}}} \makeatother \tikzset{ EDR/.style ={ line width=+1pt, preaction={remove inside=#13mm, fill=white},%<-add `fill=white' as preaction preaction={remove inside=#13mm, pattern=north west lines, pattern color=black!75} } } \begin{document} \begin{tikzpicture} \draw[thick,teal] (0,0) -- (10,4); \draw[EDR] (1,0) -- (4.5,1.5) -- (4,4) -- (1,3.5) -- (2.5,2) -- cycle; \draw[magenta,EDR=-] (5,0) rectangle (9,4) ; \draw[cyan,EDR] (6,1) rectangle (8,3); \end{tikzpicture} \begin{tikzpicture} \draw[EDR] (-3,0) -- (-1,0) -- (-1,2) -- (1,2) -- (1,0) -- (3,0); \draw[thick,teal] (-3,1) -- (3,1); \end{tikzpicture} \end{document} which gives: I wonder whether any extension could be added with the thought of nfold and \pgfoffsetpath?
- How to avoid code duplication in path along with patterns?by Explorer on May 21, 2026 at 1:06 pm
Here below is my original code: \documentclass[tikz,border=5pt]{standalone} \usepackage{fourier} \usetikzlibrary{bending,patterns.meta,angles,quotes} \begin{document} \begin{tikzpicture}[>=latex] \draw[thick,->] (0,0) -- (10,0) node[below] {$x$}; \draw[thick,->] (0,0) -- (0,-3) node[right] {$y$}; \draw[ultra thick] (7,2) -- (7,0) coordinate (A) -- (8,0) -- (8,-4) -- (7,-4) coordinate (B) -- (7,-6); %%%%%%%%%%%%%%%% path coordinate duplicated \fill[pattern={Lines[angle=-45,distance={5pt}]},preaction={fill=white}] (7,2) -- (7,0) -- (8,0) -- (8,-4) -- (7,-4) -- (7,-6) -- ++(.5,0) -- ++(0,+1.5) -- ++(1,0) -- ++(0,+5) -- ++(-1,0) -- ++(0,1.5) -- cycle; %%%%%%%%%%%%%%%% \draw(0,0) node[label={[label distance=-2.5mm]above left:$O$}] (O) {} -- (7,-4) pic[draw,<->,angle radius=2cm,angle eccentricity=1.15,"$\alpha$"] {angle = B--O--A}; \end{tikzpicture} \end{document} which gives: However, the path: (7,2) -- (7,0) -- (8,0) -- (8,-4) -- (7,-4) -- (7,-6) appeared twice, and I think that is duplicated. How to avoid and make the code more neater?
- Background picture for part pageby Martin on May 20, 2026 at 9:07 pm
I want to add a background picture for the page(s) that get created for using the \part command. But when I do this, the picture instead goes to the next side and not to the part page. How can I get the picture to the correct page? MWE: \documentclass{report} \usepackage{tikz} \usepackage[newparttoc]{titlesec} \usepackage{titletoc} \usepackage{tocloft} \titleformat{\part}[display]{\Huge\scshape\filright\centering}{}{20pt}{\thispagestyle{empty}} \titlecontents{part}[0pt]{\addvspace{2pc}\centering\large\bfseries}{}{}{} \begin{document} \part{A}\tikz[remember picture, overlay] \node[opacity=0.3, inner sep=0pt] at (current page.center){\includegraphics[width=\paperwidth, height=\paperheight]{example-image-a}}; \part{B}\tikz[remember picture, overlay] \node[opacity=0.3, inner sep=0pt] at (current page.center){\includegraphics[width=\paperwidth, height=\paperheight]{example-image-b}}; \end{document}
- Having an Elliptical Frame Go Around the Elliptical Image (on the Outside)by DDS on May 18, 2026 at 8:56 pm
Consider the code: \documentclass{book} \usepackage{graphicx} \usepackage{tikz} %\definecolor{cadmiumgreen}{rgb}{0.0, 0.42, 0.235} \definecolor{Gold}{RGB}{228,168,73} \begin{document} \thispagestyle{empty} \begin{center} \begin{tikzpicture} \clip (0,0) ellipse[x radius=4.25cm, y radius=5.5cm]; %\fill[cadmiumgreen] ellipse[x radius=4.25cm, y radius=5.5cm]; \node at (0,0) {\includegraphics[scale=1.31,clip, trim = 0 0 0 0]{example-image-a}}; \draw[line width=12pt,Gold!75!black] (225:4.25cm and 5.5cm) arc[start angle=225, end angle=-45, x radius=4.25cm, y radius=5.5cm]; \end{tikzpicture} \end{center} \end{document} with the output: QUESTION: How may I get the from to go around the ellipse on the outside? (In other words, I don't want any part of the interior of the elliptical image to be covered by the frame.) Thank you.
- expl3 syntax in pgfdeclaredataformat commandby tkl on May 13, 2026 at 5:06 pm
Is it possible to use expl3 syntax, specifically floating point operations, within a pgfdeclaredataformat command? Below is a minimal example, indeed with a workaround solution. Comment out the doesnotwork lines to get an error. Actual computations are different and involve a small Newton solver. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{datavisualization} \begin{document} \ExplSyntaxOn \def\tologarithmic#1#2{ % 0.43429 = 1/ln(10) \pgfkeys{/data~point/x=\fp_to_decimal:n{0.43429*ln(#1)}} \fp_log:n {0.43429*ln(#1)}% to see in the log file, that the calculation actually works! \pgfkeyssetvalue{/data~point/y}{\fp_to_decimal:n{0.43429*ln(#2)}} \pgfdatapoint } \ExplSyntaxOff \pgfdeclaredataformat{compute}{}{} {#1 #2}% line format {\tologarithmic{#1}{#2}}% code {}{} %\def\doesnotwork{% \begin{tikzpicture} \datavisualization[scientific axes, visualize as scatter, x axis=logarithmic, y axis=logarithmic ] data[format=compute,set=scatter] { 2.868E+03 2.804E-02 5.636E+04 2.061E-02 1.791E+06 1.079E-02 3.554E+07 7.080E-03 }; \end{tikzpicture} %}% end doesnotwork % the workaround solution \begin{tikzpicture} \datavisualization[scientific axes, visualize as scatter ] data[format=TeX code,set=scatter] { \tologarithmic{2.868E+03}{2.804E-02} \tologarithmic{5.636E+04}{2.061E-02} \tologarithmic{1.791E+06}{1.079E-02} \tologarithmic{3.554E+07}{7.080E-03} }; \end{tikzpicture} % that is how the graph should look like \begin{tikzpicture} \datavisualization[scientific axes, visualize as scatter, x axis=logarithmic, y axis=logarithmic ] data[set=scatter,separator=\space] { x y 2.868E+03 2.804E-02 5.636E+04 2.061E-02 1.791E+06 1.079E-02 3.554E+07 7.080E-03 }; \end{tikzpicture} \end{document}
- Is it possible to embed a slider-controlled interactive TikZ graph inside a PDF?by Abdellah Kahlaoui on May 3, 2026 at 11:30 am
I am currently writing a report on the Traveling Salesman Problem (TSP), and I would like to include an interactive visualization directly in my final PDF. My goal is to have a slider (or a set of buttons) that allows the reader to change the number of vertices $n$ (e.g., from 3 to 6). When the slider is moved, I want the PDF to dynamically update: A TikZ drawing of a complete graph $K_n$. A text node displaying the calculated number of edges: $|E| = \frac{n(n-1)}{2}$. I have looked into packages like animate, media9, and the possibility of embedding JavaScript via insdljs, but I am unsure which approach is the most modern, robust, and compatible with standard PDF readers (like Adobe Acrobat or web-based viewers). Here is a static Minimum Working Example (MWE) of the graph I am trying to make dynamic: \documentclass{article} \usepackage{tikz} \begin{document} % I want 'n' to be controlled by a slider in the PDF \def\n{5} \begin{center} \begin{tikzpicture}[scale=0.8] % Draw edges \foreach \i in {1,...,\n} { \foreach \j in {1,...,\n} { \ifnum\i<\j \draw[blue!40, line width=0.5pt] ({90+(\i-1)*360/\n}:1.5cm) -- ({90+(\j-1)*360/\n}:1.5cm); \fi } } % Draw vertices \foreach \i in {1,...,\n} { \node[circle, fill=blue, draw=white, inner sep=2pt, label={[font=\tiny, color=blue]{90+(\i-1)*360/\n}:$v_{\i}$}] at ({90+(\i-1)*360/\n}:1.5cm) {}; } \end{tikzpicture} \vspace{0.5cm} % I want this text to update when the slider moves Number of vertices: $n = \n$ \\ Number of edges: $|E| = \pgfmathparse{\n*(\n-1)/2}\pgfmathprintnumber{\pgfmathresult}$ \end{center} \end{document} Is there a pure LaTeX/TikZ way (perhaps with animate) to step through these values using interactive buttons?
- How come when filling in TikZ, there is a visible gap between adjacent fills?by Jasper on November 12, 2025 at 1:00 am
How come when filling in TikZ, there is a visible gap between adjacent fills? \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \fill (0,0) -- (1,1) -- (1,0) -- cycle; \fill (0,0) -- (1,1) -- (0,1) -- cycle; \end{tikzpicture} \end{document}
- How can I turn this 2d animation of a polygon into a 3d one?by xJ8v4KtZr2 on January 15, 2025 at 8:09 pm
I have the following code, which does a decent job of demonstrating an algorithm I want to present: It starts with an arbitrary convex polygon, then does a "binary search" of sorts to slowly zero in on the target. My goal is to make this polygon (and the animation) more 3d. That is, can I draw a more 3d looking convex polytope and, instead of a line cutting the 2d polygon into two pieces, I want a plane slicing the 3d polytope into two pieces (and continuing for a few iterations, like the current animation). I'd really appreciate any help on this! Thanks so much! \documentclass[ tikz,crop, border={0pt 0pt 0pt 5pt} % left bottom right top ]{standalone} \usepackage{pgfplots} \usetikzlibrary{tikzmark,arrows,shapes, arrows.meta, calc,decorations.pathmorphing,decorations.pathreplacing, decorations.markings, patterns,bending,backgrounds,positioning} \usetikzlibrary{pgfplots.colorbrewer} \pgfplotsset{ compat=newest, colormap/RdBu-9, colormap/PuBu-9, } \usepackage{amsmath} \usepackage{amssymb} \usepgfplotslibrary{colorbrewer} % L \usepackage{newpxtext} \usepackage{fontawesome5} \def\bendamtA{24} \def\bendamtB{12} \def\bendamtC{6} \def\colorA{red} \def\colorB{blue} \def\colorC{black} \begin{document} \def\verbose{0} \foreach \slideNumber in {0,10,20,30,40,50,60, 70, 80, 90, 100}{% \begin{tikzpicture}[ polygon/.style={fill=blue!45!white, draw=black, thick}, degree/.style={ultra thick}, vertices/.style={circle, radius=0.01cm,fill=white, inner sep=0,opacity=0.1}, perpendicular/.style={dashed, thick,->}, halfspace/.style={black, ultra thick, dotted}, queryS/.style={regular polygon sides=3, scale=.5, fill=pink}, vertHalf/.style={circle, radius=0.1mm,fill=red,inner sep=0, opacity=0.1}, ] % Define all coordinates \coordinate (B) at (2, 4.75); \coordinate (C) at (3.75, 2.75); \coordinate (D) at (3.75, -0.2); \coordinate (E) at (0, -2.5); \coordinate (G) at (-3.5, -0.5); \coordinate (H) at (-4, 2.35); \coordinate (J) at (-1.75, 4.75); \coordinate (HfSpace1B) at ($(B)!.3!(J) $); \coordinate (HfSpace1E) at ($ (D)!.3!(E) $); \coordinate (query1) at ($ (HfSpace1B)!.3!(HfSpace1E) $); \coordinate (HfSpace2B) at ($(H)!.5!(G) $); \coordinate (HfSpace2E) at ($ (HfSpace1B)!.45!(HfSpace1E) $); \coordinate (query2) at ($ (HfSpace2B)!.4!(HfSpace2E) $); \coordinate (HfSpace3B) at ($(G)!.5!(E) $); \coordinate (HfSpace3E) at ($ (HfSpace2B)!.40!(HfSpace2E) $); \coordinate (query3) at ($ (HfSpace3B)!.4!(HfSpace3E) $); \coordinate (HfSpace4E) at ($(HfSpace3E)!.35!(HfSpace2E)$); \coordinate (HfSpace4B) at ($(HfSpace1E)!.25!(E)$); \coordinate (query4) at ($(HfSpace4E)!.7!(HfSpace4B)$); \coordinate (HfSpace5E) at ($(HfSpace3B)!.3!(HfSpace3E)$); \coordinate (HfSpace5B) at ($(HfSpace4B)!.4!(HfSpace4E)$); \coordinate (query5) at ($(HfSpace5E)!.5!(HfSpace5B)$); \coordinate (Min) at (0, 0); % Conditional block for labeling \ifnum\verbose=1 \node[vertices] at (B) {B}; \node[vertices] at (C) {C}; \node[vertices] at (D) {D}; \node[vertices] at (E) {E}; \node[vertices] at (G) {G}; \node[vertices] at (H) {H}; \node[vertices] at (J) {J}; \node[vertHalf, radius=0.1cm] at (HfSpace1B) {1B}; \node[vertHalf, radius=0.1cm] at (HfSpace1E) {1E}; \node[vertHalf, radius=0.1cm] at (HfSpace2B) {2B}; \node[vertHalf, radius=0.1cm] at (HfSpace2E) {2E}; \node[vertHalf, radius=0.1cm] at (HfSpace3B) {3B}; \node[vertHalf, radius=0.1cm] at (HfSpace3E) {3E}; \fi \ifnum\slideNumber=0 % Draw the convex polygon using named coordinates \draw[polygon] (B) -- (C) -- (D) -- (E) -- (G) -- (H) -- (J) -- cycle; \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifnum\slideNumber=10 \draw[polygon] (B) -- (C) -- (D) -- (E) -- (G) -- (H) -- (J) -- cycle; \node[queryS]at (query1) {}; \draw[perpendicular] (query1) -- ++(196:1cm); \draw [halfspace] (HfSpace1B) -- (HfSpace1E); \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifnum\slideNumber=20 \draw[polygon] (J) -- (HfSpace1B) -- (HfSpace1E) -- (E) -- (G) -- (H) -- cycle; \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifnum\slideNumber=30 \draw[polygon] (J) -- (HfSpace1B) -- (HfSpace1E) -- (E) -- (G) -- (H) -- cycle; \node[queryS]at (query2) {}; \draw[perpendicular] (query2) -- ++(282:1cm); \draw [halfspace] (HfSpace2B) -- (HfSpace2E); \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifnum\slideNumber=40 \draw[polygon] (HfSpace2B) -- (HfSpace2E) -- (HfSpace1E) -- (E) -- (G) -- cycle; \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifnum\slideNumber=50 \draw[polygon] (HfSpace2B) -- (HfSpace2E) -- (HfSpace1E) -- (E) -- (G) -- cycle; \node[queryS]at (query3) {}; \draw[perpendicular] (query3) -- ++(-3:1cm); \draw [halfspace] (HfSpace3B) -- (HfSpace3E); \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifnum\slideNumber=60 \draw[polygon] (HfSpace2E) -- (HfSpace1E) -- (E) -- (HfSpace3B) -- (HfSpace3E) -- cycle; \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifnum\slideNumber=70 \draw[polygon] (HfSpace2E) -- (HfSpace1E) -- (E) -- (HfSpace3B) -- (HfSpace3E) -- cycle; \node[queryS]at (query4) {}; \draw[perpendicular] (query4) -- ++(219:1cm); \draw [halfspace] (HfSpace4B) -- (HfSpace4E); \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifnum\slideNumber=80 \draw[polygon] (HfSpace4E) -- (HfSpace4B) -- (E) -- (HfSpace3B) -- (HfSpace3E) -- cycle; \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifnum\slideNumber=90 \draw[polygon] (HfSpace4E) -- (HfSpace4B) -- (E) -- (HfSpace3B) -- (HfSpace3E) -- cycle; \node[queryS]at (query5) {}; \draw[perpendicular] (query5) -- ++(102:1cm); \draw [halfspace] (HfSpace5E) -- (HfSpace5B); \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifnum\slideNumber=100 \draw[polygon] (HfSpace4E) -- (HfSpace5B) -- (HfSpace5E) -- (HfSpace3E) -- cycle; \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \node[star, star points=5, star point ratio=2.5, scale= 0.3, fill=black] at (Min) {}; \node at ([yshift=-0.4cm]Min) {\scriptsize target}; \clip (-4.5,-4) rectangle (5,5.5); \end{tikzpicture} } \end{document}
- Create a paraboloid and a right circular cone opening upward, with vertex at the originby Dimitrios ANAGNOSTOU on October 22, 2024 at 10:14 am
I want to create the following figure. Here is my try for the paraboloid. \documentclass[svgnames]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.16} \usepackage{tikz-3dplot} \begin{document} \tdplotsetmaincoords{70}{30} \begin{tikzpicture} \begin{axis} [ scale=1, axis lines=center, axis on top, samples=30, ticks=none, xlabel={$x$}, ylabel={$y$}, zlabel={$z=x^2+y^2$}, domain=-2:2, colormap/violet, ] \addplot3[surf,opacity=0.3,domain=-2:2] {x^2+y^2}; \end{axis} \end{tikzpicture} \end{document} However how can I remove the facets and get the appearance of the attached figure? Here is my code for the cone. \documentclass[svgnames]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.16} \usepackage{tikz-3dplot} \begin{document} \tdplotsetmaincoords{70}{30} \begin{tikzpicture} \begin{axis} [ scale=1, axis lines=center, axis on top, ticks=none, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}, samples=30, domain=0:2*pi, y domain=0:2, zmax=2, % z buffer=sort, colormap/violet, ] % Cone surface plot \addplot3[surf, opacity=0.5] ({y*cos(deg(x))}, {y*sin(deg(x))}, {y}); % Parametric equation of the cone \end{axis} \end{tikzpicture} \end{document} The same question here as well.
- Vertical spacing in beamer classby wrb98 on September 1, 2024 at 6:32 pm
\documentclass{beamer} \usepackage{tikz} \setlength\lineskip{0pt} \setlength\baselineskip{0pt} \setlength\parskip{0pt} \setlength\parindent{0pt} \setlength{\vskip}{0pt} % This line ensures that vertical skips are removed \setlength{\abovedisplayshortskip}{0pt} \setlength{\belowdisplayshortskip}{0pt} \setlength{\abovedisplayskip}{0pt} \setlength{\belowdisplayskip}{0pt} \setbeamertemplate{navigation symbols}{} \begin{document} \begin{frame}[t] {\bf\color{blue}Title 1} {\bf\color{blue}Title 2} \makebox[\textwidth][c]{ \begin{tikzpicture}[remember picture,every node/.style={inner sep=0pt,outer sep=0pt}] % Faded rectangle \fill[blue] (0,0) rectangle (\paperwidth,3em); % Opaque text \node[anchor=west] at (1cm,1.5em) {\color{red}\bfseries\huge Title 3}; \end{tikzpicture} } \color{red}\Large\textbf{Title 4} \end{frame} I am working with the above code and would like to have more control over the vertical spacing between lines and objects in beamer. In particular, how would I reduce the vertical spacing between two lines (e.g. between Title 1 and Title 2) and between the blue banner and Title 4 to be 0? This seems to already be the case between Title 2 and the blue banner, but I haven't been able to get it consistent for the other lines. Any help is appreciated, as always.
- Diagnosing Standalone and Gensymb conflictby Altissimo on January 9, 2024 at 5:52 pm
Disclaimer: I am new-ish to LaTeX, and self-taught. I am trying to make a "Unit Circle" TikZ graphic, in which I would like to have the \degree symbol from the gensymb package in the label text of a node. My current workflow involves the standalone package, and uses the \include command to create a sort of "master file" containing each of my creations on its own page which I reference in other Overleaf projects using the 'output file from another project' and the graphicx package to reduce compile time. There is probably a better way to do this, but it keeps it simple enough for me and I like having everything in more or less the same place so I can make quick references between my images. It has worked so far, until now... My problem is, it is preferable if I don't have to update the preamble of my master document every time I add a new picture, especially since that's where I define things like colors which occasionally use identical names (e.g. gradient1). Hence, I load \usepackage[subpreambles]{standalone} to read the preamble of each standalone separately. Again, this has worked well enough so far that I have been able to solve any hiccups myself. I have failed to diagnose why exactly, but there is something going on with the [subpreambles] tag and loading the gensymb package. Here is my MWE: \documentclass[tikz]{standalone} \usepackage{textcomp,gensymb} % for degree symbol \begin{document} \begin{tikzpicture} \node at (0,0) {$0\degree$}; \end{tikzpicture} \end{document} which I have in Overleaf as degree-test.tex. When I try to reference this file in another: \documentclass[tikz]{standalone} \usepackage[subpreambles]{standalone} \begin{document} \include{degree-test} \end{document} I get the error: Package standalone Warning: Sub-preamble of file 'degree-test.tex' has changed. Content will be ignored. Please rerun LaTeX! on input line 4. I compile with LuaLaTeX, but other compilers produce similar results. Even removing \degree from the node label produces the error, despite not actually using the symbol. There must be some kind of conflict with commands which define certain things during the preamble, but I don't know how to read the error logs and they're very frightening on the surface. Is there a simple fix for this? EDIT: I have also disqualified \documentclass[tikz]{standalone} and \include vs \includestandalone as culprits.
- Circled inline letters with minimum size to contain each single letter of the a-z alphabetby Enlico on January 22, 2023 at 5:36 pm
This was a very good starting point for the solution below, which is still not perfect for my usecase. I've tried to adapt it to show 3 circled letters with zero or more intervening letter between the circled ones and zero or more letters right out of the first and third circle. In other words, the desired scheme is that I want to type xOxOxOx, where each O represents a single circled possibly different letter, and each x represents a sequence of zero or more letters. The desired result is something like this (the code is below): What I don't like of this solution is that I had to hardcode a 1.3 multiplicative factor for \f@size. Indeed, if I remove *1.3, the size of the circle around m will be bigger than that of the circles around i and j. The 1.6 in the linked answer seemed a bit too much. Here's the MWE verified on David Carlisle's TeXlive.net: \documentclass{article} \usepackage{tikz} \begin{document} \makeatletter \newcommand\stencil[7]{% \tikz[outer sep=0, inner sep=0, baseline=(A.base), anchor=west]{ \node (A) {\vphantom{Wpm}#1}; \node[shape=circle, draw, minimum height={\f@size*1.3}] (B) at (A.east) {\vphantom{Wpm}#2}; \node (C) at (B.east) {\vphantom{Wpm}#3}; \node[shape=circle, draw, minimum height={\f@size*1.3}] (D) at (C.east) {\vphantom{Wpm}#4}; \node (E) at (D.east) {\vphantom{Wpm}#5}; \node[shape=circle, draw, minimum height={\f@size*1.3}] (F) at (E.east) {\vphantom{Wpm}#6}; \node (G) at (F.east) {\vphantom{Wpm}#7}; }% } \makeatother before\stencil{h}{i}{j}{k}{}{m}{}after beforeh before \stencil{h}{i}{j}{k}{}{m}{} after before h \end{document}
- Fast(er) way of generating stacked 2d-plots in 3dby arc_lupus on June 25, 2021 at 9:14 am
I have quite a lot of 2d-data I would like to display in a 3d-plot, similar to the figure below (drawn in Python): Until now I created those figures in pgfplots with addplot3, but for an increasing amount of data the compilation slows down significantly, until LaTeX runs out of memory. Of course I could create those figures in Python, for example, but with the drawback of either having to re-create the labels and ticks in tikz afterwards to match the font style of the document, or loose the scaling capability totally when keeping them in the figure. Tikzscale is a functionality I do not want to loose, especially after my document can either be two-column or single-column wide, and therefore I would prefer automatic rescaling of the figure. Therefore, are there other (ideally similarly integrated as tikz) options for drawing such plots, but with improved speed?
- \circlearound: Misalign of the circle centerby Candu on April 25, 2019 at 5:58 pm
I am using the following code, which I found here at StackExchange to draw a circle around some letters: \newcommand\circlearound[1]{% \setbox0=\hbox{#1}% \dimen0\wd0% \divide\dimen0 by 2% \begin{tikzpicture}[baseline=(a.base)]% \useasboundingbox (-\the\dimen2,0pt) rectangle (\the\dimen0,1pt); \node[circle,draw,minimum size=1.4em,outer sep=0pt,inner sep=0.2ex] (a) {#1}; \end{tikzpicture} } This works fine for normal letter but there is a misalignment for cursive fonts (italic type). Therefore, I want to define a second command \circlearoundItalic in which I misalign the center of the circle by 0.2em. Does anybody know the TikZ code to move the center of the circle by 0.2em to the right? Thank you!
- Can Gaussian (or similar) blur be applied to Tikz text?by J. C. Salomon on November 12, 2017 at 11:06 pm
I’m trying to emulate in TikZ a title page which I’ve previously drawn in SVG. The image below is from the SVG version, where the shadowed text is achieved using a feGaussianBlur filter. But everything I’ve found regarding filters and shadows and such with TikZ seems not to apply to text. Is there a way to achieve this result? Current code (translated by hand from the SVG and adapted to my book layout): \documentclass[11pt,extrafontsizes]{memoir} \setstocksize{9in}{6in} \settrimmedsize{\stockheight}{\stockwidth}{*} \medievalpage[12] \checkandfixthelayout %\usepackage{fontspec} %\newfontfamily\gingerfont{RM Ginger} %\newcommand*{\ginger}[1]{\gingerfont\fontsize{#1}{#1}\selectfont} \newcommand*{\ginger}[1]{\normalfont\fontsize{#1}{#1}\selectfont} \usepackage{tikz} \usepackage{tikzpagenodes} \usetikzlibrary{calc,positioning,decorations.text} \tikzset{x=1in,y=1in} \begin{document} \thispagestyle{empty} \begin{tikzpicture}[remember picture,overlay,shift={($ (current page.south west) + (0.5, 0.5) $)}] \node at (2.5, 7) [font=\ginger{31.5}, anchor=base] {Unshadowed Text}; \draw[shift={(0, 5.75)}, decorate, decoration={text along path, text align=center, text={|\ginger{40.5}|The Long Title}}] (0, 0) .. controls (1, 0.5) and (1.625, 0.625) .. (2.5, 0.625) .. controls (3.375, 0.625) and (4, 0.5) .. (5, 0); \node at (2.5, 6.125) [font=\ginger{31.5}, anchor=base] {of}; \draw[shift={(0, 5)}, decorate, decoration={text along path, text align=center, text={|\ginger{81}|the Book}}] (0, 0) .. controls (1, 0.5) and (1.625, 0.625) .. (2.5, 0.625) .. controls (3.375, 0.625) and (4, 0.5) .. (5, 0); \node at (2.5, 4.25) [font=\ginger{47.25}, anchor=base] {A. U. Thor}; \node at (2.5, 3) [font=\ginger{31.5}, anchor=base] {More unshadowed text}; \node at (2.5, 2.5) [font=\ginger{27}, anchor=base] {and some more}; \end{tikzpicture} \end{document} What the SVG version looks like:
- Highlight function in minted with background colorby jakun on June 21, 2017 at 12:30 pm
I would like to highlight a function in minted by giving it a background color in order to make the connection to a visualization better visible. I used to put the functions to be highlighted in a separate minted environment and specify a background color for the entire environment (in minted v1.7): % minted 2011/09/17 v1.7 \documentclass{article} \usepackage{minted} \newminted{c}{linenos, tabsize=4, gobble=2} \makeatletter \newenvironment{mintedBlock}{% % I can not use frame=topline|bottomline because that is inside of colored box % copied from /usr/share/texlive/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty line 918 in \def\FV@SingleFrameLine \noindent \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}% }{% \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}% } \makeatother \newcommand{\colorMain}{green!10}% \newcommand{\colorSum}{yellow!20}% \begin{document} \begin{mintedBlock} % I am using old package versions which are buggy, so firstnumber=last gives wrong numbering. \begin{ccode*}{frame=none, bgcolor=white} #include <stdio.h> \end{ccode*} \begin{ccode*}{frame=none, firstnumber=2, bgcolor=white} \end{ccode*} \begin{ccode*}{frame=none, firstnumber=3, bgcolor=\colorSum} int sum(int summand1, int summand2) { return summand1 + summand2; } \end{ccode*} \begin{ccode*}{frame=none, firstnumber=7, bgcolor=white} \end{ccode*} \begin{ccode*}{frame=none, firstnumber=8, bgcolor=\colorMain} int main() { int summand1 = 1; int summand2 = 2; printf("%d + %d = %d\n", summand1, summand2, sum(summand1, summand2)); } \end{ccode*} \end{mintedBlock} \end{document} The spacing of the rules was not perfect but apart from that it was good enough in minted 1.7. However I have recently upgraded to the newest version (minted 2.4.2dev) and now there are big spaces between the seperate minted environments. I have tried to remove them with \renewcommand{\vspace}{\@ifnextchar*\@gobbletwo\@gobble}% which makes it a lot better but still leaves too big spaces. Therefore I have tried it with a new approach: using escapeinside to insert tikz nodes with remember picture and drawing a rectangle around them later on. % minted 2017/02/10 v2.4.2dev \documentclass{article} \usepackage{minted} \newminted{c}{linenos, frame=lines, tabsize=4, gobble=1} \usepackage{tikz} \newcommand{\tikzmark}[1]{\tikz[overlay,remember picture,baseline=(#1.base)] \node (#1) {\vphantom{I}};} \newcommand{\colorMain}{green!10}% \newcommand{\colorSum}{yellow!20}% \begin{document} \begin{ccode*}{breaklines, escapeinside=~~} #include <stdio.h> ~\tikzmark{sumtop}~int sum(int summand1, int summand2) { return summand1 + summand2; ~\tikzmark{sumbottom}~} ~\tikzmark{maintop}~int main() { int summand1 = 1; int summand2 = 2; printf("%d + %d = %d\n", summand1, summand2, sum(summand1, summand2)); ~\tikzmark{mainbottom}~} \end{ccode*} \begin{tikzpicture}[remember picture, overlay] \path[overlay, fill=\colorSum] (sumtop.north) rectangle ([xshift=\linewidth]sumbottom.south); \path[overlay, fill=\colorMain] (maintop.north) rectangle ([xshift=\linewidth]mainbottom.south); \end{tikzpicture} \end{document} Unfortunately the tikz picture is above the minted code. How can I put the tikzpicture behind the text? Also, I am not a hundred percent happy with this approach because I will run into problems if the code happens to move across a pagebreak. Does someone have a better idea?
- How to draw the following pictures?by bing on May 23, 2016 at 2:15 am
I want to draw the following pictures, but I don't know how to draw it. Could anyone help me?
- How to incorporate and scale matplotlib plots in latex using the PGF backend?by Nils_M on September 20, 2013 at 3:09 pm
I am using the pgf backend of matplotlib to generate pgf files which I want to put into my latex document using tikzscale to be able to resize them easily. Example python code: #!/usr/bin/env python # -*- coding: utf-8 -*- import matplotlib as mpl mpl.use('pgf') import numpy as np import matplotlib.pyplot as mplp mpl.rcParams['text.latex.unicode']=True mpl.rcParams['text.usetex']=True mpl.rcParams['pgf.texsystem'] = 'pdflatex' fig = mplp.figure() ax = fig.add_subplot(111) x = np.arange(0,2 * np.pi, .1) data = np.sin(x) fmt = {"lw" : 3, "c" : "r", "ls" : '-'} ax.plot(x, data, label=r"sample data with greek $\mu$", **fmt) ax.set_ylabel(r"sample", rotation=0) ax.legend() fig.set_size_inches(1.41,1.) # fig.savefig('./sample.pgf', dpi=500, bbox_inches='tight') fig.savefig('./sample.pgf', dpi=500) Example latex code: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{tikz} \usepackage{tikzscale} \usepackage{pgfplots} \pgfplotsset{compat=1.8} \newcommand{\includepgf}[4] { \begin{figure} \centering \includegraphics{#1} \includegraphics[width=#2\textwidth, height=#2*0.7071428571428572\textwidth]{#1} \includegraphics[width=#2\textwidth, axisratio=0.7071428571428572]{#1} \caption[]{#4} \label{#3} \end{figure} } \begin{document} \includepgf{sample.pgf}{.9}{fig:sample}{Sample Figure} \end{document} Unfortunately the following happens for the three different \includegraphics commands: Works as expected, includes plot in original size Compiles with Package tikzscale Warning: Scaling of sample.pgf's width was only (tikzscale) accurate to 208.59694pt on input line 27. Package tikzscale Warning: Scaling of sample.pgf's height was only (tikzscale) accurate to 147.29488pt on input line 27. no resizing in final pdf file. Does not compile, gives ! Package tikzscale Error: Requested to scale unscalable graphic.
- Pascal's triangle in tikzby dalibor.zeleny on May 6, 2011 at 12:21 am
I would like to typeset the top part of Pascal's triangle. To get the triangle with the names of the binomial coefficients, i.e., {n \choose k}, I used the following code \begin{tikzpicture} \foreach \n in {0,...,4} { \foreach \k in {0,...,\n} { \node at (\k-\n/2,-\n) {${\n \choose \k}$}; } } \end{tikzpicture} The result is this Now I want to be equally lazy and do something like this for the values of the binomial coefficients, i.e., replace {\n \choose \k} in the node label with \CalculateBinomialCoefficient{\n}{\k} where \CalculateBinomialCoefficient is a hypothetical macro that calculates the binomial coefficient. Has anyone done something like that? The result should look like this: