具有自訂字體大小的粗體和斜體小節標題

具有自訂字體大小的粗體和斜體小節標題

我已經定義了字體大小,即使您回答的問題幫助我解決了這種情況:

\usepackage{titlesec}

\titleformat{\chapter}

       {\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries}{\thechapter}{1em}{}

\titleformat{\section}

       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries}{\thesection}{1em}{}

\titleformat{\subsection}

       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries}{\thesubsection}{1em}{}

現在我必須只向該小節添加斜體樣式。非常感謝您的關注和寶貴的幫助!

答案1

\usepackage{titlesec}

\titleformat{\chapter}    
       {\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries}{\thechapter}{1em}{}

\titleformat{\section}    
       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries}{\thesection}{1em}{}

\titleformat{\subsection}    
       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries\itshape}{\thesubsection}{1em}{}

例如:

\documentclass{book}
\usepackage{titlesec}

\titleformat{\chapter}
       {\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries}{\thechapter}{1em}{}

\titleformat{\section}
       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries}{\thesection}{1em}{}

\titleformat{\subsection}
       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries\itshape}{\thesubsection}{1em}{}


\begin{document}

\chapter{Chapter}
\section{Section}
\subsection{Subsection}

\end{document}

章節格式設定

請注意,傾斜字體取代了斜體,因為該系列沒有可用的斜體形狀。

答案2

您應該\fontfamily盡可能避免明確的指示。您最好聲明無襯線字體,然後使用\sffamily;對於傾斜類型,添加\slshape.如果您使用 Helvetica 作為標題,則在文件中要求使用無襯線字體的所有情況下都應該使用它。

\documentclass{book}
\usepackage{helvet}
\usepackage{titlesec}

\titleformat{\chapter}
  {\normalfont\fontsize{16}{19}\sffamily\bfseries}
  {\thechapter}
  {1em}
  {}

\titleformat{\section}
  {\normalfont\fontsize{12}{17}\sffamily\bfseries}
  {\thesection}
  {1em}
  {}

\titleformat{\subsection}
  {\normalfont\fontsize{12}{17}\sffamily\bfseries\slshape}
  {\thesubsection}
  {1em}
  {}

\begin{document}
\chapter{Something}
\section{Title}
\subsection{Again}
\end{document}

請注意,您格式化的程式碼無法編譯。我更喜歡這種命令佈局\titleformat,它清楚地顯示了各種參數。

在此輸入影像描述

相關內容