我打算使用 LaTeX 字体目录仅更改某一行的字体,但整个文档都会被更改

我打算使用 LaTeX 字体目录仅更改某一行的字体,但整个文档都会被更改

虽然我打算使用 LaTeX 字体目录中提供的字体之一来更改文档中一行的字体(https://tug.org/FontCatalogue/mathfonts.html) (例如,康科思https://tug.org/FontCatalogue/computerconcrete/),但整个文档的字体将会改变。

我做如下:

\usepackage{concmath}
\usepackage[T1]{fontenc}
\newenvironment{concmath}{\fontfamily{concmath}\selectfont}{\par}

\begin{document} 
    The font of this text must be remained as it is by default.
    \begin{concmath}
            I want to change only the font of this line using one of the fonts in The LaTeX Font Catalogue.
    \end{concmath}
    The font of this text must be remained as it is by default.
 \end{document}

PS 我使用 LNCS 作为模板,使用 TeXstudio 作为编辑器。

答案1

如果你查看 concmath.sty,你会发现一行\renewcommand{\rmdefault}{ccr}。这为你提供了有关字体系列名称的线索。

\documentclass{article}  % 
\usepackage[T1]{fontenc}
\newenvironment{concmath}{\fontfamily{ccr}\selectfont}{\par}

\begin{document}
    The font of this text must be remained as it is by default.
    \begin{concmath}
            I want to change only the font of this line using one of the fonts in The LaTeX Font Catalogue.
    \end{concmath}
    The font of this text must be remained as it is by default.
 \end{document}

在此处输入图片描述

答案2

我已经扩展了你的 MWE,以便通过添加“documentclass{article}”作为第一行来进行编译。

% fontprob.tex SE 527806  local font change

\documentclass{article}  % added
\usepackage{concmath}
\usepackage[T1]{fontenc}
\newenvironment{concmath}{\fontfamily{concmath}\selectfont}{\par}

\begin{document} 
    The font of this text must be remained as it is by default.
    \begin{concmath}
            I want to change only the font of this line using one of the fonts in The LaTeX Font Catalogue.
    \end{concmath}
    The font of this text must be remained as it is by default.
 \end{document}

处理这个确实会在环境内使用不同的字体进行排版,concmath而不会改变环境外的字体。

然而出现了如下警告信息:

  LaTeX Font Warning: Font shape `T1/concmath/m/n' undefined
  (Font)              using `T1/cmr/m/n' instead on input line 10.

也许您的问题出在 LNCS 模板上(无论它是什么,无论您如何使用它)或者可能是您尚未共享的其他代码。GOM

相关内容