移除 ToC 部分上方的顶部边距

移除 ToC 部分上方的顶部边距

我想\parttoc在不使用包的情况下,从页面顶部开始生成目录,删除默认顶部边距\titlesec。我可以从一般目录中删除顶部边距,但不能从部分目录中删除顶部边距。

我在这里给出了我的测试代码:

\documentclass{report}
\usepackage{minitoc}
\usepackage[spanish]{babel}
\usepackage{tocvsec2}

\begin{document}
\doparttoc

%Removing top margin above ToC
\begingroup
\makeatletter
% Redefine the \chapter* header macro to remove vertical space
\def\@makeschapterhead#1{%
%\vspace*{50\p@}% Remove the vertical space
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries  #1\par\nobreak
\vskip 40\p@
}}
\makeatother
\tableofcontents
\endgroup

\part{MEMORIA}

%Trying to remove part ToC top margin as the previous one (doesn't work)
\begingroup
\makeatletter
% Redefine the \chapter* header macro to remove vertical space
\def\@makeschapterhead#1{%
%\vspace*{50\p@}% Remove the vertical space
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries  #1\par\nobreak
\vskip 40\p@
}}
\makeatother
\parttoc
\endgroup

\chapter{Chapter1}
\section{Section1.1}
\chapter{Chapter2}
\section{Section2.1}

\end{document}

有人能帮助我吗?

答案1

如果您希望标题向上移动,但标题和表格之间的空间保持不变(老实说,我不明白您想减少哪个空间),您可以通过重新定义来实现\mtcgapbeforeheads

\documentclass{report}
\usepackage{minitoc}
\usepackage[spanish]{babel}
\usepackage{tocvsec2}

\renewcommand\mtcgapbeforeheads{0pt}

\begin{document}
\doparttoc

%Removing top margin above ToC
\begingroup
\makeatletter
% Redefine the \chapter* header macro to remove vertical space
\def\@makeschapterhead#1{%
%\vspace*{50\p@}% Remove the vertical space
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries  #1\par\nobreak
\vskip 40\p@
}}
\makeatother
\tableofcontents
\endgroup

\part{MEMORIA}

%Trying to remove part ToC top margin as the previous one (doesn't work)
\begingroup
\makeatletter
% Redefine the \chapter* header macro to remove vertical space
\def\@makeschapterhead#1{%
%\vspace*{50\p@}% Remove the vertical space
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries  #1\par\nobreak
\vskip 40\p@
}}
\makeatother
\parttoc
\endgroup

\chapter{Chapter1}
\section{Section1.1}
\chapter{Chapter2}
\section{Section2.1}

\end{document}

结果(从页面顶部开始,但在表格后被截断):

在此处输入图片描述

相关内容