I want to add volume in front of the part level, I've implemented this feature, but there is a warning that I have not been able to dismiss.
The MWE is as follows:
\documentclass{book}
\usepackage{titlesec}
\makeatletter
\newcounter{volume}
\setcounter{volume}{0}
\def\toclevel@volume{-2}
\renewcommand\thevolume{Vol. \@arabic\c@volume}
\newcommand\volume{
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{empty}
\if@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\null\vfil
\secdef\@volume\@svolume}
\def\@volume[#1]#2{
\ifnum \c@secnumdepth >-3\relax
\refstepcounter{volume}
\addcontentsline{toc}{volume}{\thevolume\hspace{1em}#1}
\else
\addcontentsline{toc}{volume}{#1}
\fi
\markboth{}{}
{\centering
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >-3\relax
\Huge\bfseries \volumename\nobreakspace\@arabic\c@volume
\par
\vskip 20\p@
\fi
\Huge \bfseries #2\par}
\@endvolume}
\def\@svolume#1{
{\centering
\interlinepenalty \@M
\normalfont
\Huge \bfseries #1\par}
\@endvolume}
\def\@endvolume{\vfil\newpage
\if@twoside
\if@openright
\null
\thispagestyle{empty}
\newpage
\fi
\fi
\if@tempswa
\twocolumn
\fi}
\newcommand*\l@volume[2]{
\ifnum \c@tocdepth >-3\relax
\addpenalty{-\@highpenalty}
\addvspace{2.25em \@plus\p@}
\setlength\@tempdima{3em}
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
{\leavevmode
\large \bfseries #1\hfil
\hb@xt@\@pnumwidth{\hss #2
\kern-\p@\kern\p@}}\par
\nobreak
\global\@nobreaktrue
\everypar{\global\@nobreakfalse\everypar{}}%
\endgroup
\fi}
\newcommand\volumename{Volume}
\makeatother
\usepackage{titletoc}
\setlength{\titlewidth}{0.5\textwidth}
\titlecontents{volume}
[0pc]
{\addvspace{1pc}\bfseries\large\titlerule\addvspace{.3pc}\centering}
{}
{}
{\enspace \contentspage}
[\addvspace{.3pc}\titlerule]
\usepackage{hyperref}
\hypersetup{colorlinks=true,linkcolor=red}
\makeatletter
\@addtoreset{part}{volume}
\@addtoreset{chapter}{volume}
\makeatother
\title{MWE}
\begin{document}
\tableofcontents
\volume{Volume.1}
\part{Part.1.1}
\chapter{Chap.1.1.1}
\chapter{Chap.1.1.2}
\part{Part.1.2}
\chapter{Chap.1.2.1}
\chapter{Chap.1.2.2}
\volume{Volume.2}
\part{Part.2.1}
\chapter{Chap.2.1.1}
\chapter{Chap.2.1.2}
\end{document}
A warning appears after compilation:
Package titletoc: Unknown TOC type volume. I'll set it for you with
(titletoc) level -1000..
If you comment out the following sections, the warning disappears.
\titlecontents{volume}
[0pc]
{\addvspace{1pc}\bfseries\large\titlerule\addvspace{.3pc}\centering}
{}
{}
{\enspace \contentspage}
[\addvspace{.3pc}\titlerule]
Is there a way to implement functionality while eliminating warnings?