1

This may be more of a design question rather than a technical one, but I need to easily reference different cells of the following table:

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

enter image description here

I thought of coloring, numbering or even symbols for the different cells, since I need to talk about moving from one state, for example, were IPTG, aTc and Ara are (0, 0, 0), to another state were IPTG is HIGH, and the different states (cells in the table) the system could move through.

And if, for example, I choose to number each cell using roman numerals, how can I put it in the upper right corner of each cell?

  • 1
    If we are talking slide shows, one actually places a different tabular on each slide. – John Kormylo May 6 at 21:12
  • We are talking paper – Pedro Fontanarrosa May 6 at 21:13
  • Yeah I have a slide-show for this, where I create arrows that show the initial and final states, and where are the different paths for them, but don't know how to do it in writing. – Pedro Fontanarrosa May 6 at 21:14
4

You can create an appropriate counter \newcounter{mycounter}[table] ([table] is to reset it to zero at every table).

Please remember to put the caption label near the caption (otherwise, it will refer to the last counter).

I've created also two alternative solutions to avoid the awful \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}

enter image description here

  • This is exactly what I was looking for. This is so thorough thank you millions! – Pedro Fontanarrosa May 7 at 5:17
  • @PedroFontanarrosa You're welcome! Thank you for accepting my answer! – CarLaTeX May 7 at 5:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.