我用newpxtext
,但对于斜体我想使用Baskervaldx
。以下代码(借用自这答案)这样做是为了Chivo
默认对字体执行此操作,并且罗马包中的字体fourier
:
\documentclass{article}
\renewcommand{\rmdefault}{futs}
\usepackage[T1]{fontenc}
\usepackage{Chivo}
\begin{document}
\textrm{abc} (roman \texttt{fourier})
\textsf{abc} (sans \texttt{Chivo})
\end{document}
要查看这是否确实有效,请将上面的输出与代码的输出进行比较罗马字体未受影响。由于Chivo
只处理无衬线字体,罗马cm
在这种情况下,字体来自:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{Chivo}
\begin{document}
\textrm{abc} (roman \texttt{Computer Modern})
\textsf{abc} (sans \texttt{Chivo})
\end{document}
现在,当我Chivo
用newpxtext
和fourier
用替换Baskervaldx
(并重新定义斜体而不是罗马字)时,出现了问题:
\documentclass{article}
\renewcommand{\itdefault}{Baskervaldx}
\usepackage[T1]{fontenc}
\usepackage{newpxtext}
\begin{document}
\textrm{abc} (roman \texttt{New PX})
\textit{abc} (italic \texttt{Baskervaldx}, supposedly)
\end{document}
我知道在 LuaLaTeX 中指定字体属性要容易得多(通过使用fontspec
),但我需要能够在 PDFLaTeX 中做到这一点。
答案1
该\itdefault
命令没有定义仅用于斜体的字体系列,但形状参数(例如it
或sl
) 。此外,Baskervaldx
不是字体系列,但是Baskervaldx-LF
是。
如果你真的想在 PDFTeX 而不是 Unicode 引擎中做到这一点,请按以下步骤操作:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{newpxmath}
% Kitbashing together from t1zpllf.fd and t1baskervaldx-LF.fd
\makeatletter
\global\let\zpl@scaled\@empty
\gdef\zpl@lsfx{}
\DeclareFontFamily{T1}{weirdtext}{\zpl@scaled}
\DeclareFontShape{T1}{weirdtext}{b}{sc}{<-> \zpl@scaled zpl-Bold-lf-sc\zpl@lsfx-t1}{}
\DeclareFontShape{T1}{weirdtext}{b}{n}{<-> \zpl@scaled zpl-Bold-lf-t1}{}
\DeclareFontShape{T1}{weirdtext}{b}{scit}{<-> \zpl@scaled zpl-BoldItalic-lf-sc\zpl@lsfx-t1}{}
% \DeclareFontShape{T1}{weirdtext}{b}{it}{<-> \zpl@scaled zpl-BoldItalic-lf-t1}{}
\DeclareFontShape{T1}{weirdtext}{m}{sc}{<-> \zpl@scaled zpl-Regular-lf-sc\zpl@lsfx-t1}{}
\DeclareFontShape{T1}{weirdtext}{m}{n}{<-> \zpl@scaled zpl-Regular-lf-t1}{}
\DeclareFontShape{T1}{weirdtext}{m}{scit}{<-> \zpl@scaled zpl-Italic-lf-sc\zpl@lsfx-t1}{}
% \DeclareFontShape{T1}{weirdtext}{m}{it}{<-> \zpl@scaled zpl-Italic-lf-t1}{}
\DeclareFontShape{T1}{weirdtext}{bx}{sc}{<->ssub * zplLF/b/sc}{}
\DeclareFontShape{T1}{weirdtext}{bx}{n}{<->ssub * zplLF/b/n}{}
\DeclareFontShape{T1}{weirdtext}{bx}{scit}{<->ssub * zplLF/b/scit}{}
% \DeclareFontShape{T1}{weirdtext}{bx}{it}{<->ssub * zplLF/b/it}{}
% point to real slanted fonts
\DeclareFontShape{T1}{weirdtext}{m}{sl}{<-> \zpl@scaled zpl-Slanted-lf-t1}{}
\DeclareFontShape{T1}{weirdtext}{b}{sl}{<-> \zpl@scaled zpl-BoldSlanted-lf-t1}{}
\DeclareFontShape{T1}{weirdtext}{bx}{sl}{<->ssub * zplLF/b/sl}{}
\DeclareFontShape{T1}{weirdtext}{b}{scsl}{<->ssub * zplLF/b/scit}{}
\DeclareFontShape{T1}{weirdtext}{m}{scsl}{<->ssub * zplLF/m/scit}{}
\DeclareFontShape{T1}{weirdtext}{b}{scsl}{<->ssub * zplLF/b/scit}{}
\DeclareFontShape{T1}{weirdtext}{bx}{it}{
<-> ssub * weirdtext/b/it
}{}
\DeclareFontShape{T1}{weirdtext}{b}{it}{
<-> Baskervaldx-BolIta-lf-t1
}{}
\DeclareFontShape{T1}{weirdtext}{m}{it}{
<-> Baskervaldx-Ita-lf-t1
}{}
\makeatother
\renewcommand\familydefault{weirdtext}
\begin{document}
\textrm{abc} (roman \texttt{New PX})
\textit{abc} (italic \texttt{Baskervaldx})
\end{document}
这不会改变数学模式中的变量。您可能还希望mathastext
这样做。