命令 \textbf 和 \texttt 不起作用。
XeLaTeX 字体警告:字体形状“TU/pcr/m/n”未定义
.cls 文件:
\RequirePackage{fmtcount}
\newcommand{\setthesistype}[1]{\def\@thesistype{#1}}
\let\thesistype\setthesistype
\newcommand{\show@thesistype}{\@thesistype}
%\newcommand{\uselogo}{\def\@uselogo{yes}}
\global\let\@examiner\@empty
\newcommand{\setexaminer}[1]{\def\@examiner{#1}}
\let\examiner\setexaminer
\global\let\@supervisor\@empty
\newcommand{\setsupervisor}[1]{\def\@supervisor{#1}}
\let\supervisor\setsupervisor
\newcommand{\birthinfo}[1]{\normalsize \GetTranslation{born} #1}
\newcommand{\matricnumber}[1]{\normalsize \GetTranslation{matriculationnumber}: #1}
\let\oldmaketitle\maketitle
\renewcommand{\maketitle}{
\begin{titlepage}
\ifx\@uselogo\@empty
\null\vskip16mm
\else
\begin{flushright}
\includegraphics[height=16mm]{gfx/ubn-logo}
\includegraphics[height=35mm]{gfx/hrl-logo}\par
\end{flushright}
\fi
\null\vfil\vskip60pt
\centering
\begin{minipage}{0.618034\paperwidth}
\centering
{\Large \textsc{\show@thesistype}\par}\vspace{1ex}
\rule{\linewidth}{1pt}\\
{\Huge\bfseries\@title\par}
\rule{\linewidth}{1pt}\vspace{2cm}
\end{minipage}\par
{\emph{\GetTranslation{written-submitted}}\\\vspace{1em}
\Large
\begin{tabular}[t]{c}
\@author
\end{tabular}\par}\vspace{2cm}
{\def\and{\end{tabular}\\ \personprefix & \renewcommand{\arraystretch}{1.0}\begin{tabular}[t]{l} }
\def\arraystretch{1.5}
\newcounter{examinercnt}
\setcounter{examinercnt}{0}
\gdef\personprefix{\stepcounter{examinercnt}\ordinal{examinercnt} \GetTranslation{examiner}:}
\Large
\global\let\@needtable\@empty
\ifx\@examiner\@empty\else
\gdef\@needtable{yes}
\fi
\ifx\@supervisor\@empty\else
\gdef\@needtable{yes}
\fi
\ifx\@needtable\@empty\else%
\begin{tabular}[t]{rl}
\ifx\@examiner\@empty\else\personprefix & \renewcommand{\arraystretch}{1.0}\begin{tabular}[t]{l}\@examiner\end{tabular}\fi\renewcommand{\arraystretch}{1.5}\\
\ifx\@supervisor\@empty\else
\gdef\personprefix{}
% \makeatletter
% \global\def\personprefix\@empty
% \makeatother
\GetTranslation{supervisors}: & \renewcommand{\arraystretch}{1.0}\begin{tabular}[t]{l}\@supervisor\end{tabular}\renewcommand{\arraystretch}{1.5}
\fi
\end{tabular}%
\fi}
\vfill\null
{\@date\par}
\end{titlepage}
}
\RequirePackage{iftex}
\RequirePackage[margin=3cm,bindingoffset=3mm,includehead,includefoot]{geometry}
\RequirePackage{fancyhdr,emptypage,xcolor,graphicx,subcaption,booktabs}
\RequirePackage[labelfont=bf,format=hang]{caption}
\definecolor{ub-blue}{cmyk}{1,0.7,0,0}
\definecolor{ub-yellow}{cmyk}{0,0.3,1,0}
\definecolor{ub-gray}{cmyk}{0,0,0.15,0.55}
\RequirePackage[hidelinks,breaklinks]{hyperref}
\hypersetup{colorlinks=true,
linkcolor=black,
filecolor=black,
urlcolor=ub-blue,
citecolor=ub-blue, %black, %darkblue,
bookmarksnumbered=true
}
\fancypagestyle{mlai-fancy}{
\fancyhf{}
\fancyfoot[LE,RO]{\sffamily\small\thepage}
\fancyhead[LE]{\sffamily\small\leftmark}
\fancyhead[RO]{\sffamily\small\rightmark}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE,RO]{\sffamily\small\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\setlength{\headheight}{13pt}
\pagestyle{mlai-fancy}
\AtBeginDocument{\thispagestyle{plain}}
\RequirePackage[intlimits]{mathtools}
\RequirePackage[amsmath,thmmarks]{ntheorem}
\newenvironment{abstract}{
\small%
\begin{center}
\bfseries\GetTranslation{abstractname}
\end{center}%
\quotation%
}{\endquotation}
\ifPDFTeX
\wlog{PDF LaTeX detected}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\RequirePackage{textcomp,tgpagella}
\else
\ifLuaTeX
\wlog{LuaLaTeX detected}
\RequirePackage{fontspec}
\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
\else
\ifXeTeX
\wlog{XeLaTeX detected}
\RequirePackage{fontspec}
\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
\fi
\fi
\fi
答案1
您发布的内容本身并不能重现该问题。可能序言或其他软件包也在这样做,\usepackage{courier}
或者\usepackage{times}
是用于与字体编码(例如 OT1、T1 等)交互的软件包,这些编码适用于 pdfLaTeX,而不是 TU,TU 成为 XeLaTeX 的默认字体编码,用于将“Unicode”字体装入 LaTeX 字体系统。
\documentclass{article}
\RequirePackage{iftex}
\ifPDFTeX
\wlog{PDF LaTeX detected}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\RequirePackage{textcomp,tgpagella}
\else
\ifLuaTeX
\wlog{LuaLaTeX detected}
\RequirePackage{fontspec}
\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
\else
\ifXeTeX
\wlog{XeLaTeX detected}
\RequirePackage{fontspec}
\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
\fi
\fi
\fi
% \usepackage{times}
% or
\usepackage{courier}
\begin{document}
\texttt{foo}
\showoutput\thispagestyle{empty}
\end{document}
% Local variables:
% TeX-engine: xetex
% End:
并且有警告:
LaTeX Font Info: Trying to load font information for TU+pcr on input line 27
.
LaTeX Font Info: No file TUpcr.fd. on input line 27.
LaTeX Font Warning: Font shape `TU/pcr/m/n' undefined
(Font) using `TU/lmr/m/n' instead on input line 27.
\showoutput
日志中触发的额外信息
...\hbox(7.05+0.10999)x345.0, glue set 314.16fil
....\hbox(0.0+0.0)x15.0
....\TU/lmr/m/n/10 foo
....\kern 0.0
确认这一点。
因此,您应该确定您的设置中哪些内容会导致使用特定于 PDFLaTeX 的字体包。您发布的内容(在撰写本文时)不是。
在调查这个问题时,我遇到了 LaTeX NFSS 的一个奇怪现象。在上面我使用了\usepackage{times}
而不是,\usepackage{courier}
并且预期完全相同。虽然警告确实是一样的
LaTeX Font Info: Trying to load font information for TU+pcr on input line 27
.
LaTeX Font Info: No file TUpcr.fd. on input line 27.
LaTeX Font Warning: Font shape `TU/pcr/m/n' undefined
(Font) using `TU/lmr/m/n' instead on input line 27.
盒子\showoutput
日志显示:
...\hbox(7.05+0.10999)x345.0, glue set 313.33fil
....\hbox(0.0+0.0)x15.0
....\TU/ptm/m/n/10 foo
....\kern 0.0
....\glue 3.33 plus 1.665 minus 1.11
注意其中的意外情况\TU/ptm...
。
PDF 确实包含已公布的 Latin Modern 字体。但 showoutput 日志使用了一个字体名称宏,系统必须知道它在其他地方不可用。必须在日志中查找被TU/lmr
替换为的更高版本TU/ptm
,但TU/ptm
此处仍使用该宏。