How can I set the table counter?
32,113
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}
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.
Related videos on Youtube
Author by
Reactormonk
Updated on June 12, 2020Comments
-
Reactormonk over 3 years
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?-
Peter Grill about 11 yearsI 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?. -
Peter Grill about 11 yearsBased on your title, perhaps you are looking for
\setcounter{table}{<num>}
to change the value of the table counter to a specific number? -
Reactormonk about 11 yearsNo, I want to sync the values of both counters - or use one counter for both envs.
-