I'm using the font family mathptmx and I want to use baskervald only for the alphabet Q (not always but in many specific situation). So I defined
\def\Q{{\fontfamily{ybv}\selectfont
Q}}
But this does not work. How should I modify this?
I'm using the font family mathptmx and I want to use baskervald only for the alphabet Q (not always but in many specific situation). So I defined
\def\Q{{\fontfamily{ybv}\selectfont
Q}}
But this does not work. How should I modify this?
If I try this code
\documentclass{article}
\usepackage{mathptmx}
\def\Q{{\fontfamily{ybv}\selectfont Q}}
\begin{document}
Q\Q
\end{document}
I get the following warning on the console
LaTeX Font Warning: Font shape `OT1/ybv/m/n' undefined
(Font) using `OT1/cmr/m/n' instead on input line 8.
It means that Baskervald is not available in the default OT1 encoding.
Changing this to
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\def\Q{{\fontfamily{ybv}\selectfont Q}}
\begin{document}
Q\Q
\end{document}
might seem to solve the issue. However, you should be aware of two problems:
mathptmx has been created a couple of decades ago as a way to get not too heavy PostScript output from LaTeX documents;
\def is quite a dangerous command for being used by a beginner (or even an advanced user).
Issue 1 is solved by using a properly designed Times-like typeface with accompanying math font; issue 2 is solved by \newcommand.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath}
\newcommand\Q{{\fontfamily{ybv}\selectfont Q}}
\begin{document}
Q\Q
\end{document}
\def\box#1{\framebox[2\width]{#1}} (silly definition, just to make you see the issue) and use \box{ABC} in the document. With \newcommand you don't risk to redefine a command you don't know about.
– egreg
Feb 20 '20 at 18:23
\def\Q{{\fontfamily{ybv}\fontsize{1cm}{2cm}\selectfont Q}}, see e.g. https://tex.stackexchange.com/a/153659. It is general not recommended to use a single-letter macro like\Q, nor to use\defto define them (rather you should use\newcommand. – Feb 20 '20 at 05:12