|
| 1 | +\documentclass[varwidth=28cm]{standalone} |
| 2 | +\usepackage{tikz} |
| 3 | +\usetikzlibrary{decorations.pathreplacing,calligraphy} |
| 4 | +\usepackage{caption} |
| 5 | +\usepackage{subcaption} |
| 6 | + |
| 7 | +% To build: |
| 8 | +% pdflatex relative_ordinal.tex |
| 9 | +% To auto build on save: |
| 10 | +% latexmk -pdf -pvc -halt-on-error relative_ordinal.tex |
| 11 | +% To build png: |
| 12 | +% convert -density 200 relative_ordinal.pdf -quality 100 -background white -alpha remove relative_ordinal.png |
| 13 | + |
| 14 | +\def\vspacing{1.0cm} |
| 15 | +\def\hspacing{0.4cm} |
| 16 | +\def\overshoot{0.4cm} |
| 17 | +\def\offset{1.2cm} |
| 18 | + |
| 19 | +\newcommand{\abrace}[5][0.5]{ |
| 20 | + \draw [decorate, decoration = {calligraphic brace, amplitude=5pt, aspect=#1}, very thick] |
| 21 | + (#2*\hspacing + \offset, -#3*\vspacing+\overshoot) -- (#2*\hspacing + \offset, -#4*\vspacing-\overshoot) |
| 22 | + node[right=5pt, pos=#1] {#5}; |
| 23 | +} |
| 24 | + |
| 25 | +\newcommand{\funk}[3][black]{ |
| 26 | + \node[left=1cm,align=right] at (0,-#2*\vspacing) {\texttt{#3}}; |
| 27 | + \node[align=left] at (0,-#2*\vspacing) [scale=0.8,text=#1,fill=#1!5!white] |
| 28 | + {\texttt{def fun():} \\ \texttt{\quad \quad...}}; |
| 29 | +} |
| 30 | + |
| 31 | +\newcommand{\elide}[1]{ |
| 32 | + \node[minimum height=0.5cm,scale=1.5] at (0,-#1*\vspacing) {\texttt{...}}; |
| 33 | +} |
| 34 | + |
| 35 | +\begin{document} |
| 36 | +\begin{figure} |
| 37 | + % \centering |
| 38 | + \begin{subfigure}[t]{.37\linewidth} |
| 39 | + \begin{tikzpicture} |
| 40 | + \elide{1} |
| 41 | + \funk{2}{"third previous funk"} |
| 42 | + \funk{3}{"second previous funk"} |
| 43 | + \funk{4}{"previous funk"} |
| 44 | + \funk[red]{5}{} |
| 45 | + \funk{6}{"next funk"} |
| 46 | + \funk{7}{"second next funk"} |
| 47 | + \funk{8}{"third next funk"} |
| 48 | + \elide{9} |
| 49 | + \abrace{0}{6}{8}{\texttt{"next three funks"}}; |
| 50 | + \abrace{0}{2}{4}{\texttt{"previous three funks"}}; |
| 51 | + \end{tikzpicture} |
| 52 | + % \caption{Relative exclusive modifiers} |
| 53 | + \end{subfigure} |
| 54 | + \begin{subfigure}[t]{.28\linewidth} |
| 55 | + \begin{tikzpicture} |
| 56 | + \elide{1} |
| 57 | + \funk{2}{} |
| 58 | + \funk{3}{} |
| 59 | + \funk{4}{} |
| 60 | + \funk[red]{5}{"funk"} |
| 61 | + \funk{6}{} |
| 62 | + \funk{7}{} |
| 63 | + \funk{8}{} |
| 64 | + \elide{9} |
| 65 | + \abrace{0}{5}{7}{\texttt{"three funks"}}; |
| 66 | + \abrace{1}{3}{5}{\texttt{"three funks backward"}}; |
| 67 | + \end{tikzpicture} |
| 68 | + % \caption{Relative inclusive modifiers} |
| 69 | + \end{subfigure} |
| 70 | + \begin{subfigure}[t]{.3\linewidth} |
| 71 | + \begin{tikzpicture} |
| 72 | + \funk{1}{"first funk"} |
| 73 | + \funk{2}{"second funk"} |
| 74 | + \funk{3}{} |
| 75 | + \elide{4} |
| 76 | + \funk[red]{5}{} |
| 77 | + \elide{6} |
| 78 | + \funk{7}{} |
| 79 | + \funk{8}{"second last funk"} |
| 80 | + \funk{9}{"last funk"} |
| 81 | + \abrace{0}{7}{9}{\texttt{"last three funks"}}; |
| 82 | + \abrace{0}{1}{2}{\texttt{"first two funks"}}; |
| 83 | + \end{tikzpicture} |
| 84 | + % \caption{Absolute modifiers} |
| 85 | + \end{subfigure} |
| 86 | + \\ |
| 87 | + \begin{subfigure}[t]{\linewidth} |
| 88 | + \begin{tikzpicture} |
| 89 | + \funk[red]{0}{} |
| 90 | + \node[align=left,right=0.8cm] at (0,0) {= function containing input target}; |
| 91 | + \end{tikzpicture} |
| 92 | + \end{subfigure} |
| 93 | + \\ |
| 94 | + \begin{subfigure}[t]{\linewidth} |
| 95 | + \begin{tikzpicture} |
| 96 | + \funk{0}{} |
| 97 | + \node[align=left,right=0.8cm] at (0,0) {= function within iteration scope of input target}; |
| 98 | + \end{tikzpicture} |
| 99 | + \end{subfigure} |
| 100 | + |
| 101 | +\end{figure} |
| 102 | +\end{document} |
0 commit comments