我只想在数学模式下使用 Linux libertine 字体来显示“Q”。换句话说,我想创建一个数学运算符,例如:
\newcomand{\Q}{Q Linux libertine font}.
谢谢。
答案1
像这样吗?
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\usepackage{amsmath}
\DeclareMathAlphabet{\mathlinlib} {T1}{LinuxLibertineT-TLF}{m}{n}
\SetMathAlphabet{\mathlinlib}{bold}{T1}{LinuxLibertineT-TLF}{b}{n}
% Slightly inefficient, but let's keep it simple:
\DeclareMathOperator{\Q}{\mathlinlib{Q}}
% (Use "\DeclareMathOperator*" to get limits, should you ever want to.)
\begin{document}
This is cm-super. Check that \verb|\Q| behaves as an operator:
\begin{align*}
\log x && \log(x) && \log\log(x) \\
\Q x && \Q(x) && \Q\Q(x)
\end{align*}
Works with bold math too:\mathversion{bold}
\begin{align*}
\log x && \log(x) && \log\log(x) \\
\Q x && \Q(x) && \Q\Q(x)
\end{align*}
\end{document}
输出:
答案2
万一你缺少数学组而\DeclareMathAlphabet
无法使用,你可以这样做\text
(但是效率要低得多):
\documentclass{article}
\usepackage{amsmath,pdftexcmds}
\DeclareMathOperator{\Q}{\text{\linlib Q}}
\makeatletter
\newcommand{\linlib}{%
\usefont{\encodingdefault}{LinuxLibertineT-TLF}
{\ifnum\pdf@strcmp{\math@version}{bold}=\z@ b\else m\fi}{n}%
}
\makeatother
\begin{document}
This is with math version normal
\begin{align*}
\log x && \log(x) && \log\log(x) \\
\Q x && \Q(x) && \Q\Q(x)_{\Q(x)}
\end{align*}
Works with bold math too:\mathversion{bold}
\begin{align*}
\log x && \log(x) && \log\log(x) \\
\Q x && \Q(x) && \Q\Q(x)_{\Q(x)}
\end{align*}
\end{document}