# Tally marks used inside a table

I Would like to use tally marks (generally used for counting - see picture) inside a table I just generated. I could not find any \LaTeX package that do the trick. Does anyone know how to do it fast and easily.

So far I can see only three option: 1) copy the table and draw it manually then reinsert the table as a picture on the document; 2) learn Tikz and make magic; 3) use ugly&wrong underlines, overlines (\bar), | bars and slash . See my attempt below:

\begin{table}[ht!]
\centering
\label{tabTrab}
\begin{tabular}{l|l|l|l|l|l|l|}
\cline{2-7}
& \multicolumn{2}{c|}{\textbf{No período}} & \multicolumn{4}{c|}{\textbf{Na data}} \\ \cline{2-7}
& N° & \begin{tabular}[c]{@{}l@{}}Cálculo\\ de gastos\\ c/ pessoal\end{tabular} & \multicolumn{2}{l|}{\textgreater 14} & \multicolumn{2}{l|}{\textless 14} \\ \cline{4-7}
\textbf{} &  &  & H & M & H & M \\ \hline
\multicolumn{1}{|l|}{\textbf{Prod}} & | $\bar{ }$ |  for 3 &  & | for 1 &  | $\bar{ }$ for 2 &  &  \\ \hline
\multicolumn{1}{|l|}{\textbf{Perm}} & | $\bar{\underline{ \slash }}$ |   |  for 6 & \begin{tabular}[c]{@{}l@{}}Salário\\ 5x R\$960\end{tabular} & |$\bar{     }$for 2 & |$\bar{\underline{     }}$| for 4 & & | for 1 \\ \hline \multicolumn{1}{|l|}{\textbf{Temp}} & |$\bar{     }$for 2 & \begin{tabular}[c]{@{}l@{}}Diárias\\ 2 x 52d x\\ R\$ 40\end{tabular} &  & | for 1 & | for 1  &  \\ \hline
\end{tabular}
\end{table}


Which produces the following alien:

You can ask me: why not use simple arabic numbers? Answer: The numbering on the table is meant to be an example. In general, the readers will create/print an empty table similar to the example, count and then add the number with pen. To avoid miswriting the number several times it is preferable to use tally marks. Still don't understand? OK, because I want to!! :)

• You could use tikz package and draw these numbers (If I understood well) You can read \@fsize for getting a nice size close to your fontsize. If you don't already know to use tikz I can help you (But just drawing lines is enough). Sep 24, 2017 at 17:19
• @Koleygr: Yes, I know it may be possible to do it with Tickz. I not used to use it but I already compiled several examples and I find it amazing. I was looking for some further options to solve my issue (maybe not even listed) when I posted the thread. Definetively i must learn to use Tickz. But for starts I am glad to here that I can count on you for help. Where do I start, what to read? And how to use those drawing inside table enviroment? Or do I need to draw everething from scratch? I will read some manuals and return with some specific doubts. ty Sep 24, 2017 at 17:38
• I forgot to mention, I am looking for better options to acomplich my objective. I came with a 4th option (realistic for my knowledge but still bad idea I think): insert several images on each cell of my table, each with a specific "Beutiful 6 yr old drawing" bar number as shown on my post.. :D Sep 24, 2017 at 17:42
• Just wait some minutes (less than 20) and you will have a working code Sep 24, 2017 at 17:45
• @Claudia: I am courious, could you provide some refernce where these are documented? Sep 24, 2017 at 23:25

This can be done using the \tally command in the dozenal package. Documentation can be found at CTAN.

## Update:

The dozenal package also provides "handwritten" tally marks by using \textit:

\tally{1} \tally{2} \tally{3} \tally{4} \tally{5}


Here is a macro to produce tally marks of any (reasonably small) positive integer:

\newcommand{\tal}[1]{\ifthenelse{\intcalcNum{#1}<6}
{\textit{\tally{#1}}}
{\textit{\foreach \n in {1,...,\intcalcDiv{#1}{5}}{\tally{5}\,}%
\tally{\intcalcMod{#1}{5}}\ifthenelse{\intcalcMod{#1}{5}>0}{\,}{}%
}}}


The packages ifthen, intcalc and pgffor are used.

\foreach \n in {1,...,12}{\tal{\n}\quad}


will produce the following output.

Incorporating these into your table produces the following:

Here is the complete code:

\documentclass{article}

\usepackage{dozenal} % \tally{#} symbols
\usepackage{pgffor} % \foreach command
\usepackage{intcalc} % to calculate mod and div
\usepackage{ifthen} % \ifthenelse command
\usepackage{textcomp} % \textdegree

\newcommand{\tal}[1]{\ifthenelse{\intcalcNum{#1}<6}
{\textit{\tally{#1}}}
{\textit{\foreach \n in {1,...,\intcalcDiv{#1}{5}}{\tally{5}\,}%
\tally{\intcalcMod{#1}{5}}\ifthenelse{\intcalcMod{#1}{5}>0}{\,}{}%
}}}

\begin{document}

\begin{table}[ht!]
\centering
\label{tabTrab}
\begin{tabular}{l|l|l|l|l|l|l|}
\cline{2-7}
& \multicolumn{2}{c|}{\textbf{No período}} & \multicolumn{4}{c|}{\textbf{Na data}} \\ \cline{2-7}
& N\textdegree & \begin{tabular}[c]{@{}l@{}}Cálculo\\ de gastos\\ c/ pessoal\end{tabular} & \multicolumn{2}{l|}{\textgreater 14} & \multicolumn{2}{l|}{\textless 14} \\ \cline{4-7}
\textbf{} &  &  & H & M & H & M \\ \hline
\multicolumn{1}{|l|}{\textbf{Prod}} & \tal{3} &  & \tal{1} &  \tal{2} &  &  \\ \hline
\multicolumn{1}{|l|}{\textbf{Perm}} & \tal{7} & \begin{tabular}[c]{@{}l@{}}Salário\\ 5x R\$960\end{tabular} & \tal{2} & \tal{4} & & \tal{1} \\ \hline \multicolumn{1}{|l|}{\textbf{Temp}} & \tal{2}& \begin{tabular}[c]{@{}l@{}}Diárias\\ 2 x 52d x\\ R\$ 40\end{tabular} &  & \tal{1} & \tal{1} &  \\ \hline
\end{tabular}
\end{table}

\end{document}


\documentclass{article}

\expandafter\def\csname bar0\endcsname{%
\begin{picture}(10,10)
\end{picture}}
\expandafter\def\csname bar1\endcsname{%
\begin{picture}(10,10)
\put(0,0){\line(0,1){10}}
\end{picture}}
\expandafter\def\csname bar2\endcsname{%
\begin{picture}(10,10)
\put(0,0){\line(0,1){10}}
\put(0,10){\line(1,0){10}}
\end{picture}}
\expandafter\def\csname bar3\endcsname{%
\begin{picture}(10,10)
\put(0,0){\line(0,1){10}}
\put(0,10){\line(1,0){10}}
\put(10,0){\line(0,1){10}}
\end{picture}}
\expandafter\def\csname bar4\endcsname{%
\begin{picture}(10,10)
\put(0,0){\line(0,1){10}}
\put(0,10){\line(1,0){10}}
\put(10,0){\line(0,1){10}}
\put(0,0){\line(1,0){10}}
\end{picture}}
\expandafter\def\csname bar5\endcsname{%
\begin{picture}(10,10)
\put(0,0){\line(0,1){10}}
\put(0,10){\line(1,0){10}}
\put(10,0){\line(0,1){10}}
\put(0,0){\line(1,0){10}}
\put(0,10){\line(1,-1){10}}
\end{picture}}

\def\zzbar#1{%
\ifnum#1>5
\zzbar{5}\,%
\expandafter\zzbar\expandafter{\the\numexpr#1-5\relax}%
\else
\csname bar#1\endcsname
\fi}

\begin{document}

0 \zzbar{0}

1 \zzbar{1}

2 \zzbar{2}

3 \zzbar{3}

4 \zzbar{4}

5 \zzbar{5}

6 \zzbar{6}

7 \zzbar{7}

\end{document}

• That makes the trick... The only problem that remais regards spacing. What is the proper way to enlarge the cell vertical spacing? On the first cell the horizontal line of \zzbar{3} output superpose the boundary line of the table. Still TY David Sep 24, 2017 at 18:36
• @Claudia I made each picture 10*10 with a 10*10 square you could make the picture bigger keeping squares same size eg \begin{picture}(14,14)(-2,-2) would make it 14*14 with the 10*10 visible square starting 2,2 in Sep 24, 2017 at 19:02
• OK, nice. I will try that. Sep 24, 2017 at 19:09

A simple solution with commands defined in terms of tabulars, playing with horizontal and vertical rules, and a diagbox. I took the opportunity to simplify your code with makecell, which allows for line breaks in standard cells:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[usestackEOL]{stackengine}
\usepackage{array, diagbox, makecell, multirow, caption, bigstrut}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{5pt}
\setlength{\cellspacebottomlimit}{4pt}

\diagbox[outerleftsep=0pt, innerrightsep=0pt, height=1.01em, width=1.01em]{}{}\\\hline\end{tabular}}~}

\begin{document}

\begin{table}[ht!]
\centering
\setlength{\extrarowheight}{2pt}
\label{tabTrab}
\begin{tabular}{*{7}{Sl|}}
\cline{2-7}
& \multicolumn{2}{c|}{\textbf{No período}} & \multicolumn{4}{c|}{\textbf{Na data}} \\ \cline{2-7}
& N\textsuperscript{o} & \multirowcell{2}{Cálculo \\[-0.8ex] de gastos\\[-0.8ex] c/ pessoalr} & \multicolumn{2}{l|}{\textgreater 14} & \multicolumn{2}{l|}{\textless 14} \\ \cline{4-7}
\textbf{} & & & H & M & H & M \\ \hline
\multicolumn{1}{|l|}{\textbf{Prod}} & \threebar for 3 & & \onebar for 1 & \twobar for 2 & & \\ \hline
\multicolumn{1}{|l|}{\textbf{Perm}} & \fivebar\onebar for 6 & \makecell{Salário \\ 5x R\$\,960} & \twobar for 2 & \fourbar for 4 & & \onebar for 1 \\ \hline \multicolumn{1}{|l|}{\textbf{Temp}} & \twobar for 2 & \makecell{Diárias \\[-0.8ex] 2 x 52d x\\[-0.8ex] R\$\,40} & & \onebar for 1 & \onebar for 1 & \\ \hline
\end{tabular}
\end{table}

\end{document}


Here is a solution with tikz and pgf:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage{pgf}
\makeatletter

\newcommand{\mynum}[2][line width={\f@size/20}]{%
\def\sizeOfNum{\f@size/1.7}%
\def\distOfNum{\sizeOfNum/2}%
\ifdefined\ChangeRowEvery\relax
\else
\def\ChangeRowEvery{5}
\fi
\ifnum#2>0
\begin{tikzpicture}
\foreach \i in {0,...,24}{
\pgfmathsetmacro\divider{int(\i*5)}
\pgfmathsetmacro\myMod{int(#2-\divider)}
\pgfmathsetmacro\myYshift{-int(\i/\ChangeRowEvery)*(\sizeOfNum+\distOfNum)}
\pgfmathsetmacro\myXshift{-int(\i/\ChangeRowEvery)*\ChangeRowEvery*(\sizeOfNum+\distOfNum)}
\ifnum\myMod<0
\breakforeach
\else
\ifnum\myMod>0
\draw[-,#1,xshift={\myXshift pt},yshift={\myYshift pt}] ({\i*\sizeOfNum+\i*\distOfNum pt} ,{-\pgflinewidth/2})--({\i*\sizeOfNum+\i*\distOfNum pt},{\sizeOfNum pt+\pgflinewidth/2});
\fi
\ifnum\myMod>1
\draw[-,#1,xshift={\myXshift pt},yshift={\myYshift pt}] ({\i*\sizeOfNum+\i*\distOfNum pt -\pgflinewidth/2} ,{\sizeOfNum pt})--({(\i+1)*\sizeOfNum+\i*\distOfNum pt+\pgflinewidth/2 },{\sizeOfNum pt});
\fi
\ifnum\myMod>2
\draw[-,#1,xshift={\myXshift pt},yshift={\myYshift pt}] ({(\i+1)*\sizeOfNum+\i*\distOfNum pt} ,{-\pgflinewidth/2 })--({(\i+1)*\sizeOfNum+\i*\distOfNum pt},{\sizeOfNum pt +\pgflinewidth/2 });
\fi
\ifnum\myMod>3
\draw[-,#1,xshift={\myXshift pt},yshift={\myYshift pt}] ({(\i+1)*\sizeOfNum+\i*\distOfNum pt} ,0)--({\i*\sizeOfNum+\i*\distOfNum pt},0);
\fi
\ifnum\myMod>4
\draw[-,#1,xshift=\myXshift pt,yshift=\myYshift pt] ({\i*\sizeOfNum+\i*\distOfNum pt} ,{\sizeOfNum pt})--({(\i+1)*\sizeOfNum+\i*\distOfNum pt},0);
\fi
\fi
}
\end{tikzpicture}
\else
Negative Or Zero Number here!
\fi
}
\makeatother

%opening
\title{}
\author{}

\begin{document}

\def\ChangeRowEvery{3} % If you not define one it changes every (5 boxes)x5=25 number
\foreach \numb[count=\i] in {9,12,...,32}{
\pgfmathsetmacro\curentNum{int(\numb+0.5*\i)}
\pgfmathsetmacro\mymodulo{mod(\curentNum,3)==0}
\pgfmathsetmacro\mysecmodulo{mod(\curentNum,5)==0}
\pgfmathsetmacro\mythmodulo{mod(\curentNum,4)==0}
\xdef\Param{\ifnum\mymodulo=1 thick\else\ifnum\mysecmodulo=1 green\else\ifnum\mythmodulo=1 red\else\empty\fi\fi\fi}
\fbox{$\curentNum=\mynum[\Param]{\curentNum}$}\par
}

\end{document}


Output:

Usage \mynum[Optional parameter for color or thicknes]{integer possitive number}

Example: \mynum[red]{12} or mynum[thick]{28} or \mynum{6} etc

You can define and change the parameter: \ChangeRowEvery to an integer ( the number of boxes that you want to change line. Also you can select color or thicknes of the line etc by a first optional parameter.