Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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?. –  Peter Grill Oct 23 '12 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? –  Peter Grill Oct 23 '12 at 6:32
    
No, I want to sync the values of both counters - or use one counter for both envs. –  Reactormonk Oct 23 '12 at 16:51
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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