大寫、粗體並有底線的章節標題

大寫、粗體並有底線的章節標題

我的文檔是這樣的(在main.tex):

% Document type: report (master/bachelor thesis)
\documentclass[a4paper,12pt,appendix]{report}

\input{template/FormatsAndDefs.tex} % here I have specified various format settings

\begin{document}
  \input{thesis.tex}
\end{document}

FormatsAndDefs.tex已經指定了章節標題的格式,如下所示:

\usepackage[T1]{fontenc}
\usepackage{titlesec}
% various other packages

\titleformat{\chapter}
  {\normalfont\Large\bfseries}{\thechapter}{.5em}{\vspace{.5ex}}[\titlerule]
\titlespacing*{\chapter}      
    {0pt}{0pt}{15pt}

所以我的標題章節格式如下: 在此輸入影像描述

如何使本章標題「簡介」全部大寫,同時保持粗體和底線?

我嘗試過使用\MakeUppercase

\titleformat{\chapter}
  {\normalfont\LARGE\bfseries}{\MakeUppercase{\thechapter}}{.5em}{\vspace{.5ex}}[\titlerule]

但章節仍然如圖所示。

答案1

您需要掌握章節標題,唯一的方法是將選項explicittitlesec:

在此輸入影像描述

\documentclass{report}

\usepackage[explicit]{titlesec}
\usepackage{lipsum}

\titleformat{\chapter}
  {\normalfont\Large\bfseries}{\thechapter \quad \MakeUppercase{#1}}{.5em}{\vspace{.5ex}}[\titlerule]
\titlespacing*{\chapter}
  {0pt}{0pt}{15pt}

\begin{document}

\chapter{Introduction}

\lipsum

\end{document}

此選項可讓您將explicit章節標題聲明為#1,現在您可以將其包含在 中\MakeUppercase

答案2

對各個部分使用正確的位置:規則之前的間距應該放在最後一個參數(可選的)中,這樣您就可以使用單參數巨集(例如 )來完成標題參數\MakeUppercase

\documentclass{report}

\usepackage{titlesec}
\usepackage{lipsum}

\titleformat{\chapter}
  {\normalfont\Large\bfseries}
  {\thechapter}
  {.5em}
  {\MakeUppercase}
  [\vspace{.5ex}\titlerule]

\titlespacing*{\chapter}
  {0pt}
  {0pt}
  {15pt}

\begin{document}

\chapter{Introduction}

\lipsum

\end{document}

在此輸入影像描述

相關內容