如何使用 libertine 字体固定章节标题和章节编号?

如何使用 libertine 字体固定章节标题和章节编号?

我碰到章节风格并借用了代码(见下面的 MWE)。

原始代码使用字体pbk;我想改用libertine,因为它是整个论文使用的字体。

当我使用libertine标题字体变细时,我希望它更粗,像或类似的字体一样pbk

如何使用 libertine 使章节标题和编号看起来更美观?

MWE 代码

\documentclass{scrreprt}
\usepackage{lipsum}
%\usepackage{libertine}
\usepackage{tabularx}
\usepackage{xcolor,fix-cm}
\definecolor{numbercolor}{RGB}{150,20,0}

\makeatletter
\renewcommand\chapterheadstartvskip{\vskip50pt}

\newcommand\chaptitlefont{%
  \fontfamily{pbk}\fontseries{b}%
  \fontshape{n}\fontsize{25}{35}\selectfont\raggedright}

\newcommand\chapnumfont{%
  \fontfamily{pbk}\fontseries{bd}\fontshape{n}%
  \fontsize{1in}{0in}\selectfont\color{numbercolor}}

\renewcommand\chapterheadendvskip{\par\vskip2mm\hrule\vskip40pt}

\renewcommand*{\@@makechapterhead}[1]{\chapterheadstartvskip
  {%
    \setlength{\parindent}{\z@}\setlength{\parfillskip}{\fill}%
    \normalfont\sectfont\nobreak\size@chapter{}%
    \if@chapterprefix
      \let\@tempa\raggedsection
    \else
      \let\@tempa\@hangfrom
    \fi
    \@tempa{\ifnum \c@secnumdepth >\m@ne%
          \if@chapterprefix
            \expandafter\size@chapterprefix
          \else
            \expandafter\size@chapter
          \fi
          \if@chapterprefix
            \size@chapterprefix{}\endgraf\nobreak\vskip.5\baselineskip
          \fi
      \fi
    }%
\begin{tabularx}{\textwidth}{Xl}
{\parbox[b]{\linewidth}{\chaptitlefont #1}}
& \raisebox{-15pt}{\chapnumfont\thechapter}%
\end{tabularx}%
 \nobreak\chapterheadendvskip
}%
}
\renewcommand*{\@@makeschapterhead}[1]{%
  \chapterheadstartvskip%
  {\normalfont\sectfont\nobreak\size@chapter{}%
    \setlength{\parindent}{\z@}\setlength{\parfillskip}{\fill}%
    \raggedsection \interlinepenalty \@M 
\begin{tabularx}{\textwidth}{X}%
{\parbox[b]{\linewidth}{\chaptitlefont #1}%
\vphantom{\raisebox{-15pt}{\chapnumfont 1}}}
\end{tabularx}%
\par}%
  \nobreak\chapterheadendvskip%
}
\makeatother

\begin{document}
\tableofcontents
\chapter{Introduction}
\lipsum[1]
\chapter{Materials \& Methods}
\lipsum[2]
\chapter*{Curriculum Vitae}
\end{document}

输出:PBK
在此处输入图片描述

输出:浪荡子
在此处输入图片描述

答案1

您应该使用的姓氏是不是 libertine。只需更改\fontfamily{pbk}\rmfamily(这是因为默认情况下scrbook适用\sffamily于章节标题)。

\documentclass{scrreprt}
\usepackage{lipsum}
\usepackage{libertine}
\usepackage{tabularx}
\usepackage{xcolor,fix-cm}
\definecolor{numbercolor}{RGB}{150,20,0}

\makeatletter
\renewcommand\chapterheadstartvskip{\vskip50pt}

\newcommand\chaptitlefont{%
  \rmfamily\fontseries{b}%
  \fontshape{n}\fontsize{25}{35}\selectfont\raggedright}

\newcommand\chapnumfont{%
  \rmfamily\fontseries{b}\fontshape{n}%
  \fontsize{1in}{0in}\selectfont\color{numbercolor}}

\renewcommand\chapterheadendvskip{\par\vskip2mm\hrule\vskip40pt}

\renewcommand*{\@@makechapterhead}[1]{\chapterheadstartvskip
  {%
    \setlength{\parindent}{\z@}\setlength{\parfillskip}{\fill}%
    \normalfont\sectfont\nobreak\size@chapter{}%
    \if@chapterprefix
      \let\@tempa\raggedsection
    \else
      \let\@tempa\@hangfrom
    \fi
    \@tempa{\ifnum \c@secnumdepth >\m@ne%
          \if@chapterprefix
            \expandafter\size@chapterprefix
          \else
            \expandafter\size@chapter
          \fi
          \if@chapterprefix
            \size@chapterprefix{}\endgraf\nobreak\vskip.5\baselineskip
          \fi
      \fi
    }%
\begin{tabularx}{\textwidth}{Xl}
{\parbox[b]{\linewidth}{\chaptitlefont #1}}
& \raisebox{-15pt}{\chapnumfont\thechapter}%
\end{tabularx}%
 \nobreak\chapterheadendvskip
}%
}
\renewcommand*{\@@makeschapterhead}[1]{%
  \chapterheadstartvskip%
  {\normalfont\sectfont\nobreak\size@chapter{}%
    \setlength{\parindent}{\z@}\setlength{\parfillskip}{\fill}%
    \raggedsection \interlinepenalty \@M 
\begin{tabularx}{\textwidth}{X}%
{\parbox[b]{\linewidth}{\chaptitlefont #1}%
\vphantom{\raisebox{-15pt}{\chapnumfont 1}}}
\end{tabularx}%
\par}%
  \nobreak\chapterheadendvskip%
}
\makeatother

\begin{document}
\tableofcontents
\chapter{Introduction}
\lipsum[1]
\chapter{Materials \& Methods}
\lipsum[2]
\chapter*{Curriculum Vitae}
\end{document}

在此处输入图片描述

答案2

\libertineSB\chaptitlefont之前插入了之后\fontshape,但之后还是一样。

不过,我用pdflatex

\documentclass{scrreprt}
\usepackage{lipsum}
% For XeLaTeX use 
%\usepackage[type1]{libertine} instead
\usepackage{libertine}
\usepackage{tabularx}
\usepackage{xcolor,fix-cm}
\definecolor{numbercolor}{RGB}{150,20,0}

\makeatletter
\renewcommand\chapterheadstartvskip{\vskip50pt}

\newcommand\chaptitlefont{%
  \fontfamily{libertine}\fontseries{b}%
  \libertineSB% for example in here%%%%
  \fontshape{sc}\fontsize{25}{35}\selectfont\raggedright}

\newcommand\chapnumfont{%
  \fontfamily{libertine}\fontseries{b}\fontshape{sc}%
  \fontsize{1.0in}{0in}\selectfont\color{numbercolor}}

\renewcommand\chapterheadendvskip{\par\vskip2mm\hrule\vskip40pt}

\renewcommand*{\@@makechapterhead}[1]{\chapterheadstartvskip
  {%
    \setlength{\parindent}{\z@}\setlength{\parfillskip}{\fill}%
    \normalfont\sectfont\nobreak\size@chapter{}%
    \if@chapterprefix
      \let\@tempa\raggedsection
    \else
      \let\@tempa\@hangfrom
    \fi
    \@tempa{\ifnum \c@secnumdepth >\m@ne%
          \if@chapterprefix
            \expandafter\size@chapterprefix
          \else
            \expandafter\size@chapter
          \fi
          \if@chapterprefix
            \size@chapterprefix{}\endgraf\nobreak\vskip.5\baselineskip
          \fi
      \fi
    }%
\begin{tabularx}{\textwidth}{Xl}
{\parbox[b]{\linewidth}{\chaptitlefont #1}}
& \raisebox{-15pt}{\chapnumfont\thechapter}%
\end{tabularx}%
 \nobreak\chapterheadendvskip
}%
}
\renewcommand*{\@@makeschapterhead}[1]{%
  \chapterheadstartvskip%
  {\normalfont\sectfont\nobreak\size@chapter{}%
    \setlength{\parindent}{\z@}\setlength{\parfillskip}{\fill}%
    \raggedsection \interlinepenalty \@M 
\begin{tabularx}{\textwidth}{X}%
{\parbox[b]{\linewidth}{\chaptitlefont #1}%
\vphantom{\raisebox{-15pt}{\chapnumfont 1}}}
\end{tabularx}%
\par}%
  \nobreak\chapterheadendvskip%
}
\makeatother

\begin{document}
\tableofcontents
\chapter{Introduction}
\lipsum[1]
\chapter{Materials \& Methods}
\lipsum[2]
\chapter*{Curriculum Vitae}
\end{document}

在此处输入图片描述

相关内容