需要帮助格式化字体和标题周围的空间

需要帮助格式化字体和标题周围的空间

所以我是一个相当新的 Tex 用户,但我就是喜欢它,因为它让我避免点击太多按钮并能给出非常漂亮的方程式。所以我决定用 Tex 做我的一个项目报告并计划边做边学。我以前用 Tex 做过其他报告,但这次的格式似乎有点太苛刻了。通常,没有人真正发现差异,但现在他们过于强调小细节。所以我需要帮助。我确实尝试了其他答案中建议的很多解决方案,但它们似乎导致了其他奇怪的问题,比如弄乱目录中的字体大小、弄乱标题上下的空间(是的!大学要求这个空间相等,但多亏了这个网站,我已经找到了解决这个问题的方法),或者有些根本不起作用,很可能是由于包冲突。

\documentclass[hidelinks, chapterprefix=false, parskip=full, fontsize=12pt]{scrreprt}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{cancel}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage{scrlayer-scrpage}
\usepackage[A4, margin=2.7cm]{geometry}
\usepackage{CJKutf8}
\usepackage{pdfpages}
\usepackage{mathtools}
\usepackage{sectsty}
\usepackage{titlesec}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{placeins}
\usepackage{booktabs}
\makeatletter
\renewcommand*{\chapterformat}{%
  \mbox{\chapapp~\thechapter\autodot \enskip}%
}
\makeatother
\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{3}
%%%%%%%%%%%%%%%%%%%%%%%%%%%Horrible Looking Times Font%%%%%%%%%%%%%%%%%%%
\usepackage{fontspec}
\setmainfont{Times New Roman}
%%%%%%%%%%%%%%%%%%%%%%Playing with the spacing around headings%%%%%%%%%%%
\renewcommand*{\chapterheadendvskip}{%
  \vspace{1pt}%
}
\titlespacing{\section}{0pt}{*0}{*0}
\titlespacing{\subsection}{0pt}{*0}{*0}
\titlespacing{\subsubsection}{0pt}{*0}{*0}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%Adding dotted lines for Chapters in the TOC%%%%%%%%%%%%%%%
\makeatletter
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\ 
       \leaders\hbox{$\m@th
        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
        mu$}\hfil\nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%Font sizes%%%%%%%%%%%%%%%%%%%%%%%%
\chapterfont{\fontsize{16}{16}}
\sectionfont{\fontsize{15}{15}}
\subsectionfont{\fontsize{14}{14}}
\subsubsectionfont{\fontsize{12}{12}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%Making the Abstract start from the top%%%%%%%%%%%%%%%%
\usepackage{etoolbox}
\patchcmd{\abstract}{\null\vfil}{}{}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\chapterfont{\centering}
\addcontentsline{toc}{chapter}{Abstract}
\begin{document}
\cohead[Header]{Header}

\begin{abstract}
\chapterfont{\centering}
\pagenumbering{Roman}
\addcontentsline{toc}{chapter}{Abstract}
%%%%%%%%%%%Adding the header for the abstract page%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\thispagestyle{scrplain}

\cohead[Header]{Header}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter*{Abstract}
    This is the abstract.
    \\
    \\
    \textbf{Keywords:} Cool. Amazing. Awesome. Great. Fantastic.  
\end{abstract}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%Adding the header for the Table of Contents%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapterfont{\centering}
\tableofcontents
\thispagestyle{scrplain}
\cohead[Header]{Header}



\newpage
%%%%%%%%%%%%%%
\pagestyle{scrplain}
\renewcommand{\chaptermark}[1]{\markboth{#1}{#1}}

\cohead[Header]{Header}

%%%%%%%%%%%%%%%%%%%
\chapter{Introduction}
Awesome! The power is just great.
\section{My Darling}
ABCDeFGHIJKLMNOPQRSTUVWXYZ\\
abcdefghijklmnopqrstuvwxyz\\
\textit{I just jump from outta nowhere and bite prey\\
And sink my teeth in 'em, and fill 'em\\
Full of poison, and make a noise like a snake before I kill 'em\\
And let 'em know that I just don't feel 'em\\
And smack 'em with the backward E, the Eminem emblem\\
I was taught if you gonna murder somebody you should face him\\
Tell him why, look him dead in the eye, then waste him\\
And the dark shall emerge from the fiery depths of hell\\
Then swallow the shell, all the hollow who dwell\\
In the shadows of all who are willing to sell their souls\\
For this rap game and it g-g-goes\\}
\subsection{Man}
ABCDeFGHIJKLMNOPQRSTUVWXYZ\\
abcdefghijklmnopqrstuvwxyz\\
I am a God.
\subsubsection{Power of equations}
ABCDeFGHIJKLMNOPQRSTUVWXYZ\\
abcdefghijklmnopqrstuvwxyz\\
I have power.
\begin{equation} (a//b) = \int_\Omega vw \space dx \\ (a//b)_{\partial \Omega} = \int_{\partial \Omega} vw \space dx \\ u^{n + \frac{1}{2}} \approx \frac{(u^n + u^{n+1})}{2} \\ \partial_t u = \frac{u^*-u^n}{\Delta t} \end{equation}
\pagenumbering{arabic}





\renewcommand{\bibname}{References}
\begin{thebibliography}{}
\bibitem{1} Thunder Chad Dong,\textit{Projects}.
\end{thebibliography}
\end{document}

输出结果如下: 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述

这是我正在使用的最小工作代码格式示例。所以我需要以下内容。我确实尝试使用大量其他在线资源来正确完成以下内容,但我无法同时正确完成所有操作。

  • 一切都是该死的“MS-Word Times New Roman 12pt”。(我很清楚,实际上没有一种真正的 Times New Roman 字体,但我只想要一种接近 MS-Word 的字体)。坦率地说,我发现 MS-Word Times New Roman 字体不够干净,有时看起来甚至很糟糕,所以任何能欺骗眼睛认为它是“Times New Roman”的东西都足够好了,只要字体大小非常接近 MS-Word 的 Times New Roman 字体。

  • 章节标题大小为 16pt(根据 MS-Word Times New Roman 字体和大小)。它只需要足够迷惑读者,当读者从其他人准备的文档转到我的文档时,标题之间不会出现明显的大小差异。

  • 章节标题大小为 15pt(同样,MS-Word Times New Roman 字体和大小)

  • 子节标题大小为 14pt(同样,MS-Word Times New Roman 字体和大小)

  • 小节标题大小为 12pt(您做到了!MS-Word Times New Roman 字体和大小)

  • 数学大小为 10.5pt 并且使用那个该死的 MS-Word Times New ROMAN!

  • 标题大小为 10.5pt 粗体。目前,我每次写标题时都会指定这一点。我确实尝试过 caption 包,但后来标题就消失了,所以肯定存在一些冲突。如果有办法解决这个问题就好了,但这并不重要。我可以在每次写标题时都输入它,但这肯定不是一种有效的方法,所以如果你知道,看看如何重新定义该命令来实现这一点会很好。

我不知道为什么这个最小工作示例的摘要在目录中列出两次。它只出现在最小工作示例中。它没有出现在完整报告中。我已经用 Tex 完成了报告。

因此结果应该是这样的: 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述

如果您能帮助我或给我任何建议,请尽管说!我期待您的回复。

祝您度过美好的一天!

PS 我在 overleaf 上使用 XeLaTex 来渲染文档,我想是因为这样更容易使用字体。我不太确定。我愿意更改渲染引擎,只要它不会引起任何冲突。

答案1

我找到答案了!将下面的代码添加到序言中似乎可以解决问题。

%%%%%%%%Fonts%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{mathptmx}
\setkomafont{chapter}{\fontsize{16}{12}}
\setkomafont{section}{\fontsize{15}{12}}
\setkomafont{subsection}{\fontsize{14}{12}}
\setkomafont{subsubsection}{\fontsize{12}{12}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

相关内容