1

I've got my little examples env with

\newlist{examples}{enumerate}{1}                          
\setlist[examples]{label=(\arabic*), ref=\arabic*, resume}

How do I use the same counter for the table env?

3
  • I believe that it is simply table. So, \arabic{table} should yields its value? I am not sure what you want to do with it though. To access it's value you should refer to What is the proper method of accessing a counter?. Commented Oct 23, 2012 at 6:23
  • Based on your title, perhaps you are looking for \setcounter{table}{<num>} to change the value of the table counter to a specific number? Commented Oct 23, 2012 at 6:32
  • No, I want to sync the values of both counters - or use one counter for both envs. Commented Oct 23, 2012 at 16:51

1 Answer 1

7

Well, I may have misunderstood the question. But is it like this?

\documentclass[a4paper]{article}
\usepackage{enumitem}
\newlist{examples}{enumerate}{1}
\begin{document}
\setcounter{table}{4}
\begin{examples}[label=(\thetable.\arabic*)]
  \item {text to center}
  \item {text to center}
\end{examples}

\begin{table}[htb]
  \centering
  \begin{tabular}{|c|c|}
    \hline
    1 & 2 \\\hline
    3 & 4 \\
    \hline
  \end{tabular}
  \caption{This is one table}\label{tab:mytab}
\end{table}

\begin{examples}[label=(\thetable.\arabic*)]
  \item {text to center}
  \item {text to center}
\end{examples}

\end{document}

enter image description here

The settings of the list can be made global by

\setlist[examples]{label=(\thetable.\arabic*)}

Code:

\documentclass[a4paper]{article}
\usepackage{enumitem}
\newlist{examples}{enumerate}{1}
\setlist[examples]{label=(\thetable.\arabic*)}
\begin{document}
\setcounter{table}{4}
\begin{examples}
  \item {text to center}
  \item {text to center}
\end{examples}

\begin{table}[htb]
  \centering
  \begin{tabular}{|c|c|}
    \hline
    1 & 2 \\\hline
    3 & 4 \\
    \hline
  \end{tabular}
  \caption{This is one table}\label{tab:mytab}
\end{table}

\begin{examples}
  \item {text to center}
  \item {text to center}
\end{examples}

\end{document}

This will take the last value of \thetable as the first digit and second digit will be the usual arabic numbers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .