0

While I intend to change the font of only a line in the document using one of the fonts presented in the LaTeX Font Catalogue (https://tug.org/FontCatalogue/mathfonts.html) (for example, concmath: https://tug.org/FontCatalogue/computerconcrete/), but the font of the whole of document will be changed.

I do as follows:

\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}

P.S. I am using LNCS as template and TeXstudio as editor.

3
1

If you look into concmath.sty you will find a line \renewcommand{\rmdefault}{ccr}. This gives you a clue about the family name of the font.

\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}

enter image description here

5
  • It works. But, now another problem: after \end{concmath}, a new paragrapg is generated. How to continue in the same line after \end{concmath} ? Thanks
    – Questioner
    Feb 11 '20 at 10:50
  • Don't use a \par in the environment if you don't want it (it was from your example). Feb 11 '20 at 10:52
  • Yes, I removed \par and it is now like this: \newenvironment{concmath}{\fontfamily{ccr}\selectfont} , but yet a new paragraph is created after \end{concmath} , strange!
    – Questioner
    Feb 11 '20 at 10:59
  • 1
    there is no paragraph, but you should probably use {\ignorespaces} as the second argument. Feb 11 '20 at 11:01
  • Yes, it works. Thanks
    – Questioner
    Feb 11 '20 at 11:03
2

I have extended your MWE so that it is compilable by adding `documentclass{article} as the first line.

% 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}

Processing this does typeset with a different font within the concmath environment while not changing fonts outside that.

However there were warning messages such as:

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

Perhaps your problem is with the LNCS template (whatever that is and however you have used it) and maybe other code you haven't shared. GOM

1
  • Thank you. I’m going to test your code tomorrow and share the result here.
    – Questioner
    Feb 10 '20 at 19:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.