% Here is what I tried
\documentclass[a4paper, 11pt,oneside]{book}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{titlesec}
\titleformat{\chapter}[display]{\bfseries}{\Large\chaptername~\thechapter\endgraf%
\tikz\draw[very thick,fill=black] (0,0) rectangle (3.5,-0.25);%
\titlerule[1pt]}{-3ex}{\LARGE\filcenter}%
\titleformat{\section}[display]{\bfseries}{\Large\endgraf%
\tikz\draw[very thick,fill=black] (0,0) rectangle (3.5,-0.25);%
\titlerule[1pt]}{-3ex}{\LARGE\filcenter \thesection~}
\begin{document}
\chapter{Introduction}
\section{Background}
\end{document}
答案1
请随意调整以适合您的口味。
\documentclass[a4paper, 11pt,oneside]{book}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{newtx}
\usepackage{lipsum}% for mock text
\titleformat{\chapter}[display]
{\LARGE}
{\chaptername\ \thechapter}
{1ex}
{\formattitle[-\baselineskip]{\LARGE}{}}
\newcommand{\formattitle}[4][0pt]{%
\parbox[t]{\textwidth}{%
#2% fontsize
\vspace{#1}
\hrule
\hrule height 3pt width 0.3\textwidth
\vspace{0.2ex}
\hspace{0.32\textwidth}%
\parbox[t]{0.68\textwidth}{\raggedright#3#4}%
}%
}
\titleformat{\section}[display]
{\Large}
{}
{0pt}
{\formattitle{\Large}{\thesection~}}
\titleformat{name=\section,numberless}[display]
{\Large}
{}
{0pt}
{\formattitle{\Large}{}}
\begin{document}
\tableofcontents
\chapter{Introduction}
\lipsum[1][1-3]
\section{Background}
\lipsum[1][1-3]
\section{A long section title that needs being split across lines}
\lipsum[1][1-3]
\section*{Unnumbered section}
\lipsum[1][1-3]
\end{document}