自定义章节、节和小节的样式、位置和字体

自定义章节、节和小节的样式、位置和字体

我很想复制下面示例图中所示的章节和节标题的布局 在此处输入图片描述

在上图中,我们以新章节(“离散随机变量”)开始一章

有哪些方法可以自定义章节标题、节标题等的位置、布局和字体?

对于非章节开头的页面,格式为:

在此处输入图片描述

我正在使用报告文档类以防相关


\documentclass[12pt]{report}

% Font packages and settings %
\usepackage[T1]{fontenc}
\usepackage{Baskervaldx}
\usepackage[Baskervaldx,upint]{newtxmath}

% Document layout and appearence packages
\usepackage{titlesec}

% Packages for figures, schematics, diagrams, and drawings %
\usepackage{graphicx}\graphicspath{{figures/}}
\usepackage{tikz}
    \usetikzlibrary{arrows,arrows.meta,patterns,decorations,shapes.geometric}
    \usetikzlibrary{decorations.markings,decorations.pathmorphing,decorations.pathreplacing}

\begin{document}

    \chapter{Oh Chapter My Chapter}

        \section{Section}

\end{document}

答案1

以下是制作类似布局的方法:

\documentclass[12pt]{report}

% Font packages and settings %
\usepackage[T1]{fontenc}
\usepackage{Baskervaldx}
\usepackage[Baskervaldx,upint]{newtxmath}

\setcounter{secnumdepth}{0}
% Document layout and appearence packages
\usepackage{titlesec}
\titleformat{\chapter}[display]{\bfseries\filcenter}{\large\textsc{\chaptername} \thechapter}{3ex}{\Large\MakeUppercase}
\titlespacing*{\chapter}{0pt}{0ex}{6ex}

\titleformat{\section}[block]{\bfseries\filcenter}{}{0pt}{\large\textsc}
% Packages for figures, schematics, diagrams, and drawings %
\usepackage{graphicx}\graphicspath{{figures/}}
\usepackage{tikz}
    \usetikzlibrary{arrows,arrows.meta,patterns,decorations,shapes.geometric}
    \usetikzlibrary{decorations.markings,decorations.pathmorphing,decorations.pathreplacing}

\usepackage{lipsum}

\begin{document}

\tableofcontents

 \chapter{Oh Chapter! Where Art Thou?}
 \lipsum[11]

        \section{Section}

\end{document} 

在此处输入图片描述 在此处输入图片描述

答案2

如果您愿意使用memoir类(的超集和类book,那么我认为以下内容可能会提供您想要的内容。reportarticle

% chapsecprob.tex SE 532267 change chapter and section styles

\documentclass{memoir}
\usepackage{lipsum}

\makechapterstyle{yourchapterstyle}{% % a slight modification to the thatcher chapterstyle
  \chapterstyle{thatcher}%
  \renewcommand{\afterchapternum}{}% Remove the rule
}

\setsecheadstyle{\scshape\centering} % section styling

\makepagestyle{yourpagestyle}        % page header/footer styling
  \makeevenfoot{yourpagestyle}{}{}{} % no even page footer
  \makeoddfoot{yourpagestyle}{}{}{}  % no odd page footer
  \makeevenhead{yourpagestyle}{\thepage}{\leftmark}{} % even page header
  \makeoddhead{yourpagestyle}{}{\leftmark}{\thepage}  % odd page header

\begin{document}
\chapterstyle{yourchapterstyle}
\pagestyle{yourpagestyle}
\tableofcontents
\clearpage
\chapter[Random variables and probability distributions]%
  [Random variables]%
  {Random variables and probability distributions}
% \chapter[for ToC][for header]{Title in document}
\lipsum[1]
\section{Discrete Random Variables}
\lipsum[2]
\section*{Unnumbered section}
\addcontentsline{toc}{section}{Unnumbered section} % only if you want the unnumred section in the ToC
\lipsum[3]

\lipsum[4]

\clearpage
\lipsum[5]

\end{document}

阅读memoir文档 ( texdoc memoir) 了解更多信息并更改上述内容以满足您的需求。我专注于您的布局而不是字体的使用。

相关内容