| 1 |
% \iffalse meta-comment |
| 2 |
%<*internal> |
| 3 |
\iffalse |
| 4 |
%</internal> |
| 5 |
%<*readme> |
| 6 |
---------------------------------------------------------------- |
| 7 |
signchart --- v1.01 2016/02/12 |
| 8 |
E-mail: [email protected] |
| 9 |
Released under the LaTeX Project Public License v1.3c or later |
| 10 |
See http://www.latex-project.org/lppl.txt |
| 11 |
---------------------------------------------------------------- |
| 12 |
|
| 13 |
The signchart package provides you with the ability to create |
| 14 |
beautifully typeset sign charts. |
| 15 |
|
| 16 |
Refer to the documentation for usage instructions. Suggestions |
| 17 |
for improvement can be sent to the email address above. |
| 18 |
|
| 19 |
------------------ INSTALLATION INSTRUCTIONS ------------------- |
| 20 |
Copy the 'signchart.dtx' file to a temporary location, then |
| 21 |
from a terminal run the following command twice: |
| 22 |
pdflatex signchart.dtx |
| 23 |
Then we need to create the index. Run the command: |
| 24 |
makeindex -s gind.ist signchart |
| 25 |
and then run pdflatex twice more. |
| 26 |
|
| 27 |
Finally, you need to move the 'signchart.sty' to folders that |
| 28 |
are searched by your TeX distribution. |
| 29 |
---------------------------------------------------------------- |
| 30 |
%</readme> |
| 31 |
%<*internal> |
| 32 |
\fi |
| 33 |
\def\nameofplainTeX{plain} |
| 34 |
\ifx\fmtname\nameofplainTeX\else |
| 35 |
\expandafter\begingroup |
| 36 |
\fi |
| 37 |
%</internal> |
| 38 |
%<*install> |
| 39 |
\input docstrip.tex |
| 40 |
\keepsilent |
| 41 |
\askforoverwritefalse |
| 42 |
\preamble |
| 43 |
---------------------------------------------------------------- |
| 44 |
signchart --- Create beautiful sign charts. |
| 45 |
E-mail: [email protected] |
| 46 |
Released under the LaTeX Project Public License v1.3c or later |
| 47 |
See http://www.latex-project.org/lppl.txt |
| 48 |
---------------------------------------------------------------- |
| 49 |
|
| 50 |
\endpreamble |
| 51 |
\postamble |
| 52 |
|
| 53 |
Copyright (C) 2016 by Anthony Mottaz <[email protected]> |
| 54 |
|
| 55 |
This work may be distributed and/or modified under the |
| 56 |
conditions of the LaTeX Project Public License (LPPL), either |
| 57 |
version 1.3c of this license or (at your option) any later |
| 58 |
version. The latest version of this license is in the file: |
| 59 |
|
| 60 |
http://www.latex-project.org/lppl.txt |
| 61 |
|
| 62 |
This work is "maintained" (as per LPPL maintenance status) by |
| 63 |
You. |
| 64 |
|
| 65 |
This work consists of the file signchart.dtx |
| 66 |
and the derived files signchart.ins, |
| 67 |
signchart.pdf and |
| 68 |
signchart.sty. |
| 69 |
|
| 70 |
\endpostamble |
| 71 |
\usedir{tex/latex/signchart} |
| 72 |
\generate{ |
| 73 |
\file{\jobname.sty}{\from{\jobname.dtx}{package}} |
| 74 |
} |
| 75 |
%</install> |
| 76 |
%<install>\endbatchfile |
| 77 |
%<*internal> |
| 78 |
\usedir{source/latex/signchart} |
| 79 |
\generate{ |
| 80 |
\file{\jobname.ins}{\from{\jobname.dtx}{install}} |
| 81 |
} |
| 82 |
\nopreamble\nopostamble |
| 83 |
\usedir{doc/latex/signchart} |
| 84 |
\generate{ |
| 85 |
\file{README.txt}{\from{\jobname.dtx}{readme}} |
| 86 |
} |
| 87 |
\ifx\fmtname\nameofplainTeX |
| 88 |
\expandafter\endbatchfile |
| 89 |
\else |
| 90 |
\expandafter\endgroup |
| 91 |
\fi |
| 92 |
%</internal> |
| 93 |
%<*package> |
| 94 |
\NeedsTeXFormat{LaTeX2e} |
| 95 |
\ProvidesPackage{signchart}[2016/02/12 v1.01] |
| 96 |
%</package> |
| 97 |
%<*driver> |
| 98 |
\documentclass{ltxdoc} |
| 99 |
\usepackage[T1]{fontenc} |
| 100 |
\usepackage{lmodern} |
| 101 |
\usepackage{\jobname} |
| 102 |
\usepackage[numbered]{hypdoc} |
| 103 |
\usepackage{fancyvrb} |
| 104 |
\usepackage{microtype} |
| 105 |
\EnableCrossrefs |
| 106 |
\CodelineIndex |
| 107 |
\RecordChanges |
| 108 |
\begin{document} |
| 109 |
\DocInput{\jobname.dtx} |
| 110 |
\end{document} |
| 111 |
%</driver> |
| 112 |
% \fi |
| 113 |
% |
| 114 |
% \CheckSum{166} |
| 115 |
% |
| 116 |
%\GetFileInfo{\jobname.sty} |
| 117 |
% |
| 118 |
%\DoNotIndex{\if,\fi,\else,\ifnum} |
| 119 |
%\DoNotIndex{\begin,\end,\def,\let,\foreach,\i,\j,\k,\s} |
| 120 |
%\DoNotIndex{\pgfmathsetmacro,\pgfmathtruncatemacro} |
| 121 |
%\DoNotIndex{\pgfplotsset,\makeatletter,\makeatother} |
| 122 |
%\DoNotIndex{\CurrentOption,\DeclareOption,\define@key} |
| 123 |
%\DoNotIndex{\newcommand,\relax} |
| 124 |
% |
| 125 |
%\title{^^A |
| 126 |
% The \textsf{signchart} package\thanks{^^A |
| 127 |
% This file describes version \fileversion, last revised \filedate.^^A |
| 128 |
% }^^A |
| 129 |
%} |
| 130 |
%\author{^^A |
| 131 |
% Anthony Mottaz\thanks{E-mail: [email protected]}^^A |
| 132 |
%} |
| 133 |
%\date{Released \filedate} |
| 134 |
% |
| 135 |
%\maketitle |
| 136 |
% |
| 137 |
%\abstract{The signchart package provides you with the ability to create |
| 138 |
%beautifully typeset sign charts.} |
| 139 |
% |
| 140 |
% |
| 141 |
% |
| 142 |
%\section{Introduction} |
| 143 |
% |
| 144 |
%The \texttt{signchart} package provides the command |
| 145 |
%\begin{center} |
| 146 |
%|\signchart|\oarg{options}\marg{values}\marg{signs} |
| 147 |
%\end{center} |
| 148 |
%for typesetting sign charts. For example, |
| 149 |
%|\signchart{1,2,3}{+,-,+,-}| will produce |
| 150 |
%\signchart{1,2,3}{+,-,+,-} |
| 151 |
%This process is achieved using the \texttt{tikz} and \texttt{xstring} |
| 152 |
%packages to extract the \meta{values} and \meta{signs} and place |
| 153 |
%them on a number line. |
| 154 |
% |
| 155 |
% |
| 156 |
% |
| 157 |
%\section{Usage} |
| 158 |
%\subsection{Load the package} |
| 159 |
% |
| 160 |
%Load the package: |
| 161 |
%\begin{Verbatim}[gobble=1] |
| 162 |
% \usepackage\oarg{options}{signchart} |
| 163 |
%\end{Verbatim} |
| 164 |
% |
| 165 |
%Currently, there are two options that can be called when loading the |
| 166 |
%|signchart| package. |
| 167 |
% |
| 168 |
%\DescribeMacro{signunder} |
| 169 |
%Loading the package with this option will cause the signs to be placed below |
| 170 |
%the sign chart. This is achieved by changing the default value of |
| 171 |
%\texttt{height} to \texttt{$-0.3$}. \emph{(See macro options below)} |
| 172 |
% |
| 173 |
%\DescribeMacro{valunder} |
| 174 |
%Loading the package with this option will cause the values to be placed below |
| 175 |
%the sign chart. This is achieved by changing the default anchor position of |
| 176 |
%the values from \texttt{south} to \texttt{north}. \emph{(See macro options |
| 177 |
%below)} |
| 178 |
% |
| 179 |
%\subsection{Macros} |
| 180 |
% |
| 181 |
%\DescribeMacro{signchart} |
| 182 |
%|\signchart|\oarg{optons}\marg{values}\marg{signs} \quad The |\signchart| |
| 183 |
%command produces a signchart---a number line with evenly spaced ticks, |
| 184 |
%with \meta{values} placed over each tick mark and \meta{signs} placed |
| 185 |
%between each value. |
| 186 |
% |
| 187 |
%\DescribeMacro{\meta{values}} |
| 188 |
%For the \meta{values} argument, the user should enter the values |
| 189 |
%that will be placed above the tick marks in a comma separated list. |
| 190 |
% |
| 191 |
%\DescribeMacro{\meta{signs}} |
| 192 |
%For the \meta{signs} argument, the user should enter the signs that will |
| 193 |
%be placed between each of the \meta{values}, also in a comma separated list. |
| 194 |
%\textbf{It is important to note} that the number of signs should be at most |
| 195 |
%one more than the number of values. Any additional signs will be considered as |
| 196 |
%one sign and give undesired results. |
| 197 |
% |
| 198 |
%\DescribeMacro{\oarg{options}} |
| 199 |
%The width, placement of |
| 200 |
%\meta{values} and \meta{signs}, and the arrows can be adjusted with |
| 201 |
%\meta{options}. |
| 202 |
%\DescribeMacro{width} |
| 203 |
%The option \meta{width}=\meta{number} can be used to specify the width of |
| 204 |
%the sign chart using the default \texttt{tikzpicture} units (cm). If no |
| 205 |
%option is given, then \meta{width}\texttt{= 5} is used. |
| 206 |
% |
| 207 |
%\DescribeMacro{valanchor} |
| 208 |
%This macro can change the anchor for placing the \meta{values}. By default, |
| 209 |
%this is set to \texttt{south} in order to place the \meta{values} above the |
| 210 |
%number line. The other possibility is to set \texttt{valanchor=north}. |
| 211 |
% |
| 212 |
%\DescribeMacro{valsep} |
| 213 |
%This macro controls the separation distance from the \meta{values} to the |
| 214 |
%number line. By default, this is set to \texttt{3pt}. When the option |
| 215 |
%\texttt{valunder} is passed to the package, this is redefined to \texttt{13pt} |
| 216 |
%to achieve a similar distance underneath the number line. |
| 217 |
% |
| 218 |
%\DescribeMacro{height} |
| 219 |
%The option \meta{height}=\meta{number} can be used to specify the distance |
| 220 |
%between the number line and the signs using the default \texttt{tikzpicture} |
| 221 |
%units (cm). If no option is given, then \meta{height}\texttt{= 0.3} is used. |
| 222 |
% |
| 223 |
%\DescribeMacro{arrows} |
| 224 |
%The option \meta{arrows}=\meta{arrow style} can be used to specify the arrow |
| 225 |
%head shape used on the number line. If no option is given, then |
| 226 |
%\meta{arrows}\texttt{= <->} is used. |
| 227 |
% |
| 228 |
%\changes{v1.0}{2016/01/29}{First public release} |
| 229 |
%\changes{v1.01}{2016/02/12}{Improved Documentation, addition of package |
| 230 |
%options} |
| 231 |
%\StopEventually{^^A |
| 232 |
% \PrintChanges |
| 233 |
% \PrintIndex |
| 234 |
%} |
| 235 |
% |
| 236 |
%\section{Implementation} |
| 237 |
% |
| 238 |
% \begin{macrocode} |
| 239 |
%<*package> |
| 240 |
% \end{macrocode} |
| 241 |
% |
| 242 |
% |
| 243 |
% \begin{macrocode} |
| 244 |
\RequirePackage{tikz} |
| 245 |
\RequirePackage{pgfplots} |
| 246 |
\pgfplotsset{compat = 1.10} |
| 247 |
\RequirePackage{xstring} |
| 248 |
\RequirePackage{xkeyval} |
| 249 |
\def\signHeightKey{0.3} |
| 250 |
\def\valNorthSouthKey{south} |
| 251 |
\def\valSepKey{3pt} |
| 252 |
\DeclareOption{signunder}{\def\signHeightKey{-0.3}} |
| 253 |
\DeclareOption{valunder}{% |
| 254 |
\def\valNorthSouthKey{north}% |
| 255 |
\def\valSepKey{13pt}} |
| 256 |
\DeclareOption*{% |
| 257 |
\PackageWarning{signchart}{Unknown option ‘\CurrentOption’}% |
| 258 |
} |
| 259 |
\ProcessOptions\relax |
| 260 |
\define@key{signchart}{height}[\signHeightKey]{\def\signHeight{#1}} |
| 261 |
\define@key{signchart}{valanchor}[\valNorthSouthKey]{\def\valNorthSouth{#1}} |
| 262 |
\define@key{signchart}{valsep}[\valSepKey]{\def\valSep{#1}} |
| 263 |
\define@key{signchart}{width}[5]{\def\signChartWidth{#1}} |
| 264 |
\define@key{signchart}{arrows}[<->]{\def\theArrow{#1}} |
| 265 |
\makeatother |
| 266 |
\newcommand{\signchart}[3][]{ |
| 267 |
\setkeys{signchart}{height, valanchor, valsep, width, arrows, #1} |
| 268 |
\begin{center} |
| 269 |
\begin{tikzpicture} |
| 270 |
\pgfmathsetmacro{\snht}{\signHeight} |
| 271 |
\pgfmathsetmacro{\wid}{\signChartWidth} |
| 272 |
\def\vals{#2} |
| 273 |
\def\signs{#3} |
| 274 |
\def\valsarray{{\vals}} |
| 275 |
\StrCount{\vals}{,}[\len] |
| 276 |
\draw[\theArrow,thick] (0,0) -- (\wid,0); |
| 277 |
\def\thisVal{-0} |
| 278 |
\foreach \i in {0,...,\len} { |
| 279 |
\pgfmathtruncatemacro{\k}{\i + 1} |
| 280 |
\ifnum \i < \len |
| 281 |
\StrPosition[\k]{\vals}{,}[\pos] |
| 282 |
\StrBefore[\k]{\vals}{,}[\leftParti] |
| 283 |
\ifnum \i = 0 |
| 284 |
\def\thisVal{\leftParti} |
| 285 |
\else |
| 286 |
\StrBehind[\i]{\leftParti}{,}[\thisVal] |
| 287 |
\fi |
| 288 |
\else |
| 289 |
\StrBehind[\i]{\vals}{,}[\thisVal] |
| 290 |
\fi |
| 291 |
\pgfmathtruncatemacro{\j}{\i + 1} |
| 292 |
\StrBehind[\j]{\signs}{,}[\rightPart] |
| 293 |
\StrLen{\rightPart}[\aLength] |
| 294 |
\pgfmathtruncatemacro{\cutAmount}{\aLength + 1} |
| 295 |
\StrGobbleRight{\signs}{\cutAmount}[\leftPartii] |
| 296 |
\StrBehind[\j]{,\leftPartii}{,}[\s] |
| 297 |
\pgfmathsetmacro{\valpos}{(\wid/(\len+2))*(\i+1)} |
| 298 |
\pgfmathsetmacro{\signpos}{(\wid/(\len+2))*(\i+0.5)} |
| 299 |
\draw (\valpos,-0.15) -- (\valpos,0.15) node[anchor=\valNorthSouth, |
| 300 |
inner sep=\valSep] |
| 301 |
{\thisVal}; |
| 302 |
\node at (\signpos,\snht) {$\s$}; |
| 303 |
\ifnum \i = \len |
| 304 |
\pgfmathsetmacro{\signpos}{(\wid/(\len+2))*(\len+1.5)} |
| 305 |
\pgfmathtruncatemacro{\j}{\len + 1} |
| 306 |
\StrBehind[\j]{\signs}{,}[\s] |
| 307 |
\node at (\signpos,\snht) {$\s$}; |
| 308 |
\fi |
| 309 |
} |
| 310 |
\end{tikzpicture} |
| 311 |
\end{center} |
| 312 |
} |
| 313 |
% \end{macrocode} |
| 314 |
% |
| 315 |
% |
| 316 |
% \begin{macrocode} |
| 317 |
%</package> |
| 318 |
% \end{macrocode} |
| 319 |
%\Finale |