0

I have the following question: My work consists of 2 parts. If I include a figure or table in one of the parts, then this table is numbered without the part number, e.g. in the 2nd part the first table is numbered "1.1". But if I want to refer to this table, then the part number is also indicated - it says "see table 2.1.1". How do I make it that the part number is also shown in the caption? Here is my MWE:

...

\documentclass[open=any,12pt,oneside,headings=standardclasses,chapterprefix=false,numbers=noenddot]{scrbook} %headsepline obsolete: pointlessnumbers
\let\Tiny=\tiny
\usepackage{cleveref}
%%%%%\RedeclareSectionCommand[counterwithin=part]{chapter}
\renewcommand*{\thepart}{\arabic{part}}
\renewcommand*{\thechapter}{\arabic{chapter}}
%%%%%\renewcommand{\partmark}[1]{\markboth{#1}{}}
\makeatletter
\def\p@chapter{\thepart.}% Präfix für chapter-Labels
\def\p@section{\p@chapter}
\def\p@subsection{\p@section}
\def\p@subsubsection{\p@subsection}
\def\p@figure{\p@chapter}
\def\p@table{\p@chapter}
\makeatother
\usepackage[margin=10pt,font=small,labelfont=bf,belowskip=4pt,justification=centering]{caption}
%\captionsetup[figure]{labelfont=bf,textfont=it}
\captionsetup{justification   = raggedright,
              singlelinecheck = false}
% Dokumentenanfang
\begin{document}
\part{\thispagestyle{empty} {Weg}}
%%%%%%%%%%%%%%
\label{ErsterTeil}
\setcounter{section}{1}
\makeatletter
\@addtoreset{section}{part}
\makeatother
Hi (s. \ref{ma}), have a looak at table \ref{Briefkorr.I}.
\part{\thispagestyle{empty} {Übersetzung}}
\label{ZweiterTeil}
\setcounter{section}{1}
\makeatletter
\@addtoreset{section}{part}
\makeatother

\chapter{fff}

ddfdf\label{ma}\ \begin{table} \begin{tabular}[t]{lrr@{.}l} Position 1 & DM & 5 & 49\ Position 2 & DM & 10 & 95\ \end{tabular} \caption{Korrespondenz}\label{Briefkorr.I} \end{table} \end{document}

...

test
  • 97

1 Answers1

1

UPDATE

Added \renewcommand{\thetable}{\arabic{part}.\arabic{chapter}.\arabic{table}} to make the part number appear in the caption number.

The line \def\p@chapter{\thepart.} adds the part number to the chapter label as a prefix when a reference to it is requested. See include the part number.

This table is the first in chapter #1, part #2.

a

c

section and chapter numbers are reset after part

\documentclass[open=any,12pt,oneside,headings=standardclasses,chapterprefix=false,numbers=noenddot]{scrbook} %headsepline obsolete: pointlessnumbers
\let\Tiny=\tiny
\usepackage{cleveref}

\usepackage[margin=10pt,font=small,labelfont=bf,belowskip=4pt,justification=centering]{caption} \captionsetup{justification = raggedright, singlelinecheck = false}% Dokumentenanfang

\renewcommand{\thepart}{\arabic{part}} \renewcommand{\thechapter}{\arabic{chapter}} \renewcommand{\thetable}{\arabic{part}.\arabic{chapter}.\arabic{table}} %<<<<<<<<<<<<<< added

\makeatletter \def\p@chapter{\thepart.}% Präfix für chapter-Labels \makeatother

\begin{document}

\part{\thispagestyle{empty} {Weg}} \label{ErsterTeil}

Hi (s.~\ref{ma}), have a look at table~\ref{Briefkorr.I}.

\part{\thispagestyle{empty} {Übersetzung}}      
\label{ZweiterTeil}

\chapter{fff}

ddfdf\label{ma}\\

\begin{table}
    \begin{tabular}[t]{lrr@{.}l}
        Position 1 &amp; DM &amp;  5 &amp; 49\\
        Position 2 &amp; DM &amp; 10 &amp; 95\\
    \end{tabular}
    \caption{Korrespondenz}\label{Briefkorr.I}
\end{table}

\end{document}

section and chapter numbers are reset after part

(section and chapter numbers are reset after part)

Simon Dispa
  • 39,141
  • Thanks, but there is a problem: "Hi (s. 2.1), have a look at table 2.1.1." with your code becomes "Hi (p.2 – ch. 1), have a look at table 2.1.1." - can you say how I get " (s. 2.1)" with your solution. – test Sep 16 '22 at 08:08
  • An inelegant solution would be \ref{ZweiterTeil}.\ref{ma}, but is there a better soltuion? – test Sep 16 '22 at 08:20
  • Please see the updated answer – Simon Dispa Sep 16 '22 at 12:56
  • Is it possible to get table numbers that are independent from part and chapter numbers? For instance, I want that my tables are numbered 1,2,3,... - how can I get this? – test Sep 17 '22 at 13:36
  • @test Use \renewcommand{\thetable}{\arabic{table}} instead. – Simon Dispa Sep 17 '22 at 13:45
  • thanks again, but is there a possibility that the counting passes through the chapter numbers and is indepent from it? E.g. when I have 2 tables and there are in Part 1 chapter 2 and 3, it is shown "table 1" and "table 2" (actually, it is shown again "table 1"). – test Sep 18 '22 at 20:32
  • @test Add \counterwithout{table}{chapter} to suppress the reset to 1 of the table counter at the start of a chapter – Simon Dispa Sep 18 '22 at 21:16