表格内使用的计数标记

表格内使用的计数标记

我想在刚刚生成的表格中使用计数标记(通常用于计数 - 见图片)。我找不到任何可以\LaTeX实现此目的的软件包。有谁知道如何快速轻松地做到这一点。

不,我不是 6 岁

到目前为止,我只能看到三个选项:1)复制表格并手动绘制,然后将表格作为图片重新插入文档中;2)学习 Tikz 并创造奇迹;3)使用丑陋和错误的下划线、上划线 (\bar)、| 栏和斜线。请参阅下面的尝试:

\begin{table}[ht!]
\centering
\caption{Trabalhadores no estabelecimento}
\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}

由此产生了以下外星人:

蜂美

你可以问我:为什么不使用简单的阿拉伯数字?答案:表格上的编号是为了举例。一般来说,读者会创建/打印一个类似于示例的空表格,计数然后用笔添加数字。为了避免多次写错数字,最好使用计数标记。还是不明白?好的,因为我想!!:)

答案1

可以\tally使用dozenal。文档可以在 CTAN 找到

在此处输入图片描述

更新:

dozenal软件包还通过以下方式提供“手写”计数标记\textit

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

在此处输入图片描述

这是一个宏,可以生成任何(相当小的)正整数的计数标记:

\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}{\,}{}%
    }}}

使用了ifthenintcalc和包。pgffor

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

将产生以下输出。

在此处输入图片描述

将这些内容合并到您的表格中会产生以下结果:

在此处输入图片描述

完整代码如下:

\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
\caption{Trabalhadores no estabelecimento}
\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}

答案2

在此处输入图片描述

\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}

答案3

一个简单的解决方案,使用 s 定义的命令tabular,使用水平和垂直规则以及diagbox。我借此机会使用 简化了您的代码makecell,它允许在标准单元格中进行换行:

\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}

\newcommand\onebar{\,\bigstrut{\renewcommand{\arraystretch}{0.76}\begin{tabular}{|c@{\hspace*{-0.5em}}}\mbox{}\end{tabular}}~}
\newcommand\twobar{\bigstrut{\renewcommand{\arraystretch}{0.72}\begin{tabular}{|@{}p{1em}@{}}\hline~\end{tabular}}~}
\newcommand\threebar{\bigstrut{\renewcommand{\arraystretch}{0.72}\begin{tabular}{|@{}p{1em}@{}|}\hline~\end{tabular}}~}
\newcommand\fourbar{\bigstrut{\renewcommand{\arraystretch}{0.72}\begin{tabular}{|@{}p{1em}@{}|}\hline~\\\hline\end{tabular}}~}
\newcommand\fivebar{\bigstrut{\renewcommand{\arraystretch}{0.72}\begin{tabular}{|@{}p{1em}@{}|}\hline%
\diagbox[outerleftsep=0pt, innerrightsep=0pt, height=1.01em, width=1.01em]{}{}\\\hline\end{tabular}}~}

\begin{document}

\begin{table}[ht!]
  \centering
  \setlength{\extrarowheight}{2pt}
  \caption{Trabalhadores no estabelecimento}
  \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} 

在此处输入图片描述

答案4

以下是使用 tikz 和 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}

输出:

在此处输入图片描述

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

例如:\mynum[red]{12}mynum[thick]{28}\mynum{6}

您可以定义和更改参数:\ChangeRowEvery一个整数(您想要更改线条的框的数量)。您还可以通过第一个可选参数选择线条的颜色或粗细等。

相关内容