如何更改章节、表格、目录、图表的字体和大小?

如何更改章节、表格、目录、图表的字体和大小?

我怎样才能将所有\addchap{ }(章节)的字体更改为“Times”字体及其大小(最好\large大胆的)?

图表列表、表格列表和目录也应具有如上所述的相同结构。

这是我的代码示例。(如果您需要更多代码,请告诉我,我可能遗漏了一些东西)。

\documentclass[12pt,chapterprefix]{scrreprt} % for bigger size of text 
\usepackage{times}
\usepackage[english]{babel}
\renewcaptionname{english}{\listfigurename}{Figures}
\renewcaptionname{english}{\listtablename}{Tables}

\begin{center}
\listoftables
\end{center}
\begin{center}
\listoffigures
\end{center}
\renewcommand{\figurename}{Figure}
\renewcommand{\listtablename}{Tables}


\usepackage{titlesec}
\titleformat{\section}[block]{ \Large \filcenter}{}{1em}{}%\sffamily
\titleformat{\subsection}[hang]{\filright \itshape }{}{1em}{} 
%\titleformat{\chapter}[hang]{\filright \bfseries }{}{1em}{} <- if that code is used, yes the size changes, but my "Chapter [Number]" (see picture) disappears on the page itself but not in the toc.

\begin{center}
\tableofcontents\thispagestyle{empty}
\end{center

 %chapter in toc and on page (numbering)
\renewcommand*{\raggedchapter}{\centering}
\renewcommand*{\chaptermarkformat}{\chapappifchapterprefix{\nobreakspace}\thechapter\autodot:\enskip}

\let\originaladdchaptertocentry\addchaptertocentry
\renewcommand*{\addchaptertocentry}[2]{%
  \IfArgIsEmpty{#1}
    {\originaladdchaptertocentry{#1}{#2}}
    {\originaladdchaptertocentry{\chapappifchapterprefix{\nobreakspace}#1\autodot}{#2}}%
}
\RedeclareSectionCommand[
  tocentrynumberformat={\def\autodot{:}},
  tocdynnumwidth
]{chapter}

\begin{document}
\addchap{Introduction}\setcounter{page}{1} % unnumbered chapter

在此处输入图片描述

答案1

由于您使用 KOMA Script 文档类,请参阅 KOMA Script 手册中的“表 3.2:可以更改字体样式的元素”(可在此处找到:https://komascript.de/~mkohm/scrguien.pdf)。

(请注意,该times包是过时的,我在这个答案中将其更改为newtxtext,您也可以考虑使用 Stix Two Text。)

您不需要titlesec您想要的东西,而是添加\setkomafont{chapter}{\rmfamily \large}到您的序言中:

\documentclass{scrreprt}
\usepackage{newtxtext}
\setkomafont{chapter}{\rmfamily \large}
\usepackage{blindtext}%just to add a sample document

\begin{document}
\blinddocument
\end{document}

在此处输入图片描述

如果你想要全部文档标题(章节、节、小节……等)使用衬线字体作为正文,然后您可以使用sfdefaults=false带有 documentclass 的选项(感谢 Sam Carter 指出此类选项的更改名称):

\documentclass[sfdefaults=false]{scrreprt}
\usepackage{newtxtext}
\addtokomafont{chapter}{\large}
\usepackage{blindtext}%just to add a sample document

\begin{document}
\blinddocument
\end{document}

在此处输入图片描述

这两者也将改变表格列表和图表列表标题(它们也是章节)。

(另请注意,更改章节的默认行为将使您重新定义节、小节等,否则它们看起来很奇怪。您确定要更改默认设置吗?)

答案2

这个问题太长了,无法添加更多评论。

警告: 不要将该包titlesec与 KOMA-Script 类一起使用。

似乎只有章节标题才应该加粗。然后你可以使用

\addtokomafont{disposition}{\mdseries}

请注意,disposition所有标题元素均使用字体元素,例如chaptersectionsubsection

更改标题元素的字体(如chapter或已在示例中使用的section) you can use either\setkomafont and\addtokomafont or you can add optionfont \RedeclareSectionCommand`。to

\RedeclareSectionCommand[
  font=\bfseries\large,% does the same as \setkomafont{chapter}{\bfseries\large}
  tocentrynumberformat={\def\autodot{:}},
  tocdynnumwidth
]{chapter}

您还可以添加选项来更改章节标题前后的垂直空间。请阅读文档以获取更多信息。

章节和小节的设置:

% section
\RedeclareSectionCommand[font=\sffamily\Large]{section}% does the same as \setkomafont{section}{\sffamily\Large}
% subsection
\RedeclareSectionCommand[
  %indent=1em,% <- add this if the subsections should be indented
  font=\itshape% changes the font, does the same as \setkomafont{subsection}{\itshape}
]{subsection}

要使section标题居中,但不使标题居中subsectionsubsubsection请使用

\let\originalsectionlinesformat\sectionlinesformat
\renewcommand\sectionlinesformat[4]{%
  \Ifstr{#1}{section}
    {\centering #3#4}% centers section headings
    {\originalsectionlinesformat{#1}{#2}{#3}{#4}}% original definition for other section levels
}

如果只对章节(和部分)进行编号,请添加

\setcounter{secnumdepth}{\chapternumdepth}

回到序言。

在环境中不要使用\tableofcontents\listoffigures和。它们的标题自动居中。如果 ToC、LoF 和 LoT 中的页面应使用页面样式,请使用\listoftablescenter\renewcommand\raggedchapter{\centering}empty

% use page style empty in in ToC, LoF and LoT
\AfterTOCHead{\thispagestyle{empty}\pagestyle{empty}}
\AfterStartingTOC{\clearpage}

删除\renewcommand{\figurename}{Figure}\renewcommand{\listtablename}{Tables}。如果你真的想重新定义\figurename使用

\renewcaptionname{english}{\figurename}{Figure}% Figure is default?

\listtablename已被 重新定义\renewcaptionname

例子:

\documentclass[
  12pt,
  chapterprefix,
  sfdefaults=false% no sans serif headings etc., needs version 3.39 or newer
  ]{scrreprt} % for bigger size of text 
%\providecommand*\Ifstr{\ifstr}% needed up to and including KOMA-Script version 3.27, see https://komascript.de/faq_deprecatedif
\usepackage{blindtext}% only for dummy text
\usepackage{newtxtext}% <- changed
\usepackage[english]{babel}

\setcounter{secnumdepth}{\chapternumdepth}% only parts and chapters should be numbered

\addtokomafont{disposition}{\mdseries}% headings of section, subsection etc. should not be bold

%chapter in toc and on page (numbering)
\RedeclareSectionCommand[
  font=\bfseries\large,% does the same as \setkomafont{chapter}{\bfseries\large}
  tocentrynumberformat={\def\autodot{:}},
  tocdynnumwidth
]{chapter}

\renewcommand\raggedchapter{\centering}% center chapter headings
\renewcommand*{\chaptermarkformat}{\chapappifchapterprefix{\nobreakspace}\thechapter\autodot:\enskip}

\let\originaladdchaptertocentry\addchaptertocentry
\renewcommand*{\addchaptertocentry}[2]{%
  \IfArgIsEmpty{#1}
    {\originaladdchaptertocentry{#1}{#2}}
    {\originaladdchaptertocentry{\chapappifchapterprefix{\nobreakspace}#1\autodot}{#2}}%
}

% section
\RedeclareSectionCommand[font=\sffamily\Large]{section}% does the same as \setkomafont{section}{\sffamily\Large}
% subsection
\RedeclareSectionCommand[
  %indent=1em,% <- add this if the subsections should be indented
  font=\itshape% changes the font, does the same as \setkomafont{subsection}{\itshape}
]{subsection}

% format headings with style=section, eg. section, subsection and subsubsection
\let\originalsectionlinesformat\sectionlinesformat
\renewcommand\sectionlinesformat[4]{%
  \Ifstr{#1}{section}
    {\centering #3#4}% centers section headings
    {\originalsectionlinesformat{#1}{#2}{#3}{#4}}% original definition for other section levels
}

% use page style empty in in ToC, LoF and LoT
\AfterTOCHead{\thispagestyle{empty}\pagestyle{empty}}
\AfterStartingTOC{\clearpage}

% rename LoF and LoT
\renewcaptionname{english}{\listfigurename}{Figures}
\renewcaptionname{english}{\listtablename}{Tables}

\begin{document}
\pagenumbering{roman}
\tableofcontents
\listoftables
\listoffigures
\cleardoubleoddpage% <- changed
\pagenumbering{arabic}
\addchap{Introduction}
\Blindtext
\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument
\end{document}

运行三次即可获得

在此处输入图片描述

在此处输入图片描述

相关内容