使用 tikz 水平线制作章节标题 2

使用 tikz 水平线制作章节标题 2

我更改了代码 \thickhrulefill to \myrule[line width = 2.5mm]{fast cap reversed}{fast cap reversed};章节标题看起来不错,但目录与之不匹配。行长不太好(如果我可以增加该规则的长度就好了)

这是我尝试做的但看起来不太好:

\documentclass[a4paper,french,12pt,openany,twoside]{report}

%%%%%Language

\usepackage[utf8]{inputenc}
\usepackage[french]{babel} 
\usepackage[T1]{fontenc}
\usepackage{charter}
\usepackage[expert]{mathdesign}
\usepackage{geometry}
\geometry{margin=57pt}

%%%%%Police
\usepackage{lmodern}% police de caractère
\usepackage{textcomp}% caractères additionnels
\usepackage[normalem]{ulem}
\usepackage{soul}

%%%%%Graphic

\usepackage{graphicx}
\usepackage{xcolor}% gestion des couleurs
\usepackage{footnote}


%%%%%Titling

\usepackage{titling}% pour le titre
\usepackage{titlesec}% pour les sections
\usepackage{titletoc}% pour la table des matières
\usepackage{fancyhdr}% pour les en-têtes
\usepackage{enumitem}

%%%%%Math

\usepackage{array}
\usepackage{amsthm,latexsym,amssymb,amsmath, amsfonts}
\usepackage{mathtools}
\usepackage{pstricks}%pour psshadowbox
\usepackage{mathrsfs}
\usepackage{verbatim}
\usepackage{shapepar}
\usepackage{calc}% syntaxe naurelle pour les calculs

\usepackage{hyperref} 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{tikz}
\usetikzlibrary{arrows}

\newcommand{\myrule}[3][]{%
%    \begin{center}
        \begin{tikzpicture}%
            \draw[#2-#3, ultra thick, #1] (0,0) to (0.39\linewidth,0);
        \end{tikzpicture}%
%    \end{center}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Chapter Header

\renewcommand{\thechapter}{\Roman{chapter}}
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
     \vspace*{50\p@}%
     %\vspace*{10\p@}%
 {\parindent \z@ \centering \reset@font
     \myrule[line width = 2.5mm]{fast cap reversed}{fast cap reversed}\quad
       \normalfont\scshape \@chapapp{} \thechapter
       \quad\myrule[line width = 2.5mm]{fast cap reversed}{fast cap reversed} 
       \par\nobreak
       \vspace*{7mm}%
       \interlinepenalty\@M
       \hrule
       \vspace*{6mm}%
       \normalfont\Huge \bfseries \centering #1\par\nobreak
       \par
       \vspace*{7mm}%
       \hrule
   \vskip 40\p@
   \vskip 100\p@
 }}
   \def\@makeschapterhead#1{%
     \vspace*{50\p@}%
     %\vspace*{10\p@}%
     {\parindent \z@ \centering \reset@font
           \myrule[line width = 2.5mm]{fast cap reversed}{fast cap reversed} 
           \par\nobreak
           \vspace*{10\p@}%
           \interlinepenalty\@M
           \hrule
           \vspace*{10\p@}%
           \Huge \bfseries #1\par\nobreak
           \par
           \vspace*{10\p@}%
           \hrule
       \vskip 40\p@
       %\vskip 100\p@
     }}

\begin{document}
\tableofcontents
\chapter{Introduction}
\end{document}

答案1

我在您的规则中添加了一个附加参数,允许根据使用情况指定宽度:

\documentclass[a4paper,french,12pt,openany,twoside]{report}
%%%%%Language
\usepackage[utf8]{inputenc}
\usepackage[french]{babel} 
\usepackage[T1]{fontenc}
\usepackage{charter}
\usepackage[expert]{mathdesign}
\usepackage{geometry}
\geometry{margin=57pt}
%%%%%Police
\usepackage{lmodern}% police de caractère
\usepackage{textcomp}% caractères additionnels
\usepackage[normalem]{ulem}
\usepackage{soul}
%%%%%Graphic
\usepackage{graphicx}
\usepackage{xcolor}% gestion des couleurs
\usepackage{footnote}
%%%%%Titling
\usepackage{titling}% pour le titre
\usepackage{titlesec}% pour les sections
\usepackage{titletoc}% pour la table des matières
\usepackage{fancyhdr}% pour les en-têtes
\usepackage{enumitem}
%%%%%Math
\usepackage{array}
\usepackage{amsthm,latexsym,amssymb,amsmath, amsfonts}
\usepackage{mathtools}
\usepackage{pstricks}%pour psshadowbox
\usepackage{mathrsfs}
\usepackage{verbatim}
\usepackage{shapepar}
\usepackage{calc}% syntaxe naurelle pour les calculs
\usepackage{hyperref} 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz}
\usetikzlibrary{arrows}
\newcommand{\myrule}[4][]{%
        \begin{tikzpicture}%
            \draw[#2-#3, ultra thick, #1] (0,0) to (#4,0);
        \end{tikzpicture}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Chapter Header
\renewcommand{\thechapter}{\Roman{chapter}}
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
     \vspace*{50\p@}%
     %\vspace*{10\p@}%
 {\parindent \z@ \centering \reset@font
 \makebox[\linewidth]{\myrule[line width = 2.5mm]{fast cap reversed}{fast cap reversed}{0.39\linewidth}\hfill\normalfont\scshape \@chapapp{} \thechapter \hfill\myrule[line width = 2.5mm]{fast cap reversed}{fast cap reversed}{0.39\linewidth}} 
       \par\nobreak
       \vspace*{7mm}%
       \interlinepenalty\@M
       \hrule
       \vspace*{6mm}%
       \normalfont\Huge \bfseries \centering #1\par\nobreak
       \par
       \vspace*{7mm}%
       \hrule
   \vskip 40\p@
   \vskip 100\p@
 }}

\def\@makeschapterhead#1{%
     \vspace*{50\p@}%
     %\vspace*{10\p@}%
     {\parindent \z@ \centering \reset@font%
           \myrule[line width = 2.5mm]{fast cap reversed}{fast cap reversed}{.98\linewidth}%
           \par\nobreak
           \vspace*{10\p@}%
           \interlinepenalty\@M
           \hrule
           \vspace*{10\p@}%
           \Huge \bfseries #1\par\nobreak
           \par
           \vspace*{10\p@}%
           \hrule
       \vskip 40\p@
       %\vskip 100\p@
     }}

\begin{document}

\tableofcontents

\chapter{Introduction}

\end{document}

在此处输入图片描述

相关内容