From 6f2b7e75418a2fad9e80f85a4c97d3fa4da8978b Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 13 Jul 2020 03:01:06 +0000 Subject: CTAN sync 202007130301 --- graphics/pgf/contrib/nimsticks/README.md | 19 +++++ graphics/pgf/contrib/nimsticks/nimsticks.dtx | 122 +++++++++++++++++++++++++++ graphics/pgf/contrib/nimsticks/nimsticks.ins | 30 +++++++ graphics/pgf/contrib/nimsticks/nimsticks.pdf | Bin 0 -> 75196 bytes 4 files changed, 171 insertions(+) create mode 100644 graphics/pgf/contrib/nimsticks/README.md create mode 100644 graphics/pgf/contrib/nimsticks/nimsticks.dtx create mode 100644 graphics/pgf/contrib/nimsticks/nimsticks.ins create mode 100644 graphics/pgf/contrib/nimsticks/nimsticks.pdf (limited to 'graphics/pgf/contrib') diff --git a/graphics/pgf/contrib/nimsticks/README.md b/graphics/pgf/contrib/nimsticks/README.md new file mode 100644 index 0000000000..7a295a2a75 --- /dev/null +++ b/graphics/pgf/contrib/nimsticks/README.md @@ -0,0 +1,19 @@ +# nimsticks: LaTeX package for drawing Nim sticks and games + +nimsticks is a package for LaTeX that should also work with LuaTeX and XeTeX, that draws sticks for representating games of multi-pile Nim. + +By [Peter Rowlett](https://github.com/prowlett/). + +## Background + +Nim objects could be anything, of course, but conventionally sticks or stones are used. There are various types of dot in LaTeX that might look like stones, but somehow a line of dots didn't seem satisfactory. There are various ways to draw a line (e.g. just typing IIIII), including some tally markers (e.g. in hhcount). My problem with these (call me picky) is that they are all identical lines, and a `heap' of them just looks very organised. Really, I want a set of lines that looks like someone just threw them into heaps (though probably without crossings for the avoidance of ambiguity). + +The way this works is it draws a thick vertical line in TikZ with a little wobble added so each one doesn't look extremely well-lined-up with its neighbour, achieved by adding or subtracting a small random number to the top and bottom coordinate. + +It does this by providing two commands: + +- `\drawnimstick`: draws a single Nim stick with a little random wobble; +- `\nimgame`: takes a comma-separated list of numbers and draws a line of Nim heaps holding those number of sticks. + +## Licensing +This work may be distributed and/or modified under the conditions of the [MIT license](LICENSE.txt). diff --git a/graphics/pgf/contrib/nimsticks/nimsticks.dtx b/graphics/pgf/contrib/nimsticks/nimsticks.dtx new file mode 100644 index 0000000000..088eeda5c2 --- /dev/null +++ b/graphics/pgf/contrib/nimsticks/nimsticks.dtx @@ -0,0 +1,122 @@ +%\iffalse meta-comment +%Copyright (c) 2020 Peter Rowlett +% +%Permission is hereby granted, free of charge, to any person obtaining a copy +%of this software and associated documentation files (the "Software"), to deal +%in the Software without restriction, including without limitation the rights +%to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%copies of the Software, and to permit persons to whom the Software is +%furnished to do so, subject to the following conditions: +% +%The above copyright notice and this permission notice shall be included in all +%copies or substantial portions of the Software. +% +%THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +%SOFTWARE. +%\fi +%\section{Background} +% +%\lstinline{nimsticks} is a package for \LaTeX{} that draws sticks for representating games of multi-pile Nim. +% +%Nim objects could be anything, of course, but conventionally sticks or stones are used. There are various types of dot in LaTeX that might look like stones, but somehow a line of dots didn't seem satisfactory. There are various ways to draw a line (e.g. just typing IIIII), including some tally markers (e.g. in hhcount). My problem with these (call me picky) is that they are all identical lines, and a `heap' of them just looks very organised. Really, I want a set of lines that looks like someone just threw them into heaps (though probably without crossings for the avoidance of ambiguity). +% +%The way this works is it draws a thick vertical line in TikZ with a little wobble added so each one doesn't look extremely well-lined-up with its neighbour, achieved by adding or subtracting a small random number to the top and bottom coordinate. +% +%It does this by providing two commands: +%\begin{itemize} +%\item \lstinline{\drawnimstick}: draws a single Nim stick with a little random wobble; +%\item \lstinline{\nimgame}: takes a comma-separated list of numbers and draws a line of Nim heaps holding those number of sticks. +%\end{itemize} +% +%\section{Usage} +% +%For example, the input \lstinline!\nimgame{3,5,4}! will produce output like this (precise look affected by random wobble in the sticks): +% +%\nimgame{5,3,4} +% +%This is designed to look like a 3-pile Nim game with 5 sticks in the first pile (or heap), 3 in the second and 4 in the third. +% +%It is likely the user will want to use \lstinline{\nimgame} and not \lstinline{\drawnimstick} directly, but the input \lstinline{\drawnimstick} will produce output like this (precise look affected by random wobble in the sticks): \drawnimstick +% +%\lstinline{\nimgame} will happily work with one heap, so the input \lstinline!\nimgame{7}! will produce output like this (precise look affected by random wobble in the sticks): +% +%\nimgame{7} +% +%\section{Issues} +% +%There is no limit in the code to the number of piles or the number in a pile, but this code doesn't do anything to cope when line breaks start happening, and presumably there is a computational limit. +% +%In principle, if you add lots of piles it will just wrap onto multiple lines, though it will start to look less clear. For example, the input\\ +%\lstinline!\nimgame{1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1}!\\ +%will produce the output: +%\nimgame{1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1} +%Similarly, if you have a lot of sticks in the same heap, it will wrap and look confusing, for example the input \lstinline!\nimgame{128}! will produce the output: +%\nimgame{256} +%\iffalse +%<*documentation> +\documentclass{article} +\usepackage{nimsticks} +\usepackage{doc} +\usepackage{listings} +\lstset{basicstyle=\ttfamily\footnotesize,commentstyle=\color{white},language=TeX} +\title{nimsticks} +\author{Peter Rowlett} +\begin{document} +\maketitle + \DocInput{nimsticks.dtx} +\end{document} +% +%\fi + +%\iffalse +%<*nimsticks> +\ProvidesPackage{nimsticks}[2020/07/12 nimsticks 1.0] +\RequirePackage[first=-100,last=100,seed=0]{lcg} +\RequirePackage{tikz} +\@ifundefined{drawnimstick}{} + {\PackageWarning{nimsticks}{Command `drawnimstick' already defined}} +\@ifundefined{nimgame}{} + {\PackageWarning{nimsticks}{Command `nimgame' already defined}} +\@ifundefined{listofgames}{} + {\PackageWarning{nimsticks}{Command `listofgames' already defined}} +\@ifundefined{c@topx}{} + {\PackageWarning{nimsticks}{Counter `topx' already defined}} +\@ifundefined{topx}{} + {\PackageWarning{nimsticks}{Existing command `topx' conflicts with counter `topx'}} +\@ifundefined{c@botx}{} + {\PackageWarning{nimsticks}{Counter `botx' already defined}} +\@ifundefined{botx}{} + {\PackageWarning{nimsticks}{Existing command `botx' conflicts with counter `botx'}} +\@ifundefined{c@heap}{} + {\PackageWarning{nimsticks}{Counter `heap' already defined}} +\@ifundefined{heap}{} + {\PackageWarning{nimsticks}{Existing command `heap' conflicts with counter `heap'}} +\@ifundefined{c@heapindex}{} + {\PackageWarning{nimsticks}{Counter `heapindex' already defined}} +\@ifundefined{heapindex}{} + {\PackageWarning{nimsticks}{Existing command `heapindex' conflicts with counter `heapindex'}} +\newcommand{\drawnimstick}{% + \rand\pgfmathsetmacro{\topx}{(\the\value{rand})/1000}% + \rand\pgfmathsetmacro{\botx}{(\the\value{rand})/1000}% + \begin{tikzpicture}% + \draw[very thick] (\topx,0) -- (\botx,0.5);% + \end{tikzpicture}% +} +\newcommand{\nimgame}[1]{% + \begin{center}% + \def\listofgames{#1}% + \foreach \heap in \listofgames {% + \foreach \heapindex in {1, ..., \heap} {% + \drawnimstick\hspace{0.5mm}% + }% + \hspace{10mm}% + }% + \end{center}% +} +% +%\fi diff --git a/graphics/pgf/contrib/nimsticks/nimsticks.ins b/graphics/pgf/contrib/nimsticks/nimsticks.ins new file mode 100644 index 0000000000..a0233b80d8 --- /dev/null +++ b/graphics/pgf/contrib/nimsticks/nimsticks.ins @@ -0,0 +1,30 @@ +\input{docstrip.tex} +\keepsilent +\usedir{tex/latex/nimsticks} +\preamble +Copyright (c) 2020 Peter Rowlett + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +\endpreamble +\askforoverwritefalse +\generate{ + \file{nimsticks.sty}{\from{nimsticks.dtx}{nimsticks}} +} +\endbatchfile diff --git a/graphics/pgf/contrib/nimsticks/nimsticks.pdf b/graphics/pgf/contrib/nimsticks/nimsticks.pdf new file mode 100644 index 0000000000..ea9bfc6000 Binary files /dev/null and b/graphics/pgf/contrib/nimsticks/nimsticks.pdf differ -- cgit v1.2.3