如何更改图表和目录的标题位置?

如何更改图表和目录的标题位置?

我已经使用了一种样式作为 toc 和 lof 标题,但位置离页面顶部有点远,我想让它更靠近页眉

这是一个完整的例子

    \documentclass[a4paper,12pt,final]{report}
% Pour une impression recto verso, utilisez plutôt ce documentclass :
%\documentclass[a4paper,11pt,twoside,final]{article}

\usepackage{tabto} 
\usepackage{mathptmx} % text new roman font
\usepackage[english,francais]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[pdftex]{graphicx}
\usepackage{setspace}    
\usepackage[hidelinks]{hyperref}
\usepackage[french]{varioref}
\usepackage{float}
\usepackage{url}
\usepackage{amssymb}
 
\usepackage{listings}
\usepackage{lipsum}
\usepackage{courier}
 
\usepackage{listings}
\usepackage{xcolor}
\usepackage{tabularx}
\usepackage{pifont}
\usepackage{pdflscape}

\graphicspath{ {figures/} }
\usepackage{array}
\usepackage[titletoc]{appendix}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} % load a font with all the characters

%\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\usepackage{arabtex}  % caption must be loaded before arabtex
\usepackage{utf8}

% add an extra subsection
\usepackage{titlesec}
\usepackage{hyperref}

\usepackage{tikz}
\usetikzlibrary{shadows.blur}

\usepackage{titletoc}
\usepackage{lipsum}

\usepackage{calc}

\usepackage[]{titlesec} 
\definecolor{yourcolor}{HTML}{008bb2}

\colorlet{chpnumbercolor}{black}
\makeatletter
\let\oldl@chapter\l@chapter
\def\l@chapter#1#2{\oldl@chapter{#1}{\textcolor{chpnumbercolor}{#2}}}

\let\old@dottedcontentsline\@dottedtocline
\def\@dottedtocline#1#2#3#4#5{%
\old@dottedcontentsline{#1}{#2}{#3}{#4}{{\textcolor{chpnumbercolor}{#5}}}}
\makeatother

\titleformat{\chapter}[display]
  {\normalfont\color{yourcolor}}
  {\filleft\Huge\sffamily\bfseries\chaptertitlename\hspace*{2mm}%
  \begin{tikzpicture}[baseline={([yshift=-.6ex]current bounding box.center)}]
    \node[fill=yourcolor,circle,text=white] {\thechapter};
  \end{tikzpicture}}
  {1ex}
  {\titlerule[3pt]\vspace*{5ex}\huge\sffamily\itshape}
  []

\titleformat{name=\chapter,numberless}[display]
  {\normalfont\color{yourcolor}}
  {}
  {1ex}
  {\vspace*{1ex}\huge\sffamily\itshape\center}
  []        
   \titlespacing*{\chapter}{0pt}{50pt}{40pt}

%command to print the acutal minitoc
\newcommand{\printmyminitoc}{%
    \noindent\hspace{-2cm}\vspace{-2cm}%
    \colorlet{chpnumbercolor}{white}%
}
    
 
\newcommand{\mychapter}[2]{
    \setcounter{chapter}{#1}
    \setcounter{section}{0}
    \chapter*{#2}
    \addcontentsline{toc}{chapter}{#2}
}

\renewcommand\thechapter{\Roman{chapter}}

\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{#1}}{}}

%\usepackage{tocloft}                                              
%\renewcommand\cftbeforetoctitleskip{-2cm}
%\renewcommand\cftbeforeloftitleskip{-2cm}
%\renewcommand\cftbeforelottitleskip{-2cm}

\begin{document}
 \tableofcontents
  \listoffigures
   \chapter{Chapitre 1: Etude et analyse}
  \lipsum[1]

\end{document}

前

使用后

 \usepackage{tocloft}                                              
 \renewcommand\cftbeforetoctitleskip{-2cm}
 \renewcommand\cftbeforeloftitleskip{-2cm}
 \renewcommand\cftbeforelottitleskip{-2cm}

后

两个标题重叠,并且先前定义的样式已发生更改,但我只想更改位置并保持字体大小/颜色

谢谢

答案1

解决方案是使用 vspace 的负值来更改 titleFormat,如下所示:

\titleformat{name=\chapter,numberless}[display]
  {\normalfont\color{yourcolor}}
  {}
  {1ex}
  {\vspace{-20ex}\huge\sffamily\itshape\center}
  []        
   \titlespacing*{\chapter}{0pt}{50pt}{40pt}

相关内容