下午好。
考虑以下修改标题样式的代码:
\documentclass[12pt,a4paper]{book}
\usepackage{lmodern}
\usepackage[explicit]{titlesec}
\usepackage{microtype}
\usepackage{tikz}
\titleformat%
{\chapter}[hang]%
{\bfseries}{%
\begin{minipage}[t]{0.3\linewidth}
\vspace{0pt}% do not remove
\begin{tikzpicture}
\node[
outer sep=0pt,
text width=2.5cm,
minimum height=2.5cm,
fill=black,
font=\color{white}\fontsize{80}{90}\selectfont,
align=center
] (num) {\thechapter};
\node[
outer sep=0pt,
inner sep=0pt,
anchor=south,
font=\color{black}\Large\normalfont
] at ([yshift=8pt]num.north) {\textls[180]{\textsc{\chaptertitlename}}};
\end{tikzpicture}
\end{minipage}%
}
{0pt}%
{%
\begin{minipage}[t]{.7\linewidth}%
\vspace{22pt} % do not remove
\rule{\linewidth}{2.5pt}\\\vskip -1.75\baselineskip%
\rule{\linewidth}{.7pt}\vskip 5pt
{\LARGE\raggedright\textsf{#1}}
\end{minipage}%
\titleformat{\chapter}[hang]%
}
\begin{document}
\chapter{The Singular Sturm-Liouville Problems in Spectral Parameter}
\end{document}
我试图从该格式中排除以下部分:图片列表,表格列表和目录换句话说,我希望在这 3 个部分上使用默认的“纯”样式(这样就不会对它们应用上述代码)。是否可以修改 titleformat 代码,使其仅适用于章节本身,而不适用于上述部分?
非常感谢您的帮助。
答案1
您的代码有一些修正。
\documentclass[12pt,a4paper]{book}
\usepackage{lmodern}
\usepackage[explicit]{titlesec}
\usepackage{microtype}
\usepackage{tikz}
\titleformat{\chapter}[hang]% <<<<<<
{\bfseries}{%
\begin{minipage}[t]{0.3\linewidth}
\vspace{0pt}% do not remove
\begin{tikzpicture}
\node[
outer sep=0pt,
text width=2.5cm,
minimum height=2.5cm,
fill=black,
font=\color{white}\fontsize{80}{90}\selectfont,
align=center
] (num) {\thechapter};
\node[
outer sep=0pt,
inner sep=0pt,
anchor=south,
font=\color{black}\Large\normalfont
] at ([yshift=8pt]num.north) {\textls[180]{\textsc{\chaptertitlename}}};
\end{tikzpicture}
\end{minipage}%
}
{0pt}%
{%
\begin{minipage}[t]{.7\linewidth}%
\vspace{2pt} % do not remove
\rule{\linewidth}{2.5pt}\\\vskip -1.75\baselineskip%
\rule{\linewidth}{.7pt}\vskip 5pt
{\LARGE\raggedright\textsf{#1}}
\end{minipage}%
}
\titleformat{name=\chapter,numberless}[hang] % added <<<<<<<<<<<<<<<<<<
{\sffamily\bfseries\LARGE\raggedright}
{}
{0pt}
{#1}
\begin{document}
\tableofcontents
\chapter{The Singular Sturm-Liouville Problems in Spectral Parameter}
\end{document}