TikZ
- Triangle Nesting ( Similar to Sierpinski Triangles )by Discrete on August 15, 2026 at 7:09 pm
Im curious to know if there is a more efficient way to have triangles repeat themselves in one another without needing to run the \draw command for each line of the triangle; similar to Sierpinski's triangles is essentially what it is but in a different way for nesting. So far i've been doing the \draw command as such \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} [scale = 3] \draw[thick] (0,0) -- (2,0) -- (1,1.73205) -- cycle; \draw[thick] (0,0) -- (1,0.8) (2,0) -- (1,0.8) -- (1,1.73205) -- (1,0.8); \draw[thick] (1,0.8) -- (1.566667,0.769); \end{tikzpicture} \end{document} if you do put this into overleaf or some other LaTeX code editor you'll see roughly what i'm trying to achieve. If there isn't a more efficient way to do it without \draw over and over for each line then I'll just need to have patience to do \draw for each line (as well if my current code isnt enough to show what im trying to achieve then i can provide a more detailed example and unfortunately i have not been able to find any images that show what im trying to get seeing as this is a rather new discovery i have found as far as i know).
- How to draw highly accurate, continuous pH titration curves with the tangent method in TikZ/pgfplots?by Natsu on August 15, 2026 at 5:28 pm
When attempting to plot pH-metric titration curves for weak/polyprotic acids and bases using piecewise Henderson-Hasselbalch approximations, sharp breaks and discontinuous artifacts often appear near equivalence points. Is there a robust, automated way in TikZ and pgfplots to plot continuous curves using exact charge and mass balance equations, while also supporting geometric constructions such as the tangent method (méthode des tangentes)?
- How to reproduce the correct intersection curve of two 3D surfaces using PGFPlots?by Samia Rani on August 10, 2026 at 10:50 am
I am trying to reproduce a 3D figure from a mathematics book in LaTeX using TikZ/PGFPlots. The figure shows two surfaces and their intersection. The two surfaces are given by x^2 + xy - y - 3z = 0 and 2x^2 + 3xy - 2y - 3z = 0. I plotted both surfaces directly from their equations and also added their intersection curve. However, the shape and especially the intersection curve in my output look quite different from the figure in the book, even though I am using the same equations. I am not sure whether the difference is caused by the viewing angle, the plotting ranges, the parametrization of the intersection curve, or something else. Here is my current code: \documentclass[border=5pt]{standalone} \usepackage{pgfplots} \usepackage{tikz} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ view={120}{25}, axis lines=none, xmin=-2.5, xmax=2.5, ymin=-2.5, ymax=2.5, zmin=-5, zmax=5, width=11cm, height=8cm, ticks=none, ] %================================================ % GREEN SURFACE % 2x^2 + 3xy - 2y - 3z = 0 %================================================ \addplot3[ surf, shader=interp, colormap={greenmap}{ color(0cm)=(green!15); color(1cm)=(green!35) }, colormap name=greenmap, domain=-2:2, y domain=-2:2, samples=35, samples y=35, opacity=0.65, ] { (2*x^2 + 3*x*y - 2*y)/3 }; %================================================ % BLUE SURFACE % x^2 + xy - y - 3z = 0 %================================================ \addplot3[ surf, shader=interp, colormap={bluemap}{ color(0cm)=(blue!15); color(1cm)=(blue!35) }, colormap name=bluemap, domain=-2.2:2.2, y domain=-2.2:2.2, samples=30, samples y=30, opacity=0.55, ] { (x^2 + x*y - y)/3 }; %================================================ % INTERSECTION CURVE % gamma(t) = % ( t, -t^2/(2t-1), t^3/(3(2t-1)) ) %================================================ \addplot3[ very thick, red, samples=100, domain=-2.2:0.35, variable=\t, ] ( {\t}, {-\t^2/(2*\t-1)}, {\t^3/(3*(2*\t-1))} ); \addplot3[ very thick, red, samples=50, domain=0.65:2.2, variable=\t, ] ( {\t}, {-\t^2/(2*\t-1)}, {\t^3/(3*(2*\t-1))} ); \end{axis} \end{tikzpicture} \end{document} The book's figure has a noticeably different orientation and shape for the two surfaces and their intersection. The book's figure looks like this: My current output looks like this: Could someone please explain what is causing this difference and how I can modify my PGFPlots code to obtain a figure that looks like the one in the book? In particular, I would like to know whether I should change the view angles, the plotting domains, or the parametrization of the intersection curve.
- How can I draw the plane and intersection curve on a one-sheet hyperboloid in TikZ?by Samia Rani on August 9, 2026 at 5:23 pm
I am trying to recreate the following mathematical figure in LaTeX/TikZ. The figure shows the one-sheet hyperboloid x^2 + y^2 - z^2 = 1 together with the plane 2x + z = 1. Their intersection is the red curve shown on the hyperboloid. After quite a lot of effort, I have managed to draw the one-sheet hyperboloid reasonably well in TikZ. However, I am having difficulty with the two remaining parts: How can I draw the transparent red plane 2x + z = 1 behind/in front of the hyperboloid, as shown in the reference image? How can I draw the red intersection curve between the plane and the hyperboloid so that it lies correctly on the surface? I would like the final figure to look as close as possible to the reference image, including the perspective, transparency of the plane, and the red intersection curve. Here is the code I currently have for the hyperboloid: \documentclass[border=5pt]{standalone} \usepackage{pgfplots} \usepackage{tikz} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture}[>=stealth] \begin{axis}[ view={120}{22}, axis lines=none, xmin=-3.3, xmax=3.3, ymin=-3.3, ymax=3.3, zmin=-2.0, zmax=2.0, xtick=\empty, ytick=\empty, ztick=\empty, clip=false, ] %------------------------------------------------ % Red point at the origin %------------------------------------------------ \addplot3[ only marks, mark=*, mark size=2.5pt, draw=red, fill=red, ] coordinates {(0,0,0)}; %------------------------------------------------ % Smooth one-sheet hyperboloid %------------------------------------------------ \addplot3[ surf, shader=interp, draw=blue!55!black, opacity=0.65, samples=45, samples y=80, domain=-2.2:2.2, y domain=0:360, z buffer=sort, ] ( {sqrt(1+x^2)*cos(y)}, {sqrt(1+x^2)*sin(y)}, {x} ); %------------------------------------------------ % POSITIVE x-axis %------------------------------------------------ \draw[ ->, black, thick ] (axis cs:0,0,0) -- (axis cs:5.0,0,0) node[right] {$x$}; %------------------------------------------------ % NEGATIVE x-axis -- dashed %------------------------------------------------ \draw[ dashed, black, thick ] (axis cs:0,0,0) -- (axis cs:-2.0,0,0); %------------------------------------------------ % POSITIVE y-axis %------------------------------------------------ \draw[ ->, black, thick ] (axis cs:0,0,0) -- (axis cs:0,4.0,0) node[above left] {$y$}; %------------------------------------------------ % NEGATIVE y-axis -- dashed %------------------------------------------------ \draw[ dashed, black, thick ] (axis cs:0,0,0) -- (axis cs:0,-1.0,0); %------------------------------------------------ % POSITIVE z-axis %------------------------------------------------ \draw[ ->, black, thick ] (axis cs:0,0,0) -- (axis cs:0,0,3.0) node[above] {$z$}; %------------------------------------------------ % NEGATIVE z-axis -- dashed %------------------------------------------------ \draw[ dashed, black, thick ] (axis cs:0,0,0) -- (axis cs:0,0,-2.0); %------------------------------------------------ % Origin %------------------------------------------------ \node[ below right, inner sep=1pt ] at (axis cs:0,0,0) {$0$}; %------------------------------------------------ % Equation %------------------------------------------------ \node[ blue!75!black, font=\large ] at (axis cs:2.0,-0.5,1.1) {$x^2+y^2-z^2=1$}; \end{axis} \end{tikzpicture} \end{document} I would be very grateful for any suggestions on how to add the plane and, especially, the intersection curve correctly. Thank you!
- align hitbox of rotated reference cited in TikZ imageby ali bab613 on August 8, 2026 at 2:52 pm
I have a document which calls a .tex file that contains a standalone TikZ image. Within that image, I cite several references in a rotated node. I have the MWE here: main.tex: \documentclass{article} \usepackage{tikz} \usepackage{standalone} \usepackage{hyperref} \begin{document} \input{Chapter1} \bibliographystyle{IEEEtran} \bibliography{references} \end{document} and Chapter 1.tex: \documentclass{standalone} \usepackage{hyperref} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node[color=black,rotate=17] at (3.25,-2.35) {\tiny\cite{Test1,Test2,Test3,Test4,Test5}}; \end{tikzpicture} \end{document} Most answers online deal with hyperref to an image that's entirely rotated, in my case this is one node amongst many, and the picture is not rotated. I did not suppress the hitboxes in hyperref (by using \usepackage[breaklinks]{hyperref}) for demonstration purposes, but the problem (obviously) persists for both cases. Here's a screenshot of the resulting image, and its hitboxes: The issue is not only that the box does not rotate (which isn't a massive problem), it's more that it does not align vertically, especially the further along the node you go. Changing the citation to {\tiny\cite{Test1,Test2,Test3,Test4}\cite{Test5}} also does not adjust the box vertically: This may be a long shot, but is there a way to better align the hitbox with the node?
- TikZ to draw an arrow along the side of a tableby Maronite Monks on August 7, 2026 at 2:06 pm
I have a table to which I'd like to add a curved arrow (with an arrowhead at one end) running outside the table. The line will originate at the upper left portion of a table and end with the arrow pointing at the lower left portion. Another similar arrow will be outside the lower right side of the table and end pointing at the upper right side. I'd like some text to follow the curve of the arrows on each side of the table. The text for the left arrow will say: "Gives rise to the irascible". The text on the right will say: "Resolves in the concupiscible". Here's a MWE I've compiled with LuaLaTeX. \documentclass[12pt]{memoir} \addtolength\tabcolsep{.5in} \renewcommand\arraystretch{1.5} \begin{document} \begin{center} \begin{tabular}{c|c} \hline\hline {\scshape Good}& {\scshape Evil}\\\hline\hline\\[-9pt] love & hate \\\hline desire & avoid \\\hline joy & sad \\\hline\hline\\[-9pt] hope & bold \\\hline despair & fear \\\hline\hline\\[-9pt] & anger \end{tabular} \end{center} \end{document}
- How to easily draw and parameterize various pH titration curves (including diprotic/dibasic) for a beginner?by user446526 on August 6, 2026 at 8:23 am
I am a complete beginner when it comes to drawing complex functional plots in LaTeX. I am trying to create several types of pH titration curves for a document, but I am struggling to write the code from scratch. I found a very helpful French website that seems to have the exact mathematical logic and LaTeX code for what I need: https://www.astrolabe-science.fr/courbes-titrages-acido-basiques-latex/ However, as a beginner, I find it quite difficult to extract just the essential parts to create a simple, easily editable template. I need to recreate the following types of curves (I have attached images of what I am aiming for): The 4 basic monoprotic titrations: Strong Acid, Strong Base, Weak Acid, and Weak Base. Diprotic acid titration: A curve with two equivalence points (increasing pH). Dibase titration: A curve with two equivalence points (decreasing pH). My request: Could someone help provide a simplified, beginner-friendly pgfplots (or TikZ) template based on the math from that website? Ideally, I am looking for a code structure where the main parameters (like initial concentrations, volumes, and pK_a values) are defined at the top so I can easily change them. It would be incredibly helpful if you could include brief comments/instructions inside the code explaining how to switch between the different types of curves (e.g., "change this sign for a base", "uncomment this for a diprotic acid"). Thank you so much for your time and help! I have attached images of what I am aiming for.
- Code Review: A custom TikZ package for drawing Chemistry Reaction Progress Tables (ICE tables)by Natsu on August 3, 2026 at 2:33 pm
As part of my workflow for typesetting educational materials, I frequently need to draw Chemistry Reaction Progress Tables (often known as ICE tables). To automate this, I am developing a small custom package using tikz called tkzPhysTab. The package calculates the grid coordinates automatically based on the number of reactants and products, places the $+$ and $\rightarrow$ signs, and allows adding rows dynamically. Here is the package code (tkzPhysTab.sty): \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{tkzPhysTab}[2025/11/07 Physical Reaction Table by Khaldi] \RequirePackage{tikz} % ============================= % Default Values % ============================= \def\tkzPhysTabFirstColWidth{1.5} % Width of the first column \def\tkzPhysTabColWidth{2.5} % Width of the data columns \def\tkzPhysTabRowHeight{1.0} % Row height % ============================= % Setup pgfkeys % ============================= \pgfkeys{ /tkzPhysTab/.is family, /tkzPhysTab, firstcol/.store in = \tkzPhysTabFirstColWidth, colwidth/.store in = \tkzPhysTabColWidth, rowheight/.store in = \tkzPhysTabRowHeight, reset/.code = { \def\tkzPhysTabFirstColWidth{1.5} \def\tkzPhysTabColWidth{2.5} \def\tkzPhysTabRowHeight{1.0} } } % Counters (Note: I am aware calling \newcounter here might cause issues if called twice, looking for better alternatives) \newcounter{tkzcolsOne} \newcounter{tkzcolsTwo} \newcounter{tkzlevel} \newcounter{tkzrows} % ============================= % Table Initialization Command % ============================= \newcommand{\tkzPhysicsTabInit}[4][]{% % Reset default values \pgfkeys{/tkzPhysTab/reset} % Apply custom options from [options] \pgfkeys{/tkzPhysTab,#1} \setcounter{tkzcolsOne}{0} \setcounter{tkzcolsTwo}{0} \setcounter{tkzlevel}{1} \setcounter{tkzrows}{0} \foreach \c in {#3}{\stepcounter{tkzcolsOne}} \foreach \c in {#4}{\stepcounter{tkzcolsTwo}} \foreach \r in {#2}{\stepcounter{tkzrows}} \pgfmathtruncatemacro{\ncolData}{\thetkzcolsOne + \thetkzcolsTwo} \pgfmathtruncatemacro{\nrows}{\thetkzrows + 1} \pgfmathsetmacro{\W}{\tkzPhysTabFirstColWidth + \ncolData * \tkzPhysTabColWidth} \pgfmathsetmacro{\H}{\nrows * \tkzPhysTabRowHeight} \coordinate (T) at (0,0); \draw[very thick] (T) rectangle (\W,-\H); % Vertical lines \draw (\tkzPhysTabFirstColWidth, 0) -- (\tkzPhysTabFirstColWidth, -\H); \foreach \i in {1,...,\ncolData}{ \pgfmathsetmacro{\xpos}{\tkzPhysTabFirstColWidth + \i * \tkzPhysTabColWidth} \draw (\xpos, -\tkzPhysTabRowHeight) -- (\xpos, -\H); } % Horizontal lines \foreach \j in {1,...,\nrows}{ \draw (0, -\j*\tkzPhysTabRowHeight) -- (\W, -\j*\tkzPhysTabRowHeight); } % Reactants \foreach [count=\i from 1] \c in {#3} { \pgfmathsetmacro{\xcenter}{\tkzPhysTabFirstColWidth + (\i - 0.5) * \tkzPhysTabColWidth} \node at (\xcenter, -\tkzPhysTabRowHeight/2) {\c}; \ifnum\i>1 \pgfmathsetmacro{\xplus}{\tkzPhysTabFirstColWidth + (\i - 1) * \tkzPhysTabColWidth} \node at (\xplus, -\tkzPhysTabRowHeight/2) {$+$}; \fi } % Arrow between reactants and products \pgfmathtruncatemacro{\nReact}{\thetkzcolsOne} \pgfmathsetmacro{\xarrow}{\tkzPhysTabFirstColWidth + \nReact * \tkzPhysTabColWidth} \node at (\xarrow, -\tkzPhysTabRowHeight/2) {$\rightarrow$}; % Products \foreach [count=\i from 1] \c in {#4} { \pgfmathsetmacro{\xcenter}{\xarrow + (\i - 0.5) * \tkzPhysTabColWidth} \node at (\xcenter, -\tkzPhysTabRowHeight/2) {\c}; \ifnum\i>1 \pgfmathsetmacro{\xplus}{\xarrow + (\i - 1) * \tkzPhysTabColWidth} \node at (\xplus, -\tkzPhysTabRowHeight/2) {$+$}; \fi } % Row labels \foreach [count=\j from 1] \r in {#2} { \pgfmathsetmacro{\ycenter}{-(\j + 0.5) * \tkzPhysTabRowHeight} \node at (\tkzPhysTabFirstColWidth/2, \ycenter) {\r}; } } % ============================= % Add Row Command % ============================= \newcommand{\tkzPhysicsTabLine}[1]{% \stepcounter{tkzlevel} \foreach [count=\i from 1] \val in {#1} { \pgfmathsetmacro{\xcenter}{\tkzPhysTabFirstColWidth + (\i - 0.5) * \tkzPhysTabColWidth} \pgfmathsetmacro{\ycenter}{-(\thetkzlevel - 0.5) * \tkzPhysTabRowHeight} \node at (\xcenter, \ycenter) {\val}; } } And here is the Minimum Working Example (MWE) generating the table: \documentclass[border=5mm]{standalone} \usepackage{tkzPhysTab} \begin{document} \begin{tikzpicture} \tkzPhysicsTabInit[firstcol=2.0,colwidth=3,rowheight=1.2]% {$x=0$,$x=t$,$x=f$}% {$Fe_3O_4$,$4H_2$}% {$3Fe$,$4H_2O$} \tkzPhysicsTabLine{$2.18$,$9.65$,$0$,$0$} \tkzPhysicsTabLine{$2.18-x$,$-4x$,$?$,$?$} \tkzPhysicsTabLine{$2.18-x_{\max}$,$-4x_{\max}$,$??$,$??$} \end{tikzpicture} \end{document} My questions for the experts: I initially defined \newcounter inside \tkzPhysicsTabInit, which caused an error when calling the table twice. I fixed this by declaring the counters globally in the package file and using \setcounter inside the macro to reset them. Is this the standard LaTeX best practice, or is there a more elegant way to handle local counters/variables in this context without polluting the global namespace? Is manually calculating coordinates using \pgfmathsetmacro the most efficient way to draw this grid, or would you recommend using TikZ libraries like matrix or integrating with packages like tabularray? Are there any other optimizations or best practices you would suggest to make this package more robust for general users? Thank you in advance for your insights!
- How to better design the binary switch option in TikZ case?by Explorer on July 1, 2026 at 7:31 am
I have the following code modified from my previous question: % https://tex.stackexchange.com/a/96970 % https://tex.stackexchange.com/a/762399 \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{arrows.meta,bending,nfold,ext.nodes,decorations.markings} \makeatletter \tikzset{ foo/.tip={Straight Barb[harpoon,swap,length=5pt]}, mystyle/.style={thick,shorten >=2pt,shorten <=2pt}, offset/.code= \tikz@addoption{% \pgfgetpath\tikz@temp \pgfsetpath\pgfutil@empty \pgfoffsetpath\tikz@temp{#1} }, dualharpoon/.style={ draw=none, postaction={path only,draw,foo-,mystyle,offset=+#1ex}, postaction={path only,draw,-foo,mystyle,offset=-#1ex}, postaction={decorate, decoration={markings, mark=at position 0.5 with { \begin{scope}[yshift=+#1ex] \draw[-,line cap=round,thick] ++ (-.15cm,-.15cm) -- (+.15cm,+.15cm); % \draw[-,line cap=round,thick] ++ (-.15cm,+.15cm) -- (+.15cm,-.15cm); \end{scope} \begin{scope}[yshift=-#1ex] \draw[-,line cap=round,thick] ++ (-.15cm,-.15cm) -- (+.15cm,+.15cm); % \draw[-,line cap=round,thick] ++ (-.15cm,+.15cm) -- (+.15cm,-.15cm); \end{scope} }}, }, }, dualharpoon/.default=.75, } \makeatother \begin{document} \begin{tikzpicture}[ Qstyle/.style={ dualharpoon, ext/auto with offset, % default true ext/auto offset=1ex, auto, }] \node[draw,circle,fill=teal] (A) at (0,1) {A}; \node[draw,circle,fill=magenta] (B) at (0,-1) {B}; \node[draw,circle,fill=cyan] (C) at (2.5,.5) {C}; \draw[magenta,Qstyle] (A) to[bend right] node {$\Delta$} node[swap]{$\nabla$} (B); \draw[teal,Qstyle] (B) to[bend right] node {$f(x)$} node[swap]{$g(x)$} (C); \draw[orange,Qstyle] (A) -- node {$x$} node[swap]{$y$} (C); \end{tikzpicture} \end{document} Now I want two control switches: which one to place slash: positive offset one? negetive one? or both? or none? which direction to put slash? forward: \draw[-,line cap=round,thick] ++ (-.15cm,-.15cm) -- (+.15cm,+.15cm); and \draw[-,line cap=round,thick] ++ (-.15cm,-.15cm) -- (+.15cm,+.15cm); backward: \draw[-,line cap=round,thick] ++ (-.15cm,+.15cm) -- (+.15cm,-.15cm); or \draw[-,line cap=round,thick] ++ (-.15cm,+.15cm) -- (+.15cm,-.15cm);? Or in other word, I want the syntax for example: \draw[magenta,Qstyle,slash side=both,slash direction=backward] (A) to[bend right] node {$\Delta$} node[swap]{$\nabla$} (B); \draw[teal,Qstyle,slash side=positive,slash direction=forward] (B) to[bend right] node {$f(x)$} node[swap]{$g(x)$} (C); \draw[orange,Qstyle,slash side=none] (A) -- node {$x$} node[swap]{$y$} (C); I was after a neat option syntax to encapsulate the logic above. Any suggestions?
- How to avoid duplicate chapter title and absolutely position chapter title with TikZby Chen Mortenfeld on June 12, 2025 at 7:50 pm
I'm customizing chapter titles in my book using the titlesec and tikz packages. For special chapters like the "Preface", I want to: Show a custom TikZ-styled title box that is positioned exactly \TitleBoxOffset below the top of the page (absolute positioning, not relative). Avoid having the chapter title (e.g., "Preface") appear twice on the page — once inside my TikZ box and once from LaTeX's default chapter title mechanism. So basically "Preface" appears twice, and the location is set manually. Here's my code in the .sty file: \usepackage[explicit]{titlesec} \usepackage{tikz} \usepackage{xcolor} \usepackage{etoolbox} % for \IfStrEq \newcommand{\CurrentChapterTitle}{} \newlength{\ChapterTopSkip} \newcommand{\ChapterHook}[1]{% \renewcommand{\CurrentChapterTitle}{#1}% \IfStrEq{#1}{Preface}{% \titleformat{\chapter} [block] {\centering} {} % no label {0pt} {% \begin{tikzpicture} \node[ draw=lightblue, line width=1pt, rounded corners=10pt, minimum width=0.8\linewidth, minimum height=2cm, align=center, fill=white, fill opacity=1, text opacity=1 ] {\scalebox{1.4}{\textcolor{lightblue}{\Huge{#1}}}}; \end{tikzpicture} } % \titlespacing*{\chapter}{0pt}{-\topskip}{20pt} \titlespacing*{\chapter}{0pt}{-95pt}{20pt} } {% \titleformat{\chapter}[block] {\normalfont\scshape\Huge\centering} {\fontsize{140pt}{140pt}\selectfont\thechapter\\} {0pt} {\normalfont\scshape\Huge\centering #1} }% } % % Patch \chapter to call ChapterHook \let\oldchapter\chapter \renewcommand{\chapter}[1]{% \ChapterHook{#1}% \oldchapter{#1}% } % Suppress LaTeX’s default \@makechapterhead \makeatletter \renewcommand{\@makechapterhead}[1]{} \makeatother Update: I updated the code block to include the packages. Thanks to the comments, I managed to make the word "Preface" appear only once, by using: \usepackage[explicit]{titlesec} see the update code. Now my only issue is the position of the title that I define manually — I want it to be at position 0 relative to the page boundaries, and then I’ll subtract a fixed predefined offset from it. Thank you!
- Partially dashed orthogonal projection of a straight line onto a planeby Mr.Price on February 11, 2025 at 7:23 pm
I have the following 3D plot in Tikz which represents plane, segment that intersects the plane and the orthogonal projection of that segment onto that plane: \documentclass[tikz, margin=2mm]{standalone} \usetikzlibrary{angles, quotes} \usepackage{amssymb} \usetikzlibrary {arrows.meta, shapes.geometric, trees, shapes, backgrounds,intersections, patterns,decorations.markings} \usepackage{pgfplots} \usepgfplotslibrary{units} \usetikzlibrary{positioning} \usepackage{amsmath, amssymb} \usepackage{siunitx} \usepackage{tikz-3dplot} \usepackage[dvipsnames]{xcolor} \usepackage{polski} \usepackage{tkz-euclide} \begin{document} \tikzset{background grid/.append style={step=.5cm, ultra thin, dashed, gray!50}} \begin{tikzpicture}[show background grid, >=Stealth] \begin{scope}[canvas is xz plane at y=0] \path[] (0,0) coordinate (A) (4,0) coordinate (B) (4,4) coordinate (C) (0,4) coordinate (D) (2,2) coordinate (Q) (5,0) coordinate (P') ; \end{scope} \begin{scope}[canvas is xz plane at y=3] \path[] (5,2) coordinate (P); \end{scope} \tkzDrawPolygon[thick, fill=Dandelion!50, fill opacity=0.8](A,B,C,D) \tkzDefMidPoint(P,Q)\tkzGetPoint{MPQ} \tkzDrawSegment[Green, thick](P,Q) \tkzLabelSegment[Green, left, pos=0.85](P,Q){$k$} \tkzDrawPoints[black, size=3pt](P,Q) \tkzLabelPoint[above left=0 and -1mm](P){$P$} \tkzDrawSegment[Red, thick, add=1.3 and 0.5](Q,P') \end{tikzpicture} \end{document} The output is the following: What I want to do is to extend that segment to make it look like a line that cuts the plane in such a way that the part below plane is solid but the part between cutting point and bottom part of the plane is dashed. How can I do that? And also, is there a way to calculate the coordinates of orthogonal projection of point P on that plane? I just set its y coordinate to 0 but it does not seems to be correct, expecially when I want to draw an straight angle.
- Drawing the Steinmetz solid with TikZby Knudsen on September 13, 2024 at 10:48 pm
I want to draw the Steinmetz solid, the volume enclosed by two cilinder of same radius intersecting orthogonaly. I have so far been able to draw the circles in 3D and the lines till their intersecting point. \documentclass{standalone} \usepackage{tikz,tikz-3dplot} \begin{document} \def\rotx{60} \def\rotz{110} \def\eps{0.5} \tdplotsetmaincoords{\rotx}{\rotz} \begin{tikzpicture}[tdplot_main_coords][scale=0.75] \tikzstyle{every node}=[font=\small] % The axis: \draw[dashed,-latex] (-5,0,0) -- (6,0,0) node[anchor=north east]{$x$}; \draw[dashed,-latex] (0,-5,0) -- (0,6,0) node[anchor=north west]{$y$}; \draw[dashed,-latex] (0,0,-5) -- (0,0,6) node[anchor=south]{$z$}; \draw [very thick,blue](0,-3-\eps,0) [y={(0,0,1)}] circle (3); \draw [very thick,blue](0,3+\eps,0) [y={(0,0,1)}] circle (3); \draw [very thick,red](-3-\eps,0,0) [x={(0,0,1)}] circle (3); \draw [very thick,red](3+\eps,0,0) [x={(0,0,1)}] circle (3); \foreach \angle in {0,10,...,360} { %calculate the sine and cosine of the angle \tdplotsinandcos{\sintheta}{\costheta}{\angle}% % draw the lines \draw[thin, blue] (3*\costheta,-3-\eps, 3*\sintheta) -- (3*\costheta,{-3*abs(\costheta)},3*\sintheta) (3*\costheta,{3*abs(\costheta)},3*\sintheta) -- (3*\costheta,3+\eps, 3*\sintheta); \draw[thin, red] (-3-\eps, 3*\costheta,3*\sintheta) -- ({-3*abs(\costheta)},3*\costheta,3*\sintheta) ({3*abs(\costheta)},3*\costheta,3*\sintheta) -- (3+\eps, 3*\costheta,3*\sintheta); } \end{tikzpicture} \end{document} that renders as: but I am taking a black eye at drawing the intersecting elipses and hiding the lines that are not supposed to be visible. Are there automated ways to do this in TikZ and even to do a better picture of the solid, possibly using the shaded surface? Added Sep 14, 2024: After realizing that it would be harder to get a good looking picture from TikZ and a prompts from @Jasper and from @PauloNey, I went to dig a bit deeper on Asymptote. It became imediate clear that the syntax for 3D was easier and the results a lot better. With the code \documentclass{standalone} \usepackage[inline]{asymptote} \begin{document} \thispagestyle{empty} \begin{asy} import graph3; import solids; pen myBlue = cmyk(1.00, 0.15, 0, 0); pen myRed = cmyk(0, 1.00, 1.00, 0); size(0,150); currentprojection=orthographic(1,1/1.7,1/1.6); // usage revolution r = cylinder(start,radius,length,ax); revolution r=cylinder(O,1,2.8,X); draw(surface(r),myBlue,render(merge=true)); revolution r=cylinder((1.4,-1.4,0),1,2.8,Y); draw(surface(r),myRed,render(merge=true)); \end{asy} \end{document} one can get: but it is clear that ligthing is happening in one cylinder as if the other were not there, that is, on each independent of the other.
- Can I simulate colour-blindness (in Beamer / TikZ)by Chris H on July 22, 2024 at 3:31 pm
I'm putting together a talk on figures for publications, and one point I want to make is about them being accessible to colour-blind readers/viewers. So far I've been using ColorOracle to simulate what a colour-blind person might see (it's also handy for simulating greyscale). However this has a few downsides: It isn't an option using someone else's machine, like one of our seminar room setups, it doesn't play nicely with multiple monitors, and as soon as you click on another window, the display reverts to normal. This is probably wishful thinking, but is there a simple way to switch the contents of my slides to a simulated view? Just the LaTeX/TikZ content would be good, though of course imported logos and graphics would be better. Otherwise I would look for an external tool that can generate PDFs that I can then include, but that's not as flexible on the day. Some very useful background is in the preprint Easy colorblind-safe typesetting: General guidelines and a helpful LATEX package, Simon Pfahler TUG2024. My goals are similar.
- Sphere with a randomly marked region and an equatorial circleby hteica on June 17, 2024 at 2:42 pm
I'm working with spheres in 3D and would like to draw a sphere with an open region $U$ with color green and enclosed closed region $E$ filled with color red such that $E \subset U$. And a vector $x$ on the sphere with the dotted equatorial circle, however this circle should disappear in the region $U$. There is a similar post about this: Random closed line on a 3d sphere. I'd be gladly for any codes/tips/resources where I can learn to do this. Thank you
- How to build cylinders similar to this, but in reverse?by TCR on April 8, 2024 at 8:06 pm
How to build cylinder in tikz like shown in this example The example above builds a set of ever-larger cylinders on top of each other with texts on the side, starting at the bottom. The example output and code is replicated here. The source is the link above. \documentclass[border=3.14pt]{standalone} \usepackage{pgfplots} \definecolor{myellow}{RGB}{228,212,0} \definecolor{mgreen}{RGB}{5,104,57} \newcommand\funnel[3]{% \pgfmathsetmacro\mwid{(2+\xi*.7)} \pgfmathsetmacro\marc{\mwid-.4} \begin{scope}[% shift={(0,#1)}, line width=.05pt, %x=5mm, %scale=1.\xi, yshift=\xi*12 ] \draw[black,bottom color=#2, top color=#2] (-\mwid,0) -- (-\mwid+.4,-1) arc (190:350:\marc cm and 5mm) -- (\mwid,0); \draw[black,fill=#3] (0,0) ellipse (\mwid cm and 5mm); \path (-\mwid,0) -- (-\mwid+.4,-1) coordinate[midway] (a\xi); \end{scope} } \begin{document} \begin{tikzpicture}[ latent/.style={% ,circle ,draw ,thick ,minimum size=10mm } ] \foreach \text [% count=\xi starting from 0, evaluate=\xi as \shadecolor using int(25*\xi), evaluate=\xi as \coord using int(\xi-12) ] in {% Discuss and conclude\\overall findings, Combine the data\\\tiny\itshape (synthesis or meta-analysis), Assess the quality\\of the studies, Extract data from the studies }{% \funnel{\coord}{mgreen!\shadecolor !myellow}{mgreen!\shadecolor !myellow} \node[align=right, anchor=east, inner sep=10pt, font=\scriptsize, text width=2cm] at (a\xi) {\text}; } \end{tikzpicture} \end{document} I am looking for two things: A set of an arbitrary number of ever-larger cylinders on top of each other with texts on the side, starting from the top. Following the ever-larger cylinders, a set of an arbitrary number of ever-smaller cylinders on top of each other with texts on the side, starting from the top. (Effectively the same as the example, but rather than starting from the bottom and go up, it would start from the top and go down.) Ideally the size of the last (and the widest) cylinder from 1 would transition smoothly to the top-most cylinder from 2. In other words, I would like to have to have a set of cylinders first expanding as we move down and then narrowing. Thus far I have been tinkering with the funnel function by trying various combinations of positive and negative signs for \xi, \mwid, etc. None of the combinations have worked. Embarrassingly while the example code produces a wonder set of cylinders almost what I wanted, the PGF/TikZ code in it is much too advanced for my understanding. **Edits: 1. adding the final sentence as it was cut off; 2. steps I have attempted at creating what I wanted.
- How can I remove the Labels of the blue dots on the left plot and change the position of label nr16 in the right plot?by dan1365 on March 30, 2023 at 9:46 am
\documentclass[11pt]{report} \usepackage{pgfplots, pgfplotstable} \pgfplotsset{width=10cm,compat=1.18} \usepackage{graphicx} \usepackage{caption} \usepackage{subcaption} \begin{document} \begin{figure} \centering \begin{subfigure}[tb]{0.48\linewidth} \begin{tikzpicture} \begin{axis}[height=7cm, width=\linewidth, xlabel={}, ylabel={}, ytick={0,500,...,1700}, xtick={0,500,...,1700}, ymin=-170, ymax=1700, xmin=-170, xmax=1700, ymajorgrids, xmajorgrids] \addplot[ scatter/classes={0={blue}, 1={red}}, scatter, mark=*, only marks, scatter src=explicit symbolic, nodes near coords*={\Label}, visualization depends on={value \thisrow{label} \as \Label} %<- added value ] table [meta=class] { x y class label 0.3788 8.1653 0 - 6.3716 4.0196 0 - 0.4225 0.1447 0 - 14.8118 6.6124 0 - 2.7433 2.544 0 - 152.0046 30.6336 1 5 1375 428.5714 1 6 20.51 5.1280 0 - 38.8548 1492.8425 1 8 0.1409 0.000196 0 - }; \end{axis} \end{tikzpicture} \caption{} \label{} \end{subfigure}\hfill \begin{subfigure}[tb]{0.48\linewidth} \begin{tikzpicture} \begin{axis}[height=7cm, width=\linewidth, xlabel={}, ylabel={}, ytick={0,2,...,10}, xtick={0,5,...,20}, ymin=-1.133, ymax=11.333, xmin=-2.266, xmax=22.666, ymajorgrids, xmajorgrids] \addplot[ scatter/classes={0={blue}, 1={red}}, scatter, mark=*, only marks, scatter src=explicit symbolic, nodes near coords*={\Label}, visualization depends on={value \thisrow{label} \as \Label} %<- added value ] table [meta=class] { x y class label 0.3788 8.1653 0 9 6.3716 4.0196 0 10 0.4225 0.1447 0 12 14.8118 6.6124 0 13 2.7433 2.544 0 14 20.51 5.1280 0 15 0.1409 0.000196 0 16 }; \end{axis} \end{tikzpicture} \caption{} \label{} \end{subfigure}\hfill \caption{} \end{figure} \end{document} > Blockquote
- tabularray and babel frenchby jrivet on April 7, 2022 at 1:34 pm
I need to use \usetikzlibrary{babel} but it causes an error in the folowing example. \documentclass[french]{article} \usepackage{babel} \usepackage{tabularray} \usepackage{pgfplots} \usepackage{circuitikz} %to draw an electrical circuit %\usetikzlibrary{babel} %I need this library because I use french babel and circuitikz \begin{document} \begin{center} \begin{tblr}{colspec={Q[c,m]Q[c,m]},vlines,hlines} $y=2x$ & \begin{tikzpicture}[baseline=(current bounding box.center)] \begin{axis}[ xlabel = {$x$}, ylabel = {$y$}, ] \addplot[domain=0:10]{2*x}; \end{axis} \end{tikzpicture} \end{tblr} \end{center} \end{document}
- Tikz : Customize dotted line on a portion of the segmentby RedWest on May 7, 2021 at 2:21 am
I am looking to change the pattern of a segment in the middle of it or after a predefined distance in cm or pt for example. I have tried to look at the draw pattern but without finding any good solutions. Does anyone have any ideas? Here is the basic code : \documentclass[border=1cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node at (0,0) [circle,draw]{$t_1$}; \node at (1.5,0) [circle,draw]{$t_2$}; \node at (3,0) [circle,draw]{$t_3$}; \node at (4.5,0) [circle,draw]{$t_4$}; \node at (6,0) [circle,draw]{$t_4$}; \draw [color=red!100,line width=1pt](0,-0.4) to [bend right=45] (1.5,-0.4); \draw [color=red!100,line width=1pt](1.5,-0.4) to [bend right=45] (3,-0.4); \draw [color=red!100,line width=1pt](3,-0.4) to [bend right=45] (4.5,-0.4); \draw [color=red!100,line width=1pt](4.5,-0.4) to [bend right=45] (6,-0.4); \draw [color=blue!100,line width=1pt](0,-0.4) to [bend right=45] (3,-0.4); \draw [color=green!100,line width=1pt](0,-0.4) to [bend right=45] (3,-0.4); \draw [color=blue!100,line width=1pt](0,0.4) to [bend left=45] (6,0.4); \end{tikzpicture} \end{document}
- Remove Zero as Chapter Number in Header Using scrlayer-scrpageby Echo on April 9, 2020 at 7:16 pm
I am currently working on a layout for a document (based on this post and this), using scrbook with scrlayer-scrpage. After a long struggle to get lines with rounded corners in the header and footer, everything works as expected -- except the numbering of the table of contents in the header. For some reason that I do not understand (I am sure because lack of basic knowledge) it gets a chapter number 0 and section number 0.0, instead of an empty field, which is the desired output for unnumbered chapters. When I compile my document with the slightly modified original code for the header no numbers are given for the table of contents. Based on this, my idea was to use \ifnumbered{chapter}{THEN}{ELSE}, either by redefining \chaptermarkformat and \sectionmarkformat (IDEA 1) or by changing the output for \lehead{} (and \rohead{} IDEA 2). What am I missing? Any help is much appreciated. Thank you in advance. Here is the code containing my approaches and the modified original code for the header and footer for camparison: \documentclass[12pt,paper=a4,DIV=calc,parskip=off,numbers=noenddot,chapterprefix=false]{scrbook} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage[ngerman]{babel} \usepackage[T1]{fontenc} \usepackage{calc} \usepackage[dvipsnames]{xcolor} \usepackage[inner=1.5cm,outer=3.0cm,top=1.5cm,bottom=2cm,headheight=8mm,headsep=1cm,footskip=1cm,includeheadfoot]{geometry} % ,showframe \setlength{\marginparwidth}{2.77cm} \setlength{\marginparsep}{.2cm} \usepackage[onehalfspacing]{setspace} % Chapter Title Layout ------------------------------------------------- % BASED ON: https://tex.stackexchange.com/questions/423091/chapter-heading-designs-in-koma-script \usepackage{tikz} \usetikzlibrary{positioning, backgrounds} \usepackage[outline]{contour} \contourlength{1.25pt} \usepackage{tikzpagenodes} \renewcommand\raggedchapter{\raggedright} \setkomafont{chapter}{\Huge} \setkomafont{chapterprefix}{\LARGE} \newkomafont{chapternumber}{\bfseries\fontsize{75pt}{75pt}\selectfont} \tikzset{ headings/base/.style = { outer sep = 0pt, inner sep = 0pt, %draw, rectangle % just for testing purposes }, headings/chapterbackground/.style = { headings/base, % if shades are to be used (gave ugly results for the shading): % shade, % left color = white, % right color = black, % without shades: color = black }, headings/chapapp/.style = { headings/base, text = black, font = \usekomafont{chapterprefix} }, headings/chapternumber/.style= { headings/base, text = black, font = \usekomafont{chapternumber} } } \makeatletter \renewcommand*\chapterlinesformat[3]{% \ifstr{#1}{chapter}{% \begin{tikzpicture}[baseline=(title.base)] \node[headings/base,anchor=center](title){% \parbox[t]{\dimexpr\textwidth\relax} {\parbox[t][\height]{\dimexpr\textwidth\relax}{\raggedchapter{#3}}\strut}% {\raggedchapter{\leavevmode\vphantom{\textbf{Ôp'}}#3}} //orig: {\raggedchapter #3} }; % chapter number \ifstr{#2}{} { % a phantom chapternumber is set to achieve the same vertical spacing for toc and other unnumbered chapters as for numbered chapters \node(chapternumber)[anchor=south west,headings/chapternumber] at([yshift=-14.5pt] title.north east){\leavevmode\vphantom{88}};% \fill[headings/base,anchor=north west,rounded corners=2.5 pt] ([xshift=4 pt]chapternumber.north west) rectangle ([yshift=-7 pt,xshift=.33\marginparwidth+4 pt]chapternumber.north west);% \fill[headings/base,color=black!85,anchor=north west,rounded corners=2.5 pt] ([yshift=-9 pt,xshift=5.5pt]chapternumber.north west) rectangle ([yshift=-16 pt,xshift=.33\marginparwidth+5.5pt]chapternumber.north west);% \fill[headings/base,color=black!70,anchor=north west,rounded corners=2.5 pt] ([yshift=-18 pt,xshift=9pt]chapternumber.north west) rectangle ([yshift=-25 pt,xshift=.33\marginparwidth+9pt]chapternumber.north west);% \fill[headings/base,color=black!50,anchor=north west,rounded corners=2.5 pt] ([yshift=-27 pt,xshift=16.5pt]chapternumber.north west) rectangle ([yshift=-34 pt,xshift=.33\marginparwidth+16.5pt]chapternumber.north west);% \fill[headings/base,color=black!20,anchor=north west,rounded corners=2.5 pt] ([yshift=-36 pt,xshift=30pt]chapternumber.north west) rectangle ([yshift=-43 pt,xshift=.33\marginparwidth+30pt]chapternumber.north west);% \fill[headings/base,color=black!10,anchor=north west,rounded corners=2.5 pt] ([yshift=-45 pt,xshift=52pt]chapternumber.north west) rectangle ([yshift=-52 pt,xshift=.33\marginparwidth+52pt]chapternumber.north west);% } { % number definition for numbered chapters \node(chapternumber)[anchor=south west,headings/chapternumber] at([yshift=-14.5pt] title.north east){#2};% } % decorative element(s) \ifstr{#2}{}{}{ \fill[headings/chapterbackground,anchor=east,rounded corners=1 pt] ([yshift=11.5 pt]title.north east) rectangle ([yshift=13.5 pt,xshift=4.2 cm]title.north);% } % chapter prefix \node(chapapp)[headings/chapapp,anchor=north east] at (chapternumber.north west){\ifstr{#2}{}{\leavevmode\vphantom{\contour{white}\chapapp}}{\contour{white}\chapapp}\strut};% \end{tikzpicture} \par }{% \@hangfrom{#2}{#3}% other section levels using style=chapter }% } \makeatother % Header and Footer Layout -------------------------------- \usepackage[automark]{scrlayer-scrpage} \setkomafont{pageheadfoot}{\footnotesize} \setkomafont{pagehead}{\sffamily\normalsize} \setkomafont{pagenumber}{\sffamily\large} \clearpairofpagestyles \newlength{\vrulewidth} \setlength{\vrulewidth}{1.25 pt} \renewcommand\chaptermark[1]{% \markboth{\ifnumbered{chapter}{#1}{#1}}{\ifnumbered{chapter}{#1}{#1}}% } % IDEA 1: Supposed to remove chapternumber from header in table of contents -- does not % \renewcommand*{\chaptermarkformat}{% % \ifnumbered{chapter}{\chapappifchapterprefix{\ }\thechapter\autodot\enskip}{}% taken from scrguide % } \renewcommand\sectionmark[1]{% \markright{\ifnumbered{section}{#1}{#1}}% } % IDEA 1 (part 2): Supposed to remove sectionumber from header in table of contents -- does not % \renewcommand*{\sectionmarkformat}{% % \ifnumbered{section}{\thesection\autodot\enskip}{}% taken from scrguide % } \lehead{% % \ifnumbered{chapter}{% IDEA 2: Supposed to remove chapternumber from header in table of contents -- does not \begin{tikzpicture}[overlay,remember picture] \fill[headings/base,color=black,anchor=south east,rounded corners=0.5\vrulewidth] ([xshift=-\marginparsep+.5\vrulewidth] current page header area.south west) rectangle ([xshift=-\marginparsep-.5\vrulewidth,yshift=\baselineskip] current page header area.south west); \node[headings/base,anchor=south east] at ([xshift=-2\marginparsep] current page header area.south west){\ifnumbered{chapter}{\leavevmode\vphantom{\headmark\strut}\chaptermarkformat}{\leavevmode\vphantom{\headmark\strut}}}; \node[headings/base,anchor=south west] at (current page header area.south west){\headmark\strut}; \end{tikzpicture} % }% IDEA 2 (part 2) % {% % \begin{tikzpicture}[overlay,remember picture] % \fill[headings/base,color=black,anchor=south east,rounded corners=0.5\vrulewidth] % ([xshift=-\marginparsep+.5\vrulewidth] current page header area.south west) % rectangle % ([xshift=-\marginparsep-.5\vrulewidth,yshift=\baselineskip] current page header area.south west); %% \node[headings/base,anchor=south east] at ([xshift=-2\marginparsep] current page header area.south west){\ifnumbered{chapter}{\leavevmode\vphantom{\headmark\strut}\chaptermarkformat}{\leavevmode\vphantom{\headmark\strut}}}; % \node[headings/base,anchor=south west] at (current page header area.south west){\headmark\strut}; % \end{tikzpicture} % } } \rohead{% (IDEA 2 did not work for \lehead) \begin{tikzpicture}[overlay,remember picture] \fill[headings/base,color=black,anchor=south west,rounded corners=0.5\vrulewidth] ([xshift=\marginparsep-.5\vrulewidth] current page header area.south east) rectangle ([xshift=\marginparsep+.5\vrulewidth,yshift=\baselineskip] current page header area.south east); \node[headings/base,anchor=south west] at ([xshift=2\marginparsep] current page header area.south east){\ifnumbered{section}{\leavevmode\vphantom{\headmark\strut}\sectionmarkformat}{\leavevmode\vphantom{\headmark\strut}}}; \node[headings/base,anchor=south east] at (current page header area.south east){\headmark\strut}; \end{tikzpicture} } \lefoot*{% \begin{tikzpicture}[overlay,remember picture] \fill[headings/base,color=black,anchor=south east,rounded corners=0.5\vrulewidth] ([xshift=-\marginparsep+.5\vrulewidth] current page footer area.south west) rectangle ([xshift=-\marginparsep-.5\vrulewidth,yshift=-3\baselineskip] current page footer area.south west); \node[headings/base,anchor=south east] at ([xshift=-2\marginparsep,yshift=-3\baselineskip] current page footer area.south west){\pagemark\strut}; \end{tikzpicture}% } \rofoot*{% funktioniert ohne * nur auf nicht chapter-Seiten \begin{tikzpicture}[overlay,remember picture] \fill[headings/base,color=black,anchor=south west,rounded corners=0.5\vrulewidth] ([xshift=\marginparsep-.5\vrulewidth] current page footer area.south east) rectangle ([xshift=\marginparsep+.5\vrulewidth,yshift=-3\baselineskip] current page footer area.south east); \node[headings/base,anchor=south west] at ([xshift=2\marginparsep,yshift=-3\baselineskip] current page footer area.south east){\pagemark\strut}; \end{tikzpicture}% } % https://tex.stackexchange.com/questions/272824/pagenumbers-headers-with-vertical-lines-style %% here there are no numbers for the table of contents in the headings -- numbering in TOC as desired % \renewcommand*{\chaptermark}[1]{% % \markboth{% % \makebox[0pt][r]{% % \ifnumbered{chapter}{% % \chaptermarkformat% Kapitelnummer % %\enskip% Abstand -- wird zu groß, wenn nicht auskommentiert % \rule[-\dp\strutbox]{\vrulewidth}{\baselineskip}% Linie -- Offset,Breite,Höhe % \hspace*{\marginparsep}% Abstand % }{}% % }% % #1% Text % }{% % #1%Text % \makebox[0pt][l]{% % \hspace*{\marginparsep}% Abstand % \ifnumbered{chapter}{% % \rule[-\dp\strutbox]{\vrulewidth}{\baselineskip}% Linie -- Offset,Breite,Höhe % \enskip% Abstand % \chaptermarkformat% Kapitelnummer % }{}% % }% % }% % } % \renewcommand*{\sectionmark}[1]{% % \markright{% % #1%Text % \makebox[0pt][l]{% % \ifnumbered{section}{% % \hspace{\marginparsep}% Abstand % \rule[-\dp\strutbox]{\vrulewidth}{\baselineskip}% Linie -- Offset,Breite,Höhe % \enskip% Abstand % \sectionmarkformat% Abschnittsnummer % }{}% % }% % }% % } % \ohead{\headmark} % \rofoot*{% % \makebox[0pt][l]{% % \hspace{\marginparsep}% % \raisebox{0pt}[\ht\strutbox][\dp\strutbox]{% % \rule[-\dp\strutbox]{\vrulewidth}{2\baselineskip}% Linie -- Offset,Breite,Höhe % }% % \enskip % \pagemark % }% % } % \lefoot*{% % \makebox[0pt][r]{% % \pagemark % \enskip % \raisebox{0pt}[\ht\strutbox][\dp\strutbox]{% % \rule[-\dp\strutbox]{\vrulewidth}{2\baselineskip}% Linie -- Offset,Breite,Höhe % }% % \hspace{\marginparsep}% % }% % } \usepackage{blindtext} \usepackage[raiselinks,colorlinks,bookmarks,pageanchor,hyperindex]{hyperref} \hypersetup{linkcolor=RoyalBlue} \begin{document} \markboth{Inhaltsverzeichnis}{Inhaltsverzeichnis} \setcounter{page}{1} \pagenumbering{Roman} \tableofcontents \setcounter{tocdepth}{3} \clearpage \setcounter{page}{1} \pagenumbering{arabic} \Blinddocument \Blinddocument \Blinddocument \Blinddocument \Blinddocument \Blinddocument \Blinddocument \Blinddocument \Blinddocument \appendix \Blinddocument \end{document} Edit: here are some images to visualize the differences: EDIT: I just figured out (here) that the problem is that \ifnumbered{chapter} checks the value of secnumdepth which is not altered in the header, as far as I understood, and a redefinition of chaptermark is needed. My redefinition is obviously not enough for the intended result.
- How can I draw great circles on a diagram using specific coordinates with arbitrary rotation?by Demitri on April 9, 2020 at 6:35 am
I'm trying to reproduce 3D diagrams like these of quadrilateralized spheres (taken from here) using TikZ: It's important that I use specific celestial coordinates (lat/lon can be substituted without a problem) so that I can draw individual bins as well as label them. More generally, the problem is how to draw arcs of great circles from provided coordinates (all lines of the scheme are great circles). My aim is to do this while working in native coordinates, e.g. "draw an arc from (0°,-45°) to (0°,45°) to (45°,45°) to (45°,0°)". I have found all of the pieces to solve this problem from these sources: Spheres, great circles and parallels by Denis Roegel" - aiming for this look This fantastic StackExchange answer This example The first link is in Metapost but contain the maths, which are used in the second two links. However, the latter two approaches are just different enough that I've not been able to generalize the solution. One uses \tdplotsetmaincoords to set the viewing angle and rotate the coordinate system, while the other uses \begin{scope} to modify the frame. I've tried to reconstruct each plot from basics, but have not been able to sufficiently abstract away the geometry while being able to arbitrarily rotate the sphere and use my "native" coordinates (and keeping the ability to have the "hidden" dashed lines drawn). There are a lot of moving parts! (The visual quality of the examples above are preferred over the above diagrams.) Any help greatly appreciated.
- A hyperbolic triangle embedded in a saddle-shaped surfaceby Tony on August 16, 2018 at 5:49 pm
This is the diagram I would like to recreate. (from https://en.wikipedia.org/wiki/Hyperbolic_triangle) From Is there any easy way to draw a ruled surface like a hyperbolic paraboloid in TikZ?, I found a way to draw the saddle-shaped surface. Is there a way to draw the triangle on it? And get the colours/transparency like the picture? \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} \addplot3 [surf,shader=flat,draw=black] {x^2-y^2}; \end{axis} \end{tikzpicture} \end{document}
- Clipping more complicated shapes in TikZby user121799 on December 31, 2017 at 2:33 am
I have tried to understand TikZ clipping better but I am stuck. I'd like to clip the area bounded by the blue contour in this picture: Unfortunately, the MWE is rather lengthy, and based on Alain Matthes cool macros and some additional macros from the answer here. \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc,fadings,decorations.pathreplacing,shadings} \usepackage{verbatim} \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{\RadiusSphere*\cosEl*\sint} \tikzset{#1/.style={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}} % } \newcommand\NewLatitudePlane[4][current plane]{% \pgfmathsinandcos\sinEl\cosEl{#3} % elevation \pgfmathsinandcos\sint\cost{#4} % latitude \pgfmathsetmacro\yshift{#2*\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,opacity=0.4] (\angVis-180:1) arc (\angVis-180:\angVis:1); } \newcommand\DrawLongitudeArc[4][black]{ \LongitudePlane{\angEl}{#2} \tikzset{current plane/.prefix style={scale=1}} \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} % \pgfmathsetmacro\angA{mod(max(\angVis,#3),360)} % \pgfmathsetmacro\angB{mod(min(\angVis+180,#4),360} % \draw[current plane,#1,opacity=0.4] (#3:\RadiusSphere) arc (#3:#4:\RadiusSphere); \draw[current plane,#1] (\angA:\RadiusSphere) arc (\angA:\angB:\RadiusSphere); }% \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,opacity=0.4] (180-\angVis:1) arc (180-\angVis:\angVis:1); } \newcommand\DrawLatitudeArc[4][black]{ \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)))} \pgfmathsetmacro\angA{max(min(\angVis,#3),-\angVis-180)} % \pgfmathsetmacro\angB{min(\angVis,#4)} % \draw[current plane,#1,opacity=0.4] (#3:\RadiusSphere) arc (#3:#4:\RadiusSphere); \draw[current plane,#1] (\angA:\RadiusSphere) arc (\angA:\angB:\RadiusSphere); } %% document-wide tikz options and styles \tikzset{% >=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}% } \begin{document} \begin{tikzpicture} % "THE GLOBE" showcase \def\RadiusSphere{4} % sphere radius \def\angEl{20} % elevation angle \def\angAz{-20} % azimuth angle \shade[ball color = gray!40, opacity = 0.5] (0,0) circle (\RadiusSphere); \tikzset{ every path/.style={ color=black } } \DrawLatitudeArc[blue]{40}{-140}{-30} \DrawLongitudeArc[blue]{-140}{-30}{40} \DrawLatitudeArc[blue]{-30}{-140}{-30} \DrawLongitudeArc[blue]{-30}{-30}{40} \end{tikzpicture} \end{document} The problem is that, according to what I read, clip needs to be the only option of \draw, but this clashes with the way the arcs are drawn here. So I am wondering if there is a way to have both. EDIT Motivated by the great progress by John Kormylo, I tried (and to some extent succeeded) to find alternative ways of shading the area. They are based on this post, and require the spath package (run pdflatex spath.dtx). \documentclass{article} \usepackage{tikz} \usetikzlibrary{shadings} \usepackage{spath} % from https://tex.stackexchange.com/a/26664/121799 \usetikzlibrary{calc,fadings,decorations.pathreplacing,shadings} \usepackage{verbatim} \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{\RadiusSphere*\cosEl*\sint} \tikzset{#1/.style={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}} % } \newcommand\NewLatitudePlane[4][current plane]{% \pgfmathsinandcos\sinEl\cosEl{#3} % elevation \pgfmathsinandcos\sint\cost{#4} % latitude \pgfmathsetmacro\yshift{#2*\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,opacity=0.4] (\angVis-180:1) arc (\angVis-180:\angVis:1); } \newcommand\DrawLongitudeArc[4][black]{ \LongitudePlane{\angEl}{#2} \tikzset{current plane/.prefix style={scale=1}} \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} % \pgfmathsetmacro\angA{mod(max(\angVis,#3),360)} % \pgfmathsetmacro\angB{mod(min(\angVis+180,#4),360} % \draw[current plane,#1,opacity=0.4] (#3:\RadiusSphere) arc (#3:#4:\RadiusSphere); \draw[current plane,#1] (\angA:\RadiusSphere) arc (\angA:\angB:\RadiusSphere); }% \newcommand\ClipLongitudeArc[4][black]{ \LongitudePlane{\angEl}{#2} \tikzset{current plane/.prefix style={scale=1}} \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} % \pgfmathsetmacro\angA{mod(max(\angVis,#3),360)} % \pgfmathsetmacro\angB{mod(min(\angVis+180,#4),360} % \path[save path=\tmppathI,current plane,#1,opacity=0.4] (#3:\RadiusSphere) arc (#3:#4:\RadiusSphere); \path[save path=\tmppathII,current plane,#1] (\angA:\RadiusSphere) arc (\angA:\angB:\RadiusSphere); }% \newcommand\ClipLongitudeArcReverse[4][black]{ \LongitudePlane{\angEl}{#2} \tikzset{current plane/.prefix style={scale=1}} \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} % \pgfmathsetmacro\angA{mod(max(\angVis,#3),360)} % \pgfmathsetmacro\angB{mod(min(\angVis+180,#4),360} % \path[save path=\tmppathI,current plane,#1,opacity=0.4] (#4:\RadiusSphere) arc (#4:#3:\RadiusSphere); \path[save path=\tmppathII,current plane,#1] (\angB:\RadiusSphere) arc (\angB:\angA:\RadiusSphere); }% \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,opacity=0.4] (180-\angVis:1) arc (180-\angVis:\angVis:1); } \newcommand\DrawLatitudeArc[4][black]{ \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)))} \pgfmathsetmacro\angA{max(min(\angVis,#3),-\angVis-180)} % \pgfmathsetmacro\angB{min(\angVis,#4)} % \draw[current plane,#1,opacity=0.4] (#3:\RadiusSphere) arc (#3:#4:\RadiusSphere); \draw[current plane,#1] (\angA:\RadiusSphere) arc (\angA:\angB:\RadiusSphere); } \newcommand\ClipLatitudeArc[4][black]{ \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)))} \pgfmathsetmacro\angA{max(min(\angVis,#3),-\angVis-180)} % \pgfmathsetmacro\angB{min(\angVis,#4)} % \path[save path=\tmppathI,current plane,#1,opacity=0.4] (#3:\RadiusSphere) arc (#3:#4:\RadiusSphere); \path[save path=\tmppathII,current plane,#1] (\angA:\RadiusSphere) arc (\angA:\angB:\RadiusSphere); } \newcommand\ClipLatitudeArcReverse[4][black]{ \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)))} \pgfmathsetmacro\angA{max(min(\angVis,#3),-\angVis-180)} % \pgfmathsetmacro\angB{min(\angVis,#4)} % \path[save path=\tmppathI,current plane,#1,opacity=0.4] (#4:\RadiusSphere) arc (#4:#3:\RadiusSphere); \path[save path=\tmppathII,current plane,#1] (\angB:\RadiusSphere) arc (\angB:\angA:\RadiusSphere); } %% document-wide tikz options and styles \tikzset{% >=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}% } \begin{document} \begin{tikzpicture} % "THE GLOBE" showcase \def\RadiusSphere{4} % sphere radius \def\angEl{20} % elevation angle \def\angAz{-20} % azimuth angle \shade[ball color = gray!40, opacity = 0.5] (0,0) circle (\RadiusSphere); \tikzset{ every path/.style={ color=black } } \ClipLatitudeArc[blue]{40}{-140}{-30} \pgfoonew \patha=new spath(\tmppathI) \pgfoonew \pathb=new spath(\tmppathII) \ClipLongitudeArc[blue]{-30}{40}{-40} \pgfoonew \pathc=new spath(\tmppathI) \pgfoonew \pathd=new spath(\tmppathII) \ClipLatitudeArc[blue]{-40}{-30}{-140} \pgfoonew \pathe=new spath(\tmppathI) \pgfoonew \pathf=new spath(\tmppathII) \ClipLongitudeArc[blue]{-140}{-30}{40} \pgfoonew \pathg=new spath(\tmppathI) \pgfoonew \pathh=new spath(\tmppathII) \patha.concatenate with lineto(,\pathc) \patha.concatenate with lineto(,\pathe) \patha.concatenate with lineto(,\pathg) \patha.close() \patha.use path with tikz(line width=1pt,draw=black,fill=blue,path fading=south) \end{tikzpicture} \end{document} Although this comes somewhat closer to what I wish to achieve, I am still puzzled that these paths can not be used for clippings. (This also means that John Kormylo's approach is much cleaner and better.) And I am wondering if there is a cleaner or at least alternative way that does not rely on the inofficial spath package.
- rotate node in 3Dby Fadwa on November 19, 2015 at 6:54 am
I am trying to draw this 3D shape I draw the 4 arrows and the cylinder, but can't rotate the arrows in 3D to put them on the top. \documentclass{standalone} \usepackage[usenames,dvipsnames]{xcolor} \usepackage{tikz} \usetikzlibrary{shapes.geometric} \usetikzlibrary{shapes.arrows} \begin{document} %,rotate around={30:(0,1,1)} \begin{tikzpicture} \node[cylinder, draw=white,fill=blue, shape aspect=0.7,rotate=90,minimum height=0.7cm, minimum width=2cm] {hh}; \node [fill=red,single arrow, draw=none, rotate=90,minimum height=1cm,minimum width=0.7cm]at(0,0) {}; \node [fill=blue,single arrow, draw=none, rotate=-90,minimum height=1cm,minimum width=0.7cm] at (0,1.5) {}; \node [fill=red,single arrow, draw=none, rotate=-180,minimum height=1cm,minimum width=0.7cm]at(-0.75,0.7) {}; \node [fill=blue,single arrow, draw=none, rotate=-360,minimum height=1cm,minimum width=0.7cm] at (0.75,0.7) {}; \end{tikzpicture} \end{document}
- PGF: draw longitudinal arcs in 3D axis environmentby Bloch on February 4, 2015 at 3:54 pm
I want to draw a sphere similar to the first one here: http://www.texample.net/tikz/examples/map-projections/ But, of course, different. This is what I did so far: The dashed lines are behind the arrows and the solid lines on top to create the illusion of the arrows to be in the sphere. What I did is a bit tricky and probably not the most elegant method. I created a tilted sphere (surface plot) in the background and covered it with a better looking 'ball'. I originally intended the surface plot sphere to be the actual sphere and then decided that it did not look good enough. But I kept it in the background because I needed the axis environment as I did not manage to do it without the axis cs. The latitude lines are basically 360° arcs originating from the (axis cs: 1,0,0) point (arc (0:360:1)). It turned out that arc interpreted the angle as the polar angle (the angle in the x-y-plane), which made it easy. But it seems to make it impossible for longitude lines. Is there something like an arc3D knowing an azimuthal angle in addition to the polar angle? Or could I redraw the latitude lines and rotate them by 90 degrees? Does anyone know another solution? My attempts to do it without the axis environment also failed. Actually I am not unhappy with my axis solution, as it makes it easier to plot the arrows in the right direction (what it will be all about in the end). I hope I could make it clear what my problem is and hope there is someone coming up with an easy arc3D solution. 😉 My code is: \documentclass[tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.9} \usetikzlibrary{arrows.meta} \tikzset{>=Latex} \begin{document} \begin{tikzpicture} \def\tilt{45} \def\azimuth{30} \begin{axis}[% axis equal, width=14cm, height=14cm, hide axis, enlargelimits=0.3, view/h=\tilt, view/v=\azimuth, scale uniformly strategy=units only, colormap={bluewhite}{color=(blue) color=(white)}, ] \coordinate (X) at (axis cs: 1,0,0); \coordinate (-X) at (axis cs: -1,0,0); \coordinate (Y) at (axis cs: 0,1,0); \coordinate (-Y) at (axis cs: 0,-1,0); \coordinate (Z) at (axis cs: 0,0,1); \coordinate (-Z) at (axis cs: 0,0,-1); Kugel \addplot3[ surf, shader= interp, opacity = 1, samples=2, domain=-1:1,y domain=0:2*pi, z buffer=sort ] ({sqrt(1-x^2) * cos(deg(y))}, {sqrt( 1-x^2 ) * sin(deg(y))}, x); \filldraw[ball color=white] (axis cs: 0,0,0) circle (2.5cm); %dashed lines %Breitengrade \pgfplotsinvokeforeach {-80,-60,...,80}{ \pgfplotsextra{ \pgfmathsetmacro\sinVis{sin(#1)/cos(#1)*sin(\azimuth)/cos(\azimuth)} % angle of "visibility" \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))} \coordinate (X) at (axis cs: {cos(#1)},0,{sin(#1)}); \draw [gray,dashed] (X) arc (0:360:{100*cos(#1)}); } } %Achsen \draw [-{>[scale=2]},gray] (axis cs: -1,0,0) -- (axis cs: 1.5,0,0) node [above] {$\sigma_x$}; %x-Achse \draw [-{>[scale=2]},gray] (axis cs: 0,-1,0) -- (axis cs: 0,1.5,0) node [above] {$\sigma_y$}; %y-Achse \draw [-{>[scale=2]},gray] (axis cs: 0,0,-1) node [below]{$\sigma_-$} -- (axis cs: 0,0,1.3) node [above] {$\sigma_+$}; %z-Achse \draw [-{>[scale=1]},cyan,line width = 3pt] (axis cs: 0,0,0) -- (axis cs: 0,0,1.1); \draw [-{>[scale=1]},blue,line width = 3pt] (axis cs: 0,0,0) -- (axis cs: 1,0,0); %Arcs \pgfplotsinvokeforeach {-80,-60,...,80}{ \pgfplotsextra{ \pgfmathsetmacro\sinVis{sin(#1)/cos(#1)*sin(\azimuth)/cos(\azimuth)} % angle of "visibility" \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))} \coordinate (X) at (axis cs: {cos(#1)},0,{sin(#1)}); \draw [gray] (X) arc (0:\tilt+\angVis:{100*cos(#1)}) (X) arc (0:-180+\tilt-\angVis:{100*cos(#1)}); } } \end{axis} \end{tikzpicture} \end{document}
- Parabolic Moebius map on sphere using tikzby sheik yerbouti II on September 2, 2014 at 6:06 pm
There is a discussion here about coding the elliptic Moebius map. I however am interested in how I might do the parabolic one. case [d] The arrow heads are not an issue, but how do I get the lines on the surface of the sphere? Most (all?) tutorials only focus on lines of latitude and longitude)
- Improving the visual appearance of a truncated cone in TikZby Ingo on August 27, 2014 at 4:19 pm
I have drawn a truncated cone in TikZ and am generally happy with the result. Here is the output and an MWE: \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[>=latex] \fill[fill=gray!50] (1,0) ellipse (0.166 and 0.5); \fill[fill=gray!50] (4,0) ellipse (0.498 and 1.5); \fill[fill=gray!50] (1, 0.5) -- (4, 1.5) -- (4, -1.5) -- (1, -0.5) -- (1, 0.5); \draw[thick,->] (0,0,0) -- (5,0,0) node[anchor=west]{$z$}; \draw[thick,->] (0,0,0) -- (0,2,0) node[anchor=south]{$x$}; \draw[thick,->] (0,0,0) -- (0,0,2) node[anchor=north east]{$y$}; \draw[semithick] (1,0) ellipse (0.166 and 0.5); \draw[semithick] (4,0) ellipse (0.498 and 1.5); \draw (1, 0.5) -- (4, 1.5); \draw (1, -0.5) -- (4, -1.5); \end{tikzpicture} \end{document} However, I think that there is room for improvement. Here are some things that I could not figure out: How can we (automatically) dash the z-axis where it should be hidden, as well as part of the ellipse of one of the sides, which should not be visible? Would there be a sane way of adding some shading to the drawing, that would add depth? Can you help me out with these points?
- Rectangles around cells in tableby James on October 23, 2013 at 6:48 am
I asked a question here but, rather stupidly, added extra information after it had been answered. My additional question is this: I have a table with varying lengths of words. I want to encircle different groups of cells, including diagonals. If possible, it would be great if the rectangles don't overlap each other where possible. I looked at the answer here, which, whilst tedious, worked except for the overlap. This is where I've got to so far: \documentclass[fleqn,12pt,a4paper,landscape]{article} \usepackage{tikz} \usepackage{tabularx} \begin{document} % Introduce a new counter for counting the nodes needed for circling \newcounter{nodecount} % Command for making a new node and naming it according to the nodecount counter \newcommand\tabnode[1]{\addtocounter{nodecount}{1} \tikz \node (\arabic{nodecount}) {#1};} % Some options common to all the nodes and paths \tikzstyle{every picture}+=[remember picture,baseline] \tikzstyle{every node}+=[inner sep=0pt,anchor=base, minimum width=1.8cm,align=center,text depth=.25ex,outer sep=1.5pt] \tikzstyle{every path}+=[thick, rounded corners] \begin{table}[ht] \begin{minipage}[b]{1 \linewidth}\centering \begin{tabular}{cccccc} % Turn the cells needed for defining the circling paths into nodes with our custom command \tabnode{Long ago}& \tabnode{A few days ago}& \tabnode{Day before yesterday}& \tabnode{Yesterday} & & \\ & & & & \tabnode{Today} & \tabnode{Now}\\ \tabnode{Long time in the future}& \tabnode{A few days on}& \tabnode{Day after tomorrow}& \tabnode{Tomorrow} & & \\ \end{tabular} \end{minipage} \begin{tikzpicture}[overlay] % Define the circle paths \draw [blue](1.north west) -- (1.north east) -| (7.north east) |- (7.south west) |- (1.north west); \draw [red](8.south west) -| (2.north east) -| (2.south west) |- (8.south west); \draw [yellow](9.south west) -| (3.north east) -| (3.south west) |- (9.south west); \draw [green](8.south west) -| (3.north east) -| (2.south west) |- (8.south west); \end{tikzpicture} \end{table} \end{document} %%% Local Variables: %%% mode: latex %%% TeX-master: t %%% End:
- Is there a way to show the version of a document as seen by a colour blind reader?by alexwlchan on July 5, 2013 at 2:25 pm
I’m creating a number of coloured grids with TikZ, which look something like this: This exercise is designed to demonstrate reflections and rotational symmetry. It’s important that the individual colours be distinguishable, and a problem in the past has been colour blindness. Readers who are colour blind can’t distinguish the individual colours, which makes it harder to see the symmetries. I’m using the tool Colour Oracle to test the colours against deuteranopia (green deficiency), protanopia (red deficiency) and tritanopia (blue deficiency), but I’d like to be able to output a PDF that retains these filters, without recalculating every colour by hand. Is there a package that I can use at compile time, or a PDF tool that allows me to simulate colour blindness? As a bonus, the ability to simulate the desaturation that comes from using a projector in a lit room would also be useful. (If anybody is interested in the exercise the original version is a problem on the NRICH website. I’m updating it as part of my summer work.)
- How to plot functions like x=f(y) using TikZ?by Sisabe on March 27, 2013 at 3:48 pm
To plot functions in the form of y=f(x), we simply write \draw [smooth,samples=100,domain=0:2] plot(\x,{(\x)...}); But how about functions like x=f(y)? How to plot them? How to specify their domains in terms of "y"? \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [smooth,samples=100,domain=0:2] plot(???); \end{tikzpicture} \end{document}
- How to make beamer overlays with Tikz nodeby Peter Smit on November 29, 2010 at 7:23 am
I have a diagram of 4 nodes in my beamer slide. \begin{figure}[h] \begin{centering} \begin{tikzpicture}[system/.style={draw,rectangle,rounded corners=3,minimum width=2cm,text width=1.8cm,text centered}] \node [system] (fe) {Feature Extraction}; \node [system] (am) [right=of fe] {Acoustic Model}; \node [system] (lm) [right=of am] {Language Model}; \node [system] (d) [below=of lm] {Decoder}; \draw[->] (fe) |- (am); \draw[->] (am) |- (d); \draw[->] (lm) -- (d.north); \end{tikzpicture} \end{centering} \end{figure} How can I in a second slide "highlight" one of the nodes, like I can do with <alert@n> for a item in a list? With highlighting I mean for example giving a color and thickening the lines.