这可能更多的是一个设计问题而不是技术问题,但我需要轻松引用下表的不同单元格:
\begin{table}[!htb]
\centering
\caption{Karnaugh Map}
\begin{tabular}{|c||c|c|c|c|}\hline
\diagbox[outerrightsep=10pt, innerrightsep = -10pt, width = 7em]{Ara}{IPTG aTc}
&\makebox[2em]{0 0}&\makebox[2em]{0 1}&\makebox[2em]{1 1}
&\makebox[2em]{1 0}\\ \hline\hline
0 & 1 & 0 & 0 & 0 \\ \hline
1 & 1 & 1 & 0 & 1\\ \hline
\end{tabular}
\label{tab:karnaughMap}
\end{table}
我想到为不同的单元格着色、编号甚至用符号表示,因为我需要讨论从一种状态(例如,IPTG、aTc 和 Ara 为 (0, 0, 0))移动到另一种状态(IPTG 为 HIGH),以及系统可以经历的不同状态(表中的单元格)。
例如,如果我选择使用罗马数字为每个单元格编号,那么如何将其放在每个单元格的右上角?
答案1
您可以创建一个适当的计数器\newcounter{mycounter}[table]
([table]
在每张桌子上将其重置为零)。
请记住将标题标签放在标题附近(否则它将引用最后一个计数器)。
我还创建了两种替代解决方案来避免可怕的情况\diagbox
。
\documentclass{article}
\usepackage{caption}
\usepackage{diagbox}
\usepackage{array}
\renewcommand{\arraystretch}{1.3}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcounter{mycounter}[table]
\newcommand{\mycount}{\multicolumn{1}{r|}{\stepcounter{mycounter}\footnotesize\roman{mycounter}}}
\usepackage{booktabs}
\newcommand{\mycountb}{\multicolumn{1}{r}{\stepcounter{mycounter}\footnotesize\roman{mycounter}}}
\begin{document}
\begin{table}[!htb]
\centering
\caption{Karnaugh Map}\label{tab:karnaughMap}% label near the caption
\begin{tabular}{|c||*4{C{2em}|}}\hline
\diagbox[outerrightsep=10pt, innerrightsep = -10pt, width = 7em]{Ara}{IPTG aTc}
&0 0&0 1&1 1&1 0\\\hline\hline
& \mycount & \mycount & \mycount & \mycount\\
0 & 1 & 0 & 0 & 0\\\hline
& \mycount & \mycount & \mycount & \mycount\\
1 & 1 & 1 & 0 & 1\\\hline
\end{tabular}
\end{table}
\begin{table}[!htb]
\centering
\caption{Karnaugh Map without \texttt{\textbackslash diagbox}}\label{tab:kar}% label near the caption
\begin{tabular}{|c||*4{C{2em}|}}
\hline
\multicolumn{1}{|c||}{} & \multicolumn{4}{c|}{IPTG aTc}\\
\cline{2-5}
Ara &0 0&0 1&1 1&1 0\\\hline\hline
& \mycount & \mycount & \mycount & \mycount\\
0 & 1 & 0 & 0 & 0\\\hline
& \mycount & \mycount & \mycount & \mycount\\
1 & 1 & 1 & 0 & 1\\\hline
\end{tabular}
\end{table}
\begin{table}[!htb]
\centering
\caption{Karnaugh Map with \texttt{booktabs}\label{tab:karb}}% label near the caption
\begin{tabular}{c*4{C{2em}}}
\toprule
\multicolumn{1}{c}{} & \multicolumn{4}{c}{IPTG aTc}\\
\cmidrule(lr){2-5}
Ara &0 0&0 1&1 1&1 0\\
\midrule
& \mycountb & \mycountb & \mycountb & \mycountb\\
0 & 1 & 0 & 0 & 0\\
\midrule
& \mycountb & \mycountb & \mycountb & \mycountb\\
1 & 1 & 1 & 0 & 1\\
\bottomrule
\end{tabular}
\end{table}
\end{document}