2

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.

  • Just don't use this to distinguish between Q in computer modern! – Au101 Oct 8 '16 at 3:10
5

Something 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:

Output of the code

2

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}

enter image description here

  • Could you please tell me how to discover the "LinuxLibertineT-TLF" in your code? And can it be automatically determined by a TeX command? – user21820 May 1 '19 at 17:46
  • @user21820 By looking in the libertine package and related .fd files. – egreg May 1 '19 at 18:25
  • Hmm so I don't think I would be able to figure it out. Is there an automatic way to determine the default math font and use that. I actually want to do remove letter spacing without changing anything else, but also without having to know the original font. – user21820 May 2 '19 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy