关于此代码,我想个性化目录中框和章节之间的间距
\documentclass{book}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,top=3cm,bottom=3cm,left=1.5cm,right=1.5cm]{geometry}
\usepackage{xcolor}
\usepackage{imakeidx}
\usepackage[tight, italian]{minitoc}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}
\usepackage{hyperref}
\newif{\ifTOC}
\newcommand{\mytikzmark}[1]{\ifTOC\tikzmark{#1}\fi}
\setcounter{chapter}{-1}
\setcounter{section}{-1}
\newcommand*{\arabicdec}[1]{\the\numexpr\value{#1}-1\relax}
%\renewcommand*{\thechapter}{\arabicdec{chapter}}
\renewcommand*{\thesection}{\thechapter.\arabicdec{section}}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{4}
\begin{document}
\title{\color{red}{\Huge{\textbf{ALGEBRA LINEARE}}}}
\author{\color{blue}{\Huge{\textbf{???}}}}
\date{27 Febbraio 2021 $-$ xx Mese Anno}
\frontmatter
\maketitle
\dominitoc
\TOCtrue
\tableofcontents
\TOCfalse
\newpage
\section*{PREFAZIONE GENERALE}
\addcontentsline{toc}{section}{\protect\numberline{}PREFAZIONE GENERALE}
\mainmatter
\chapter{NOTAZIONI PRELIMINARI}
\minitoc %\minilof\minilot
\mtcskip
\pagestyle{plain}
\section{??}
\newpage
\part[FONDAMENTI DELL'ALGEBRA LINEARE]%
{\huge\color{red}{FONDAMENTI DELL'ALGEBRA LINEARE}}
\section*{Prefazione alla Prima Parte}
\addcontentsline{toc}{section}{Prefazione alla Prima Parte}
%\Large{Inserire una Prefazione}
\chapter{One}
\minitoc %\minilof\minilot
\mtcskip
\addtocontents{toc}{\string\mytikzmark{TOCboxA}}%
\section[One.One\string\hspace{130pt}]{One.One}
\subsection[One.One.One\string\hspace{78pt}]{One.One.One}
\subsubsection[Very long Expression\string\mytikzmark{TOCboxB}]{One.One.One.One}
\addtocontents{toc}{\string\tikz[overlay,remember picture]% make sure on same apge
{\string\draw ($(pic cs:TOCboxA)+(-2pt,3pt-\the\dp\strutbox)$) rectangle
($(pic cs:TOCboxB)+(3pt,0pt-\the\dp\strutbox)$);}}%
\addtocontents{toc}{\string\mytikzmark{TOCboxC}}%
\section[One.One\string\hspace{116pt}]{One.One}
\subsection[One.One.One\string\hspace{64pt}]{One.One.One}
\subsubsection[One.One.One.One\string\mytikzmark{TOCboxD}]{One.One.One.One}
\addtocontents{toc}{\string\tikz[overlay,remember picture]% make sure on same apge
{\string\draw ($(pic cs:TOCboxC)+(-5pt,3pt-\the\dp\strutbox)$) rectangle
($(pic cs:TOCboxD)+(3pt,0pt-\the\dp\strutbox)$);}}%
\addtocontents{toc}{\string\mytikzmark{TOCboxE}}%
\section[One.One\string\hspace{116pt}]{One.One}
\subsection[One.One.One\string\hspace{64pt}]{One.One.One}
\subsubsection[One.One.One.One\string\mytikzmark{TOCboxF}]{One.One.One.One}
\addtocontents{toc}{\string\tikz[overlay,remember picture]% make sure on same apge
{\string\draw ($(pic cs:TOCboxE)+(-5pt,3pt-\the\dp\strutbox)$) rectangle
($(pic cs:TOCboxF)+(3pt,0pt-\the\dp\strutbox)$);}}%
\end{document}
我该怎么办?非常感谢,并致以最诚挚的问候。
第一次编辑:此外,有没有办法为所有部分创建一个 strutbox?谢谢
第二次编辑:添加这张照片,我希望我的问题更清楚,不是吗?
答案1
目录的布局由\l@...
命令指定,因此\l@chapter
在这里。有些包提供了更高级别的接口,但在这里,如果只需要进行更改,则只需复制原始定义并调整间距即可。
我刚刚将注释行添加到定义中并添加到你的序言中:
\makeatletter
% copied from book
\renewcommand*\l@chapter[2]{%
\ifnum \c@tocdepth >\m@ne
\addpenalty{-\@highpenalty}%
\vskip 1.0em \@plus\p@
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \bfseries
\advance\leftskip\@tempdima
\hskip -\leftskip
#1\nobreak\hfil
\nobreak\hb@xt@\@pnumwidth{\hss #2%
\kern-\p@\kern\p@}\par
\penalty\@highpenalty
\vspace{-10pt}% or whatever
\endgroup
\fi
}
\makeatother
制作
后面有空格 1 一减少了 10pt。
请注意,初始章节然后打印,因此您必须在其他地方进行额外的空间更改才能完成工作