0

Is there a way to make some of my tables look like this:

Example of table

In particular, I cannot get the table numbering to work automatically. It is now manually set, but I would like this to be numbered according to the table counter, and to be able to label it and refer to it. The code of the image is

\documentclass{article}
\usepackage{tcolorbox}

\begin{document}

\begin{tcolorbox}[width=.95\linewidth]
  \begin{center}
    \textbf{Table 10.2: Some axioms}
    \begin{itemize}
      \item $\top \leq a \to a$
      \item $\top \to \bot \leq \bot$
    \end{itemize}
  \end{center}
\end{tcolorbox}

\end{document}
2
  • As I see, your equations are automatically numbered by use of enumerate. What you mean with " I would like this to be numbered according to the table counter". So far your table number is manually set. Please, clarify this and also extend your code sniped to complete small document, which produce showed image. – Zarko Jul 22 at 2:38
  • Oops I meant the table number. I changed the question so that there is no enumerate in it. – Math Student 020 Jul 22 at 2:53
2

You could do this in your preamble:

\NewDocumentEnvironment{mytable}{ m }
  {
   \begin{tcolorbox}[width=.95\linewidth]
     \begin{center}
     \refstepcounter{table} % ❶
     \textbf{Table \thetable: #1}% ❷
     \par
  }
  {
     \end{center}
    \end{tcolorbox}
  }

and then in your document:

\begin{mytable}{Some axioms}
  \begin{itemize}
    \item $\top \leq a \to a$
    \item $\top \to \bot \leq \bot$
  \end{itemize}
\end{mytable}

Of course tcolorbox includes the \newtcolorbox command which can integrate all of this for you so you don't need to declare the environment. See texdoc tcolorbox for the hair details. I'm not sure that, for this case, it makes things easier, but if you wanted to, say, offset the title in some way, it can make your life a bit simpler.

1

Another posibility: by use of \captionof command:

\documentclass{article}
\usepackage{caption}
\renewcommand\thetable{\thesection.\arabic{table}}
\usepackage{tcolorbox}

\begin{document}

\setcounter{section}{9}
\section{Axioms}
\begin{tcolorbox}[width=.95\linewidth]
\captionsetup{font=bf}
  \begin{center}
\captionof{table}{Some axioms}
    \begin{itemize}
      \item $\top \leq a \to a$
      \item $\top \to \bot \leq \bot$
    \end{itemize}
  \end{center}
\end{tcolorbox}

\end{document}

enter image description here

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.