Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tally symbols in LaTeX?

2,170 views
Skip to first unread message

Michael Friendly

unread,
Sep 7, 2003, 11:03:38 AM9/7/03
to
How can one print in LaTeX the tally symbols
(/, //, ///, ////, cant do 5 on a keyboard, but it has a diagonal stroke
thru the ////)
often used manually to count occurrences of things?

Ideally, I'd like to have a way to type

\tally{12}
and get the equivalent tally, two groups of 5, followed by //

-Michael

--
Michael Friendly Email: frie...@yorku.ca
Professor, Psychology Dept.
York University Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT M3J 1P3 CANADA

Ulrike Fischer

unread,
Sep 7, 2003, 11:35:32 AM9/7/03
to
Michael Friendly <frie...@yorku.ca> schrieb:

> How can one print in LaTeX the tally symbols
> (/, //, ///, ////, cant do 5 on a keyboard, but it has a diagonal stroke
> thru the ////)
> often used manually to count occurrences of things?

Look at the symbollist
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=symbols

Ulrike Fischer

Michael Friendly

unread,
Sep 9, 2003, 2:00:21 PM9/9/03
to Ulrike Fischer

For the record, thanks to Ulrike (should have known to look there
first), I found these symbols in the ifsym package,
\usepackage[misc]{ifsym}

then I can say \StrokeFive\StrokeFive\StrokeTwo to get the tally symbol
for 12.

I'd like to use this more easily, to say \tally{12} to get the same
result, but I think this goes beyond my TeXnical expertise.

Brian Blackmore

unread,
Sep 9, 2003, 3:24:53 PM9/9/03
to
Michael Friendly <frie...@yorku.ca> wrote:
> For the record, thanks to Ulrike (should have known to look there
> first), I found these symbols in the ifsym package,
> \usepackage[misc]{ifsym}

> then I can say \StrokeFive\StrokeFive\StrokeTwo to get the tally symbol
> for 12.

> I'd like to use this more easily, to say \tally{12} to get the same
> result, but I think this goes beyond my TeXnical expertise.

\def\tally#1{{\count0=#1\loop\ifcase\count0\or\StrokeOne\or\StrokeTwo
\or\StrokeThree\or\StrokeFour\else\StrokeFive\fi
\advance\count0by-5 \ifnum\count0>0\repeat}}

Someone a bit more TeXnical can propose some improvements.

--
Brian Blackmore
blb8 at po dot cwru dot edu

Hartmut Henkel

unread,
Sep 9, 2003, 4:08:45 PM9/9/03
to
In article <3F5E1535...@yorku.ca>,

Michael Friendly <frie...@yorku.ca> wrote:
>
>I'd like to use this more easily, to say \tally{12} to get the same
>result, but I think this goes beyond my TeXnical expertise.

Here's a version which goes without the brackets. Throw away the
\Stroke... definitions if you use ifsym package (I don't have ifsym
installed):

\documentclass{article}
%\usepackage[misc]{ifsym}
\newcommand{\StrokeOne}{I}
\newcommand{\StrokeTwo}{II}
\newcommand{\StrokeThree}{III}
\newcommand{\StrokeFour}{IIII}
\newcommand{\StrokeFive}{\rlap{\raise1ex\hbox{\underline{%
\hphantom{\StrokeFour}}}}\StrokeFour}

\newcount\tallycount
\newcommand{\dotally}{%
\loop\ifnum\tallycount>4\relax\StrokeFive\
\advance\tallycount by-5\repeat
\ifcase\tallycount\or\StrokeOne\or\StrokeTwo\or
\StrokeThree\or\Strokefour\else ERROR\fi\unskip}

\newcommand{\tally}{\afterassignment\dotally\tallycount }

\begin{document}
Zero: \tally 0.
Two: \tally 2.
Twelve: \tally12.
Hundred: \tally100.
\end{document}

Greetings Hartmut
--
Hartmut Henkel, Oftersheim, Germany

Peter Simon

unread,
Sep 9, 2003, 10:22:17 PM9/9/03
to
Michael Friendly <frie...@yorku.ca> wrote in message news:<3F5E1535...@yorku.ca>...

> Ulrike Fischer wrote:
> > Michael Friendly <frie...@yorku.ca> schrieb:
> >
> >
> >>How can one print in LaTeX the tally symbols
> >>(/, //, ///, ////, cant do 5 on a keyboard, but it has a diagonal stroke
> >>thru the ////)
> >>often used manually to count occurrences of things?
> >
> >
> > Look at the symbollist
> > http://www.tex.ac.uk/cgi-bin/texfaq2html?label=symbols
> >
> > Ulrike Fischer
>
> For the record, thanks to Ulrike (should have known to look there
> first), I found these symbols in the ifsym package,
> \usepackage[misc]{ifsym}
>
> then I can say \StrokeFive\StrokeFive\StrokeTwo to get the tally symbol
> for 12.
>
> I'd like to use this more easily, to say \tally{12} to get the same
> result, but I think this goes beyond my TeXnical expertise.
>
> -Michael

I don't know how to program in TeX, but I do know some LaTeX. Here is
a version of the tally{} macro you requested using only features
documented in Lamport:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tallyho.tex
% Peter S. Simon
% 9 September 2003

\documentclass[12pt]{article}
\usepackage[misc]{ifsym}
\usepackage{ifthen}

%% Define \tally{#1} command where #1 is a number. The macro then
%% typesets the appropriate number of tally marks from the ifsym
%% package. Also requires the ifthen package, documented in Lamport.
\newcounter{strokecount}
\newcommand{\tally}[1]{\setcounter{strokecount}{#1}%
\whiledo{\value{strokecount}>5}%
{\addtocounter{strokecount}{-5}\StrokeFive}%
\ifthenelse{\value{strokecount}=5}{\StrokeFive}{}%
\ifthenelse{\value{strokecount}=4}{\StrokeFour}{}%
\ifthenelse{\value{strokecount}=3}{\StrokeThree}{}%
\ifthenelse{\value{strokecount}=2}{\StrokeTwo}{}%
\ifthenelse{\value{strokecount}=1}{\StrokeOne}{}}


\begin{document}

%% Test out the \tally macro in a loop from 1 to 29:
\newcounter{mycounter}
\setcounter{mycounter}{1}

\whiledo{\value{mycounter}<30}%
{\tally{\value{mycounter}} is \arabic{mycounter}.
\par\addtocounter{mycounter}{1}}

\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ebonuedie

unread,
Oct 23, 2012, 8:51:19 PM10/23/12
to
Have you tried the package hhccount?


0 new messages