I want to use Linux libertine font only for "Q" on math mode. In the other words I want to create a math operator such as:
\newcomand{\Q}{Q Linux libertine font}.
Thanks.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communitySomething like this?
% 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}
The output:
In case you are short of math groups and \DeclareMathAlphabet
cannot be used, you can get away with \text
(much less efficient, however):
\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}