diff options
author | Karl Berry <karl@freefriends.org> | 2020-07-12 20:03:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-07-12 20:03:01 +0000 |
commit | 50753c1a6a9ab86deab3775588d09f740bf0f94c (patch) | |
tree | 2b7a501dddafb7cc2a28befdadd5a8f2a47adc7b | |
parent | 8e237c3f52a9a653972fc117404b1f94d79a26c3 (diff) |
nimsticks (12jul20)
git-svn-id: svn://tug.org/texlive/trunk@55821 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/nimsticks/README.md | 19 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nimsticks/nimsticks.pdf | bin | 0 -> 75196 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/nimsticks/nimsticks.dtx | 122 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/nimsticks/nimsticks.ins | 30 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nimsticks/nimsticks.sty | 74 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tlpkg-ctan-check | 2 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/collection-games.tlpsrc | 1 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/nimsticks.tlpsrc | 0 |
8 files changed, 247 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/nimsticks/README.md b/Master/texmf-dist/doc/latex/nimsticks/README.md new file mode 100644 index 00000000000..7a295a2a75b --- /dev/null +++ b/Master/texmf-dist/doc/latex/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/Master/texmf-dist/doc/latex/nimsticks/nimsticks.pdf b/Master/texmf-dist/doc/latex/nimsticks/nimsticks.pdf Binary files differnew file mode 100644 index 00000000000..ea9bfc60000 --- /dev/null +++ b/Master/texmf-dist/doc/latex/nimsticks/nimsticks.pdf diff --git a/Master/texmf-dist/source/latex/nimsticks/nimsticks.dtx b/Master/texmf-dist/source/latex/nimsticks/nimsticks.dtx new file mode 100644 index 00000000000..088eeda5c25 --- /dev/null +++ b/Master/texmf-dist/source/latex/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} +%</documentation> +%\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}% +} +%</nimsticks> +%\fi diff --git a/Master/texmf-dist/source/latex/nimsticks/nimsticks.ins b/Master/texmf-dist/source/latex/nimsticks/nimsticks.ins new file mode 100644 index 00000000000..a0233b80d8c --- /dev/null +++ b/Master/texmf-dist/source/latex/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/Master/texmf-dist/tex/latex/nimsticks/nimsticks.sty b/Master/texmf-dist/tex/latex/nimsticks/nimsticks.sty new file mode 100644 index 00000000000..d1664fe7285 --- /dev/null +++ b/Master/texmf-dist/tex/latex/nimsticks/nimsticks.sty @@ -0,0 +1,74 @@ +%% +%% This is file `nimsticks.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% nimsticks.dtx (with options: `nimsticks') +%% 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. +%% + +\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}% +} +\endinput +%% +%% End of file `nimsticks.sty'. diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 3b959ff5726..fbf47e5798c 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -528,7 +528,7 @@ my @TLP_working = qw( newverbs nextpage nfssext-cfr nicefilelist niceframe niceframe-type1 nicematrix nicetext nidanfloat nih nihbiosketch - nimbus15 njurepo nkarta nlctdoc + nimbus15 nimsticks njurepo nkarta nlctdoc nmbib noconflict nodetree noindentafter noitcrul nolbreaks nomencl nomentbl nonfloat nonumonpart nopageno norasi-c90 normalcolor nostarch notes notes2bib notespages notestex diff --git a/Master/tlpkg/tlpsrc/collection-games.tlpsrc b/Master/tlpkg/tlpsrc/collection-games.tlpsrc index a49a6d40316..5bf2559c434 100644 --- a/Master/tlpkg/tlpsrc/collection-games.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-games.tlpsrc @@ -23,6 +23,7 @@ depend jigsaw depend labyrinth depend logicpuzzle depend musikui +depend nimsticks depend onedown depend othello depend othelloboard diff --git a/Master/tlpkg/tlpsrc/nimsticks.tlpsrc b/Master/tlpkg/tlpsrc/nimsticks.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/nimsticks.tlpsrc |