TikZ
- Aligning labels in multi-panel figuresby NicolasBourbaki on June 16, 2026 at 2:11 pm
I would like to create a multi-panel figure with two subpanels of different width and height. The labels should be placed in the upper left corner of each subpanel with the left margin of the labels aligned to the left margin of the graphic in the corresponding subpanel (and baseline of the letters on the same height just on top ("north") of the highest graphic of the subpanels: My approach in TikZ does not exactly align the left margin of the labels to the left margin in the corresponding subpanel: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} % the files green_ellipse and blue_square are on my disk; any graphics file would do \node[anchor=east, inner sep=0pt] at (0,0){\includegraphics[width=.3\textwidth]{green_ellipse}}; \node[anchor=south east] at (-3.7,1.8) {a}; \node[anchor=west,inner sep=0pt] at (1,0){\includegraphics[width=.6\textwidth]{blue_square}}; \node[anchor=south east] at (1,1.8) {b}; \end{tikzpicture} \end{document} How could the left margins of the labels with the left margins of the graphics in the subpanels and the baseline of the letters just on top ("north") of the highest graphic of the subpanels.
- TikZ move scope to bottom left of a figureby Thomas on June 16, 2026 at 7:42 am
I have a figure to which I add representation of axis. Using scope environment I'm able to scale and move it where I want on the figure. Would it be possible to make it always at a specific position in the figure (for instance bottom left), so if I change the content of the figure by adding other element, the scope would still be placed where I intended. For a node I would use anchor. Here is a MWE: \documentclass{article} \usepackage{tikz} \usetikzlibrary{backgrounds} \begin{document} \begin{tikzpicture}[show background rectangle] \draw[red,fill=yellow] (0,0,0) -- ++(-2,0,0) -- ++(0,-1,0) -- ++(2,0,0) -- cycle; \draw[red,fill=yellow] (0,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle; \draw[red,fill=yellow] (0,0,0) -- ++(-2,0,0) -- ++(0,0,-1) -- ++(2,0,0) -- cycle; \begin{scope}[xshift=-3cm, yshift=-0.56cm, scale=0.4] \draw[->, red] (0,0) -- (0,1) node[anchor=north east] {$x$}; \draw[->, green] (0,0) -- (-1,0) node[anchor=north west] {$y$}; \draw[blue] (0,0) node {$\odot$}; \draw[blue] (0,0) node[anchor=north west] {$z$}; \end{scope} \end{tikzpicture} \end{document} I manually set the xshift and yshift so the arrows are on the bottom part of the figure. (Note: here the scope does enlarge the figure on the left because there is nothing, but in my case where I'm facing this issue, there are other object on the top left part of it)
- How to design station signs for Taiwan Railway in TeX?by mathrm alpha on June 16, 2026 at 4:08 am
Although I wrote a LaTeX-like design for Taiwanese train station signs, the resemblance is still somewhat lacking. https://upload.wikimedia.org/wikipedia/commons/thumb/f/f1/ROC_Taiwan_Railways_Administration_Logo.svg/960px-ROC_Taiwan_Railways_Administration_Logo.svg.png \documentclass{article} \usepackage{xeCJK,amssymb} \usepackage[ paperwidth=5in, paperheight=3in, margin=0.2in ]{geometry} \usepackage{graphicx} \usepackage{tikz} \pagestyle{empty} \begin{document} \begin{tikzpicture}[remember picture,overlay] \node[anchor=north west, xshift=0in, yshift=0in] at (current page.north west) { \includegraphics[width=0.5in,height=0.5in]{960px-ROC_Taiwan_Railways_Administration_Logo.svg.png} }; \end{tikzpicture} \begin{tikzpicture}[remember picture,overlay] \node[align=center, text=black, yshift=0.25in] at (current page.center) { {\fontsize{28pt}{34pt}\selectfont Miaoli} \\[0.2em] {\fontsize{32pt}{38pt}\selectfont 苗栗} }; \end{tikzpicture} \begin{tikzpicture}[remember picture,overlay] \node[ draw, line width=0.8pt, minimum size=0.9in, inner sep=0pt, align=center, font=\fontsize{12pt}{12pt}\selectfont ] at ([xshift=1.25in, yshift=0.25in]current page.center) { 苗栗縣\\ 苗栗市 }; \end{tikzpicture} \begin{tikzpicture}[remember picture,overlay] \node[anchor=south west, xshift=0.2in, yshift=0.2in] at (current page.south west) { {\Large 豐富 Fengfu} }; \node[anchor=south east, xshift=-0.2in, yshift=0.2in] at (current page.south east) { {\Large 南勢 Nanshi} }; \end{tikzpicture} \begin{tikzpicture}[remember picture,overlay] \draw[green!60!black, line width=1.2pt] ([yshift=0.65in]current page.south west) -- ([yshift=0.65in]current page.south east); \node[anchor=west, text=green!60!black] at ([yshift=0.78in]current page.south west) {\large $\blacktriangleleft$ 3.9 公里 (km)}; \node[anchor=east, text=green!60!black] at ([yshift=0.78in]current page.south east) {\large 6.6 公里 (km) $\blacktriangleright$}; \end{tikzpicture} \end{document} A better version should be: Source: http://trstour.com/miao-li.htm
- Print service tells me the gradient I created with TikZ is longer than the Earth's circumferenceby flyx on June 15, 2026 at 8:08 am
I am designing playing cards, and I use a print service (https://meinspiel.de if that's relevant). I create my cards with a heading styled with tikz, like so: \documentclass{article} \usepackage[paperwidth=65mm,paperheight=97mm, margin=7mm]{geometry} \pagestyle{empty} \RequirePackage[x-4]{pdfx} \setCMYKcolorprofile{coated_FOGRA39L_argl.icc} {Coated FOGRA39} {FOGRA39 (ISO Coated v2 300\% (ECI))} {http://www.argyllcms.com/} \usepackage[overprint]{colorspace} \RequirePackage{tikz} \usetikzlibrary{positioning,shapes,calc,backgrounds} \definecolor{blue1}{cmyk}{0.6818,0.3939,0,0.7412} \definecolor{blue2}{cmyk}{0.6339,0.2768,0,0.5608} \tikzset{ pics/heading/.style={code={ \node[anchor=north west] (heading) at ($(current page.north west) + (7, -7)$) {\textoverprint[0]{\textcolor{white}{\textsf{#1}}}}; \begin{scope}[on background layer] \fill[top color=blue1, bottom color=blue2] (current page.north west) -- (heading.south west-|current page.north west) -- (heading.south east) .. controls +(right:5) and +(left:5) .. +(10, 2) -| (current page.north east) -- cycle; \end{scope} }} } \begin{document} \begin{tikzpicture}[x=1mm, y=1mm, remember picture, overlay] \pic {heading={My Heading}}; \end{tikzpicture} \end{document} As you can see, I set the card's dimensions, specify PDF/X-4 output and the ISO Coated v2 300% (ECI) color profile just like the print service requires. Then I enable overprint (unsure whether this is relevant for my issue) for black text (but the heading is white, so I disable it there again). I define a tikz pic to use for drawing the heading of each card. Finally, I create a document with a single card that uses that pic as heading. The result looks like this: I gave that to the printing service, and they printed the heading as two areas split horizontally with different colors, instead of the gradient. When I asked them what the problem is, they answered this (translated from German): The data is set up in a strange way. The gradient consists of two parts, which lead to it being cut back during conversion. Also, the size of the gradient is extremely huge. I don't exaggerate. It has a width of 352777777777,425mm, i.e. 352.777,78km! While we do have meter scale from time to time, I've never seen kilometers. (The circumference of Earth at the equator is about 40.075 km to put that into context.) It may be that this is why there was an error during conversion. We suggest to embed the gradient as picture to avoid such errors. Also, when gradients are pictures, the print is cleaner and smoother. So, I guess my question is: How do I create the gradient so that the print service is happy? I don't feel like I have enough control over whatever tikz does here.
- Cover page in LaTeXby Jos on June 14, 2026 at 7:38 pm
How can I get this cover page using LaTeX? I have tried using this code, but I can´t get it. This is a cover page that I want for my dissertation. \documentclass{article} \usepackage{tikz} \usepackage{graphicx} \begin{document} \begin{titlepage} \begin{tikzpicture}[remember picture, overlay] % Your logo \node[anchor=north west] at (1.5in,-1.0625in) {% \includegraphics[width=1in,height=1.0625in]{example-image-duck} }; % Line 1: arriba (horizontal) \draw[line width=2pt] (3in, -1.5in) -- (7in, -1.5in); % Line 2: abajo (horizontal, más cerca) \draw[line width=1pt] (3in, -1.8in) -- (7in, -1.8in); % ===== TRES LÍNEAS VERTICALES ===== % La imagen termina en: -1.0625in - 1.0625in = -2.125in % Línea vertical 1 (desde abajo de la imagen hacia abajo) \draw[line width=1pt] (1.9in, -2.5in) -- (1.9in, -8in); % Línea vertical 2 (centro, espaciada 0.5in) \draw[line width=2pt] (2.1in, -2.5in) -- (2.1in, -8in); % Línea vertical 3 (derecha, espaciada 0.5in) \draw[line width=1pt] (2.3in, -2.5in) -- (2.3in, -8in); \end{tikzpicture} \begin{tikzpicture}[remember picture, overlay] \node[anchor=south west] at (1.5in,-8.8125 in) {% \includegraphics[width=1in,height=1.0625in]{example-image-duck} }; \end{tikzpicture} \end{titlepage} \end{document}
- Symbol of cannonby Sebastiano on June 14, 2026 at 12:15 pm
I want to reproduce a cannon considering in old style (one of these) considering that I have not seen a specific symbol. Does anyone know if there’s a symbol that resembles one of this image? I have not found anything.
- TikZ snail's 🐌 outline rotation text layoutby mathrm alpha on June 14, 2026 at 2:31 am
Although this was mentioned last time: TeX chinese image poetry image text layout However, it seems no one has mentioned the layout of the snail's rotating circle text in the TeX code. Source: https://jedi.nehs.hc.edu.tw/newsletter/306/poem.html I wrote a LaTeX program that rotates text, but the result isn't quite like this image; it's just a reference to the circle rotation text format. Furthermore, the "比羚羊還要快。" part is missing display. \documentclass{article} \usepackage{tikz,xeCJK} \usepackage[margin=0.5in]{geometry} \setCJKmainfont{Noto Sans CJK TC} \usetikzlibrary{decorations.text} \begin{document} \centering \begin{tikzpicture} % Define colors based on the image \definecolor{snailbody}{RGB}{240, 200, 180} \definecolor{shellbase}{RGB}{220, 170, 150} % Body and Tail \fill[snailbody] (-3.5, 0.5) .. controls (-4, -1) and (-3.5, -3.5) .. (0, -3.5) -- (6, -2.5) -- (0, -2.8) .. controls (-2, -2.8) and (-3, -1) .. (-3.5, 0.5); % Head \fill[snailbody] (-3.5, 0.5) circle (0.9); % Antennae \draw[snailbody, line width=4pt] (-3.9, 1.2) -- (-4.3, 2.6); \fill[snailbody] (-4.3, 2.7) circle (0.2); \draw[snailbody, line width=4pt] (-3.1, 1.2) -- (-2.9, 2.6); \fill[snailbody] (-2.9, 2.7) circle (0.2); % Shell (large circle) \fill[shellbase] (0.5, 0) circle (3.7); %text parts \path [ decorate, decoration={ text along path, text={背著重重的家,上山下海,尋找食物,我總比別人慢一步,我想如果我拋棄沉重的家,我一定爬得比羚羊還要快。}, text align=center } ] (0.5, 0) ++(180:4.0) arc (180:0:4.0); \end{tikzpicture} \end{document} Although there are similar: How to fine tune rotation of text along circular path? However, There was no mention of a text rotation format resembling a snail's outline.
- TikZ customize in big operators symbols, can't display big TikZ operatorsby mathrm alpha on June 13, 2026 at 8:59 am
I followed the LaTeX question reference below to adapt it to the tikz big operators version, but it didn't display in tikz "⅌" symbol. How can I define a big plus operator that works like \bigcup? ⅌ apply in tikz text symbols? % Source - https://tex.stackexchange.com/a/394912 % Posted by GuM, modified by community. See post 'Timeline' for change history % Retrieved 2026-06-13, License - CC BY-SA 3.0 \documentclass{article} \usepackage{tikz,iftex,amsmath} \usepackage{graphicx} \makeatletter \newcommand*\@bigper[1]{\vcenter{\hbox{#1$\m@th ⅌$}}} \newcommand*\bigper{% \DOTSB % omit this line if you are not using the amsmath package \mathop{% \mathchoice {\@bigper ⅌}% {\@bigper \LARGE}% {\@bigper {}}% {\@bigper \footnotesize}% }% \slimits@ % omit this line if you are not using the amsmath package } \makeatother \ifPDFTeX \usepackage[utf8]{inputenc} \else \usepackage{newunicodechar} \fi \DeclareRobustCommand{\TikZPerSign}{% \tikz[ baseline=-.25ex, x=.13em, y=.13em, line cap=round, line join=round ]{% % Fixed box: this is important for text-like behaviour. \path[use as bounding box] (-3.05,-3.35) rectangle (3.95,4.35); % 1. The horizontal ellipse \draw[line width=.05em] (0.4,0) ellipse[x radius=2.2,y radius=.7]; % 2. The main U shape \draw[line width=.05em] (-.6,1.5) .. controls (-.6,-3.2) and (.6,-3.2) .. (.6,1.5); % 3. The top-left flourish \draw[line width=.05em] (-.6,1.5) .. controls (-1.8,2.8) and (-3.0,1.5) .. (-2.2,1.2); \fill (-.5,1.9) circle[radius=.22]; % 4. The large right loop \draw[line width=.05em] (.6,1.5) .. controls (.6,4.2) and (3.5,3.2) .. (3.5,.5) .. controls (3.5,-.8) and (2.5,-1.2) .. (1.8,-1.0); }% } \ifPDFTeX \DeclareUnicodeCharacter{214C}{\TikZPerSign} \else \newunicodechar{⅌}{\TikZPerSign} \fi \begin{document} $$\sum^1_2 \bigper^3_4$$ \end{document}
- Drawing tikz five line style arrows in text displayby mathrm alpha on June 11, 2026 at 12:15 pm
Although a five-line arrow was unearthed, but: This is simply a very long, cramped five-line tikz arrows result, not the size of the blue arrow in the image. Furthermore, none of the arrows in the @Explorer answer (in the image) scaled down to the the same text size. This is example diagram text in: A \LLleftarrow B \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{nfold} \begin{document} \begin{tikzpicture} \draw[double equal sign distance, nfold=5, arrows=-Implies] (0,-0.7) -- (3,-0.7); \end{tikzpicture} \end{document} References: Drawing a quadruple arrow
- PGFPlots / TikZ: Filtering data from a file when the x-axis contains string valuesby joseldsm on June 10, 2026 at 9:57 am
I am generating a plot in PGFPlots/TikZ where the x-axis contains string values and the y-axis contains numerical data. The data is imported from a CSV file, and everything works correctly so far. However, when I use skip coordinates between index, the filtering is applied to the y-values and not to the x-axis categories. In this case, I want to draw only the data with the string value B. Is there a way to correctly apply this filtering to both x-axis ? Thanks! Here is the MWE. Keep in mind that in my case the data are extract from csv file. \documentclass{article} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=1.18} \pgfplotstableread{ String Value A 0 A 6 A 4 B 9 B 5 B 1 B 3 B 7 C 4 C 7 C 9 C 3 }\data \begin{document} \begin{tikzpicture} \begin{axis}[ ybar, ymin=0, xtick=data, xticklabels from table={\data}{String}, nodes near coords ] \addplot table[ x expr=\coordindex, y={Value}, skip coords between index={0}{3}, skip coords between index={8}{100} ]{\data}; \end{axis} \end{tikzpicture} \end{document}
- Custom Sidebar Table of Contents in Beamerby wrb98 on September 17, 2024 at 2:15 pm
I'm working with a blank Beamer presentation template and want to recreate a sidebar similar to one shown in the image below. Unlike typical Beamer sidebars that extend to the page's edge, this one is part of a custom frame. I'd like the sidebar to display boxed sections with sharp drop shadows. The current section should be highlighted by a red shadow, while the current subsection should be bolded and appear on a white horizontal strip. Subsections from other sections should remain hidden until the presentation reaches that specific section, at which point they should appear in a dropdown list in the sidebar (e.g. in the image, we're on SO so subsections of SO are shown in the sidebar, but subsections of Section Two and Section Three are not). Note: By 'subsection' I really mean slide titles. How can I implement this effect in LaTeX? Any help would be appreciated. \documentclass[11pt]{beamer} \usepackage{tikz} \usepackage{microtype} \usepackage{xcolor} \usepackage{soul} \usetikzlibrary{calc} \usepackage{ lmodern, babel, amsmath, eurosym } \definecolor{darkpastelgreen}{rgb}{0.01, 0.75, 0.24} \usepackage[default]{sourcesanspro} \usepackage[T1]{fontenc} \setbeamertemplate{navigation symbols}{} \setbeamertemplate{background}{% \begin{tikzpicture}[overlay,remember picture] \fill[sharp corners,fill=darkpastelgreen] ($ (current page.north west) + (0.4cm,-0.4cm) $) rectangle ($ (current page.south east) + (-0.4cm,0.4cm) $); \end{tikzpicture}% \begin{tikzpicture}[overlay,remember picture] \fill[sharp corners,color=white] ($ (current page.north west) + (0.5cm,-0.5cm) $) rectangle ($ (current page.south east) + (-2cm,0.5cm) $); \end{tikzpicture}% } \setbeamersize{text margin left=0.8cm, text margin right=0.85cm} % Reduce side margins \setbeamertemplate{frametitle}{\color{black}\bfseries\insertframetitle \nointerlineskip \bigskip } \addtobeamertemplate{frametitle}{\vspace*{0cm}}{\vspace*{-0.4cm}} \addtolength{\headsep}{0.6cm} \begin{document} \begin{frame}[t]{} \frametitle{A Subsection} Slide content goes here... \end{frame} \end{document}
- Instead of repeatedly writing the year I would like the year to appear only onceby user21161308 on April 2, 2024 at 4:57 pm
I cant just delete the year part, would like to know how I have to adjust it s.t. it only shows the year once. \documentclass[border=5pt,varwidth,11pt]{standalone} \usepackage{tikz} \usetikzlibrary{matrix,calc,positioning} \colorlet{darkerblue}{blue!50!black} % Source - https://tex.stackexchange.com/q/714618 % Posted by user21161308, modified by community. See post 'Timeline' for change history % Retrieved 2026-06-17, License - CC BY-SA 4.0 %% Code by Claudio: %% https://tex.stackexchange.com/a/197447/221452 %% Uses code by Andrew: %% http://tex.stackexchange.com/a/28452/13304 \makeatletter \let\matamp=& \catcode`\&=13 \def&{% \iftikz@is@matrix \pgfmatrixnextcell \else \matamp \fi } \makeatother \newcounter{lines} \def\endlr{\stepcounter{lines}\\} \newcounter{vtml} \setcounter{vtml}{0} \newif\ifvtimelinetitle \newif\ifvtimebottomline \tikzset{ description/.style={column 2/.append style={#1}}, timeline color/.store in=\vtmlcolor, timeline color=red!80!black, timeline color st/.style={fill=\vtmlcolor,draw=\vtmlcolor}, use timeline header/.is if=vtimelinetitle, use timeline header=false, add bottom line/.is if=vtimebottomline, add bottom line=false, timeline title/.store in=\vtimelinetitle, timeline title={}, line offset/.store in=\lineoffset, line offset=4pt, } \NewDocumentEnvironment{vtimeline}{O{}+b}{% \setcounter{lines}{1}% \stepcounter{vtml}% \begin{tikzpicture}[column 1/.style={anchor=east}, column 2/.style={anchor=west}, text depth=0pt,text height=1ex, row sep=1ex, column sep=1em, #1 ] \matrix(vtimeline\thevtml)[matrix of nodes]{#2}; \pgfmathtruncatemacro\endmtx{\thelines-1} \path[timeline color st] ($(vtimeline\thevtml-1-1.north east)!0.5!(vtimeline\thevtml-1-2.north west)$)-- ($(vtimeline\thevtml-\endmtx-1.south east)!0.5!(vtimeline\thevtml-\endmtx-2.south west)$); \foreach \x in {1,...,\endmtx}{ \node[circle,timeline color st, inner sep=0.15pt, draw=white, thick] (vtimeline\thevtml-c-\x) at ($(vtimeline\thevtml-\x-1.east)!0.5!(vtimeline\thevtml-\x-2.west)$){}; \draw[timeline color st](vtimeline\thevtml-c-\x.west)--++(-3pt,0); } \ifvtimelinetitle% \draw[timeline color st]([yshift=\lineoffset]vtimeline\thevtml.north west)-- ([yshift=\lineoffset]vtimeline\thevtml.north east); \node[anchor=west,yshift=16pt,font=\large] at (vtimeline\thevtml-1-1.north west) {\textsc{Timeline \thevtml}: \textit{\vtimelinetitle}}; \else% \relax% \fi% \ifvtimebottomline% \draw[timeline color st]([yshift=-\lineoffset]vtimeline\thevtml.south west)-- ([yshift=-\lineoffset]vtimeline\thevtml.south east); \else% \relax% \fi% \end{tikzpicture} }{} \begin{document} \begin{vtimeline}[timeline color=darkerblue, line offset=2pt] 2016 & Hate speech detection using AI begins\endlr 2017 & Convolutional neural network for document classification. \endlr 2017 & Transformer Paper published. \endlr 2017 & Bi-Transformer paper published.\endlr 2018 & Scaling NLP across many languages.\endlr 2018 & Understanding text in images/videos with ML.\endlr 2018 & CV tools for objectionable content detection.\endlr 2019 & XLM for pre-training cross-lingual models. \endlr 2019 &Self-Supervision improves Hate Speech detection. \endlr 2019 &Improvements in image post classifications. \endlr 2019 &Whole entity understanding.\endlr 2019 &Bi-Transformer in hate speech detection. \endlr 2019 &XLM in hate speech review.\endlr 2020 & Self-supervision enhances hate speech detection. \endlr 2020 & Classification improvements for image posts. \endlr 2020 & Whole entity: More robust image understanding. \endlr 2020 & Whole entity: Weak-supervision. \endlr 2020 & RIO: reinforcement-learning optimization. \endlr 2020 & Linformer: Efficient text encoder.\endlr \end{vtimeline} \end{document}
- tikz: specifying coordiantes system in 3dby climber on January 9, 2024 at 10:14 am
currently I am working with TikZ program in latex to draw a 3d figure. I need to redefine a coordinates system in 3d. The following is a MWE I tried: \documentclass{scrreprt} \usepackage{tikz} \usetikzlibrary{3d} \begin{document} \begin{tikzpicture}[x={(0:1)},y={(60:1)},z={(30:1cm)}] \draw[->] (0,0,0) -- (1,0,0); \draw[->] (0,0,0) -- (0,1,0); \draw[->] (0,0,0) -- (0,0,1); \end{tikzpicture} \end{document} And it gives the followings figure: But when I tried to change the z coordinate as z={(30:1)} (without dimension), it gives another picture as follows: \documentclass{scrreprt} \usepackage{tikz} \usetikzlibrary{3d} \begin{document} \begin{tikzpicture}[x={(0:1)},y={(60:1)},z={(30:1)}] \draw[->] (0,0,0) -- (1,0,0); \draw[->] (0,0,0) -- (0,1,0); \draw[->] (0,0,0) -- (0,0,1); \end{tikzpicture} \end{document} So I wonder how the XYZ vectors are rotated? Are they all rotated based on the vector (1cm,0)? I didn't find the answer in the pgf manual and search for help here. Thank you for any help.
- types of systems of linear equations and intersection of planes, with tikzby Juan Leal on July 22, 2023 at 2:57 pm
Is there a simple way using tikz to graph a plane from its equation (like those of the systems on the right side, e.g. 2x +3y -z = 11), and that allows me to represent the intersection of two or three of them (even four)? If possible, I additionally need it to allow me to have flat colors in each of the planes involved and not to be represented by pieces as suggested by some of the solutions I have seen. I want to represent graphically to my students all the possibilities that can be presented with a system of linear equations with three unknowns, in a way similar to the one in the image I include. I have been reading the material related to this topic for three days and I have not found a completely satisfactory solution (or maybe there is one, but I have not appreciated it properly). I know a bit about tikz, pgfplots and tikz-3dplot (and I come from the old school of pstricks).
- Non uniform outer layer of gridsby felix on June 16, 2023 at 7:41 am
I am trying to draw grids without the outer layer. Here is the code, \documentclass{article} \usepackage{tikz} \begin{document} \begin{center} \begin{tikzpicture} \draw[step=2cm,color=gray] (.2,.2) grid (10.75,10.75); \end{tikzpicture} \end{center} \end{document} The output looks like this. As one can see, the outerlayer is not uniformly placed. Can anyone please point out how to make it uniform? Thanks in advance.
- How to draw on any plane with 3dtoolsby rpapa on March 24, 2022 at 3:53 pm
Salvation I am testing the 3Dtools library (https://github.com/marmotghost/tikz-3dtools). I find the idea interesting. It is possible to define a plane either by 3 points, or by a vector and a point, very well. on the other hand I did not find how to choose this plan to draw above. So I'm looking for an example of use.
- Drawing arc with superimposed label in TikZ 3Dby L Mascolo on November 21, 2021 at 11:40 am
I would like to receive some help from you. I've been able to add the label for a vector in the middle of the arrow itself in tikz3d by using a command like: \tdplotsetcoord{Mp}{\rvm}{\phm}{\thm} \path (O) -- node[sloped] (text) {$\bv{r}_{kj}(t)$} (Mp); \draw[-latex,shorten >=3mm] (O) -- (text) -- (Mp); However I would like to obtain the same with arcs. Given that I'm using the command: \tdplotdrawarc[-latex]{(O)}{0.8}{0}{\thm}{anchor=north}{$\vth_k(t)$} I cannot find a way to include it. Here is a MWE: \documentclass[tikz,border=5pt]{standalone} \usepackage{graphicx} \usepackage{tkz-euclide} % \usetkzobj{all} % obselete \usetikzlibrary{arrows.meta,angles,quotes,positioning} \usepackage{tikz-3dplot} \tdplotsetmaincoords{75}{110} \begin{document} \begin{tikzpicture}[scale=4,tdplot_main_coords] \definecolor{earth}{RGB}{0,128,0} \definecolor{moon}{RGB}{119,136,153} \pgfmathsetmacro{\rvm}{1.2} \pgfmathsetmacro{\phm}{70} \pgfmathsetmacro{\thm}{150} \coordinate (O) at (0,0,0); \draw[thick,-latex] (0,0,0) -- (1.5,0,0) node[anchor=north east]{${ I}$}; \draw[thick,-latex] (0,0,0) -- (0,1.5,0) node[anchor=north west]{${ J}$}; \draw[thick,-latex] (0,0,0) -- (0,0,1.2) node[anchor=south]{${ K}$}; % Earth \tdplotsetcoord{Ep}{0}{0}{0} % draw Moon position, theta, phi, RTN CS \tdplotsetcoord{Mp}{\rvm}{\phm}{\thm} \path (O) -- node[sloped] (text) {${r}_{kj}(t)$} (Mp); \draw[-latex,shorten >=3mm] (O) -- (text) -- (Mp); \draw[dashed,shorten >=-20pt ] (O) -- (Mpxy); \tdplotdrawarc[-latex]{(O)}{0.8}{0}{\thm}{anchor=north}{$\vartheta_k(t)$} \shade[ball color = earth] {(Ep)} circle (2.5pt); \shade[ball color = moon] {(Mp)} circle (2pt); \end{tikzpicture} \end{document}
- How to plot the 3D graph of the following three inequalities in latex (e.g., tikz/pgf)?by learner on July 9, 2021 at 9:27 am
How to plot the 3D graph of the following three inequalities in latex (tikz/pgf) ? z <= x+y+1, z <= 4x, z <= 5y. My attempt: \documentclass[12pt,leqno]{amsart} \usepackage{pgfplots} \usepackage{tikz} \begin{document} \begin{tikzpicture} \begin{axis} \addplot3 [ domain=-5:20, domain y = -3:10, samples = 20, samples y = 8, surf] {x+y+1}; \addplot3[domain=-5:20, domain y = -3:10, samples = 20, samples y = 8, surf, opacity=0.25]{4*x}; \addplot3[domain=-5:20, domain y = -3:10, samples = 20, samples y = 8, surf, opacity=0.25]{5*y}; \end{axis} \end{tikzpicture} \end{document} The above Latex code produces the above figure: But the above graph is not clear, the intersecting line of the three half-planes are not clear. Any help to draw clear image with clear intersection. Any help both with the 3D graph of the given 3 inequalities. Thanks Edit: The 2D projection of the above 3 inequalities becomes: and this is justified by the answer of @Juan Castaño.
- How do I crop a 3D surface in pgfplots?by Lucas Abounader on February 20, 2021 at 2:00 am
I am attempting to reproduce the following graph using pgfplots: Here is the MWE code I developed, along with the corresponding plot generated: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{pgfplots} \pgfplotsset{compat=1.17} \begin{document} \begin{center} \begin{tikzpicture} \begin{axis}[ width=8cm, height=12cm, axis lines=center, view={120}{30}, mesh/interior colormap name=hot, colormap/cool, point meta min=0.5, point meta max=6, xmin=-2, xmax=2, xlabel=\Large{$s$}, ymin=-0.5, ymax=2.5, ylabel=\large{$t$}, zmin=0, zmax=6, ] \addplot3[ surf, shader=interp, samples=50, domain=-2:2, y domain=-0.5:2.5 ] {14*x*x+20*x*y-22*x+11*y*y-24*y+14}; \end{axis} \end{tikzpicture} \end{center} \end{document} There are a few issues: The view box does not crop the plot as I would like. I am looking for the elliptic intersection with the plane z=6 akin to the first image. The interior surface (colored by mesh/interior colormap name=hot) is not visible. pgfplots is giving the following warning: Package pgfplots Warning: the combination 'shader=interp,interior colormap name ' is inefficient (it uses 'shader=faceted interp,faceted color=none') and may s low down the *display* of your document on input line 44. I only know the command shader=interp to remove mesh gridlines and I would like to shade the interior and exterior surfaces with different colormaps. What is going on? How can I get the desired "crop" effect? For reference, here is the surface rendered with gridlines:
- Plane intersecting sphere with tikz and tikz-3dby B. Dors on November 3, 2020 at 3:57 pm
I'm really surprised that I couldn't find an answer to this question, but here it goes: how can I draw a plane intersecting a sphere using tikz and tikz-3dplots? I managed to do the following, using a mixture of this answer and this answer (code below): But what I really want is something like this (it's a shame and something I totally don't understand why Geogebra does not convert 3D figures to tikz): Clearly, I'm almost there. But the shading is wrong: the plane is being plotted as if it was covering the sphere, and not as if it is intersecting it. I found out here that apparently there is no way of doing the shading automatically, but I'm ok with doing it manually. The only problem is, I have no idea how to do it. I spent more than a day already trying to understand what was happening in the codes of the previous mentioned answers, as they were made for specific cases and I needed to transform them into a random sphere intersecting a random plane. I added some comments to the code with what I gathered. But I still am not sure how all of those commands work, so I can't properly identify where should I end and begin an arc to fill with some darker gray color on top of the plane plotting. I know that using an external programm to generate images would work (here is a nice example using Asymptote), but I have to add many different spheres intersecting different planes to my file, and I would prefer to be able to generate them directly in Latex with tikz, instead of having multiple figures. So my question reduces to: how to manually add the proper shading in my figure? (Notice that there is need for two shades: one for the cap of the sphere and a darker one for the back part of the sphere's cap.) Of course, an alternative code, which can be easily modified for different spheres and planes (specially planes not parallel to xy), is very welcome as well. What I have so far: \documentclass{article} \usepackage{tikz} \usepackage{tikz-3dplot} \usetikzlibrary{backgrounds, intersections} %I don't have a clear idea of what is happening here, but they are used for the plane construction \newcommand\pgfmathsinandcos[3]{% \pgfmathsetmacro#1{sin(#3)}% \pgfmathsetmacro#2{cos(#3)}% } \newcommand\LongitudePlane[3][current plane]{% \pgfmathsinandcos\sinEl\cosEl{#2} % elevation \pgfmathsinandcos\sint\cost{#3} % azimuth \tikzset{#1/.style={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}} } \newcommand\LatitudePlane[3][current plane]{% \pgfmathsinandcos\sinEl\cosEl{#2} % elevation \pgfmathsinandcos\sint\cost{#3} % latitude \pgfmathsetmacro\yshift{\cosEl*\sint} \tikzset{#1/.style={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}} % } \newcommand\DrawLongitudeCircle[2][1]{ \LongitudePlane{\angEl}{#2} \tikzset{current plane/.prefix style={scale=#1}} % angle of "visibility" \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} % \draw[current plane] (\angVis:1) arc (\angVis:\angVis+180:1); \draw[current plane,dashed] (\angVis-180:1) arc (\angVis-180:\angVis:1); } \newcommand\DrawLatitudeCircle[2][1]{ \LatitudePlane{\angEl}{#2} \tikzset{current plane/.prefix style={scale=#1}} \pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)} % angle of "visibility" \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))} \draw[current plane] (\angVis:1) arc (\angVis:-\angVis-180:1); \draw[current plane,dashed] (180-\angVis:1) arc (180-\angVis:\angVis:1); } \begin{document} \begin{figure} \centering \tdplotsetmaincoords{60}{110} \begin{tikzpicture}[tdplot_main_coords, declare function={dicri(\t,\th,\ph,\R)=sin(\th)*sin(\ph)*(\R*cos(\t)) - sin(\th)*cos(\ph)*(\R*sin(\t))+ cos(\th)*(1);}] %dicri is defined according to a parametrization n+r*cos(t)*u+r*sen(t)*v, being u and v orthonormal vectors in the intersecting plane \pgfmathsetmacro{\R}{5}% \path coordinate (T) at (0,0,3) %center of circle defined by the intersection coordinate (I) at (0,0,0); \path[tdplot_screen_coords,shift={(I)},use as bounding box] (-1.2*\R,-1.2*\R)rectangle (1.2*\R,1.2*\R);%this limits the image position %draws dot+label for coordinates T and I \foreach \v/\position in {T/above,I/below} { \draw[fill=black] (\v) circle (0.7pt) node [\position=0.2mm] {$\v$}; } \begin{scope}[tdplot_screen_coords, on background layer] \fill[ball color=white, opacity=0.8] (I) circle (\R); % determine the zeros of dicri \path[overlay,name path=dicri] plot[variable=\x,domain=0:360,samples=73] ({\x*1pt},{dicri(\x,\tdplotmaintheta,\tdplotmainphi,4)}); \path[overlay,name path=zero] (0,0) -- (360pt,0); \path[name intersections={of=dicri and zero,total=\t}] let \p1=(intersection-1),\p2=(intersection-2) in \pgfextra{\xdef\tmin{\x1}\xdef\tmax{\x2}}; \end{scope} %this has to do with finding the equation of the intersection circle, I believe \pgfmathsetmacro{\SmallR}{4} %the radius of the intersection circle is supposed as known % Draw dashed part of intersecting circle \draw[dashed] plot[variable=\t,domain=\tmin:\tmax,samples=50,smooth] ({\SmallR*cos(\t)}, {\SmallR*sin(\t)}, {3}); % Draw continuous part of intersecting circle \draw[thick,save path=\pathA] plot[variable=\t,domain=\tmax:\tmin+360,samples=50,smooth] ({\SmallR*cos(\t)}, {\SmallR*sin(\t)}, {3}); %same parametrization used in dicri. %Plane construction %% some definitions \def\angEl{35} % elevation angle \def\angAz{-105} % azimuth angle \def\angPhi{-40} % longitude of point P \def\angBeta{19} % latitude of point P %% working planes \pgfmathsetmacro\H{\R*cos(\angEl)} % distance to north pole \tikzset{xyplane/.style={ cm={cos(\angAz),sin(\angAz)*sin(\angEl),-sin(\angAz),cos(\angAz)*sin(\angEl),(0,-\H)} }, >=latex, % option for nice arrows inner sep=0pt,% outer sep=2pt,% mark coordinate/.style={inner sep=0pt,outer sep=0pt,minimum size=3pt, fill=black,circle} } \LatitudePlane[equator]{\angEl}{0} %% draw xy shifted plane \filldraw[xyplane,shift={(0,0,3)},fill=gray!10,opacity=0.2] (-1.8*\R,-2.6*\R) rectangle (2.2*\R,2*\R); \end{tikzpicture} \end{figure} \end{document} EDIT: I managed to find the points where the continuous circle turns into a dashed circle using this: \path ({\SmallR*cos(\tmin)}, {\SmallR*sin(\tmin)}, {3}) coordinate (pmin) ({\SmallR*cos(\tmax)}, {\SmallR*sin(\tmax)}, {3}) coordinate (pmax); Those points are where the new shading should begin, now I'm only missing how to find the arcs of the dashed circle and of the upper sphere surface.
- LaTeX Tikz: Compare two \def argumentsby Erick Saldaña on March 11, 2020 at 4:41 pm
I am writing a macro definition that draws dimensions in the style of technical drawing. I need to perform an inequality of two of the arguments to know which is coordinate is higher up, but the console doesn't understand the condition I used as the \ifthenelse argument. % (#1,#2): Starting coordinate % (#3,#4): Ending coordinate % #5: Vertical upwards distance from the body % #6: Dimension text \usetikzlibrary{calc} \def\DimensionTop(#1,#2)(#3,#4)[#5,#6]{ \ifthenelse{#2>#4} { % If point (#1,#2) is higher than (#3,#4) \coordinate (D1) at ($ (#1,#2) + (0,#5) $); \coordinate (D2) at ($ (#3,#4) + (0,#2-#4) + (0,#5) $); } { % If point (#3,#4) is higher than (#1,#2) \coordinate (D1) at ($ (#1,#2) + (0,#4-#2) + (0,#5) $); \coordinate (D2) at ($ (#3,#4) + (0,#5) $); } \draw (#1,#2) -- (D1) -- ++(0,0.2); \draw (#3,#4) -- (D2) -- ++(0,0.2); \draw[ <->, >=latex, thin ] (D1) -- (D2) node[ fill=white, midway ] {$\mathtt{#6}$}; } The function is used like this in the main document \documentclass[border=2pt,convert={outext=.png}]{standalone} \usepackage{tikz} \usetikzlibrary{patterns} \usetikzlibrary{arrows} \begin{document} \begin{tikzpicture} % Custom command for the background grid, ignore \GuideCartesian(-2,-2)(8,8); \draw[ very thick ] (0,4) -- (2,5); \DimensionTop(0,4)(2,5)[1,1.50]; \end{tikzpicture} \end{document} Since the console doesn't understand the condition, it goes directly to the else case, which works when the point on the right is higher than the point on the left as in the picture. What would be a correct way to express this condition?
- Draw the polyhedra tessellation in the 3-dimensional-spaceby wonderich on February 16, 2020 at 12:26 am
Consider a polyhedron composed by 24 vertices (4×6) 14 faces (contain 6 squares and 8 hexagons) 36 edges (4×6+6×82=36). This polyhedron can pack and tessellate the 3-dimensional-space like this. Question: What are the available methods to draw this in LaTex? (My attempt was that I showed such packing is possible and prepared this figure [not using LaTex..].)
- Are there simple ways to draw parallelepipeds in tikz?by Brian Fitzpatrick on October 16, 2019 at 3:57 am
I'm trying to draw some parallelepipeds in tikz and find the task surprisingly frustrating. For example, I'd like to recreate this figure from wikipedia: I've found lots of tikz examples of cubes but none of parallelepipeds. Is there a simple way to do this?
- Intersection of a sphere and a plane knowing equationsby minhthien_2016 on March 25, 2019 at 1:27 am
I am trying draw a circle is intersection of a plane has equation 2 x − 2 y + z − 15 = 0 and the equation of the sphere is ( x − 1)^2 + ( y + 1)^ 2 + ( z − 2)^ 2 − 25 = 0. The plane cut the sphere is a circle with centre (3,-3,3 and radius r = 4. I can't draw the circle. I tried \documentclass[12pt,border = 2 mm]{standalone} \usepackage{tikz} \usepackage{tikz-3dplot} \usetikzlibrary{arrows,calc,backgrounds} \begin{document} \tdplotsetmaincoords{60}{110} \begin{tikzpicture}[tdplot_main_coords] \path coordinate (T) at (3,-3,3) coordinate (I) at (1,-1,2); \foreach \v/\position in {T/above,I/below} { \draw[fill=black] (\v) circle (0.7pt) node [\position=0.2mm] {$\v$}; } \draw[dashed] (T) circle[radius={4}]; \begin{scope}[tdplot_screen_coords, on background layer] \pgfmathsetmacro{\R}{5}% \fill[ball color=purple, opacity=1.0] (I) circle (\R); \end{scope} \end{tikzpicture} \end{document} How can I draw the circle?
- TikZ, draw a 3D intersection of planesby BowPark on April 19, 2018 at 11:05 am
A first example of intersection between two planes is already shown in this answer. I would like to use TikZ. I already tested that code, but it has a different axes layout (the axes in the linked answer are like a box containing the planes; the required axes here are instead the cartesian ones), a different position of the planes and a different fill pattern for the planes: I don't know how to modify it according to my requirements. The final result should be like the following image, with these differences: only its left part is to be considered (the right part can be completely ignored); the planes in my picture have a vertical intersection line (instead of the horizontal intersection line of the picture); the text line of intersection and its arrow are not necessary. How to accomplish this (with or without the code in the linked answer)?
- Pie chart size from Bordaigorlby Laura K on April 27, 2017 at 7:10 pm
I have been using this great pie chart code: How to draw Bar & Pie Chart The code is from Bordaigorl. I was wondering if anyone can see how it is possible to have two pie charts in the same environment with different sizes. The part of the code that is responsible for this is "scale" when you call the function pie chart: \begin{tikzpicture} [ pie chart, slice type={g}{giallo}, slice type={A}{rosso}, slice type={B}{blu}, pie values/.style={font={\small}}, scale=2 ] \pie{t=1, A in power}{66/g,34/A} \pie[xshift=2.2cm]% {t=2, B in power}{33/g,33/B} \end{tikzpicture} My question is: does anyone see how to create two "types" of pies, one with scale=2 and another with scale=2.5, for example? For the purpose of understanding, I will post an MWE based on the whole code created by Bordaigorl here. What I would like is to have the left pie chart in one scale and the pie chart on the right in another scale. Please note that I am not the one who designed this code and credit must be given to Bordaigorl: \documentclass[border=10pt,multi,tikz]{standalone} \definecolor{rosso}{RGB}{220,57,18} \definecolor{giallo}{RGB}{255,153,0} \definecolor{blu}{RGB}{102,140,217} \definecolor{verde}{RGB}{16,150,24} \definecolor{viola}{RGB}{153,0,153} \makeatletter \tikzstyle{chart}=[ legend label/.style={font={\scriptsize},anchor=west,align=left}, legend box/.style={rectangle, draw, minimum size=5pt}, axis/.style={black,semithick,->}, axis label/.style={anchor=east,font={\tiny}}, ] \tikzstyle{bar chart}=[ chart, bar width/.code={ \pgfmathparse{##1/2} \global\let\bar@w\pgfmathresult }, bar/.style={very thick, draw=white}, bar label/.style={font={\bf\small},anchor=north}, bar value/.style={font={\footnotesize}}, bar width=.75, ] \tikzstyle{pie chart}=[ chart, slice/.style={line cap=round, line join=round, very thick,draw=white}, pie title/.style={font={\bf}}, slice type/.style 2 args={ ##1/.style={fill=##2}, values of ##1/.style={} } ] \pgfdeclarelayer{background} \pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground} \newcommand{\pie}[3][]{ \begin{scope}[#1] \pgfmathsetmacro{\curA}{90} \pgfmathsetmacro{\r}{1} \def\c{(0,0)} \node[pie title] at (90:1.3) {#2}; \foreach \v/\s in{#3}{ \pgfmathsetmacro{\deltaA}{\v/100*360} \pgfmathsetmacro{\nextA}{\curA + \deltaA} \pgfmathsetmacro{\midA}{(\curA+\nextA)/2} \path[slice,\s] \c -- +(\curA:\r) arc (\curA:\nextA:\r) -- cycle; \pgfmathsetmacro{\d}{max((\deltaA * -(.5/50) + 1) , .5)} \begin{pgfonlayer}{foreground} \path \c -- node[pos=\d,pie values,values of \s]{$\v\%$} +(\midA:\r); \end{pgfonlayer} \global\let\curA\nextA } \end{scope} } \newcommand{\legend}[2][]{ \begin{scope}[#1] \path \foreach \n/\s in {#2} { ++(0,-10pt) node[\s,legend box] {} +(5pt,0) node[legend label] {\n} } ; \end{scope} } \begin{document} \begin{tikzpicture} [ pie chart, slice type={g}{giallo}, slice type={A}{rosso}, slice type={B}{blu}, pie values/.style={font={\small}}, scale=2 ] \pie{1}{66/g,34/A} \pie[xshift=2.2cm]% {2}{33.3/g,33.3/B,33.3/A} \end{tikzpicture} \end{document} I apologize if that is an obvious question. I've tried in 2 differents ways and they were all not succesful: I've tried to remove the scale from the preamble on tikz and added scale=2 when was calling pie function: \pie[xshift=2.2cm, scale=2]{2}{33.3/g,33.3/B,33.3/A} I've also tried to create two functions in the preamble of the document, one pie1 and another pie2. The code doesn't compile Thank you!
- `edge quotes mid` TikZ issueby Geremia on May 22, 2014 at 10:28 pm
When I render this with LuaLaTeX: \documentclass[tikz,border=4mm]{standalone} \usetikzlibrary{graphdrawing,graphs} \usegdlibrary{layered,trees,circular,force} \begin{document} \tikz \graph[ spring layout, edge quotes mid, edges={nodes={font=\scriptsize, fill=white, sloped, inner sep=1pt}} ] { 1 ->["Das"] 2 ->["ist"] 3 ->["das"] 4 ->["Haus"] 2 ->["vom" near start] 5 ->["Ni"] 4 ->["ko" near start] 1 ->["laus", orient=right] 5; }; \end{document} I get this error: ! Package pgfkeys Error: I do not know the key '/tikz/"{Das}"' and I am going t o ignore it. Perhaps you misspelled it. See the pgfkeys package documentation for explanation. Type H <return> for immediate help. ... l.14 } ; ? Why?
- Draw Spiral Cone TikZby Sebastian on September 13, 2013 at 3:50 pm
Im trying to do a spiral cone in TikZ. I dont know what is the best way to do this.
- TikZ: two ellipses in different planesby dustin on July 12, 2013 at 2:14 am
How can show that two ellipses are in different planes? \documentclass[convert = false, border = 1cm]{standalone} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \pgfmathsetmacro{\as}{2}; \pgfmathsetmacro{\bs}{1.95}; \pgfmathsetmacro{\cs}{sqrt(\as^2 - \bs^2)} \pgfmathsetmacro{\al}{3}; \pgfmathsetmacro{\bl}{2.25}; \pgfmathsetmacro{\cl}{sqrt(\al^2 - \bl^2)} \pgfmathsetmacro{\xs}{abs(\cs - \cl)} \draw (0, 0) ellipse [x radius = \as cm, y radius = \bs cm]; \draw (\xs, 0) ellipse [x radius = \al cm, y radius = \bl cm]; \filldraw[black] (-\cs, 0) circle [radius = .1cm]; \filldraw[black] (-\cl + \xs, 0) circle [radius = .1cm]; \end{tikzpicture} \end{document} From the image, we see that both ellipses are in the same plane. How can I rotate the small ellipse to make it appear as if the smaller ellipse is in a different plane? Using rotate around doesn't achieve that look. Edit 2: I am a little hesitant about using xslant and yslant since it appears that the ellipse is being shifted and stretched. Here is a poor picture(my phone camera flash refused to work) of two ellipse in different planes. If adjust my smaller ellipse, it stretches and appears to shift dramatically. From the image below, the focus appears to be in the center of smaller ellipse now and it has elongated. Edit: So I found this post Why isn't the arc drawn on the good plane using tikz-3dplot in Tait-Bryan convention but I don't fully understand the code. However, the poster was able to rotate ellipse and have a better visual appeal and the poster could define the plane it is in such as xy, yz, and xz. How could I adapt this code to my situation?
- Using TikZ inside a figure captionby Nico Schlömer on May 16, 2012 at 1:52 pm
I have a PNG plot with a couple of black patches in it, and I'd like to refer to it in the \caption of the figure. According to the TikZ manual, I'd have to \tikz \fill[black] (1ex,1ex) circle (1ex); which works perfectly outside a \caption. Using this inside a \caption, though, leaves me with the compile error ! Use of \use@pgflibrary doesn't match its definition. \pgfutil@ifnextchar ...1\def \pgfutil@reserved@a { #2}\def \pgfutil@reserved@... l.375 ...blah blah.} ? The following produces the compile error \documentclass{article} \usepackage{tikz} \begin{document} \tikz \fill[orange] (1ex,1ex) circle (1ex); \begin{figure} \caption{\tikz \fill[orange] (1ex,1ex) circle (1ex);} \end{figure} \end{document} Any hints here?