暂时禁用主字体

暂时禁用主字体

在下面的 MWE 中,我将其定义cabin为默认字体。

\documentclass[12pt]{book}
\usepackage[sfdefault]{cabin} 
\usepackage{lipsum}

\begin{document}
\thispagestyle{empty}
\lipsum[12]
\vspace{10pt}

% I would like to use the default font for this paragraph.
\lipsum[3]
\vspace{10pt}

% I would now like to restore the default font (cabin).
\lipsum[13]
\end{document}

输出:

在此处输入图片描述

我如何才能禁用主字体以打印第二段仅有的使用默认字体?

有人知道默认字体是什么吗?如果不是 Times New Roman,我该如何仅为第二段指定 Times New Roman?

答案1

我不确定原因是什么。无论如何,使用 pdflatex 时,您需要知道您获得的是 Times(恐怕不是 Times New Roman)或其家族名称的克隆,并且您可以在几个中进行选择。

\documentclass[12pt]{book}
\usepackage[sfdefault]{cabin} 
\usepackage{lipsum}

\begin{document}

\lipsum[12]

\vspace{10pt}

% I would like to use the default font for this paragraph.
{\fontfamily{ptm}\selectfont % the legacy clone
\lipsum[3][1-4]}

\vspace{10pt}

% I would like to use the default font for this paragraph.
{\fontfamily{qtm}\selectfont % TeX Gyre
\lipsum[3][1-4]}

\vspace{10pt}

% I would like to use the default font for this paragraph.
{\fontfamily{ntxtlf}\selectfont % NewTX
\lipsum[3][1-4]}

\vspace{10pt}

% I would now like to restore the default font (cabin).
\lipsum[13]

\end{document}

在此处输入图片描述

但是,您想为该作业定义一个环境。

\documentclass[12pt]{book}
\usepackage[sfdefault]{cabin} 
\usepackage{lipsum}

\newenvironment{usetimes}{% use ptm, qtm, ntxtlf or other
  \par\fontfamily{ptm}\selectfont}{\par}

\begin{document}

\lipsum[12]

\vspace{10pt}

\begin{usetimes}
\lipsum[3][1-4]
\end{usetimes}

\vspace{10pt}

% I would now like to restore the default font (cabin).
\lipsum[13]
\end{document}

在此处输入图片描述

答案2

默认字体是 Computer Modern。如果您想使用 Times New Roman,则必须从编译器 pdfLaTeX 切换到 LuaLaTex 或 XeLaTeX。关于字体有很多文档。如果您想深入了解,请开始搜索有关 open type 和 type 1 字体的信息,然后继续。为了简单起见,使用 LuaLaTex 或 XeLaTeX 作为编译器,并更改序言,如下所示:

\documentclass[12pt]{book}
\usepackage{fontspec} %for LuaLaTeX and XeLaTeX if you use an open type font
\usepackage{polyglossia}%it is like babel but for LuaLaTeX and XeLaTeX

\usepackage{cabin} 

\usepackage{lipsum}

\begin{document}

\thispagestyle{empty}
\lipsum[12] %default is computer modern
\vspace{10pt}

%usually for famous fonts you can use just their name if they are already installed in your pc
{\setmainfont{Times New Roman} 
\lipsum[3]
}
\vspace{10pt}

{\setmainfont{Arial}
\lipsum[13]
}
\vspace{10pt}

%you can also specify fon by \usefont{<encoding>}{<family>}{<series>}{<shape>}
{\usefont{T1}{qpl}{m}{sc}
\lipsum[15]
}
\end{document}


相关内容