编辑:我已经复制了整个 main.tex 以便澄清。
我希望标题使用 Helvetica 字体,正文和公式使用 Times New Roman 字体。我该如何具体更改公式和正文的字体?
\documentclass[a4paper,portrait]{article}
\usepackage[style=authoryear, backend=biber]{biblatex}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
citecolor=green,
urlcolor=blue
}
\addbibresource{references.bib}
\usepackage{helvet}
\renewcommand\familydefault{\sfdefault}
\usepackage{sectsty}
\allsectionsfont{\normalfont\sffamily}
\usepackage{nicematrix}
\usepackage{caption}
\usepackage{mathtools}
\usepackage{nicematrix}
\usepackage{blkarray, bigstrut}
\usepackage{lipsum}
\usepackage{nicefrac}
\usepackage{cancel}
\usepackage{textcomp}
\usepackage{subfig}
\usepackage{float}
\usepackage{geometry}
\usepackage{hyperref}
\usepackage{graphicx, multicol}
\usepackage{xcolor}
\usepackage{pseudocode}
\usepackage[mmddyy]{datetime}
\usepackage{fancyhdr}
\usepackage[framed]{matlab-prettifier}
\usepackage[T1]{fontenc}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[C]{\begin{minipage}{\textwidth}\centering\thepage\end{minipage}}
\newcommand{\note}[1]{\marginpar{\scriptsize \textcolor{red}{#1}}}
\DeclareMathOperator*{\argmin}{arg\,min}
\geometry{
left=2.27cm,
right=2.27cm,
top=0.27cm,
bottom=0.27cm,
columnsep=20pt,
}
%\renewcommand{\rmdefault}{bch}
\setlength{\columnseprule}{0.5pt}
\begin{document}
%\pagecolor{mybackgroundcolor4}
\pagenumbering{arabic}
\input{car2.tex}
%\lipsum[2-4]
\printbibliography
\end{document}
答案1
以下设置适用于 pdfLaTeX 和 LuaLaTeX。
\documentclass{article} % or some other suitable document class
\usepackage{iftex}
\ifpdftex % 'true' if we're running pdfLaTeX
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath} % Times Roman clone
\usepackage[scaled=0.86]{helvet} % Helvetica clone
\else
\usepackage{unicode-math}
\setmainfont{Times Roman}
\setmathfont{XITS Math}[Scale=MatchLowercase]
\setsansfont{Helvetica}[Scale=MatchLowercase]
\fi
\usepackage{sectsty}
\allsectionsfont{\sffamily} % use sans-serif in sectioning headers
\begin{document}
\section{Hello World}
Once upon a time\dots\quad $E=mc^2$ \quad xx\textsf{xx}
\end{document}