TikZ
- add a grid background only inside a tabular columnby Christopher Madec on April 19, 2026 at 5:19 pm
I am trying to create a worksheet layout in LaTeX where one column of a table contains a writing area with a grid (like squared paper), while the other column contains several questions (Here is an example with just one question). \documentclass{article} \usepackage{array} \usepackage{xcolor} \usepackage{geometry} % \usepackage{arydshln} \usepackage{lipsum} \geometry{a4paper, left=0.35in, right=-0.1in, top=0.6in, bottom=0.4in} \definecolor{burgundy}{HTML}{8B2252} \usepackage{scrlayer-scrpage} \usepackage{tikz} \newcommand*\Circled[1]{\tikz[baseline=(char.base)]{\textcolor{burgundy}{\node[shape=circle,draw,inner sep=2pt] (char) {#1};}}} \usepackage{tikzducks} \usetikzlibrary{calc} \newcommand{\pageframe}{% \begin{tikzpicture}[remember picture, overlay] \fill [burgundy!80!white] (current page.north west) rectangle (current page.south east); \fill [white, rounded corners=1cm] ($(current page.north west)+(0.5cm,-1cm)$) rectangle ($(current page.south east)+(-0.5cm,1cm)$); \node [align=center] at ($(current page.north)+(0,-0.6cm)$) {$\color{white}\mathrm{Chapitre \ 2 - Diffusion \ thermique}$}; \node [align=center] at ($(current page.south)+(0,1.9cm)$) {\centering\begin{tikzpicture}[scale=0.5] \shuffleducks \duck[\randomhead,\randomaccessories, /tikz/nodes={scale/.evaluated={\value{page}>99?0.4:0.6},font=\bfseries}, signpost=\scalebox{1.6}{ \parbox{6cm}{\hspace{-0.4em}\color{black} \centering\thepage}}, signback =white] \end{tikzpicture}}; %%% Background grid \draw[step=5mm, gray!30, very thin] ($(current page.north west)+(7cm,-1.5cm)$) grid ($(current page.south east)+(-1cm,5cm)$); \end{tikzpicture} } \cehead[\pageframe]{\pageframe} \cohead[\pageframe]{\pageframe} \pagestyle{scrheadings} % Another try \usepackage{makecell} \newcommand{\gridcell}[1][4cm]{% \begin{tikzpicture} \draw[step=5mm, gray!40, very thin] (0,-0.2) grid (\linewidth, #1); \end{tikzpicture}% } \begin{document} \renewcommand{\arraystretch}{6} \begin{tabular}{>{\centering\raggedright}m{0.25\textwidth}||>{\centering\arraybackslash}m{0.60\textwidth}} \Circled{1} \'Enoncer le théorème de Green-Ostrograski & \\ \hline \end{tabular} \end{document} Goal I would like the second column of the table to contain a grid background (like graph paper) so that students can write their answers. I want to find the best way to create a grid (squared background) that is confined to a specific table column, and that does not overflow outside the table. What I tried so far Using a page-wide background grid, but it overflows outside the table and does not align with the table structure \draw[step=5mm, gray!30, very thin] ($(current page.north west)+(7cm,-1.5cm)$) grid ($(current page.south east)+(-1cm,5cm)$); \end{tikzpicture} The code looks like this: Drawing a grid with TikZ inside a cell → does not scale correctly with row height \newcommand{\gridcell}[1][4cm]{% \begin{tikzpicture} \draw[step=5mm, gray!40, very thin] (0,-0.2) grid (\linewidth, #1); \end{tikzpicture}% }
- TikZ nodes within a scope are not projectedby Tianjian Qin on April 19, 2026 at 4:55 pm
I'm trying to draw a 3D panel, within each panel there are dashed panel frame, some circles, lines connecting the circles, text, and maybe other objects. I tried to draw all these within a scope, then apply a projection so that all of these drawings can be 3D-rotated, but this trick only works on the panel frame, not properly on the other objects, see the screenshot: And here is the standalone tex code: \documentclass[tikz,border=6pt]{standalone} \usepackage{xcolor} \usetikzlibrary{arrows.meta,calc} % Example colors \definecolor{Accent}{RGB}{60,90,150} \definecolor{PersistCol}{RGB}{70,130,90} \definecolor{ReactCol}{RGB}{180,110,60} \definecolor{NewCol}{RGB}{180,70,80} \begin{document} \begin{tikzpicture}[ font=\small, >=Latex, side layer projection/.style={x={(0.46cm,0.25cm)}, y={(0cm,0.75cm)}}, frame/.style={ draw=black!78, dashed, line width=.72pt, dash pattern=on 5pt off 4pt, line cap=round }, v/.style={ circle, draw=gray!55, fill=gray!22, minimum size=4pt, inner sep=0pt }, pe/.style={draw=PersistCol, line width=1.0pt}, re/.style={draw=ReactCol, line width=1.0pt}, ne/.style={draw=NewCol, line width=1.0pt} ] \def\P{1.10} \newcommand{\PlaneFrame}{% \draw[frame] (-\P,-\P)--(\P,-\P)--(\P,\P)--(-\P,\P)--cycle; } \newcommand{\PlaneLabel}[1]{% \path (-.86,-\P)--(.86,-\P) node[midway, below=2pt, sloped, transform shape, font=\scriptsize] {#1}; } \newcommand{\PoolNodes}{% \node[v] (a) at (-.75,.55) {}; \node[v] (b) at (-.10,.88) {}; \node[v] (c) at (.68,.42) {}; \node[v] (d) at (-.70,-.55) {}; \node[v] (e) at (.65,-.55) {}; } % One projected layer only \begin{scope}[side layer projection] \PlaneFrame \PlaneLabel{selected \(E_t^\star\)} \PoolNodes \draw[pe] (a)--(b); \draw[re] (d)--(e); \draw[ne] (c)--(e); \end{scope} \end{tikzpicture} \end{document} What I did wrong here? UPDATE: Just tried to add \usetikzlibrary{3d} and use something like \begin{scope}[canvas is zy plane at x=0, every node/.style={transform shape}]. This only solve the issue in text and circles, not the edges (straight lines):
- Arrow tips look wrong at the end of a plotby Muhannad Al Ayoubi on April 19, 2026 at 4:31 pm
I have a weird problem with arrow heads at the end of plots, where they look wrong, as you can see in the picture (look below left; the line seems to exceed the arrow tip). Removing colour or changing thickness did not solve the problem. Interestingly, making the arrow longer does fix the issue, but is not a plausible fix. Also increasing the scale seems to hide the issue, but I would not like to do that, as diagrams would get too big. This issue does not appear with the longer parabola or the blue line which I drew normally. Here is an MWE. \documentclass[10pt]{book} \usepackage{tikz} \usetikzlibrary{arrows.meta} % Tikz libraries \tikzset{>={Stealth}} \begin{document} \begin{tikzpicture}[scale=0.4] \draw[->, thick, red, domain=-1:3.5, variable=\t, smooth, samples=75] plot ({\t,2-0.5*\t*\t}); \draw[<-, thick, red, domain=-2:-0.5, variable=\t, smooth, samples=75] plot (2*\t,\t-1); \draw[draw=red, fill=white] (-1,-1.5) circle (4pt); \draw[thick, blue,<->] (0,-3) -- (1,-2); \draw[red, fill] (-1,1.5) circle (4pt); \end{tikzpicture} \end{document} Any idea what is going wrong? And how to fix it? Zoomed in picture on the issue:
- How to construct the "double dotted"-framed box?by Explorer on April 18, 2026 at 3:04 am
What I tried to replicate is something as below: Noted that the double-dotted is aligned as the red line denoted, and the "rotated box" is NOT what I want(just because the image I get rotated itself), I just want something the same as \dashbox or \doublebox, the normal horizonal box. The post here, I think, just want to focus the dots alignment. Now I have the following code: \documentclass{article} \usepackage[most]{tcolorbox} \usepackage{tikz} \usepackage{lipsum} \usepackage{dashbox} \usepackage{fancybox} % https://tex.stackexchange.com/a/101263/322482 \makeatletter \tikzset{ dot diameter/.store in=\dot@diameter, dot diameter=3pt, dot spacing/.store in=\dot@spacing, dot spacing=10pt, dots/.style={ line width=\dot@diameter, line cap=round, dash pattern=on 0pt off \dot@spacing }, } \tcbset{ doubledotted/.style={ empty, sharp corners, frame engine=path, frame empty, frame code={ \draw[dots](frame.south west) rectangle (frame.north east); \draw[dots]([xshift=-\dot@spacing,yshift=-\dot@spacing]frame.south west) rectangle ([xshift=\dot@spacing,yshift=\dot@spacing]frame.north east); }, } } \makeatother \begin{document} AAA \qquad\tcbox[doubledotted,nobeforeafter,box align=center]{This is a tcolorbox.}\qquad BBB \vspace{1cm} \begin{tcolorbox}[doubledotted] \lipsum[2] \end{tcolorbox} \bigskip \fbox{This is a framebox.} \dashbox{This is a dashed framebox.} \doublebox{This is a doublebox.} \end{document} which gives: The disturbing point is that the dotted in a \path is hard to control the alignment precisely. I have to cliam that, I think that would be two different approach to achieved this: One with tcolorbox and tikz Another with some "plain" approaches for example dashedbox and fancybox: fancybox.sty: % fancybox.sty % Line 143 \def\doublebox{\VerbBox\@doublebox} \def\@doublebox#1{% \begingroup \setbox\@fancybox\hbox{{#1}}% \fboxrule=.75\fboxrule \setbox\@fancybox\hbox{\fbox{\box\@fancybox}}% \fboxrule=2\fboxrule \fboxsep=\fboxrule \advance\fboxsep .5pt \fbox{\box\@fancybox}% \endgroup} dashbox.sty: %% %% This is file `dashbox.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% dashbox.dtx (with options: `package') %% Dashed and layered boxes. %% %% File `dashbox.dtx'. %% Copyright (C) 1997-2001 Reuben Thomas (rrt@sc3d.org) %% This file is distributed under the LaTeX Project Public License, %% and comes with no warranty. %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{dashbox} [2001/12/11 v1.14 Dashed and layered boxes] \RequirePackage{calc} \RequirePackage{ifthen} \newlength{\dashlength} \setlength{\dashlength}{6pt} \newlength{\dashdash} \setlength{\dashdash}{3pt} \newlength{\layersize} \setlength{\layersize}{\dashdash} \newcommand{\hd@shrule}[1]{% \hbox to #1% {\vrule height \fboxrule width \dashdash% \cleaders\hbox to \dashlength% {\hfill\rule{\dashdash}{\fboxrule}\hfill}\hfill% \ifthenelse{\lengthtest{#1 > 2\dashdash}}% {\vrule height \fboxrule width \dashdash}{}% }} \newcommand{\vd@shrule}[1]{% \vbox to #1% {\hrule height \dashdash width \fboxrule% \cleaders\vbox to \dashlength% {\vfill\rule{\fboxrule}{\dashdash}\vfill}\vfill% \ifthenelse{\lengthtest{#1 > 2\dashdash}}% {\hrule height \dashdash width \fboxrule}{}% }} \newsavebox{\d@shedsavebox} \newlength{\d@shedboxwidth} \newlength{\d@shedboxtotalheight} \newcommand{\m@kedashbox}{% \setlength{\d@shedboxtotalheight}% {\dp\d@shedsavebox+\ht\d@shedsavebox+\fboxsep*2+\fboxrule*2}% \raisebox{-\fboxrule-\fboxsep-\dp\d@shedsavebox}{% \parbox[b]{\d@shedboxwidth}{% \offinterlineskip% \parskip=0pt% \hd@shrule{\d@shedboxwidth}% \kern-\fboxrule% \par% \parbox{\fboxrule}{\vd@shrule{\d@shedboxtotalheight}}% \kern\fboxsep% \parbox{\wd\d@shedsavebox}% {\vspace{\fboxsep}\usebox{\d@shedsavebox}\vspace{\fboxsep}}% \kern\fboxsep% \parbox{\fboxrule}{\vd@shrule{\d@shedboxtotalheight}}% \par% \kern-\fboxrule% \hd@shrule{\d@shedboxwidth}}% }} \newcommand{\dbox}[1]{% \sbox{\d@shedsavebox}{#1}% \setlength{\d@shedboxwidth}{\wd\d@shedsavebox+\fboxsep*2+\fboxrule*2}% \m@kedashbox} \def\dashbox{\@ifnextchar[\@dashbox\dbox} \def\@dashbox[#1]{\@ifnextchar[{\@idashbox[#1]}{\@idashbox[#1][c]}} \long\def\@idashbox[#1][#2]#3% {\setlength{\d@shedboxwidth}{#1}% \savebox{\d@shedsavebox}[#1-\fboxsep*2-\fboxrule*2][#2]{#3}% \m@kedashbox} \newsavebox{\l@yersavebox} \newlength{\l@yerwidth} \newlength{\l@yerboxwidth} \newlength{\l@yertotalheight} \newlength{\l@yerlineheight} \newlength{\l@yervoffset} \newcommand{\m@kelayer}[1]{% \setlength{\l@yertotalheight}% {\dp\l@yersavebox+\ht\l@yersavebox+\layersize-#1\layersize}% \setlength{\l@yerlineheight}% {\ht\l@yersavebox-#1\layersize-\fboxrule}% \setlength{\l@yervoffset}% {-\layersize-\dp\l@yersavebox}% \setlength{\l@yerboxwidth}% {\wd\l@yersavebox+\layersize-#1\layersize}% \parbox{\l@yerwidth}{% \offinterlineskip% \parskip=0pt% \usebox{\l@yersavebox}% \rule[\l@yerlineheight]{\layersize}{\fboxrule}% \kern-\fboxrule% \rule[\l@yervoffset]{\fboxrule}{\l@yertotalheight}% \kern-\wd\l@yersavebox\kern-\layersize\kern#1\layersize \rule[\l@yervoffset]{\fboxrule}{\layersize}% \kern-\fboxrule \rule[\l@yervoffset]{\l@yerboxwidth}{\fboxrule}% }} \newcommand{\l@yer}[2]{% \sbox{\l@yersavebox}{#2}% \setlength{\l@yerwidth}{\wd\l@yersavebox+\layersize}% \m@kelayer{#1}} \newcommand{\m@kedashlayer}[1]{% \setlength{\l@yertotalheight}% {\dp\l@yersavebox+\ht\l@yersavebox+\layersize-#1\layersize}% \setlength{\l@yerlineheight}{\ht\l@yersavebox-#1\layersize-\fboxrule}% \setlength{\l@yervoffset}{-\layersize-\dp\l@yersavebox}% \setlength{\l@yerboxwidth}% {\wd\l@yersavebox+\layersize-#1\layersize}% \parbox{\l@yerwidth}{% \offinterlineskip% \parskip=0pt% \usebox{\l@yersavebox}% \raisebox{\l@yerlineheight}{\hd@shrule{\layersize}}% \kern-\fboxrule% \raisebox{\l@yervoffset}% {\parbox[b]{\fboxrule}{\vd@shrule{\l@yertotalheight}}}% \kern-\wd\l@yersavebox\kern-\layersize\kern#1\layersize \raisebox{\l@yervoffset}% {\parbox[b]{\fboxrule}{\vd@shrule{\layersize}}}% \kern-\fboxrule \raisebox{\l@yervoffset}% {\hd@shrule{\l@yerboxwidth}}% }} \newcommand{\dl@yer}[2] {\sbox{\l@yersavebox}{#2}% \setlength{\l@yerwidth}{\wd\l@yersavebox+\layersize}% \m@kedashlayer{#1}} \newcounter{l@yercount} \newcommand{\l@yers}[3] {\setcounter{l@yercount}{1}% \sbox{\l@yersavebox}{#2}% \whiledo{\not\(\value{l@yercount} > #1\)}% {\sbox{\l@yersavebox}% {#3{\value{l@yercount}}{\usebox{\l@yersavebox}}}% \stepcounter{l@yercount}}% \usebox{\l@yersavebox}% } \newcommand{\lbox}[2][2]{% \l@yers{#1}{#2}{\l@yer}} \newcommand{\dlbox}[2][2]{% \l@yers{#1}{#2}{\dl@yer}} \endinput %% %% End of file `dashbox.sty'. I was not sure which one is more elegant/easy, any solution are all welcome!
- Bug with tikz backgrounds-libraryby DraUX on April 17, 2026 at 9:22 am
I recently noticed a bug, where the TikZ backgrounds library ignores any other options applied within the same scope definition. As you can see in the MWE below, I have a scope on the background layer with the additional options blue and ultra thick, which are ignored. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{backgrounds} \begin{document} \begin{tikzpicture} \draw[red, ultra thick] (0,0) -- (2,0); \begin{scope}[on background layer,blue,ultra thick] \draw (1,-1) -- (1,1); \end{scope} \end{tikzpicture} \end{document} Using nested scopes or defining the options directly in the path definition gives the desired result. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{backgrounds} \begin{document} \begin{tikzpicture} \draw[red, ultra thick] (0,0) -- (2,0); \begin{scope}[on background layer] \begin{scope}[blue,ultra thick] \draw (1,-1) -- (1,1); \end{scope} \end{scope} \end{tikzpicture} \end{document} Is this a bug? It isn't mentioned in the manual. I couldn't find a git repo to report an issue, so I hope this is the right place to ask.
- How to create a TikZ node whose top matches one node’s north and bottom matches another node’s south?by Lecthor on April 16, 2026 at 3:18 pm
I have two rectangular TikZ nodes placed one below the other: B1 is above B2. I would like to create a third rectangular node B3, shifted to the right in the x-direction, such that: the top of B3 is aligned with B1.north the bottom of B3 is aligned with B2.south I am not sure what is the best TikZ way to do this cleanly. Here is a minimal example of the situation: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \tikzstyle{block} = [draw, fill=white, rectangle, inner xsep=0pt, align=center, font=\small]% \begin{tikzpicture} \node [block, text width=3em] (B1) {Block 1}; \node [block, anchor=north, text width=3em] (B2) at ([yshift=-5em]B1.south) {Block 2}; \node [block, anchor=west] (B3) at ([xshift=5em]$(B1.east)!0.5!(B2.east)$) {Block 3}; \end{tikzpicture} \end{document} I tried using minimum height with coordinate differences, but I could not make it work properly. What is the recommended approach?
- Bezier curves with controls?by Raffaele Santoro on April 16, 2026 at 8:45 am
How to make rounded corner and curve (..controls?) for this path (or similar)? \documentclass[margin={1.5cm 1,5cm 1.5cm 1.5cm}]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \fill[cyan] (0,0)--(2,0)--(5,2)--(7,3)--(6,4)--(4,7)--(2,7)--(.5,5)--(0,2)--cycle; \end{tikzpicture} \end{document}
- How to extend the `dim` feature in `tkz-euclide` to label the dimension with arrow in diverse direction?by Explorer on April 15, 2026 at 10:45 am
Muzimuzhi has extended the dim feature in tkz-euclide here: However, not all the segments are long enough to label distance "inside", in some case, I need the following "invert"-dim feature: \documentclass[border=5pt]{standalone} \usepackage{tkz-euclide} \usepackage{fourier} \begin{document} \begin{tikzpicture} \tkzDefPoints{0/0/O,3/0/A,1/1/A2,.5/2/C2} \tkzDefRectangle(A2,C2)\tkzGetPoints{B2}{D2} \tkzDrawPolygon[thick,black,fill=yellow!50](A2,B2,C2,D2) \tkzLabelSegment[below](A2,B2){$t$} \draw[thick](A2) --+(0,-.5cm) ++(0,-.25cm) coordinate(tmpA) (B2) --+(0,-.5cm) ++(0,-.25cm) coordinate(tmpB); \draw[thick,latex-] (tmpB) -- +(-.4cm,0); \draw[thick,latex-] (tmpA) -- +(.4cm,0); %%%%%%%%%%%%%% \tkzDrawSegment[thick,dim style/.append style={red,dash pattern={on 2pt off 2pt}},dim={$a$,-.5cm,inner xsep=3pt}](O,A) %%%%%%%%%%%%%% \end{tikzpicture} \end{document} I have not quite familiar with pgf macros, I wonder whether that is possible to learn from muzimuzhi's code to support the "invert"-dim feature, to label these kind of segments distance from the two-side inwards more elegantly?
- alaligne not working on tikzpicture environmentby ABV on April 15, 2026 at 3:39 am
/alaligne (new line space for system score) not working on tikzpicture environment. The basic code is as follow: \documentclass[% border={35pt 100pt 150pt 5pt},% left bottom right top varwidth]{standalone} % ========== PAQUETES ========== \usepackage{tikz} \usetikzlibrary{arrows.meta,calc} %LIBRERIA PARA LAS FORMAS \usetikzlibrary{quotes} \usetikzlibrary{shapes} \usetikzlibrary{fit,positioning} \usetikzlibrary{arrows.meta} \usetikzlibrary{decorations} \usepackage{amsmath}% \usepackage{musicography}% \usepackage{musixtex}% \input musixlyr% \usepackage{xcolor}% \xdefinecolor{red-undar}{RGB}{179,35,79} \begin{document}% \begin{tikzpicture} \node[anchor=north west, inner sep=0pt] (score) at (0,0) {% \begin{music}% \resetlyrics% \font\A=phvb8t at 10pt% \font\B=phvb8t at 8pt% \setsongraise1{-1.5mm}% \staffbotmarg3\Interligne% \setclef1\treble% \nobarnumbers% \nostartrule% %\startextract% \startpiece%\addspace\afterruleskip% % AQUI EMPIEZOOO \Notes\zw{h}\hu{j}\qsk\hu{l}\en\bar% \Notes\zw{f}\hu{k}\qsk\hu{j}\en\bar% \Notes\zw{g}\hu{i}\sk\en\setdoublebar\bar% \Notes\zw{h}\hu{m}\qsk\hu{l}\en\bar% \Notes\zw{f}\hu{k}\qsk\hu{j}\en\bar\setdoublebar% \Notes\zw{g}\hu{i}\sk\en\alaligne%%\setdoublebar\bar% \Notes\zw{b}\hu{g}\qsk\hu{f}\en\bar% \Notes\zw{c}\hu{e}\qsk\hu{g}\en\setdoublebar\bar% \Notes\zw{g}\hu{i}\qsk\hu{k}\en\bar% \Notes\zw{c}\hu{l}\qsk\hu{n}\en\setdoublebar% \endpiece% %\endextract% \end{music}% }; % CURVA 1 % \draw[line width=0.9pt, color=red-undar] % ($(score.north west)+(-1.1cm,-0.7cm)$) % punto INICIO (nota arriba) % .. controls % ($(score.north west)+(-1.7cm,-1.2cm)$) % punto control 1 (curva izquierda) % and % ($(score.north west)+(-1.9cm,-1.0cm)$) % punto control 2 (curva izquierda) % .. % ($(score.north west)+(-2.0cm,-1.1cm)$); % punto FIN (nota abajo) % % % CURVA 2 % \draw[line width=0.9pt, color=red-undar] % ($(score.north west)+(0.6cm,-0.9cm)$) % punto INICIO (nota arriba) % .. controls % ($(score.north west)+(0.5cm,-1.1cm)$) % punto control 1 (curva izquierda) % and % ($(score.north west)+(0.2cm,-1.2cm)$) % punto control 2 (curva izquierda) % .. % ($(score.north west)+(-0.1cm,-1.2cm)$); % punto FIN (nota abajo) % % % CURVA 3 % \draw[line width=0.9pt, color=red-undar] % ($(score.north west)+(4.1cm,-0.7cm)$) % punto INICIO (nota arriba) % .. controls % ($(score.north west)+(3.8cm,-1.0cm)$) % punto control 1 (curva izquierda) % and % ($(score.north west)+(3.6cm,-1.0cm)$) % punto control 2 (curva izquierda) % .. % ($(score.north west)+(3.2cm,-1.1cm)$); % punto FIN (nota abajo) % % % CURVA 4 % \draw[line width=0.9pt, color=red-undar] % ($(score.north west)+(5.8cm,-0.9cm)$) % punto INICIO (nota arriba) % .. controls % ($(score.north west)+(5.6cm,-1.1cm)$) % punto control 1 (curva izquierda) % and % ($(score.north west)+(5.4cm,-1.2cm)$) % punto control 2 (curva izquierda) % .. % ($(score.north west)+(5.1cm,-1.2cm)$); % punto FIN (nota abajo) % % % CURVA 5 % \draw[line width=0.9pt, color=red-undar] % ($(score.north west)+(9.2cm,-1.3cm)$) % punto INICIO (nota arriba) % .. controls % ($(score.north west)+(9.1cm,-1.5cm)$) % punto control 1 (curva izquierda) % and % ($(score.north west)+(8.7cm,-1.6cm)$) % punto control 2 (curva izquierda) % .. % ($(score.north west)+(8.4cm,-1.6cm)$); % punto FIN (nota abajo) % % % CURVA 6 % \draw[line width=0.9pt, color=red-undar] % ($(score.north west)+(11.0cm,-1.2cm)$) % punto INICIO (nota arriba) % .. controls % ($(score.north west)+(10.8cm,-1.4cm)$) % punto control 1 (curva izquierda) % and % ($(score.north west)+(10.5cm,-1.5cm)$) % punto control 2 (curva izquierda) % .. % ($(score.north west)+(10.2cm,-1.5cm)$); % punto FIN (nota abajo) % % % CURVA 7 % \draw[line width=0.9pt, color=red-undar] % ($(score.north west)+(12.9cm,-0.8cm)$) % punto INICIO (nota arriba) % .. controls % ($(score.north west)+(12.8cm,-1.0cm)$) % punto control 1 (curva izquierda) % and % ($(score.north west)+(12.4cm,-1.2cm)$) % punto control 2 (curva izquierda) % .. % ($(score.north west)+(12.0cm,-1.2cm)$); % punto FIN (nota abajo) % % % CURVA 8 % \draw[line width=0.9pt, color=red-undar] % ($(score.north west)+(14.6cm,-0.6cm)$) % punto INICIO (nota arriba) % .. controls % ($(score.north west)+(14.5cm,-1.1cm)$) % punto control 1 (curva izquierda) % and % ($(score.north west)+(14.2cm,-1.4cm)$) % punto control 2 (curva izquierda) % .. % ($(score.north west)+(13.9cm,-1.5cm)$); % punto FIN (nota abajo) % % \node[anchor=south west] at ($(score.north west)+(1.6cm, -0.6cm)$) % {\small\textbf{Etc.}}; % % \node[anchor=south west] at ($(score.north west)+(6.9cm, -0.6cm)$) % {\small\textbf{Etc.}}; % % \node[anchor=south west] at ($(score.north west)+(0.0cm, -0.2cm)$) % {\small\textbf{a)}}; % % \node[anchor=south west] at ($(score.north west)+(5.1cm, -0.2cm)$) % {\small\textbf{b)}}; % \\ % \node[anchor=south west] at ($(score.north west)+(9.5cm, -0.2cm)$) % {\small\textbf{c)}}; % \node[anchor=south west] at ($(score.north west)+(13.1cm, -0.2cm)$) % {\small\textbf{d)}}; % PUNTOS DE REFERENCIA %\fill[red] ($(score.north west)+(4.4cm,-0.9cm)$) circle (1pt); % INICIO %\fill[blue] ($(score.north west)+(0.5cm,-1.2cm)$) circle (1pt); % FIN %\fill[green] ($(score.north west)+(14.5cm,-0.9cm)$) circle (1pt); % CONTROL 1 %\fill[green] ($(score.north west)+(14.2cm,-1.1cm)$) circle (1pt); % CONTROL 2 \end{tikzpicture} \end{document}% The current output is as follow:
- Graphing a system of inequalities in 3 dimensionsby Henry Timmons on April 11, 2026 at 2:14 pm
I am trying to graph a system of 3 inequalities in 3 dimensions. These ineuqalities are: y-z>=1/2x, x-z>=0, and x+y>=3z. Currently I am struggling to get even a basic output. My input is: \documentclass[12pt, a4paper]{article} \usepackage{float, ulem, amsmath, amsthm, amssymb, pgfplots, tikz} \pgfplotsset{width=10cm,compat=1.9} \usepgfplotslibrary{external, fillbetween} \tikzexternalize \begin{document} \begin{tikzpicture} \begin{axis}[domain=0:10,y domain=0:10] \addplot3[surf] {y-(\frac{1}{2}*x)}; \addplot3[surf] {x}; \addplot3[surf] {\frac{x+y}{3}}; \end{axis} \end{tikzpicture} \end{document} I am getting the error: ! Package tikz Error: Sorry, the system call 'pdflatex -halt-on-error -interact ion=batchmode -jobname "mwe-figure0" "\def\tikzexternalrealjob{mwe}\input{mwe}" ' did NOT result in a usable output file 'mwe-figure0' (expected one of .pdf:.j pg:.jpeg:.png:). Please verify that you have enabled system calls. For pdflatex , this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or so mething like that. Or maybe the command simply failed? Error messages can be fo und in 'mwe-figure0.log'. If you continue now, I'll try to typeset the picture. See the tikz package documentation for explanation. Type H <return> for immediate help. ... l.19 \end{tikzpicture} ?
- How to create lines perfectly lie on a circle shape with TikZ?by user516076 on March 12, 2026 at 6:49 am
It's very difficult to make a perfect line that lies on exact circle. This is my full work: \documentclass[tikz,border=1pt]{standalone} \usepackage{tikz} \usepackage{calligra} \usepackage[T1]{fontenc} \begin{document} \begin{tikzpicture}[line width=1pt] \path[use as bounding box] (-5.6,-1.2) rectangle (6.4,7.2); % Circle \draw (2.6,3.0) circle (3.1); % Secant line P-T-U \draw (-5.0,0.1) -- (4.7,5.6); % Chords \draw (2.6,2.3) -- (1.2,1.7); % short chord near S \draw (1.2,1.7) -- (4.0,1.4); % S to V \draw (4.0,1.4) -- (4.7,5.6); % V to U % Angle at S \draw (1.2,1.7) ++(0.55,0) arc[start angle=0,end angle=123,radius=0.55]; % Angle at V \draw (4.0,1.4) ++(-0.55,0) arc[start angle=180,end angle=95,radius=0.55]; % Labels \node[font=\fontsize{34}{34}\selectfont] at (-5.0,-0.4) {$P$}; \node[font=\fontsize{34}{34}\selectfont] at (0.2,2.9) {$T$}; \node[font=\fontsize{34}{34}\selectfont] at (5.2,5.9) {$U$}; \node[font=\fontsize{34}{34}\selectfont] at (4.3,0.4) {$V$}; \node[font=\fontsize{34}{34}\selectfont] at (0.9,0.7) {$S$}; % Angle labels \node[font=\fontsize{28}{28}\selectfont] at (2.0,2.5) {$123^\circ$}; \node[font=\fontsize{28}{28}\selectfont] at (3.6,2.0) {$85^\circ$}; \end{tikzpicture} \end{document} and this is the result: What I want: Please along with full MWE ready to copy paste, could you explain, what the trick is and what to add and where to add, so that I can also learn? T.I.A.
- How can I draw grid of cylinders?by minthao_2011 on November 25, 2025 at 9:02 am
I used Mathematica and tried grid of cylinder I don’t know how to draw with other tools. How can I draw it?
- how can draw conical helix with latex tikz picture?by Samia Rani on August 30, 2024 at 12:10 pm
I am not much better at mathematics equations, but I need to draw some graphs in latex. I tried this one but it's not look exactly the same as shown in the image. Please I will be very grateful if anyone can help regarding this. \documentclass[tikz, border=1pt]{standalone} \usetikzlibrary{arrows.meta, ext.topaths.arcthrough, decorations.markings} \usetikzlibrary{math} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ hide axis, % Hide the axis lines, labels, and ticks view={45}{45}, axis equal, grid=none, samples=50, domain=0:7*pi, ] % First helix shifted upwards \addplot3[black, smooth] ({x*cos(deg(x))}, {x*sin(deg(x))}, {x + 1}); % Second helix shifted downwards \addplot3[black, smooth] ({-x*cos(deg(x))}, {-x*sin(deg(x))}, {-x - 1}); \end{axis} \end{tikzpicture} \end{document}
- TikZ text node and edge position in TikZitby Qohelet on November 27, 2023 at 5:46 pm
I am using the TikZit application to construct a diagram containing nodes that "contain" or "consist of" only text (formatted with color, etc.) and that are connected by various edges. When inputing the text as the label argument, the connecting edge encroaches into the middle of the text, like this: Here is the source code generated by TikZit: \begin{tikzpicture} \begin{pgfonlayer}{nodelayer} \node [style=none] (0) at (-2.5, 7) {Hello world!}; \node [style=green dot] (1) at (1.75, 5) {}; \node [style=red dot] (2) at (2.25, -0.75) {}; \node [style=none] (3) at (-3, -2) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw (0.center) to (1); \draw [in=30, out=45, looseness=2.25] (1) to (2); \draw (3.center) to (2); \end{pgfonlayer} \end{tikzpicture} I was able to use the label={POSITION:TEXT} option to modify the default behavior \node [style=none, label={above=Hello \textcolor{blue}{World!}}] (0) at (-2.5, 7) {}; which renders which is what I am wanting. The problem is that I do not want to manually input the position parameter for each node and I do not know how to set up a node style that will automatically position the edge connection relative to the text node without having to specify the position in each case. To put it in question form: Is there a way to set up a node style that will automatically position the connecting edge on the "outside" of the node relative to the text like the second image above? Any help is appreciated.
- 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
- Tikz: Align Text Within Each Sector of A Circleby Daniel James on June 11, 2022 at 11:13 am
What I Want I want the texts to be within each sector and not beyond. I want the texts to align at the top and not at the centre. What I Have Here is \documentclass[border=1cm]{standalone} \usepackage[dvipsnames]{xcolor} \usepackage{newtxtext} \usepackage{tikz} \usetikzlibrary{decorations.text, fadings} \tikzfading[name=fade out, inner color=transparent!0, outer color=transparent!5] \tikzset{ figNode/.style={ path picture={ \node at (path picture bounding box.center) {#1};}} } \usepackage[OT2, OT1]{fontenc} \begin{document} \pgfmathsetmacro\Nsector{15} \pgfmathsetmacro\Asector{360/\Nsector} \pgfmathsetmacro\Aorig{30} \begin{tikzpicture}[font=\large, main/.style = {draw, circle, text=black, preaction={draw, ultra thick, transform canvas={yshift=-0.2ex}, path fading=fuzzy ring 100 percent, opacity=0.25} }] \foreach[count=\xi] \dpt/\c/\uI in {% Human Resurce Mgt/Cyan!70!ForestGreen!40!/App Pro \& Disc\\Training \& Welfare, Gen. Service/Cyan!70!Magenta!40!/Gen. Service\\ Maintainance, Finance/Cyan!70!ForestGreen!40!/Exp\\ Budget\\ Revenue\\ Financial \& Fiscal Reporting, Legal Services \& Board Affair/Cyan!40!YellowOrange!70!/Legal Services\\Board Affairs, Comm \& Public Relation/Magenta!70!ForestGreen!40!/Communication\\ Public Affairs, Information Communication Tech/Cyan!70!ForestGreen!40!/Sys Prog \& Magtm\\Data Processing \& Analysis\\ Hardware \& Networking, Feild Services \& and Method./Cyan!40!ForestGreen!70!/Feild Services\\Methodology, National Acc Energy \& Environment/Cyan!70!ForestGreen!40!/National Account\\ Energy \& Environment, Corperate Planning \& Statistical Coordination/Cyan!70!/Corperate Planning \\ Statistical Coordination, Agric \& Biz Enter/Cyan!30!/Agric Statistics\\Biz Enterprice, Trade \& Prices/Cyan!130!/Trade\\Prices, Gender \& Social Stat/ForestGreen!30!/Gender \& Social Inclusion\\Social Stat, Intl Statistical Devpt/Cyan!70!YellowOrange!30!/Donor Coordination\\Intl Action Plan, Demo \& HH Stat/Cyan!30!YellowOrange!70!/Demographics\\Household, Procurement/Cyan!30!ForestGreen!30!YellowOrange!30!/Procurement Plans\\Tender Advertisement } {\draw[draw=white, fill = \c,thin] (\Aorig-\xi*\Asector:3cm)-- (\Aorig-\xi*\Asector:10cm) arc (\Aorig-\xi*\Asector:\Aorig-\xi*\Asector-\Asector:10) -- (\Aorig-\xi*\Asector-\Asector:3cm) arc (\Aorig-\xi*\Asector-\Asector:\Aorig-\xi*\Asector:3); \draw[decoration={text along path, text={|\bfseries\large|{\parbox{4em}{\centering{\large\color{red} \dpt}\\ \uI}}},text align={center}, raise=-1.2cm}, decorate] (\Aorig-\xi*\Asector:10cm) arc (\Aorig-\xi*\Asector:\Aorig-\xi*\Asector-\Asector:10); % or with %\node [align=center] at (\Aorig-\xi*\Asector-.5*\Asector:6.5cm){\dpt\\ \uI}; } % inner circle \draw[draw=white,fill = gray!10,thick] circle[radius = 2.8cm]; \draw[draw=white,fill = gray!40,thick] circle[radius = 2.3cm]; \draw[draw=white,fill = gray!10,thick] circle[radius = 2cm]; \pgfmathsetmacro\uAAAangle{90} \coordinate (uAAA) at (\uAAAangle:2.2cm); \draw[decoration={text along path, text={|\bfseries\large|Internal Audit},text align={center}, raise=0.2cm}, decorate] (uAAA) arc (\uAAAangle:\uAAAangle-180:2.2); %%Label2 \draw[decoration={text along path, text={|\bfseries\large|Economic Intelligence Unit},text align={center}, raise=0.2cm}, decorate] (\uAAAangle-180:2.2cm) arc (\uAAAangle-180:\uAAAangle-360:2.2); \end{tikzpicture} \end{document}
- Double entry tableby Dunno on May 27, 2021 at 10:23 am
I would like to make a double entry table in LaTeX. Here is the result that I would like to get: I found a clue here: \documentclass{article} \usepackage{multirow} \begin{document} \begin{center} \begin{tabular}{ c || l | r | c } & \multicolumn{3}{c}{Columns} \\ \hline \hline \multirow{3}{*}{Rows} & A1 & B1 & C1 \\ \cline{2-4} & A222 & B22 & C2 \\ \cline{2-4} & A3 & B333 & C33 \end{tabular} \end{center} \end{document} I managed to get a partial solution: \begin{document} \begin{center} \begin{tabular}{ l || r | c } A1 & B1 & C1 \\ \hline \hline A222 & B22 & C2 \\ \hline A3 & B333 & C33 \end{tabular} \end{center} \end{document} However, it doesn't solve all my problems. Is it possible to get square cells with everything centered in the cell? I found other partial solutions here but I don't know tikz at all. The matrix environment might not suit my needs because I would like to avoid outer borders and I didn't find any solution with double lines separing row's titles from the inner cells.
- How do I make a multiedge/tree-edge from a node to a box in latex-tikz?by notSpock on November 30, 2020 at 8:13 pm
I have to draw a graph in LaTeX and I have to draw an edge from a node to a rectangle as seen here. (image description: there is a node on the left and a box on the right, with multiple straight lines going from the node to the box, all having different angles, the endpoints form a straight line) I haven't found an answer yet and would rather avoid making a ton of small edges, especially since I need to make such an edge multiple times and in different directions. I am using tikz with calc library. \documentclass{scrreprt} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{graphicx} \usepackage{subfigure} \usepackage[ngerman]{babel} \usepackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{decorations.markings} \begin{document} \begin{tikzpicture} %big box \coordinate (lowleftbox) at (1,0); \coordinate (uprightbox) at (9.5,10.5); \draw[] (lowleftbox) rectangle (uprightbox); %vertices \coordinate (v1) at (0,5.5); \coordinate (v2) at (0.5,5.5); \fill (v1) circle[radius=3pt]; \fill (v2) circle[radius=3pt]; %edge between them \draw[] (v1) to (v2); %edge to box, manually, the code I want to improve \draw[] (v2) to (1,5.5); \draw[] (v2) to (1,5.6); \draw[] (v2) to (1,5.7); \draw[] (v2) to (1,5.8); \draw[] (v2) to (1,5.9); \draw[] (v2) to (1,6); \draw[] (v2) to (1,5.4); \draw[] (v2) to (1,5.3); \draw[] (v2) to (1,5.2); \draw[] (v2) to (1,5.1); \draw[] (v2) to (1,5.0); \end{tikzpicture} \end{document} I would be grateful for any tips regarding this. Thank you!
- 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.
- Dowsing chart book with Tikz with full circle (2)by zaord on March 18, 2020 at 9:49 pm
I works between science and geobiology in France and I would like to create custom dowsing charts which would looks like the exemples above : Those charts are for longer text and they have to be in the axis of each portion of circle and starting from the outer side of the center for the left half center and staring from the center for the right half center to be readeable... If you have any idea for this, it could be really good ! On the left side, there is some index for dowsing from a dowsing chart to one other and a title permit to have some reference to link those chart together. Actually I am not really skilled in programming and I am a simple user of latex, so i might need help to start with this. Maybe anyone have in mind some clues / exemples to look on to get this working with TikZ. In my mind I would like to enter a list of terms, and that the TikZ script automatic split into angle angle sections with automation. Thanks a lot !
- Bottom arrow between cells in latexby GoDev on November 28, 2019 at 9:57 pm
How can I draw bottom arrows from cell to cell at the borders of a table? More precisely I'd like to get something like this: \begin{tikzpicture}[ % -{Stealth[length = 2.5pt]}, start chain = going right, node distance = 0pt, MyStyle/.style={draw, minimum width=1.6em, minimum height=2em, outer sep=0pt, on chain}, ] \node [MyStyle] (1) {$A$}; \node [MyStyle] (2) {$B$}; \node [MyStyle] (3) {$C$}; \node [MyStyle] (4) {$D$}; \node [MyStyle] (5) {$E$}; \node [MyStyle] (6) {$F$}; \node [MyStyle] (7) {$G$}; \node [MyStyle] (8) {$Q$}; \node [MyStyle] (9) {$B$}; \node [MyStyle] (10) {$G$}; \node [MyStyle] (11) {$A$}; \node [MyStyle] (12) {$D$}; \node [MyStyle] (13) {$W$}; \node [MyStyle] (14) {$B$}; \node [MyStyle] (15) {$n$}; \node [MyStyle] (16) {$6$}; \begin{scope}%[-{Stealth[length = 2.5pt]}] %\draw (1.north) [out=25, in=155] to (2.north); %\draw (1.north) [out=30, in=155] to (3.north); \draw (1.north) [out=35, in=155] to (4.north); \draw (1.north) [out=40, in=155, below] to (6.north); \draw (1.south) [out=40, in=155, below] to (6.south); \end{scope} %\draw[decorate,decoration={brace, amplitude=10pt, raise=5pt, mirror}] %(2.south west) to node[black,midway,below= 15pt] {$k$-elements} (7.south east);% \end{tikzpicture} This code produces the following output: Problem: Bottom arrows between items. Code is based on: proportional boxes in Tikz (array diagram)
- Draw a pulley systemby Epa on April 22, 2019 at 3:15 am
Consider: I need to draw a pulley system as in the figure. How can I do that? \begin{tikzpicture} \fill[pattern=north east lines] (-3,0) rectangle (3,.3); \draw(-3,0)--(3,0); \draw(-2.5,0)--(-2.5,-2.4); \draw(2.5,0)--(2.5,-1); \draw[fill=white] (-2.5,-2.4) circle (.3); \draw[fill=white] (2.5,-1) circle (.3); \draw[fill=white] (0,-3) circle (.153); \draw (2.5,-1) coordinate (a) node[right] {} -- (0,-3) coordinate (b) node[left] {} -- (0,-2.75) coordinate (c) node[above right] {} pic["$\beta$", draw=orange, <->, angle eccentricity=1.2172, angle radius=.51cm] {angle=a--b--c}; \draw (0,-2.75) coordinate (a) node[right] {} -- (0,-3) coordinate (b) node[left] {} -- (-2.5,-2.4) coordinate (c) node[above right] {} pic["$\alpha$", draw=orange, <->, angle eccentricity=.72172, angle radius=.751cm] {angle=a--b--c}; \draw[dashed] (0,-3)--(0,-1); \draw[fill=white] (-2.5,-2.4) circle (.3); \draw[fill=white] (2.5,-1) circle (.3); \draw[fill=white] (0,-3) circle (.153); \end{tikzpicture}
- Pie chart with color palette, info inside and legendby José on August 27, 2018 at 8:19 am
I am trying to build the following pie chart with latex and the code below, however it seems quite difficult to match the legend, colors palette and external circle grouping colors. \documentclass[tikz,border=10pt]{standalone} \begin{document} \def\angle{0} \def\radius{3} \def\cyclelist{{"orange","blue","red","green"}} \newcount\cyclecount \cyclecount=-1 \newcount\ind \ind=-1 \begin{tikzpicture}[nodes = {font=\sffamily}] \foreach \percent/\name in { 0.01/1\% Cash, 4.26/ 5\% Miton Multi-Cap Income, 6.86/6\% Schroder Income Maximiser, 3.82/6\% Trojan Income, 3.32/7\% CF Woodford Equity Income, 2.91/7\% Artemis Global Income, 2.87/4\% First State Global Listed Infraestructure 2.63/4\% Lazard Global Listed Infraestructure 3.50/4\% Legg Mason RARE Global Income 2.55/6\% Newton Global Income 4.6/5\% Henderson Strategic Bond 5.01/4\% Invesco Perpetual Monthly Income Plus 4.4/5\% Jupiter Strategic Bond 0/4\% L&G All Stocks Index Linked Gilt Index 2.3/5\% L&G Short Dated Sterling Corporate Bond Index 5.95/4\% Royal London Short Duration Global High Yield Bond 3.55/4\% Twenty Four Corporate Bond 5.03/4\% Twenty Four Dynamic Bond 4.8/5\% F&C Property Growth & Income 4.44/5\% Aviva Multi Strategy Target Income 3.45/5\% Invesco Perpetual Global Targeted Income } { \ifx\percent\empty\else % If \percent is empty, do nothing \global\advance\cyclecount by 1 % Advance cyclecount \global\advance\ind by 1 % Advance list index \ifnum3<\cyclecount % If cyclecount is larger than list \global\cyclecount=0 % reset cyclecount and \global\ind=0 % reset list index \fi \pgfmathparse{\cyclelist[\the\ind]} % Get color from cycle list \edef\color{\pgfmathresult} % and store as \color % Draw angle and set labels \draw[fill={\color!50},draw={\color}] (0,0) -- (\angle:\radius) arc (\angle:\angle+\percent*3.6:\radius) -- cycle; \node at (\angle+0.5*\percent*3.6:0.7*\radius) {\percent\,\%}; \node[pin=\angle+0.5*\percent*3.6:\name] at (\angle+0.5*\percent*3.6:\radius) {}; \pgfmathparse{\angle+\percent*3.6} % Advance angle \xdef\angle{\pgfmathresult} % and store in \angle \fi }; \end{tikzpicture} \end{document} I found particularly complex to replicate it with latex, so any help will be welcome. Thanks for your support!
- Loops & insertions in Tikz-Feynmanby Janosh on June 29, 2017 at 8:35 pm
I'd like to produce these diagrams using Tikz-Feynman. What I have so far is \RequirePackage{luatex85} \documentclass{standalone} \usepackage[compat=1.1.0]{tikz-feynman} \begin{document} $\feynmandiagram [horizontal=a to b, layered layout, baseline=(i1.base)] { i1 -- a [dot] -- [photon,half left,momentum'=\(q\)] b [dot] -- [photon,half left,momentum'=\(q\)] a, b -- f1 }; + \feynmandiagram [horizontal=a to b, layered layout, baseline=(a.base)] { {i1,i2} -- a [dot] -- [photon,half left,momentum'=\(q\)] b [crossed dot] -- [photon,half left,momentum'=\(q\)] a, };$ \end{document} There are a few open questions: How can I move the momentum arrows outside the loops? How can I shorten the in and outgoing lines? How can I precisely vertically align the center of both diagrams with the plus sign? How can I add the crossed dot on the first diagram? Update With the help of JP-Ellis I was able to get \RequirePackage{luatex85} \documentclass{standalone} \usepackage[compat=1.1.0]{tikz-feynman} \begin{document} $\feynmandiagram [horizontal=a to c,inline=(a.base)] { a [dot] -- [charged boson,quarter left,edge label=\(q\)] b -- [photon,quarter left] c [dot] -- [charged boson,quarter left,edge label=\(q\)] d [crossed dot] -- [charged boson,quarter left,edge label=\(q\)] a, f1 -- c, i1 -- a, }; \quad\raisebox{-0.5ex}{+}\quad \feynmandiagram [horizontal=a to b, layered layout, inline=(a.base)] { {i1,i2} -- a [dot] -- [charged boson,half left,edge label=\(q\)] b [crossed dot] -- [charged boson,half left,edge label=\(q\)] a [desired at={(0, 0)}], };$ \end{document} One question remains: is there a way to move the arrow on charged boson and its edge label to the end of a line? My intent is to to have them at the top of the upper arch in the first diagram (rather than in the middle of the first quarter).
- Draw circle with three colours in tikzby whatamess on May 8, 2017 at 2:15 pm
I would like to have a circle where the circumference is coloured with three different colours, something like the following but a line and with only three colours: I initially tried \documentclass{article} \usepackage{amsmath} \usepackage{tikz} \pagestyle{empty} \begin{document} \begin{tikzpicture} \draw [red] (0,0) arc [radius=1, start angle=0, end angle=120]; \draw [green] (1,0) arc [radius=1, start angle=120, end angle=240]; \draw [blue] (0,0) arc [radius=1, start angle=240, end angle=360]; \end{tikzpicture} \end{document} but this does not give the right result, and the arguments of the function are such that it's quite difficult to make what I have in mind.
- Aligning text along a sector of a circleby lexxie on May 23, 2016 at 1:52 pm
How can I align text along the circumference of a circle like this using TikZ? Please ignore the icons. I tried using paths and decorations, but I don't know how to constrain the text to each sector. This is the code I used to draw the circles and the sectors \begin{tikzpicture} \draw[thick] (0cm,0cm) circle(3cm); \foreach \x in {0,45,...,360} { % lines from center to point \draw[black] (0cm,0cm) -- (\x:3cm); } \end{tikzpicture}
- Beginner: Drawing using Tikzby Sooraj on July 15, 2014 at 6:15 am
I was quite impressed by the figures generated by TikZ and wanted to try TikZ to generate a few figures (please see the attached image drawn using an external WYSWYG program). When I tried to reproduce the figures myself using TikZ I found it very difficult to control the shapes in required positions. What is the simplest method to draw!these figures using TikZ?
- PGF/TikZ Clipping & Drawing: How to customize lines?by Mohammed on January 29, 2012 at 8:51 pm
I have gotten some undesirable behavior with PGF/TikZ related to clipping and drawing paths with different color, say gray. So I tried with no success to exchange between \clip[draw=gray], \draw[clip,gray] or \path[draw=gray, clip] or maybe using indirectly styles, the Emacs' output throws a TeX error message: Extra options not allowed for clipping path command... the only way to do so is by using scopes: \begin{scope}[draw=gray] ... \end{scope} Unfortunately, this technique requires that all the scoped objects' lines should be switched to black. So is there a trickery way to achieve this without passing by scope environment?
- Write inside divided circleby Nicolas on October 24, 2011 at 1:35 pm
At this address Label Points in a circle in tikz you can see the code to divide a circle into x cells. How to write a phrase into each cell of the divided circle?
- Molecular orbital diagrams in LaTeX?by Richard Terrett on March 19, 2011 at 8:04 am
Update 2026: mohelper This new package comes with a webhelper. You can edit your diagrams there and insert the tex output into your projects. However (!), please view the repo and read the manual (you can find it on ctan or from the repo). This question led to a new package: modiagram I'm wondering if anyone has seen a package for drawing (qualitative) molecular orbital splitting diagrams in LaTeX? Or if there exist any packages that can be easily re-purposed to this task? Otherwise, I think I'll have a go at it in TikZ. Example (Cropped from a graphic on Wikipedia by 'orci' - I suspect it was drawn manually due to the slight misalignment of various elements) Having a go at it in TikZ I decided to try doing this in TikZ and have prepared a MO diagram for dioxygen (prior attempt at much simpler dihydrogen below) - this is the kind of scheme I'm going for. There are at least three problems with this approach: It's not very general and I don't know any strategies to make it arbitrarily extensible (e.g. stacking energy levels etc like in the example diagram.) Partially addressed The H, H_{2} labels are not aligned at the baseline of each H, so the H_{2} is slightly higher than the other two. Solved, thanks @Matthew Leingang The coordinates, whilst text-proportionate, are all hard coded and I would like to know how to make this diagram scalable in terms of a total width, total height and separation of the split levels. Addressed using (probably too many) variables and in-coordinate calculation Please help me improve this probably pretty naive approach. Specification MO diagrams can be drawn in a variety of different ways. In the simplest case, such as for either O2 or H2 here, the left column represents the orbitals of one atom as horizontal lines, arranged vertically in order of their relative energies. The right column does the same for the other atom. In this case the example picture represents orbitals as boxes for clarity as several orbitals can have the same energy, which is what occurs in the case of the 3x 2p orbitals and the pi_x, pi_y orbitals. In this situation they are shown side by side. Orbitals may have zero, one or two (antiparallel) electrons. It is fairly common to simply see orbitals represented as horizontal lines rather than boxes. Lines connect the orbitals to indicate the contribution of the atomic orbitals to a molecular orbital. The center column shows the molecular orbitals generated from the combination of the atomic orbitals, which can either be additive (in which case the relative energy drops, giving a bonding orbital) or subtractive (in which case the relative energy increases with respect to the atomic orbitals, i.e. an antibonding orbital). As this diagram is qualitative only, the splitting can be treated as symmetric. Source \documentclass{article} \usepackage{tikz} \usepackage{textcomp} \usepackage[version=3]{mhchem} \newcommand{\moup}{\textuparrow} \newcommand{\modown}{\textdownarrow} \newcommand{\moupdown}{\textuparrow\textdownarrow} \begin{document} \begin{tikzpicture}[scale=1] \def\sbaseline{0em}; \def\pbaseline{14em}; \def\ssplit{6em}; \def\psplit{12em}; \def\pextend{5em}; \def\psso{4em}; \def\pxyoffset{1em}; \def\mwidth{3em}; \def\hsep{2em}; \tikzstyle{split} = [densely dashed,draw=gray] \tikzstyle{orbital} = [rectangle, rounded corners, fill=white, draw=black, minimum width=3.5ex, minimum height=3.5ex] \tikzstyle{label} = [rectangle, minimum width=3.5ex, node distance=3.5ex] %1s splitting \draw (\mwidth/-2-\hsep*2,\sbaseline) -- (\mwidth/-2-\hsep ,\sbaseline); \draw[split] (\mwidth/-2-\hsep ,\sbaseline) -- (\mwidth/-2 ,\sbaseline+\ssplit/2); \draw (\mwidth/-2 ,\sbaseline+\ssplit/2) -- (\mwidth/2 ,\sbaseline+\ssplit/2); \draw[split] (\mwidth/2 ,\sbaseline+\ssplit/2) -- (\mwidth/2+\hsep ,\sbaseline); \draw (\mwidth/2+\hsep ,\sbaseline) -- (\mwidth/+2+\hsep*2,\sbaseline); \draw[split] (\mwidth/-2-\hsep ,\sbaseline) -- (\mwidth/-2 ,\sbaseline+\ssplit/-2); \draw (\mwidth/-2 ,\sbaseline+\ssplit/-2) -- (\mwidth/2 ,\sbaseline+\ssplit/-2); \draw[split] (\mwidth/2 ,\sbaseline+\ssplit/-2) -- (\mwidth/2+\hsep ,\sbaseline); %left 1s \draw[] (-\mwidth-\hsep,0em) node[orbital] (l1s) {\moupdown}; \node[label, below of=l1s] (l1sl) {$2s$}; %right 1s \draw[] (\mwidth+\hsep,0em) node[orbital] (r1s) {\moupdown}; \node[label, below of=r1s] (r1sl) {$2s$}; %sigma bonding \draw[] (0em,\ssplit/-2) node[orbital] (sb) {\moupdown}; \node[label, below of=sb] (sbl) {$\sigma$}; \node[label, left of=sb, node distance = 9ex] {\tiny{\color{gray}{$\Psi_{a}+\Psi_{b}$}}}; %sigma antibonding \draw[] (0em,\ssplit/2) node[orbital] (sa) {\moupdown}; \node[label, below of=sa] (sal) {$\sigma^{*}$}; \node[label, left of=sa, node distance = 9ex] {\tiny{\color{gray}{$\Psi_{a}-\Psi_{b}$}}}; %orbital labels \node[label, below of=l1sl, node distance=6em] (a) {\smash[b]{\ce{O_{a}}}}; \node[label, right of=a , node distance=\mwidth+\hsep] (ab) {\smash[b]{\ce{{O2}}}}; \node[label, right of=a , node distance=\mwidth*2+\hsep*2] (b) {\smash[b]{\ce{O_{b}}}}; %Title \node[label, below of=ab , node distance=3em] (desc) {Dioxygen ($|S|=1$)}; %2p splitting \draw (\mwidth/-2-\hsep*2-\pextend,\pbaseline) -- (\mwidth/-2-\hsep ,\pbaseline); \draw[split] (\mwidth/-2-\hsep ,\pbaseline) -- (\mwidth/-2 ,\pbaseline+\psplit/2); \draw (\mwidth/-2 ,\pbaseline+\psplit/2) -- (\mwidth/2 ,\pbaseline+\psplit/2); \draw[split] (\mwidth/2 ,\pbaseline+\psplit/2) -- (\mwidth/2+\hsep ,\pbaseline); \draw (\mwidth/2+\hsep ,\pbaseline) -- (\mwidth/+2+\hsep*2+\pextend,\pbaseline); \draw[split] (\mwidth/-2-\hsep ,\pbaseline) -- (\mwidth/-2 ,\pbaseline+\psplit/-2); \draw (\mwidth/-2 ,\pbaseline+\psplit/-2) -- (\mwidth/2 ,\pbaseline+\psplit/-2); \draw[split] (\mwidth/2 ,\pbaseline+\psplit/-2) -- (\mwidth/2+\hsep ,\pbaseline); \draw[split] (\mwidth/-2-\hsep ,\pbaseline) -- (\mwidth/-2 ,\pbaseline-\psso+\psplit/2); \draw (\mwidth/-2 ,\pbaseline-\psso+\psplit/2) -- (\mwidth/2 ,\pbaseline-\psso+\psplit/2); \draw[split] (\mwidth/2 ,\pbaseline-\psso+\psplit/2) -- (\mwidth/2+\hsep ,\pbaseline); \draw[split] (\mwidth/-2-\hsep ,\pbaseline) -- (\mwidth/-2 ,\pbaseline+\psso+\psplit/-2); \draw (\mwidth/-2 ,\pbaseline+\psso+\psplit/-2) -- (\mwidth/2 ,\pbaseline+\psso+\psplit/-2); \draw[split] (\mwidth/2 ,\pbaseline+\psso+\psplit/-2) -- (\mwidth/2+\hsep ,\pbaseline); %left 2p \draw[] (-\mwidth-\hsep,\pbaseline) node[orbital] (l2pa) {\moupdown}; \node[orbital, left of=l2pa] (l2pb) {\moup}; \node[orbital, left of=l2pb] (l2pc) {\moup}; \node[label, below of=l2pb] (l2pl) {$2p$}; %right 2p \draw[] (\mwidth+\hsep,\pbaseline) node[orbital] (r2pa) {\moupdown}; \node[orbital, right of=r2pa] (r2pb) {\moup}; \node[orbital, right of=r2pb] (r2pc) {\moup}; \node[label, below of=r2pb] (r2pl) {$2p$}; %sigmap bonding \draw[] (0em,\pbaseline+\psplit/-2) node[orbital] (spb) {\moupdown}; \node[label, below of=spb] (spbl) {$\sigma$}; %sigmap antibonding \draw[] (0em,\pbaseline+\psplit/2) node[orbital] (spab) {}; \node[label, below of=spab] (spabl) {$\sigma^{*}$}; %pi antibonding levels \draw[] (-\pxyoffset,\pbaseline+\psso-\psplit/2) node[orbital] (ppabx) {\moupdown}; \node[label, below of=ppabx] (ppabxl) {$\pi_{x}$}; \draw[] (+\pxyoffset,\pbaseline+\psso-\psplit/2) node[orbital] (ppaby) {\moupdown}; \node[label, below of=ppaby] (ppabyl) {$\pi_{y}$}; %pi antibonding levels \draw[] (-\pxyoffset,\pbaseline-\psso+\psplit/2) node[orbital] (ppbx) {\moup}; \node[label, below of=ppbx] (ppbxl) {$\pi^{*}_{x}$}; \draw[] (+\pxyoffset,\pbaseline-\psso+\psplit/2) node[orbital] (ppby) {\moup}; \node[label, below of=ppby] (ppbyl) {$\pi^{*}_{y}$}; \end{tikzpicture} \end{document}