I'm aware that using package titletoc one can easily change the format of ToC. But, I'm wondering if there exist some solutions to make the left margin in ToC flexible. By "flexible", I mean that the left margin of certian level will change according to the current label number. For example, if there exist a \chapter, but no \section, \subsection and \subsubsection, then an immediate \paragraph will have the same margin in TC as the normal \section. I know that the margin of a section title is basically controlled by the <left> option in titletoc package. So my naive idea is to combine this with some \ifthenelse.
\documentclass{book}
\usepackage{xifthen}
\usepackage{titletoc}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\newlength{\TOCparagraphskip}
\setlength{\TOCparagraphskip}{9em}
\titlecontents*
{paragraph}
[\ifnum\pdfmatch{.[.].[.].[.]0[.].}{\thecontentslabel}=1
\setlength{\TOCparagraphskip}{7em}%
\ifnum\pdfmatch{.[.].[.]0[.]0[.].}{\thecontentslabel}=1
\setlength{\TOCparagraphskip}{3.8em}%
\ifnum\pdfmatch{.[.]0[.]0[.]0[.].}{\thecontentslabel}=1
\setlength{\TOCparagraphskip}{1.5em}%
\ifnum\pdfmatch{0[.]0[.]0[.]0[.].}{\thecontentslabel}=1
\setlength{\TOCparagraphskip}{0em}%
\fi
\fi
\fi
\else
\setlength{\TOCparagraphskip}{9em}%
\fi
\TOCparagraphskip]{}{\textbullet{};}{}{}[\quad]
\begin{document}
\tableofcontents
\paragraph{paragraph}
\chapter{chapter one}
\end{document}
But, unfortunately, my naive try give error message.
(./test.toc
./test.toc:1: Missing number, treated as zero.
<to be read again>
\protect
l.1 ...aph}{\numberline {0.0.0.0.1}paragraph}{1}{}
%
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
./test.toc:1: Illegal unit of measure (pt inserted).
<to be read again>
\protect
l.1 ...aph}{\numberline {0.0.0.0.1}paragraph}{1}{}
%
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)
./test.toc:1: Package calc Error: `\let ' invalid at this point.
See the calc package documentation for explanation.
Type H <return> for immediate help.
...
l.1 ...aph}{\numberline {0.0.0.0.1}paragraph}{1}{}
%
I expected to see one of: + - * / )
But I've checked that with or without my personal hack, the .toc file are in fact the same.
\contentsline {paragraph}{\numberline {0.0.0.0.1}paragraph}{1}{}%
\contentsline {chapter}{\numberline {1}chapter one}{3}{}%
\contentsfinish
So, I don't know where is the problem. Or, maybe someone else has some better idea to implement this functionality?

tocloftpackage is also designed for controlling the appearance of the ToC, etc. – Peter Wilson Nov 16 '21 at 19:42\chapterby a\paragraphwith no intermediate divisions. As a reader I would find that very confusing. – Peter Wilson Nov 17 '21 at 18:10