我需要更改在该网站的另一个页面上找到的以下代码,以便\chapter{Intro}
在左侧的水平线上方显示章节标题(例如):
\documentclass{report}
\usepackage{lmodern}
\usepackage{titlesec}
\usepackage{microtype}
\usepackage{tikz}
\definecolor{myblue}{RGB}{0,82,155}
\titleformat{\chapter}[display]
{\normalfont\bfseries\color{myblue}}
{\filleft%
\begin{tikzpicture}
\node[
outer sep=0pt,
text width=2.5cm,
minimum height=3cm,
fill=myblue,
font=\color{white}\fontsize{80}{90}\selectfont,
align=center
] (num) {\thechapter};
\node[
rotate=90,
anchor=south,
font=\color{black}\Large\normalfont
] at ([xshift=-5pt]num.west) {\textls[180]{\textsc{\chaptertitlename}}};
\node[
font=\color{white}\Large\normalfont,
anchor=north,
inner sep=0pt
] at ([yshift=2.5cm]num.north) {\chaptertitlename};
\end{tikzpicture}%
}
{10pt}
{\titlerule[2.5pt]\vskip3pt\titlerule\vskip4pt\LARGE\rmfamily}
\begin{document}
\chapter{Introduction}
答案1
更新
titlesec
您可以尝试使用以下代码的明确选项:
\documentclass{report}
\usepackage{lmodern}
\usepackage[explicit]{titlesec}% use option explicit
\usepackage{microtype}
\usepackage{tikz}
\definecolor{myblue}{RGB}{0,82,155}
\titleformat{\chapter}[display]
{\normalfont\bfseries\color{myblue} }
{%
\parbox[b]{\dimexpr \textwidth-4cm}{\LARGE\rmfamily\raggedright#1}\hfill % use a parbox for longer titles
\begin{tikzpicture}
\node[
outer sep=0pt,
text width=3cm,
minimum height=3cm,% expanded to accommodate two digits
fill=myblue,
font=\color{white}\fontsize{80}{90}\selectfont,
align=center
] (num) {\thechapter};
\node[
rotate=90,
anchor=south,
font=\color{black}\Large\normalfont
] at ([xshift=-5pt]num.west) {\textls[180]{\textsc{\chaptertitlename}}};
\end{tikzpicture}%
}
{4pt}
{\titlerule[2.5pt]\vskip3pt\titlerule}
\begin{document}
\setcounter{chapter}{9} % test two digits
\chapter{This is a bigger chapter title that needs to be adjusted here}
\end{document}