Создание элемента оглавления, отступ которого подстраивается под предыдущий элемент
Создание элемента оглавления, отступ которого подстраивается под предыдущий элемент. Т.е. (что я имею ввиду?): Требуется чтобы следующий код:
\section{S1}
\paragraph{P1}
\section{S2}
\subsection{S3}
\paragraph{P2}
Выдавал в оглавлении нечто следующее:
1.1 S1
$1 P1
1.2 S2
1.2.1 S3
$1 P2
(Решение есть, но решение крайне костыльное, хотелось бы чего-нибудь получше) Костыльное решение:
\makeatletter
\newcounter{paragraphl}[subsubsection]
\newcommand{\paragraphl}{\@startsection{paragraphl}{4}{0pt}{1em}{1em}{\Large\bf}}
\renewcommand{\theparagraphl}{\S\ \@arabic\c@paragraphl}
\newcommand*{\l@paragraphl}{\@dottedtocline{4}{3.75em}{2em}}
\newcommand{\paragraphlmark}[1]{}
\newcounter{subparagraphl}[paragraphl]
\newcommand{\subparagraphl}{\@startsection{subparagraphl}{5}{0pt}{1em}{1em}{\Large\bf}}
\renewcommand{\thesubparagraphl}{\S\ \@arabic\c@paragraphl.\@arabic\c@subparagraphl}
\newcommand*{\l@subparagraphl}{\@dottedtocline{5}{5.75em}{3em}}
\newcommand{\subparagraphlmark}[1]{}
\newcounter{paragraphll}[subsubsection]
\newcommand{\paragraphll}{\@startsection{paragraphll}{4}{0pt}{1em}{1em}{\Large\bf}}
\renewcommand{\theparagraphll}{\S\ \@arabic\c@paragraphll}
\newcommand*{\l@paragraphll}{\@dottedtocline{4}{7em}{2em}}
\newcommand{\paragraphllmark}[1]{}
\newcounter{subparagraphll}[paragraphll]
\newcommand{\subparagraphll}{\@startsection{subparagraphll}{5}{0pt}{1em}{1em}{\Large\bf}}
\renewcommand{\thesubparagraphll}{\S\ \@arabic\c@paragraphll.\@arabic\c@subparagraphll}
\newcommand*{\l@subparagraphll}{\@dottedtocline{5}{9em}{3em}}
\newcommand{\subparagraphllmark}[1]{}
\newcommand{\SetL}{\renewcommand{\paragraph}{\paragraphl}\renewcommand{\subparagraph}{\subparagraphl}}
\newcommand{\SetLL}{\renewcommand{\paragraph}{\paragraphll}\renewcommand{\subparagraph}{\subparagraphll}}
\renewcommand{\section}{\SetL\@startsection{section}{1}{0pt}{1em}{1em}{\Large\bf}}
\renewcommand{\subsection}{\SetLL\@startsection{subsection}{2}{0pt}{1em}{1em}{\Large\bf}}
\makeatother
Заключается в создании двух видов параграфа с нужными отступами и переопределении базового параграфа "налету".