0

I would like to have my Table counting like

Table P1.1
Table P1.2
Table P1.3

I tried with \renewcommand{\thetable}{P1.???}, and I do not know what to put on the question marks.

EDIT I wrote this code

\setcounter{figure}{0}
\begin{figure}[htbp!]
\includegraphics[scale=0.5]{Figures/P1.1.png}
\caption{\label{fig:P1.1}When reading from a scale, make sure that you know what each division on the scale represents.}
\end{figure}

and I would like that my figure/table have enter image description here

Figure P1.2.png instead of P1.16.2 after using this

\let\oldthetable\thetable
\renewcommand{\thetable}{P1.\oldthetable}
\let\oldthefigure\thefigure
\renewcommand{\thefigure}{P1.\oldthefigure}

2 Answers2

2

It depends on what the components of your figure/table number represent what you need to do. Here are some options:

  1. P1 is just a prefix and has no connection to anything within your document.

    \let\oldthefigure\thefigure
    \renewcommand{\thefigure}{P1.\oldthefigure}
    \let\oldthetable\thetable
    \renewcommand{\thetable}{P1.\oldthetable}
    
  2. P1 refers to \part one of your document, and is therefore tied to parts.

    \let\oldthefigure\thefigure
    \renewcommand{\thefigure}{P\arabic{part}.\oldthefigure}
    \let\oldthetable\thetable
    \renewcommand{\thetable}{P\arabic{part}.\oldthetable}
    

  3. In a numbering that resembles P1.16.2, the 16 represents either a chapter (in the book or report class, or something similar that provides \chapter) or a section (in article, or something similar that doesn't provide \chapter); the former is more common than the latter. For this option you'll have to allow your figure/table numbering to be continuous across these document elements (see Continuous v. per-chapter/section numbering of figures, tables, and other document elements) in addition to updating the counter representation:

    % Continuous figure/table numbering: https://tex.stackexchange.com/q/28333/5764
    \usepackage{chngcntr}
    \counterwithout{figure}{chapter}% or \counterwithout{figure}{section}
    \counterwithout{table}{chapter}% or \counterwithout{table}{section}
    \renewcommand{\thefigure}{P1.\arabic{figure}}
    \renewcommand{\thetable}{P1.\arabic{table}}
    
Werner
  • 603,163
0

The easiest way I can think of doing this is simply reusing whatever \thetable was before:

\documentclass{article}
\let\oldthetable\thetable
\renewcommand{\thetable}{P1.\oldthetable}
\begin{document}
    \listoftables
    \begin{table}[tp]
        Test 1\caption{Test 1}\label{tab:test1}
    \end{table}
    \begin{table}[tp]
        Test 2\caption{Test 2}\label{tab:test2}
    \end{table}
    \begin{table}[tp]
        Test 3\caption{Test 3}\label{tab:test3}
    \end{table}
\end{document}
chsk
  • 3,667