
我想將文件的字體設定為由 產生的字體\textsf{}
,但在定義和定理等環境中保留預設字體。我試圖聲明
\documentclass[a4paper,12pt]{book}
\usepackage{amsthm}
\renewcommand{\familydefault}{\sfdefault}
\newtheorem{defi}{Definition}[chapter]
\newtheoremstyle{defi}% name
{3pt}% Space above
{3pt}% Space below
{crm}% Body font
{}% Indent amount
{\itshape}% Theorem head font
{:}% Punctuation after theorem head
{.5em}% Space after theorem head
{}% Theorem head spec (can be left empty, meaning ‘normal’)
\begin{document}
\begin{defi} Text with default font. \end{defi}
Text in sans-serif font.
\end{document}
但它不起作用,因為所有文字的字體都被定義為無襯線字體。我想知道我上面所說的正文字體是否正確。如果有人能給予提示,我將不勝感激。建議我不要使用這種無襯線字體來排版我的文件。所以,我想要一些建議。先致謝!
答案1
至少存在以下幾個問題:
字體應指定為
\rmfamily
,而不是cmr
;您必須在聲明之前呼叫新樣式
\newtheorem
。
嘗試這個:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\usepackage{amsmath,amsthm}
\renewcommand{\familydefault}{\sfdefault}
\newtheoremstyle{defi}% name
{3pt}% Space above
{3pt}% Space below
{\rmfamily}% Body font
{}% Indent amount
{\rmfamily\itshape}% Theorem head font
{:}% Punctuation after theorem head
{.5em}% Space after theorem head
{}% Theorem head spec (can be left empty, meaning "normal")
\theoremstyle{defi}
\newtheorem{defi}{Definition}[section] % not "chapter" because I'm using the
% "article" document class
\begin{document}
\section{A title}
Some text before the first definition: this text should be in ``sans-serif''.
\begin{defi}
This is a definition, and it should be in \verb|\rmfamily| (that is,
\emph{with} serifs).
\end{defi}
Some text after the definition, again in \verb|\sffamily|.
\end{document}
你可以自己檢查一下結果是否只是排版不佳:
事實上,用無襯線字體排版一篇文章(或者更糟的是,一份報告:你使用的是章節,不是嗎?)本身就已經是有問題的;但要設置,之內這樣的文檔,帶有襯線的定義......