| 1 |
%% |
| 2 |
%% This is file `signchart.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% signchart.dtx (with options: `package') |
| 8 |
%% ---------------------------------------------------------------- |
| 9 |
%% signchart --- Create beautiful sign charts. |
| 10 |
%% E-mail: [email protected] |
| 11 |
%% Released under the LaTeX Project Public License v1.3c or later |
| 12 |
%% See http://www.latex-project.org/lppl.txt |
| 13 |
%% ---------------------------------------------------------------- |
| 14 |
%% |
| 15 |
\NeedsTeXFormat{LaTeX2e} |
| 16 |
\ProvidesPackage{signchart}[2016/02/12 v1.01] |
| 17 |
\RequirePackage{tikz} |
| 18 |
\RequirePackage{pgfplots} |
| 19 |
\pgfplotsset{compat = 1.10} |
| 20 |
\RequirePackage{xstring} |
| 21 |
\RequirePackage{xkeyval} |
| 22 |
\def\signHeightKey{0.3} |
| 23 |
\def\valNorthSouthKey{south} |
| 24 |
\def\valSepKey{3pt} |
| 25 |
\DeclareOption{signunder}{\def\signHeightKey{-0.3}} |
| 26 |
\DeclareOption{valunder}{% |
| 27 |
\def\valNorthSouthKey{north}% |
| 28 |
\def\valSepKey{13pt}} |
| 29 |
\DeclareOption*{% |
| 30 |
\PackageWarning{signchart}{Unknown option ‘\CurrentOption’}% |
| 31 |
} |
| 32 |
\ProcessOptions\relax |
| 33 |
\define@key{signchart}{height}[\signHeightKey]{\def\signHeight{#1}} |
| 34 |
\define@key{signchart}{valanchor}[\valNorthSouthKey]{\def\valNorthSouth{#1}} |
| 35 |
\define@key{signchart}{valsep}[\valSepKey]{\def\valSep{#1}} |
| 36 |
\define@key{signchart}{width}[5]{\def\signChartWidth{#1}} |
| 37 |
\define@key{signchart}{arrows}[<->]{\def\theArrow{#1}} |
| 38 |
\makeatother |
| 39 |
\newcommand{\signchart}[3][]{ |
| 40 |
\setkeys{signchart}{height, valanchor, valsep, width, arrows, #1} |
| 41 |
\begin{center} |
| 42 |
\begin{tikzpicture} |
| 43 |
\pgfmathsetmacro{\snht}{\signHeight} |
| 44 |
\pgfmathsetmacro{\wid}{\signChartWidth} |
| 45 |
\def\vals{#2} |
| 46 |
\def\signs{#3} |
| 47 |
\def\valsarray{{\vals}} |
| 48 |
\StrCount{\vals}{,}[\len] |
| 49 |
\draw[\theArrow,thick] (0,0) -- (\wid,0); |
| 50 |
\def\thisVal{-0} |
| 51 |
\foreach \i in {0,...,\len} { |
| 52 |
\pgfmathtruncatemacro{\k}{\i + 1} |
| 53 |
\ifnum \i < \len |
| 54 |
\StrPosition[\k]{\vals}{,}[\pos] |
| 55 |
\StrBefore[\k]{\vals}{,}[\leftParti] |
| 56 |
\ifnum \i = 0 |
| 57 |
\def\thisVal{\leftParti} |
| 58 |
\else |
| 59 |
\StrBehind[\i]{\leftParti}{,}[\thisVal] |
| 60 |
\fi |
| 61 |
\else |
| 62 |
\StrBehind[\i]{\vals}{,}[\thisVal] |
| 63 |
\fi |
| 64 |
\pgfmathtruncatemacro{\j}{\i + 1} |
| 65 |
\StrBehind[\j]{\signs}{,}[\rightPart] |
| 66 |
\StrLen{\rightPart}[\aLength] |
| 67 |
\pgfmathtruncatemacro{\cutAmount}{\aLength + 1} |
| 68 |
\StrGobbleRight{\signs}{\cutAmount}[\leftPartii] |
| 69 |
\StrBehind[\j]{,\leftPartii}{,}[\s] |
| 70 |
\pgfmathsetmacro{\valpos}{(\wid/(\len+2))*(\i+1)} |
| 71 |
\pgfmathsetmacro{\signpos}{(\wid/(\len+2))*(\i+0.5)} |
| 72 |
\draw (\valpos,-0.15) -- (\valpos,0.15) node[anchor=\valNorthSouth, |
| 73 |
inner sep=\valSep] |
| 74 |
{\thisVal}; |
| 75 |
\node at (\signpos,\snht) {$\s$}; |
| 76 |
\ifnum \i = \len |
| 77 |
\pgfmathsetmacro{\signpos}{(\wid/(\len+2))*(\len+1.5)} |
| 78 |
\pgfmathtruncatemacro{\j}{\len + 1} |
| 79 |
\StrBehind[\j]{\signs}{,}[\s] |
| 80 |
\node at (\signpos,\snht) {$\s$}; |
| 81 |
\fi |
| 82 |
} |
| 83 |
\end{tikzpicture} |
| 84 |
\end{center} |
| 85 |
} |
| 86 |
%% |
| 87 |
%% Copyright (C) 2016 by Anthony Mottaz <[email protected]> |
| 88 |
%% |
| 89 |
%% This work may be distributed and/or modified under the |
| 90 |
%% conditions of the LaTeX Project Public License (LPPL), either |
| 91 |
%% version 1.3c of this license or (at your option) any later |
| 92 |
%% version. The latest version of this license is in the file: |
| 93 |
%% |
| 94 |
%% http://www.latex-project.org/lppl.txt |
| 95 |
%% |
| 96 |
%% This work is "maintained" (as per LPPL maintenance status) by |
| 97 |
%% You. |
| 98 |
%% |
| 99 |
%% This work consists of the file signchart.dtx |
| 100 |
%% and the derived files signchart.ins, |
| 101 |
%% signchart.pdf and |
| 102 |
%% signchart.sty. |
| 103 |
%% |
| 104 |
%% |
| 105 |
%% End of file `signchart.sty'. |