
我使用該titlesec
包來設定切片命令的樣式。但我對章節寬度或右邊距有疑問:
文字的寬度只能達到藍線,“組織”和“顯示”應該會中斷。我知道\\
這是一個選項,但在頁腳中還有引用的章節名稱:
因此,如果我使用\\
,頁腳中的文字為:「Konzepte für die semantische」...
造型是:
% > formats: \chapter
\titleformat{\chapter}[display]%
{\usekomafont{chapter}}%
{\vspace{-8em}\raggedleft{%
{\color{ctcolorchapterline}%
\rule[-5pt]{2pt}{5cm}}\quad%
{\color{ctcolorchapternum}
\fontsize{60}{60}\selectfont\thechapter}%
}%
}%
{-2.1em}%
{\raggedright}%
[\phantomsection]
答案1
您可以使用explicit
titlesec 選項將標題放置在\parbox
所需長度的 a 內;請注意,現在您需要使用#1
(通常在 的最後一個強制參數中\titleformat
)來取得分段單元的標題。我用作\textwidth-3em
框的寬度,但您可以根據需要更改此值。在下面的範例中,我提供了所使用顏色的一些定義,因為問題中沒有給出它們:
\documentclass{scrbook}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage{lmodern}% just for the example
\usepackage{lipsum}% just for the example
\usepackage{hyperref}
\colorlet{ctcolorchapterline}{cyan}
\colorlet{ctcolorchapternum}{cyan}
\titleformat{\chapter}[display]%
{\usekomafont{chapter}}%
{\vspace{-8em}\raggedleft{%
{\color{ctcolorchapterline}%
\rule[-5pt]{2pt}{5cm}}\quad%
{\color{ctcolorchapternum}
\fontsize{60}{60}\selectfont\thechapter}%
}%
}%
{-2.1em}%
{\parbox[b]{\dimexpr\textwidth-3em\relax}{\raggedright#1}}%
[\phantomsection]
\begin{document}
\chapter{A test chapter with a long title that will span two lines}
\lipsum[4]
\end{document}
作為艾格雷格已指出在他的評論,可以避免使用explicit
使用輔助巨集的選項:
\documentclass{scrbook}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{lmodern}% just for the example
\usepackage{lipsum}% just for the example
\usepackage{hyperref}
\colorlet{ctcolorchapterline}{cyan}
\colorlet{ctcolorchapternum}{cyan}
\newcommand\mychapformat[1]{%
\parbox[b]{\dimexpr\textwidth-3em\relax}{\raggedright#1}}
\titleformat{\chapter}[display]%
{\usekomafont{chapter}}%
{\vspace{-8em}\raggedleft{%
{\color{ctcolorchapterline}%
\rule[-5pt]{2pt}{5cm}}\quad%
{\color{ctcolorchapternum}
\fontsize{60}{60}\selectfont\thechapter}%
}%
}%
{-2.1em}%
{\mychapformat}%
[\phantomsection]
\begin{document}
\chapter{A test chapter with a long title that will span two lines}
\lipsum[4]
\end{document}
我添加\sectfont
到您的定義中,以便您可以保留 KOMA 截面單位中預設使用的粗體 sansseerf 字體:
\documentclass{scrbook}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{lmodern}% just for the example
\usepackage{lipsum}% just for the example
\usepackage{hyperref}
\colorlet{ctcolorchapterline}{cyan}
\colorlet{ctcolorchapternum}{cyan}
\newcommand\mychapformat[1]{%
\parbox[b]{\dimexpr\textwidth-3em\relax}{\raggedright#1}}
\titleformat{\chapter}[display]%
{\usekomafont{chapter}\sectfont}%
{\vspace{-8em}\raggedleft{%
{\color{ctcolorchapterline}%
\rule[-5pt]{2pt}{5cm}}\quad%
{\color{ctcolorchapternum}
\fontsize{60}{60}\selectfont\thechapter}%
}%
}%
{-2.1em}%
{\mychapformat}%
[\phantomsection]
\begin{document}
\chapter{A test chapter with a long title that will span two lines}
\lipsum[4]
\end{document}
請注意,titlesec
和 KOMA-Script 可能不完全相容(載入時您會收到來自 KOMA 類別的警告titlesec
);看KOMA-Script 和 titlesec 之間的不相容性