• Pgfplots -- Make units exactly 1 cm
    by klirk on October 13, 2025 at 1:56 pm

    I am trying to make a pgf plot so that when printed, the units are exactly 1 cm, i.e, the grid lines should be 1 cm apart. However, whatever I do, I cannot make it work and I really don't know why. This is my minimal example: \documentclass[a4paper]{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ width=6cm, height=6cm, scale only axis, enlargelimits=false, xmin=0, xmax=6, ymin=0, ymax=6, grid=both, xtick={0,1,...,6}, ytick={0,1,...,6}, ] \end{axis} \end{tikzpicture} \end{document} When I print the pdf and measure distances with a ruler, the grid lines have distance slightly smaller than 1cm, resulting in a size of around 5.7 cm instead of 6 cm for the entire axis.

  • Probleme newmdenv
    by Matmat81 on October 12, 2025 at 5:43 pm

    I'm having a problem with the newmdenv environment. In a long reminder that spans two pages, the framework is fed. Thank you for your help. \documentclass[11pt,a4paper]{book} \usepackage[left=4.5cm,right=4.5cm,top=5cm,bottom=5cm]{geometry} \usepackage[explicit]{titlesec} \usepackage[T1]{fontenc} \usepackage{fourier} \usepackage[francais]{babel} \usepackage{tikz} \usetikzlibrary{arrows,3d,arrows,shapes} \usepackage{fancyhdr} \usepackage{amssymb, amsmath} \usepackage{amsthm} \usepackage{enumitem} \usepackage[framemethod=tikz]{mdframed} \usepackage{tikz,tkz-tab} \usepackage{xcolor} \usepackage{tocloft} \usetikzlibrary{matrix, positioning} \usepackage{lipsum} %%%%%% Rappel de cours %%%%%% \newcounter{rappel}[chapter] \newmdenv[ innertopmargin=0pt, roundcorner=2pt, backgroundcolor=gray!30, linewidth=0.7pt, linecolor=black, innertopmargin=\baselineskip, singleextra={ \node[ anchor=west, xshift=-1.52pt, fill=white, rounded corners=1pt, draw] at (P-|O) {{\stepcounter{rappel}}{\textbf{Rappel de cours~\thechapter.\therappel}}}; }, firstextra={ \node[ anchor=west, xshift=-1.52pt, fill=black, rounded corners=1pt, draw] at (P-|O) {{\stepcounter{rappel}}{\textbf{Rappel de cours~\thechapter.\therappel}}}; } ]{rappel} \begin{document} \begin{rappel} Essai \end{rappel} \begin{rappel} \lipsum[1-4] \end{rappel} \end{document}

  • Is there a edge style with double lines in the tikz -package?
    by Josh on October 11, 2025 at 6:34 pm

    I am looking for a way to draw edges in the tikz-package, like \Rightarrow in the amssymb-package. Does anyone know of an option like that? Perhaps via edge/.style? \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture}[every node/.style={draw}] \draw (0,0) node {A} -> (0,1) node {B}; \end{tikzpicture} \end{document}

  • Fraction Operations (Graphically - Area Model)
    by UberMorlock80 on October 11, 2025 at 3:03 pm

    I'm trying to divide the rectangle horizontally and vertically into parts without rotating it to create something similar to the image below and graphically display the sum, product, and division of fractions. I also want to create a macro to do this mechanically. Do you have an idea?

  • tblr-tikz draw relation lines between two tables
    by user1850133 on October 11, 2025 at 7:18 am

    It seems that there is no way to give a name to a tblr table. Because of that, with the tikz library for tblr tables it is impossible to draw things implying other tables than the first that latex finds after the tblrtikzabove environment. Here I have made two tables with some tikz elements. I want to draw lines from one table to the other. Like in the drawing here: by the way... if anybody could find the actual rows/columns corner nodes, not the middle segment between them. Since I set a non-null rowsep and colsep, a separation should be seen between the two rectangles. mwe: \documentclass[aspectratio=169]{beamer} \mode<presentation> \usetheme{metropolis} \usepackage{tabularray,tikz} \UseTblrLibrary{booktabs,tikz} \tikzset{ styleall/.style = {rounded corners=.4ex,thick} } \setlength{\parindent}{0pt} \begin{document} \begin{frame}{aaa} \begin{columns}[t] \begin{column}{.45\textwidth} \frametitle{beamer} \textbf{letters} \begin{tblrtikzabove} \draw[red,styleall] (1-1.north west) rectangle (1-4.south east); \draw[green,styleall] (2-1.north west) rectangle (2-4.south east); \end{tblrtikzabove} \SetTblrInner{rowsep=6pt} \begin{tblr}{colspec={cccc},rowsep={4pt},colsep={4pt}} a & e & i & o\\ b & c & d & f\\ \end{tblr} \end{column} \begin{column}{.45\textwidth} \textbf{letters again} \begin{tblrtikzabove} \draw[red,styleall] (1-1.north west) rectangle (1-2.south east); \draw[green,styleall] (2-1.north west) rectangle (2-4.south east); \end{tblrtikzabove} \begin{tblr}{cccc} u & y & &\\ g & h & j & k\\ \end{tblr} \end{column} \end{columns} \end{frame} \end{document}

  • Undesirable slant in ylabel in pgfplots
    by Scholar on October 11, 2025 at 3:20 am

    I am trying to plot multiple curves, of which some are trigonometric, on the same plot. However, the ylabel appears to be slanted every time I use trig format=rad in my code. If I remove this, everything works fine and the label appears the way I expect it to (standard ylabel). Here is the MWE. Any help leading to a fix is highly appreciated. \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage{geometry} \begin{document} \begin{tikzpicture} \begin{axis}[ trig format=rad, ylabel={This is a test label}, xlabel={$t$ (s)}, grid=both, axis lines=box, xmin=0, xmax=20, ] \addplot [blue, thick, domain=0:20, samples=100] {2*(1-cos(x))}; \end{axis} \end{tikzpicture}

  • How do I prevent "see-through" when overlaying a surf plot with a point cloud?
    by Peter1509 on October 10, 2025 at 3:08 pm

    I am trying to create a surf plot with an additional point cloud on top. The data for both is saved in two different tables, which are then read and plottet into the same axis environment. Currently I have the problem, that some points (which are actually covered by the surf plot) can be seen through the surface. I want only be able to see the points, which from the given view perspective are not covered by some part of the surface plot. I already tried the pgfplot option \pgfplotsset{set layers}, but it didn't change anything. Also the order of \addplot3 -commands had no influence on the resulting plot. Are there any other options to solve my problem? Here is the important part of my current code structure: \pgfplotsset{set layers} \begin{tikzpicture} \begin{axis}[% width=0.65\figurewidth, height=1.2\figureheight, at={(0\figurewidth,0\figureheight)}, scale only axis, xmin=0, xmax=20, xtick distance = 5, tick align=outside, xlabel style={font=\color{white!15!black}}, xlabel={$t$ in \si{\hour}}, ymin=0, ymax=0.605, ylabel style={font=\color{white!15!black}}, ylabel={$z$}, zmin=0, zmax=220, ztick distance = 50, zlabel style={font=\color{white!15!black}}, zlabel={$x(z,t)$}, view={-35}{60}, axis background/.style={fill=white}, title style={font=\bfseries}, axis x line*=bottom, axis y line*=left, axis z line*=left, xmajorgrids, ymajorgrids, zmajorgrids, ylabel near ticks, xlabel near ticks, title style={font=\small}, xlabel style={font=\footnotesize, yshift = 2mm}, ylabel style={font=\footnotesize, yshift = 1mm,xshift = 5mm}, xticklabel style ={/pgf/number format/fixed, /pgf/number format/precision=3}, ylabel style={font=\footnotesize, rotate=-90}, yticklabel style ={/pgf/number format/fixed, /pgf/number format/precision=3,/pgf/number format/use comma}, zticklabel style = {yshift = -2.5mm}, zlabel shift={-5pt}, zlabel style = {xshift = -3mm}, legend style={font=\scriptsize}, ticklabel style={font=\scriptsize} ] \addplot3 [only marks, mark=*, mark options={}, mark size=1.0607pt, color=red, fill=red, forget plot, z buffer=sort] table[meta index = 2, col sep=tab, x expr=\thisrowno{0}/3600, y index=1] {tikz/Simulationsplots/xzt_chebypoints-2.tsv}; \addplot3[% surf, shader=flat corner, colormap={mymap}, mesh/rows=30, z buffer=sort] table[col sep=tab, x expr=\thisrowno{0}/3600, y index=1] {% tikz/Simulationsplots/xzt_chebypoints-1.tsv}; \end{axis} \end{tikzpicture}%

  • How to add extra y ticks to a pgfplots axis on the right with fixed width?
    by Tristan Nemoz on October 10, 2025 at 8:39 am

    I have the plot of several functions on a single axis, and I would like to add extra y ticks on the right of the plot to show the different numbers to which these functions converge to. However, I can't manage to have the total tikzpicture to be \textwidth wide, the extra ticks label making an overfull hbox. MWE: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[ xlabel=$x$, ylabel={$f(x) = x$}, width=\textwidth, height=\axisdefaultheight, extra y ticks={1}, extra y tick labels={\(\log_2(5)-\sum_ii\)}, extra y tick style={ yticklabel pos=right, grid=major, major grid style={gray, thin, densely dashed}, }, ] \addplot {x}; \end{axis} \end{tikzpicture} \end{document} I've tried the solution of this answer to no avail, it still results in an overfull hbox: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[ xlabel=$x$, ylabel={$f(x) = x$}, width=\textwidth, height=\axisdefaultheight, extra y ticks={1}, extra y tick labels={\makebox[0pt][l]{\(\log_2(5)-\sum_ii\)}}, extra y tick style={ yticklabel pos=right, grid=major, major grid style={gray, thin, densely dashed}, yticklabel style={ % add a name to the extra y tick label name=ylabel-\ticknum, }, }, ] \addplot {x}; \end{axis} \pgfmathsetlengthmacro{\MyExtraLabel}{width("$\log_2(5)-\sum_ii$")} \path (ylabel-0) -- +(\MyExtraLabel,0); \end{tikzpicture} \end{document} Finally, I also tried using a second axis environment, as in this answer, once again to no avail: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[ xlabel=$x$, ylabel={$f(x) = x$}, width=\textwidth, height=\axisdefaultheight, ] \addplot {x}; \end{axis} \begin{axis}[ width=\textwidth, height=\axisdefaultheight, hide x axis, axis y line*=right, ymin=-6, ymax=6, ytick=\empty, extra y ticks={1}, extra y tick labels={\(\log_2(5)-\sum_ii\)} ] \addplot[draw=none] {x}; % dummy plot \end{axis} \end{tikzpicture} \end{document} Also, this solution would force me to know the ymin and ymax of the first plot if I'm not mistaken, which isn't convenient. Is there a way to make these extra ticks on the right taken into account when computing the width of the end figure?

  • Why the last % in `foreach` list not the must if last parameter is protected with brace?
    by Explorer on October 9, 2025 at 7:21 am

    This question raise from this question and egreg's comment: a % must be appended to the last item Let' consider the following two cases: With {} in the last term, % is not must: \documentclass[tikz,border=5pt]{standalone} \begin{document} \begin{tikzpicture} \foreach \x/\y/\col/\lab in {% 2.5/1.2/blue/{(0,0)}, 4/2.0/teal/{(0,1)}, 6/2.5/orange/{(1,0)}, 7.5/3.8/purple/{(1,1)}, 5.5/4.3/pink/{(2,1)}, 3.5/4.6/green!60!black/{(1,2)} }{% \fill[\col!80] (\x,\y) circle (2.5pt); \node[above left=1pt] at (\x,\y) {\lab}; } \end{tikzpicture} \end{document} egreg's case mentioned in the comment: \documentclass[tikz,border=5pt]{standalone} \begin{document} \begin{tikzpicture} \foreach \x/\y/\col in {% 2.5/1.2/blue, 4/2.0/teal, 6/2.5/orange, 7.5/3.8/purple, 5.5/4.3/pink, 3.5/4.6/green!60!black } {% \fill[\col!80] (\x,\y) circle (2.5pt); \node[above left=1pt] at (\x,\y) {}; } \end{tikzpicture} \end{document} Without % after 3.5/4.6/green!60!black, it complained that: ! Package xcolor Error: Undefined color `black '. See the xcolor package documentation for explanation. Type H <return> for immediate help. ... l.15 } ? That black indicate that there is extra space at linebreak.... It can be fixed via \foreach \x/\y/\col in {% ... 5.5/4.3/pink, 3.5/4.6/green!60!black} {% \fill[\col!80] (\x,\y) circle (2.5pt); \node[above left=1pt] at (\x,\y) {}; } or \foreach \x/\y/\col in {% ... 5.5/4.3/pink, 3.5/4.6/green!60!black% } {% \fill[\col!80] (\x,\y) circle (2.5pt); \node[above left=1pt] at (\x,\y) {}; } In all, my question is: Why {} in the fourth parameter \lab happened to "gobble" the extra space? Is egreg's comment always must? even in the 3.5/4.6/green!60!black/{(1,2)} case, IMO, "put % appended to the last item" is always a safe approach?

  • Is that possible to tune this NiceTabular Node position?
    by Explorer on October 8, 2025 at 5:02 pm

    What I want is to plot something as below: Now I have the following code: \documentclass{article} \usepackage{nicematrix} \usepackage{tikz} \usetikzlibrary{decorations.pathreplacing} \begin{document} \begin{NiceTabular}{>{\ttfamily}c}[hvlines] \CodeBefore \rowlistcolors{1}{% blue!50, magenta!50,magenta!50,magenta!50, blue!50,blue!50,blue!50, magenta!50,magenta!50,magenta!50, blue!50,blue!50,blue!50, magenta!50,magenta!50,magenta!50, blue!50,blue!50,blue!50, magenta!50,magenta!50,magenta!50, blue!50,blue!50,blue!50, magenta!50 } \Body ... ... \\ darr[3][2] \\ darr[3][1] \\ darr[3][0] \\ darr[2][2] \\ darr[2][1] \\ darr[2][0] \\ darr[1][2] \\ darr[1][1] \\ darr[1][0] \\ darr[0][3] \\ darr[0][2] \\ darr[0][0] \\ ... ... \\ \CodeAfter \begin{tikzpicture} \foreach \x/\y in {2/4,5/7,8/10,11/13}{ \draw[decorate,decoration={brace,mirror,raise=.23cm,amplitude=10}] (\x-1.north west) -- (\y-1.south west); } \foreach \x[count = \i] in {3,6,9,12}{ \node[font=\ttfamily] at ([xshift=-1.25cm]\x-1.west) {darr[\fpeval{4-\i}]}; } \draw[decorate,decoration={brace,mirror,raise=.23cm,amplitude=40}] ([xshift=-1.5cm]2-1.north west) -- ([xshift=-1.5cm]13-1.south west); \node[font=\ttfamily] at ([xshift=-3.65cm]7-1.south west) {darr}; \end{tikzpicture} \end{NiceTabular} \end{document} Which gives: My question is, now the brace's shape and the begin and end point of (\x-1.north west) -- (\y-1.south west) is not exactly what I want, with NiceTabular. Is that possbile to promote the code, to better mimic the desired sketch result?

  • Tikz generates auxlock file [closed]
    by Victor Eijkhout on October 8, 2025 at 1:09 pm

    (Apologies in advance for not having a reproducer. My document is very complicated.) A document that used to work now generates an auxlock file, and that prevents the aux file from being generated, with obvious problems down the road. \def \tikzexternallocked {0} Best I can tell this is caused by a regular update of my TeXlive installation. Otherwise the single pass formatting ends successfully: TeX does not break with an error. I'm using XeTeX, but LuaTeX has the same problem. Does this ring a bell with anyone?

  • How to Incorporate an includegraphics Image into This Braided Frame? [closed]
    by DDS on October 8, 2025 at 12:37 pm

    This post asks for an extension of the answer of @Daniel N found here: How to Give an Elliptical Border a Braided Effect Consider the code: \documentclass[11pt, border=1cm]{standalone} \usepackage{tikz,graphicx} \usetikzlibrary{math, calc} \usetikzlibrary{decorations.markings} \definecolor{CadmiumGreen}{RGB}{0, 107, 60} \definecolor{Gold}{RGB}{228, 168, 53} \definecolor{DarkGold}{RGB}{221, 137, 53} \begin{document} \tikzset{% braid/.style 2 args={% nb of steps, width in pts preaction={draw=DarkGold, line width=#2pt}, decoration={% markings, mark=between positions 0 and 1 step 1/#1 with { \tikzmath{% \dl = \pgfdecoratedpathlength/#1; { \draw[DarkGold, line width=#2/13 pt, fill=Gold, rounded corners=5pt, rotate=-40] (.4*\dl pt, 0) rectangle ++(.7*\dl pt, .8*#2 pt); \draw[DarkGold, line width=#2/10 pt, fill=Gold, rounded corners=3pt, rotate=20] (0, -.3*#2 pt) rectangle ++(\dl pt -1pt, .7*#2 pt); }; } } }, postaction=decorate } } \begin{tikzpicture} \draw[Gold, fill=CadmiumGreen, line width=10pt, braid={60}{12}] ellipse (4.25cm and 5.5cm); %\node[inner sep=0pt] (whitehead) at (0,0){\includegraphics[width=.25\textwidth]{\includegraphics[width=3cm]{example-image-a}}}; \end{tikzpicture} \end{document} which produces the output: I would like to add an image to the tikzpicture; however, when I invoke the commented out command in the code, I get an error. QUESTION: How may I incorporate an \includegraphics picture into the tikzpicture so that I may then adjust to fit nicely within the displayed braided frame? Thank you.

  • Color and font settings overflow causing them to take effect outside the group
    by Clara on October 8, 2025 at 8:57 am

    I made some simple modifications to the code, which better expressed my confusion about why the green color and font size settings were used by the Test node in the upper left corner. \documentclass{article} \usepackage{tikz} \usepackage{tikzpagenodes} \usepackage{everypage} \AddEverypageHook{ \begin{tikzpicture} \node at (current page text area.south west) {Test}; \end{tikzpicture} } \NewDocumentCommand{\CC}{m}{{\sffamily\bfseries\LARGE\begin{itemize}\item \color{green} #1\end{itemize}}} \begin{document} ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par hhhhhh\par \CC{Hello} ooooo \end{document} original question I tried my best to construct an MWE. In this MWE, the \CC command already has {} surrounding, why are the \color{red} and \tfamily leaked? We can see that the Test in the upper left corner is \ttfamily and is red. Is it an issue with itemize? Is it still an issue with \AddEverypageHook? In this MWE, I constructed many blank lines using \par because Hello happens to be on the first line of the next page, which is why this situation occurs. I found that replacing #1 with {#1} can solve the problem. I am currently confused about two points. 1. The \CC command already has {} surround, why do \color{red} and \tfamily leak? Why does this situation only occur when Hello happens to be on the first line of the next page. Is it caused by the triggering mechanism of \AddEverypageHook? \documentclass{article} \usepackage{tikz} \usepackage{tikzpagenodes} \usepackage{everypage} \AddEverypageHook{ \begin{tikzpicture} \node at (current page text area.south west) {Test}; \end{tikzpicture} } \NewDocumentCommand{\CC}{m}{{\ttfamily\begin{itemize}\item #1\end{itemize}}} \begin{document} ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par ~\par hhhhhh\par \CC{\color{red}Hello} ooooo \end{document} Edit by @jlab This issue concerns all font settings, not only the color, even when set inside an environment, where we usually don't expect that this can be propagated elsewhere. It it related with the shipout/background hook used internally by \AddEverypageHook. We can reproduce it without tikz nor everypage: \documentclass{article} \AddToHook{shipout/background}{% \put (1in,-1in){ [shipout/background] } } \NewDocumentEnvironment{test}{}{% \sffamily\bfseries\LARGE \begin{itemize} \item }{% \end{itemize} } \begin{document} \vspace*{\dimeval{\textheight-2\baselineskip}} A line \begin{test} Test environment \end{test} Another line \end{document}

  • Help with drawing a smooth curve through given points in TikZ
    by RiverSage on October 8, 2025 at 7:48 am

    I’m trying to draw a smooth curve that passes through a set of given points in TikZ. I’ve experimented with several approaches, including plot[smooth], to[curve through={...}], and the hobby library, but I can’t seem to achieve the desired smooth shape. Here’s a simplified example of my current code: \documentclass[tikz,border=5mm]{standalone} \usetikzlibrary{hobby} \begin{document} \begin{tikzpicture}[scale=0.45, every node/.style={font=\small}, use Hobby shortcut] %Axis and grid \draw[step=1, black!40,] (-8,-6) grid (8,6); \draw[very thick,->] (-8,0) -- (8,0) node[right] {$x$}; \draw[very thick,->] (0,-6) -- (0,6) node[above] {$y$}; %Curve % \draw[thick, smooth] plot coordinates { % (-7,-3) (-6,0) ( -5,3) (-3,6) (-1,2) (0,0) (1,-2) (3,-6) (5,-3) (6,0) (7,3) % }; \draw (-7,-3) to[curve through={ ([tension=2] -6,0) ([tension=2] -5,3) ([tension=2] -4,5) ([tension=2] -3,6) ([tension=2] -2,5) ([tension=2] -1,2) ([tension=1] 0,0) ([tension=2] 1,-2) ([tension=2] 2,-5) ([tension=2] 3,-6) ([tension=2] 4,-5) ([tension=2] 5,-3) ([tension=2] 6,0) }] (7,3); \end{tikzpicture} \end{document} I’m attaching an image of the shape I’d like to achieve. Could someone please suggest the correct way to draw a smooth continuous curve that passes through all these points? Thank you!

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

    Here the curve is drawn with a single color (red) It's easy to get the solution curve. The below figure is drawn in this app for y'=x^2+y^2-1, y(0)=1/2. As you can notice the color of the curve is varying from red (x<-1) to purple (-1<x<1) then to blue (x>1). It is not color set of the rainbow, so it is not synchronious to the Rainbow colormap. My question: How to add a given colormap (such as Rainbow) to a solution curve of a vector field? I guess this is a kind of popular, but can not find a way with Asymptote. I expect not only Asymptote code but also any others as TikZ, MetaPost, lua, etc. The code should be apply for any colormaps Please use my code here as MWE.

  • latex/tikz loop issue
    by xico net on October 7, 2025 at 7:22 pm

    I have a foreach loop which includes labels in a .tex document: \documentclass[tikz,border=5mm]{standalone} \begin{document} \begin{tikzpicture} \foreach \x/\y/\col/\lab in { 2.5/1.2/blue/(0,0), 4/2.0/teal/(0,1), 6/2.5/orange/(1,0), 7.5/3.8/purple/(1,1), 5.5/4.3/pink/(2,1), 3.5/4.6/green!60!black/(1,2) }{ \fill[\col!80] (\x,\y) circle (2.5pt); \node[above left=1pt] at (\x,\y) {\lab}; } \end{tikzpicture} \end{document} The problem is that the expected labels (0,0), (0,1)... are drawn as (0 , (1, , etc.. and the pgf package complains that no shape named '0' is known. I'm very new to latex and tikz, sorry if my issue seems trivial. How could I fix this?

  • Arrays in TikZ environments, dynamic availability of location index
    by Reinhard Neuwirth on October 7, 2025 at 9:25 am

    I wish to to define graphics based on information contained in various arrays, therefore define these arrays in the tikzpicture environment. In using these arrays I need to have dynamic access to the 'location index' in \foreach statements. With arrays defined explicitly there appears to be no issue, however I need to define my arrays as macros in \def statements, for which the PGF/TikZ manual states in Section 94.2 states double braces, like \def\myarray{{1,2,3,0}}, to be mandatory. However, running the \foreach statement for such arrays only generates the first index. One advise I have is that including a evaluate clause in the \foreach options would fix the problem - whether the clause should read evaluate=\index as \index or evaluate=\index as \xeval I am not certain, but evidently neither has the desired effect. What does fix the problem though, even obviating the need for the evaluate clause, is to define my arrays with single brackets, like \def\myarray{1,2,3,0}. The concern I have is what ramifications this may produce further down the track. PGF/TikZ seems quite definitive about the need for double braces! \documentclass{article} %----------------------- \usepackage{tikz} \begin{document} \section{Exlicit array} \begin{tikzpicture} \foreach \x [count=\index from 0] in {1,2,3,0} { \node at (\index, 0) {\index: \x}; } \end{tikzpicture} \section{Macro defined array, double braces} \begin{tikzpicture} \def\myarray{{1,2,3,0}} \foreach \x [count=\index from 0] in \myarray { \node at (\index, 0) {\index: \x}; } \end{tikzpicture} \begin{tikzpicture} \def\myarray{{1,2,3,0}} \foreach \x [count=\index from 0, evaluate=\index as \index] in \myarray { \node at (\index, 0) {\index: \x}; } \end{tikzpicture} \begin{tikzpicture} \def\myarray{{1,2,3,0}} \foreach \x [count=\index from 0, evaluate=\index as \xeval] in \myarray { \node at (\index, 0) {\index: \x}; } \end{tikzpicture} \section{Macro defined array, single braces} \begin{tikzpicture} \def\myarray{1,2,3,0} \foreach \x [count=\index from 0] in \myarray { \node at (\index, 0) {\index: \x}; } \end{tikzpicture} \end{document}

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

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

  • Is there better method to declare tikz picture with proper baseline and fontsize?
    by Explorer on June 13, 2025 at 11:52 am

    I want to use tikz to custom construct the following "steel" symbols: With my poor tikz practice, I get the following MWE: \documentclass{article} \usepackage{tikz} \newcommand*\steelA{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw (0,-.85ex) -- (0,.85ex); }}% \newcommand*\steelB{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw (0,-.85ex) -- (0,.85ex) (-.3em,-.85ex) -- (.3em,-.85ex); }}% \newcommand*\steelC{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw[xshift=-.1em] (0,-.85ex) -- (0,.85ex); \draw[xshift=.1em] (0,-.85ex) -- (0,.85ex); \draw (-.3em,-.85ex) -- (.3em,-.85ex); }}% \newcommand*\steelD{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw[xshift=-.1em] (0,-.85ex) -- (0,.85ex); \draw[xshift=.1em] (0,-.85ex) -- (0,.85ex); \draw (-.3em,-.85ex) -- (.3em,-.85ex) (-.3em,.85ex) -- (.3em,.85ex); }}% \begin{document} A\steelA B A\steelB B A\steelC B A\steelD B { \Huge% A\steelA B A\steelB B A\steelC B A\steelD B }% \end{document} But there are some drawbacks: poor method to handle the absolute distance(with some hard-encoded parameters(eg. .85ex)) the handle of baseline is not eleagnt, and not perfectly align: I want the top of the symbol EXACTLY the same height as A and B; and the bottom of the symbol the same depth as A and B When I test the different fontsize, it seemed that the symbol's thickness is too thin, is that possible to automaticallly change the thickness? Or in other word, how to better turn a tikzpicture into a "text symbol"? Sorry for (a little) mix three requirements together, but sepreate it into three questions seemed a bit inefficient. Thanks in advance! Edited with the symbol's information: but I don't know anything about these symbols, so maybe this style does not really make sense It comes from a standard file "GB 50010-2010"(I'm sorry for I can't provide the link here) at Page.22. The steel is graded into FOUR levels:

  • Issue: Unable to Display Text Below TikZ Code in LyX"
    by Evya1 on January 20, 2024 at 10:35 am

    I am currently facing a challenge in LyX where, after typing several lines of text, I insert TikZ code either inside a TeX box or directly into the apex preamble. However, I have observed that the text following the TikZ code is not visible. In the case of placing the code in the preamble, none of the text I have written in the document is visible. I am seeking assistance in resolving this issue and understanding how to ensure the proper display of text below inserted TikZ code in LyX. Any guidance or solutions would be greatly appreciated. LyX file: #LyX 2.3 created this file. For more info see http://www.lyx.org/ \lyxformat 544 \begin_document \begin_header ... \end_header \begin_body \begin_layout Standard Text here. 1 Algorithms - question 1 1 . ~~~Trying to show the figure here ~~~ ~~~ Text of the solution that isn't shown in rendered pdf~~~ \end_layout \end_body \end_document LaTeX preamble: \usepackage{autobreak} \usepackage{fontspec} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{autobreak} \usepackage{xcolor} \usepackage{amssymb} \usepackage{polyglossia} \usepackage{tikz} \setmainlanguage{hebrew} \setotherlanguage{english} \spaceskip=1\fontdimen2\font plus 1\fontdimen3\font minus 1.5\fontdimen4\font \everymath{\, } \usepackage{xcolor} \definecolor{blue}{RGB}{14,107,217} \definecolor{green}{RGB}{0,158,40} \definecolor{red}{RGB}{235,16,16} \definecolor{brown}{RGB}{164,66,0} \definecolor{orange}{RGB}{231,135,26} \definecolor{purple}{RGB}{94,53,177} \usepackage{amssymb} \renewcommand{\qedsymbol}{$\blacksquare$} \pagestyle{empty} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows, positioning} \begin{document} \begin{tikzpicture}[->,>=stealth',auto,node distance=2.5cm, thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries, minimum size=1cm}, align=center] \node[main node] (s) {$s$}; \node[main node] (v1) [below right=0.8cm and 1.8cm of s] {$v_1$}; \node[main node] (v2) [above right=0.8cm and 1.8cm of s] {$v_2$}; \node[main node] (vn-3) [right=1.2cm of v1] {$v_{n-3}$}; \node[main node] (vn-2) [right=1.2cm of v2] {$v_{n-2}$}; \node[main node] (t) [below right=0.8cm and 1.8cm of vn-2] {$t$}; \draw [->] (s) -- (v1); \draw [->] (s) -- (v2); \draw [->] (vn-3) -- (t); \draw [->] (vn-2) -- (t); \draw [dashed] [->,blue] (v1) -- (vn-2); \draw [dashed] [->,blue] (v2) -- (vn-3); \draw [dashed, ->, bend right] (v1.north) to (v2.south); \draw [dashed, ->, bend] (v2.south) to (v1.north); \draw [dashed, ->, bend right] (vn-3.north) to (vn-2.south); \draw [dashed, ->, bend] (vn-2.south) to (vn-3.north); % Add dashed lines to represent the cutted paths \draw [dashed] (s) -- (v1); \draw [dashed] (s) -- (v2); \draw [dashed] (v1) -- (vn-3); \draw [dashed] (v2) -- (vn-2); \draw [dashed] (vn-3) -- (t); \draw [dashed] (vn-2) -- (t); \end{tikzpicture} \end{document}

  • Draw a great circle passing through two points on a sphere
    by abc123 on July 12, 2022 at 6:19 pm

    Hi, I would like to draw something like the image below using TikZ - a great circle passing through two points on a sphere.

  • How to plot vector field of a function with tikz?
    by Huhu on August 11, 2021 at 5:44 am

    How can I draw a vector field of a function with tikz? For example f(x,y) = 4x2 + y2 - 5

  • Tikz with equation regions
    by sean1860 on November 5, 2020 at 11:57 am

    I'd like to plot in tikz the below constraint on the unit cube defined by the region x, y, z in [-1, 1]. x^2 + y^2 + z^2 - 2 * x * y * z <= 1 I found Making a 3D colored pyramid in tikz though it doesn't work with the above constraint. The following is the graph from http://www.jstor.org/stable/10.2307/2684832. I'd prefer it to look more "modern" or similar to the 3d pyramid style. Any help is much appreciated.

  • How to uncover underbraces without unwanted text moves?
    by natsirt on October 30, 2019 at 12:02 pm

    I'm trying to uncover underbraces, and I do not want distracting and annoying text moves, like in this example : \documentclass[12pt,a4paper]{beamer} \usepackage{tikz} \usetikzlibrary{arrows, arrows.meta, bending, calc, fadings, hobby, positioning, shadows, shadows.blur, shapes, shapes.misc, tikzmark} \usetikzlibrary{matrix, overlay-beamer-styles} \begin{document} \begin{frame} $(2k+1)^2=(2k+1)(2k+1)=2k\!\times\!2k+2k\!\times\!1+1\!\times\!2k+1\!\times\!1$\\ \pause $\hphantom{(2k+1)^2}=4k^2+2k+2k+1 = \alt<2>{4k^2+4k+1}{{\underbrace{4k^2\onslide<3->}_{\text{pair}}+\underbrace{4k\onslide<3->}_{\text{pair}}+1}}$ \pause so $(2k+1)^2$ is also odd \end{frame} \end{document} This renders to : I can imagine tricks with box saving, measurement and \rule, or \hphantom, or opacity and \rlap, but this seems to be tricky and ungly solutions. Do you have some ideas to get an elegant solution ? Many thanks in advance.

  • Intersection of a line with a plane, where is wrong in my code?
    by minhthien_2016 on February 3, 2019 at 3:07 pm

    Let SABCD be a pyramid, A(0,0,0), B(-2,5,0), C(4,4,0), D(6,2,0), S(a,b,h), O is intersection of two line AC and BD. A plane passing through O and parallel to the lines AB and SC cut the lines AB, BC, SB, SA respectively at E, F, G, H. We can prove that EF, GH are parallel to AB and OH is parallel to SC. In my code, I see that, OH is not parallel to SC. By calculting, I have coordinates of the point H (in picture is H') is ({-238*\h*\a/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h*\b/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h^2/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}) and then, OH' is parallel to SC. This is my code base on the answer at Intersection of a line with a plane, where is wrong in third way? \documentclass[border=3.14mm,12pt,tikz]{standalone} \usepackage{tikz,tikz-3dplot} \usetikzlibrary{intersections,calc,backgrounds} %% smuggling from https://tex.stackexchange.com/a/470979/121799 \newcounter{smuggle} \DeclareRobustCommand\smuggleone[1]{% \stepcounter{smuggle}% \expandafter\global\expandafter\let\csname smuggle@\arabic{smuggle}\endcsname#1% \aftergroup\let\aftergroup#1\expandafter\aftergroup\csname smuggle@\arabic{smuggle}\endcsname } \DeclareRobustCommand\smuggle[2][1]{% \smuggleone{#2}% \ifnum#1>1 \aftergroup\smuggle\aftergroup[\expandafter\aftergroup\the\numexpr#1-1\aftergroup]\aftergroup#2% \fi } \def\parsecoord(#1,#2,#3)>(#4,#5,#6){% \def#4{#1}% \def#5{#2}% \def#6{#3}% \smuggle{#4}% \smuggle{#5}% \smuggle{#6}% } \def\SPTD(#1,#2,#3).(#4,#5,#6){#1*#4+#2*#5+#3*#6} \def\VPTD(#1,#2,#3)x(#4,#5,#6){(#2*#6-#3*#5,#3*#4-#1*#6,#1*#5-#2*#4)} \def\VecMinus(#1,#2,#3)-(#4,#5,#6){(#1-#4,#2-#5,#3-#6)} \def\VecAdd(#1,#2,#3)+(#4,#5,#6){(#1+#4,#2+#5,#3+#6)} \tikzset{intersection of line trough/.style args={#1 and #2 with plane containing #3 and normal #4}{% /utils/exec={\pgfmathsetmacro{\ltest}{abs(\SPTD#2.#4-(\SPTD#1.#4))} \parsecoord#1>(\myAx,\myAy,\myAz) \parsecoord#2>(\myBx,\myBy,\myBz) \ifdim\ltest pt<0.01pt \typeout{Plane\space and\space line\space are\space parallel!\ltest} \pgfmathsetmacro{\myd}{0} \else \pgfmathsetmacro{\myd}{((\SPTD#3.#4)-(\SPTD#1.#4))/((\SPTD#2.#4)-(\SPTD#1.#4))} \fi %\typeout{({\myAx+\myd*(\myBx-\myAx)},{\myAy+\myd*(\myBy-\myAy)},{\myAz+\myd*(\myBz-\myAz)})} \def\myP{({\myAx+\myd*(\myBx-\myAx)},{\myAy+\myd*(\myBy-\myAy)},{\myAz+\myd*(\myBz-\myAz)})} \smuggle\myP}, insert path={% \myP} }} \begin{document} \tdplotsetmaincoords{70}{90} \begin{tikzpicture}[tdplot_main_coords,scale=1,line join = round, line cap = round] \pgfmathsetmacro\a{3} \pgfmathsetmacro\b{3} \pgfmathsetmacro\h{4} % definitions \path coordinate(A) at (0,0,0) coordinate (D) at (6,2,0) coordinate (C) at (4,4,0) coordinate (B) at (-2,5,0) coordinate (S) at (\a,\b,\h) coordinate (H') at ({-238*\h*\a/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h*\b/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h^2/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}) ; \begin{scope} \draw [dashed, name path=B--D] (B) -- (D); \draw [dashed, name path=A--C] (A) -- (C); \path [name intersections={of=B--D and A--C,by=O}]; \end{scope} \def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)} \typeout{\mynormal:(-5 \h, -2 \h, -28 + 5 \a + 2 \b)} \path[intersection of line trough={(0,0,0) and (6,2,0) with plane containing (34/11, 34/11, 0) and normal (-5 \h, -2 \h, -28 + 5 \a + 2 \b)}] coordinate (E); \def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)} \typeout{\mynormal:(-5 \h, -2 \h, -28 + 5 \a + 2 \b)} \path[intersection of line trough={ (-2,5,0) and (4,4,0) with plane containing (34/11, 34/11, 0) and normal (-5 \h, -2 \h, -28 + 5 \a + 2 \b)}] coordinate (F); \def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)} \typeout{\mynormal:(-5 \h, -2 \h, -28 + 5 \a + 2 \b)} \path[intersection of line trough={(0,0,0) and (\a,\b,\h) with plane containing (34/11, 34/11, 0) and normal (-5 \h, -2 \h, -28 + 5 \a + 2 \b)}] coordinate (H); \def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)} \typeout{\mynormal:(-5 \h, -2 \h, -28 + 5 \a + 2 \b)} \path[intersection of line trough={(-2,5,0) and (\a,\b,\h) with plane containing (34/11, 34/11, 0) and normal (-5 \h, -2 \h, -28 + 5 \a + 2 \b)}] coordinate (G); \begin{scope} \draw[very thick] (S)--(A) -- (D) --(C) -- (B) --cycle (S)-- (B) (S)--(C) (S)--(D) (H)--(E) (F)--(G); \draw[dashed] (S) -- (O) (A) --(B) (H)--(G) (E)-- (F) (O) --(H); \end{scope} \draw[dashed,red] (O) -- (H'); \foreach \point/\position in {A/left,D/below,C/below,S/above,B/right,O/below,E/left,F/right,G/right,H/left,H'/above} { \fill (\point) circle (1.5pt); \node[\position=1.5pt] at (\point) {$\point$}; } \end{tikzpicture} \end{document} Where is wrong in my code? I did as marmot's comment, and got \documentclass[border=3.14mm,12pt,tikz]{standalone} \usepackage{tikz,tikz-3dplot} \usetikzlibrary{intersections,calc,backgrounds} %% smuggling from https://tex.stackexchange.com/a/470979/121799 \newcounter{smuggle} \DeclareRobustCommand\smuggleone[1]{% \stepcounter{smuggle}% \expandafter\global\expandafter\let\csname smuggle@\arabic{smuggle}\endcsname#1% \aftergroup\let\aftergroup#1\expandafter\aftergroup\csname smuggle@\arabic{smuggle}\endcsname } \DeclareRobustCommand\smuggle[2][1]{% \smuggleone{#2}% \ifnum#1>1 \aftergroup\smuggle\aftergroup[\expandafter\aftergroup\the\numexpr#1-1\aftergroup]\aftergroup#2% \fi } \def\parsecoord(#1,#2,#3)>(#4,#5,#6){% \def#4{#1}% \def#5{#2}% \def#6{#3}% \smuggle{#4}% \smuggle{#5}% \smuggle{#6}% } \def\SPTD(#1,#2,#3).(#4,#5,#6){#1*#4+#2*#5+#3*#6} \def\VPTD(#1,#2,#3)x(#4,#5,#6){(#2*#6-#3*#5,#3*#4-#1*#6,#1*#5-#2*#4)} \def\VecMinus(#1,#2,#3)-(#4,#5,#6){(#1-#4,#2-#5,#3-#6)} \def\VecAdd(#1,#2,#3)+(#4,#5,#6){(#1+#4,#2+#5,#3+#6)} \tikzset{intersection of line trough/.style args={#1 and #2 with plane containing #3 and normal #4}{% /utils/exec={\pgfmathsetmacro{\ltest}{abs(\SPTD#2.#4-(\SPTD#1.#4))} \parsecoord#1>(\myAx,\myAy,\myAz) \parsecoord#2>(\myBx,\myBy,\myBz) \ifdim\ltest pt<0.01pt \typeout{Plane\space and\space line\space are\space parallel!\ltest} \pgfmathsetmacro{\myd}{0} \else \pgfmathsetmacro{\myd}{((\SPTD#3.#4)-(\SPTD#1.#4))/((\SPTD#2.#4)-(\SPTD#1.#4))} \fi %\typeout{({\myAx+\myd*(\myBx-\myAx)},{\myAy+\myd*(\myBy-\myAy)},{\myAz+\myd*(\myBz-\myAz)})} \def\myP{({\myAx+\myd*(\myBx-\myAx)},{\myAy+\myd*(\myBy-\myAy)},{\myAz+\myd*(\myBz-\myAz)})} \smuggle\myP}, insert path={% \myP} }} \begin{document} \tdplotsetmaincoords{70}{90} \begin{tikzpicture}[tdplot_main_coords,scale=1,line join = round, line cap = round] \pgfmathsetmacro\a{3} \pgfmathsetmacro\b{3} \pgfmathsetmacro\h{4} % definitions \path coordinate(A) at (0,0,0) coordinate (D) at (6,2,0) coordinate (C) at (4,4,0) coordinate (B) at (-2,5,0) coordinate (S) at (\a,\b,\h) coordinate (H') at ({-238*\h*\a/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h*\b/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h^2/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}) ; \begin{scope} \draw [dashed, name path=B--D] (B) -- (D); \draw [dashed, name path=A--C] (A) -- (C); \path [name intersections={of=B--D and A--C,by=O}]; \end{scope} \def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)} \typeout{\mynormal:(-5*\h, -2*\h, -28 + 5*\a + 2*\b)} \path[intersection of line trough={(0,0,0) and (6,2,0) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}] coordinate (E); \def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)} \typeout{\mynormal:(-5*\h, -2*\h, -28 + 5*\a + 2*\b)} \path[intersection of line trough={ (-2,5,0) and (4,4,0) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}] coordinate (F); \def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)} \typeout{\mynormal:(-5*\h, -2*\h, -28 + 5*\a + 2*\b)} \path[intersection of line trough={(0,0,0) and (\a,\b,\h) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}] coordinate (H); \def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)} \typeout{\mynormal:(-5*\h, -2*\h, -28 + 5*\a + 2*\b)} \path[intersection of line trough={(-2,5,0) and (\a,\b,\h) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}] coordinate (G); \begin{scope} \draw[very thick] (S)--(A) -- (D) --(C) -- (B) --cycle (S)-- (B) (S)--(C) (S)--(D) (H)--(E) (F)--(G); \draw[dashed] (S) -- (O) (A) --(B) (H)--(G) (E)-- (F) (O) --(H); \end{scope} \draw[dashed,red] (O) -- (H'); \foreach \point/\position in {A/left,D/below,C/below,S/above,B/right,O/below,E/left,F/right,G/right,H/left,H'/above} { \fill (\point) circle (1.5pt); \node[\position=1.5pt] at (\point) {$\point$}; } \end{tikzpicture} \end{document} Code is written by Maple \documentclass[border=3.14mm,12pt,tikz]{standalone} \usepackage{tikz,tikz-3dplot} \begin{document} \tdplotsetmaincoords{70}{90} \begin{tikzpicture}[tdplot_main_coords,scale=1,line join = round, line cap = round] \pgfmathsetmacro\a{3} \pgfmathsetmacro\b{3} \pgfmathsetmacro\h{4} % definitions \path coordinate(A) at (0,0,0) coordinate (D) at (6,2,0) coordinate (C) at (4,4,0) coordinate (B) at (-2,5,0) coordinate (S) at (\a,\b,\h) coordinate (O) at (34/11, 34/11, 0) coordinate (E) at (42/11, 14/11, 0) coordinate (F) at (29/11, 93/22, 0) coordinate (H) at ({-238*\h*\a/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h*\b/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h^2/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}) coordinate (G) at ({-2-238*\h*(2+\a)/(11*(-5*\h*(2+\a)-2*\h*(-5+\b)+(-28+2*\b+5*\a)*\h))}, {5-238*\h*(-5+\b)/(11*(-5*\h*(2+\a)-2*\h*(-5+\b)+(-28+2*\b+5*\a)*\h))},{ -238*\h^2/(11*(-5*\h*(2+\a)-2*\h*(-5+\b)+(-28+2*\b+5*\a)*\h))}); \begin{scope} \draw[very thick] (S)--(A) -- (D) --(C) -- (B) --cycle (S)-- (B) (S)--(C) (S)--(D) (H)--(E) (F)--(G); \draw[dashed] (S) -- (O) (A) --(B) (H)--(G) (E)-- (F) (O) --(H); \end{scope} \draw[dashed,red] (O) -- (H); \foreach \point/\position in {A/left,D/below,C/below,S/above,B/right,O/below,E/left,F/right,G/right,H/left} { \fill (\point) circle (1.5pt); \node[\position=1.5pt] at (\point) {$\point$}; } \end{tikzpicture} \end{document}

  • How to draw intersect of line sphere?
    by Yim Phearun on August 16, 2018 at 10:35 am

    How to draw intersect of line sphere?

  • Drawing a tangent from a point outside of a circle to it!
    by Hermann on March 27, 2016 at 12:19 am

    I have an easy question. I want to draw the tangents from origin to a circle with center at e.g. (0,2) and radius 1.5. Here the code of the circle: \begin{tikzpicture} \draw[->] (0,-.5) -- (3,-.5) node[right] {$x$}; \draw[->] (0,-.5) -- (0,2) node[above] {$y$}; \draw (0,2) circle (1.5); \end{tikzpicture} I need a simple solution, because I'm not good at drawing with tikz. Thanks!

  • Create angle bisectors in TikZ
    by marmistrz on March 15, 2015 at 4:47 pm

    Suppose we have a triangle ABC of given coordinates. Let AD be its altitude. How can I draw the bisector of angle BCD? I'd like to avoid manual calculation of coordinates. I'd rather not use tkz-euclide due to its lack of English documentation. My minimal working example: \documentclass[11pt]{article} \usepackage{tikz} \usetikzlibrary{positioning,calc,intersections} \begin{document} \begin{tikzpicture} \coordinate[label=below left:$C$](C) at (-2,0); \coordinate[label=below right:$A$](A) at (8,0); \coordinate[label=above left:$B$] (B) at (0,7); \coordinate[label=above right:$D$](D) at ($(A)!(C)!(B)$); \draw (A) -- (B) -- (C) -- cycle; \draw (C) -- (D); \end{tikzpicture} \end{document}

  • How can we make a pumpkin, jack-o-lantern, or other halloween spirit, ghoul, or skeleton?
    by A.Ellett on October 31, 2014 at 7:04 pm

    We have questions about Christmas trees and Hearts for Valentines but we have no questions that specialize in Halloween or Dia de los Muertos art. Here it goes: Using TikZ or PSTricks or any other of your favorite LaTeX tools, create pumpkins, ghouls, etc., appropriate to the season. I think multiple submissions should be fine provided different objects are created.

  • How can I draw a 3D, three-sided 5-7-9 triangle with TikZ or PSTricks?
    by minthao_2011 on March 29, 2014 at 11:23 pm

    I want to draw a triangle with three sides 5, 7, 9 and its incircle in geometry 3D. I used GeospacW. I tried Draw a circle (T) has center origin and has radius r=15/sqrt(11). Take a point A on (T) and draw a circle (C1) has center A and has radius r=5. Find the intersection of points between (T) and (C1), say one of them is B. Draw a circle (C2) has center B and has radius 7. Find the intersection of points between (T) and (C2), say one of them is C. Draw the triangle ABC and its incircle. After drawing the triangle, I draw a pyramid DABC with DC perpendicular to the plane (ABC) and DC=\sqrt{33}/2.