Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Inspired by Paulo Cereda's question here, I would like to draw tally marks using PSTricks (or TikZ, if no one can help with PSTricks).

I have no idea how to start, so I cannot even present a try myself. :( (This is not good, I know!)

What I would like to have, is a command like \tallymarks;

\tallymarks{1}
\tallymarks{2}
...
\tallymarks{10}

and get an output like the following:

enter image description here

without the table and the arabic numerals, i.e., only the tally marks themselves.

Update 1

Inspired by Herbert idea, here is an attempt to use PSTricks.

\documentclass{article}

\usepackage{pstricks-add}

\newcommand*{\tallymarksOne}{
  \pslineByHand(0,0)(0,1)
}
\newcommand*{\tallymarksTwo}{
  \pslineByHand(0,0)(0,1)
  \pslineByHand(0.25,0)(0.25,1)
}
\newcommand*{\tallymarksThree}{
  \pslineByHand(0,0)(0,1)
  \pslineByHand(0.25,0)(0.25,1)
  \pslineByHand(0.5,0)(0.5,1)
}
\newcommand*{\tallymarksFour}{
  \pslineByHand(0,0)(0,1)
  \pslineByHand(0.25,0)(0.25,1)
  \pslineByHand(0.5,0)(0.5,1)
  \pslineByHand(0.75,0)(0.75,1)
}
\newcommand*{\tallymarksFive}{
  \pslineByHand(0,0)(0,1)
  \pslineByHand(0.25,0)(0.25,1)
  \pslineByHand(0.5,0)(0.5,1)
  \pslineByHand(0.75,0)(0.75,1)
  \pslineByHand(-0.75,0)(1,1)
}

\newcounter{TallyTemp}
\def\tallymark#1{%
  \setcounter{TallyTemp}{#1}%
  \ifnum#1>5
    {\Tally E}\addtocounter{TallyTemp}{-5}%
  \else{\Tally%   
    \ifcase#1\or
    \tallymarksOne\addtocounter{TallyTemp}{-1}\or
    \tallymarksTwo\addtocounter{TallyTemp}{-2}\or
    \tallymarksThree\addtocounter{TallyTemp}{-3}\or
    \tallymarksFour\addtocounter{TallyTemp}{-4}\or
    \tallymarksFive\addtocounter{TallyTemp}{-5}%
    \fi}%
  \fi%
  \ifnum\theTallyTemp>0 \expandafter\tallymark\expandafter{\theTallyTemp}\fi
}

\begin{document}

\tallymark{0}
\tallymark{1}
\tallymark{2}
\tallymark{3}
\tallymark{4}
\tallymark{5}
\tallymark{14}

\end{document}

When compiling, I get an error:

! Undefined control sequence.
\tallymark ...ounter {TallyTemp}{-5}\else {\Tally 
                                                  \ifcase #1\or \tallymarksO...
l.50 \tallymark{0}

Update 2

Garbage Coloector's hinted me to the following in the PSTricks manual, but the code won't compile:

\documentclass{article}

\usepackage{pstricks-add}

\def\PstLineFuzzy[#1](#2,#3)(#4,#5)(#6,#7)(#8,#9){%
\pscurve[#1](! #2 rand 101 mod 1000 div sub
#3 rand 101 mod 1000 div sub)
(! #4 rand 101 mod 1000 div sub
#5 rand 101 mod 1000 div sub)
(! #6 rand 101 mod 1000 div sub
#7 rand 101 mod 1000 div sub)
(! #8 rand 101 mod 1000 div sub
#9 rand 101 mod 1000 div sub)}

\def\PstSticks#1{%
\multido{\iStick=0+1,\nXA=0.1+0.1,\nXB=-0.5+0.1,
\nXC=-0.35+0.10,\nXD=-0.15+0.10}{#1}{%
\pst@cnta=\iStick
\pst@cnth=\iStick
\divide\pst@cnth by 5
\multiply\pst@cnth by 5
\ifnum\iStick>0\relax
\ifnum\pst@cnta=\pst@cnth
\PstLineFuzzy[linecolor=red]%
(\nXB,0.2)(\nXC,0.4)(\nXD,0.6)(\nXA,0.8)
\hbox to 0.2\psxunit{}
\fi
\fi
\PstLineFuzzy[](\nXA,0.1)(\nXA,0.4)(\nXA,0.7)(\nXA,1)}}

\begin{document}

\psset{xunit=0.8,yunit=0.3}%
\begin{tabular}{|l|r|p{5.5cm}|}
\hline
Linux
& 27 & \PstSticks{27} \\ \hline
Mac OS X
& 14 & \PstSticks{14} \\ \hline
Windows XP & 43 & \PstSticks{43} \\ \hline
\end{tabular}

\end{document}

The error is

! Undefined control sequence.
<inserted text> \pst 
                     @cnta=\iStick \pst @cnth=\iStick \divide \pst @cnth by ...
l.38 & 27 & \PstSticks{27}
                           \\ \hline
share|improve this question
2  
Paulo Cereda's question contains a TikZ implementation. Look for \drawvotes macro. –  JLDiaz Mar 12 '13 at 8:15
1  
@JLDiaz I know. :) I would like to use PSTricks if possible. –  Svend Tveskæg Mar 12 '13 at 8:22
1  
If you need fuzzy lines (to mimic hand made tally marks), invoke texdoc pstricks and read the page 283-284. –  Who is crazy first Mar 12 '13 at 15:20
    
@GarbageCollector Really Great, but the code won't compile with xelatex (or latex for that matter). (See update 2.) –  Svend Tveskæg Mar 12 '13 at 15:28
1  
\makeatletter ... \makeatother is missing in the new example –  Herbert Mar 12 '13 at 15:35

1 Answer 1

up vote 7 down vote accepted

with xelatex or lualatex. The font TallyMark is available from http://www.fonts2u.com/tally-mark.font

\documentclass{article}
\usepackage{fontspec}
\newfontface\Tally{TallyMark}
\newcounter{TallyTemp}
\def\tallymark#1{%
  \setcounter{TallyTemp}{#1}%
  \ifnum#1>5
    {\Tally E}\addtocounter{TallyTemp}{-5}%
  \else{\Tally%   
    \ifcase#1\or
    A\addtocounter{TallyTemp}{-1}\or
    B\addtocounter{TallyTemp}{-2}\or
    C\addtocounter{TallyTemp}{-3}\or
    D\addtocounter{TallyTemp}{-4}\or
    E\addtocounter{TallyTemp}{-5}%
    \fi}%
  \fi%
  \ifnum\theTallyTemp>0 \expandafter\tallymark\expandafter{\theTallyTemp}\fi
}

\begin{document}

\tallymark{0}
\tallymark{1}
\tallymark{2}
\tallymark{3}
\tallymark{4}
\tallymark{5}
\tallymark{14}

\end{document}

enter image description here

If you want to use PSTricks then define the commands \ONE, \TWO, ... and draw the lines. Really simple:

\documentclass{article}    
\usepackage{pstricks-add}    
\newcommand*\tallymarksOne{\pslineByHand(0,0)(0,1)}
\newcommand*\tallymarksTwo{\tallymarksOne\pslineByHand(2pt,0)(2pt,1)}
\newcommand*\tallymarksThree{\tallymarksTwo\pslineByHand(4pt,0)(4pt,1)}
\newcommand*\tallymarksFour{\tallymarksThree\pslineByHand(6pt,0)(6pt,1)}
\newcommand*\tallymarksFive{\tallymarksFour\pslineByHand(-17pt,0)(8pt,1)}

\newcounter{TallyTemp}
\def\tallymark#1{%
  \setcounter{TallyTemp}{#1}%
  \ifnum#1>5
    \tallymarksFive\kern14pt \addtocounter{TallyTemp}{-5}%
  \else%   
    \ifcase#1\or
    \tallymarksOne\kern3pt \addtocounter{TallyTemp}{-1}\or
    \tallymarksTwo\kern6pt \addtocounter{TallyTemp}{-2}\or
    \tallymarksThree\kern9pt \addtocounter{TallyTemp}{-3}\or
    \tallymarksFour\kern12pt \addtocounter{TallyTemp}{-4}\or
    \tallymarksFive\kern14pt \addtocounter{TallyTemp}{-5}%
    \fi%
  \fi%
  \ifnum\theTallyTemp>0 \expandafter\tallymark\expandafter{\theTallyTemp}\fi
  \vspace{1cm}
}

\begin{document}

\tallymark{0}\par
\tallymark{1}\par
\tallymark{2}\par
\tallymark{3}\par
\tallymark{4}\par
\tallymark{5}\par
\tallymark{14}

\end{document}

enter image description here

share|improve this answer
    
Very nice, Herbert! Do you know how to make the lines hand-drawn as is the TikZ example? –  Svend Tveskæg Mar 12 '13 at 9:23
    
\psLineByHand from pstricks-add –  Herbert Mar 12 '13 at 9:24
    
Great! Thank you. –  Svend Tveskæg Mar 12 '13 at 9:28
1  
then show what you did so far ... –  Herbert Mar 12 '13 at 11:39
1  
@SvendMortensen: see edited answer. You can define a height for the lines then it is easier to modify. –  Herbert Mar 12 '13 at 16:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.