From ffe1d907f22a7f3837f34e3ed507c91e4179f9ea Mon Sep 17 00:00:00 2001 From: Christophe Garion <tofgarion@runbox.com> Date: Mon, 12 Dec 2016 11:37:53 +0100 Subject: [PATCH] my-tikz: move nodes command to my-tikz --- my-env.sty | 35 ----------------------------------- my-tikz.sty | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/my-env.sty b/my-env.sty index 20e76c1..d3fdfd4 100644 --- a/my-env.sty +++ b/my-env.sty @@ -101,38 +101,3 @@ \newcommand{\setmark}[2]{% \ifundef{#1}{\def#1{#2}}{}% } - -% draw CS arrays -\newcounter{nodeidx} -\setcounter{nodeidx}{0} - -\newif\ifcontinuearray - -\pgfkeys{ - /myarray/.is family, - /myarray, - default/.style={ - sep distance = 0, - array number = 0, - }, - continue/.initial = false, - sep distance/.estore in=\sepDistance, - array number/.estore in=\arrayNum, - continue/.is if=continuearray -} - -\newcommand{\nodes}[2][]{% - \pgfkeys{/myarray, default, #1}% - \begin{scope}[\ifcontinuearray continue \else start \fi chain=my-array-temp-{\arrayNum} going right, node - distance=\sepDistance] - \foreach \num in {#2}{ - \node[minimum size=2em, draw, rectangle, on - chain=my-array-temp-{\arrayNum}] (nodearray-\arrayNum-\arabic{nodeidx}) {\num}; - \stepcounter{nodeidx} - } - \end{scope} -} - -\newcommand{\brckt}[4]{% from, to, lvl, text - \draw (nodearray-#1.south west) ++($(-.1, -.1) + (-.1*#3, 0)$) -- ++($(0,-.1) + (0,-#3*1.25em)$) -- node [below] {#4} ($(nodearray-#2.south east) + (.1,-.1) + (.1*#3, 0) + (0,-.1) + (0,-#3*1.25em)$) -- ++($(0,#3*1.25em) + (0,.1)$);% -} diff --git a/my-tikz.sty b/my-tikz.sty index 81ccded..557afb4 100644 --- a/my-tikz.sty +++ b/my-tikz.sty @@ -180,3 +180,39 @@ \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path } } + +% draw CS arrays +\usetikzlibrary{intersections} +\newcounter{nodeidx} +\setcounter{nodeidx}{0} + +\newif\ifcontinuearray + +\pgfkeys{ + /myarray/.is family, + /myarray, + default/.style={ + sep distance = 0, + array number = 0, + }, + continue/.initial = false, + sep distance/.estore in=\sepDistance, + array number/.estore in=\arrayNum, + continue/.is if=continuearray +} + +\newcommand{\nodes}[2][]{% + \pgfkeys{/myarray, default, #1}% + \begin{scope}[\ifcontinuearray continue \else start \fi chain=my-array-temp-{\arrayNum} going right, node + distance=\sepDistance] + \foreach \num in {#2}{ + \node[minimum size=2em, draw, on + chain=my-array-temp-{\arrayNum}] (nodearray-\arrayNum-\arabic{nodeidx}) {\num}; + \stepcounter{nodeidx} + } + \end{scope} +} + +\newcommand{\brckt}[4]{% from, to, lvl, text + \draw (nodearray-#1.south west) ++($(-.1, -.1) + (-.1*#3, 0)$) -- ++($(0,-.1) + (0,-#3*1.25em)$) -- node [below] {#4} ($(nodearray-#2.south east) + (.1,-.1) + (.1*#3, 0) + (0,-.1) + (0,-#3*1.25em)$) -- ++($(0,#3*1.25em) + (0,.1)$);% +} -- GitLab