
Antwort1
Ich habe eine neue Umgebung mit einem Argument definiert, der Anzahl der Spalten, die ihre Zellen automatisch nummeriert:
\documentclass[12pt,a4paper]{report}
\usepackage{array, siunitx, makebox}
\newcounter{cellctr}
\newenvironment{countcells}[1]{\setcounter{cellctr}{0}\setlength{\extrarowheight}{4pt}\tabular{|*{#1}{c<{\enspace \stepcounter{cellctr}\raisebox{1.5ex}{\scriptsize\makebox*{\scriptsize000}[l]{\num[minimum-integer-digits=4]{\thecellctr}}}}|}}}%
{\endtabular\setcounter{cellctr}{0}}
\begin{document}
\begin{countcells}{4}\hline%
A & B & C & D \\ \hline
E & F & G & H \\ \hline
\makebox*{H}{I} & J & K & L \\ \hline
\end{countcells}
\end{document}
Antwort2
Sie können einen Befehl mit einer tabular
Umgebung definieren, um ihn in Ihrer Tabelle zu verwenden:
\documentclass[12pt,a4paper]{report}
\newcommand{\mycell}[2]{\begin{tabular}{@{}c@{}c@{}}&\tiny #2\\\Large #1&\end{tabular}}
\begin{document}
\begin{tabular}{|c|c|c|c|}\hline
\mycell{A}{0001}& \mycell{B}{0002} & \mycell{C}{0003}& \mycell{D}{0004}\\\hline
\end{tabular}
\end{document}
Mithilfe des Tikz-Pakets können Sie Folgendes tun:
\documentclass[12pt,a4paper]{report}
\usepackage{tikz}
\makeatletter
\def\myFontSize{\f@size pt}
\makeatother
\def\BoxFactor{2.5}
\def\fsize{\myFontSize}
\newcommand{\mycontent}[2]{\begin{tabular}{@{}c@{}c@{}}&\tiny #2\\\Large #1&\end{tabular}}
\newcommand{\mycell}[3][black,1]{%
\foreach \item[count=\i from 1] in {#1}{\ifnum\i=1\xdef\mycolor{\item}\else\xdef\NoFLine{\item}\fi}
\begin{tikzpicture}[inner sep=0pt,outer sep=0pt]
\draw[-,thick,color={\mycolor}](0,0) --({\fsize*\BoxFactor},0)--({\fsize*\BoxFactor},{\fsize*\BoxFactor} )--(0,{\fsize*\BoxFactor}) coordinate (A);
\ifnum\NoFLine=1
\relax
\else
\draw[-,thick,color={\mycolor}](A)--(0,0);
\fi
\node at ({\fsize*\BoxFactor/2},{\fsize*\BoxFactor/2}) {\mycontent{#2}{#3}};
\end{tikzpicture}
}
\begin{document}
\noindent\(\mycell[blue,0]{A}{0001}\!\mycell{B}{0002}\mycell{C}{0003}\mycell{D}{0004}\)
\end{document}
Antwort3
Mit einer TikZ-Matrix und einem \foreach
:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix [
matrix of nodes,
column sep=-\pgflinewidth,
every node/.style={
draw,
align=center,
font=\bfseries\Huge,
text height=30pt,
text depth=10pt,
text width=40pt
},
] (mymatr) {
A & B & C & D \\
};
\foreach \i in {1, 2, ..., 4}
{\node[anchor=north east, font=\scriptsize]
at (mymatr-1-\i.north east) {\texttt{000\i}};}
\end{tikzpicture}
\end{document}