我為我的論文設定了以下章節格式:
% Selected packages from my pre-amble.
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{graphicx}
% Chapter format
\definecolor{myblue}{RGB}{0,82,155}
\titleformat{\chapter}[display]
{\normalfont\bfseries}
{\filleft\hspace*{-60pt}
\rotatebox[origin=c]{90}{%
\normalfont\color{black}\Large%
\textls[90]{\textsc{\chaptertitlename}}%
}\hspace{10pt}%
{\setlength\fboxsep{0pt}%
\colorbox{myblue}{\parbox[c][3cm][c]{2.5cm}{%
\centering\color{white}\fontsize{80}{90}\selectfont\thechapter}%
}}
}
{10pt}
{\titlerule[2.5pt]\vskip3pt\titlerule\huge}
產生以下結果:
但是,我希望章節標題能向上移動,如下所示:
我將不勝感激任何能讓我完成上述任務的貢獻!
謝謝 :)
答案1
這是一個解決方案。請注意,block
樣式更適合這一點。接下來,您應該新增水平規則作為optional
的參數\titleformat
:
\documentclass[a4paper, 11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{graphicx}
% Chapter format
\definecolor{myblue}{RGB}{0,82,155}
\titleformat{\chapter}[block]
{\normalfont\bfseries}
{\rlap{\makebox[\linewidth][r]{%
\rotatebox[origin=c]{90}{%
\normalfont\color{black}\Large%
\textls[90]{\textsc{\chaptertitlename}}%
}\hspace{10pt}%
{\setlength\fboxsep{0pt}%
\colorbox{myblue}{\parbox[c][3cm][c]{2.5cm}{%
\centering\color{white}\fontsize{80}{90}\selectfont\thechapter}%
}}}%
}}
{0pt}
{\huge\parbox{\dimexpr\linewidth-4cm}}[{\medskip\titlerule[2.5pt]}\vskip3pt\titlerule]
\usepackage{lipsum}
\begin{document}
\chapter{Serious Title. Serious Title. Serious Title. Serious Title. Serious Title.}
\lipsum[1]
\end{document}