[Tex/LaTex] Importing single symbol from MnSymbol

fontssymbols

I wish to use a symbol provided by the package MnSymbol but if I have a \usepackage{MnSymbol} in my document then many other symbols change, including even the equals sign (=), which appears much shorter now.

How can I use a package to just get a few particular symbols without having my entire document in the font that the package imposes?

Best Answer

Similar questions

It is, my apologies, very difficult to get a symbol from MnSymbol. In the old questions,

Discard symbols from package (MnSymbol)
The standard \cup vs. the mathabx \cup (mathabx)
Importing a Single Symbol From a Different Font (mathabx)

some similar technique is used to get a symbol from a package — In fact we just redefine the symbol like the font package do.

About MnSymbol

However, in MnSymbol we must define a more things than other packages, as Ulrike Fischer do in her answer. I'll provide another very similar example from another site:

Before reading the explanations below, you'd better have a look at fntguide document.

Assuming you want \rightlsquigarrow from MnSymbol, you must check the source code MnSymbol.sty, then we have

\Decl@Mn@Char\rightlsquigarrow       {MnSyA}{\mathrel}

It's awful! We still do not know which the symbol is. In fact \Decl@Mn@Char is just \DeclareMathSymbol which increase the character number automatically. \rightlsquigarrow is the 160th symbol, thus char code is 160. Or you can use fonttable package to find the code of the glyph. That's to say, \rightlsquigarrow is

\DeclareMathSymbol{\rightlsquigarrow}{\mathrel}{MnSyA}{160}

\mathrel here means that the symbol is a math binary relation symbol. Other symbols may be \mathord (odinary symbol), \mathop (operator), \mathbin (binary operation), \mathopen (open delimiter), \mathclose (close delimiter), etc. You can read fntguide for more details of these commands.

But before that, you must define MnSyA math family first. Then copy this from MnSymbol.sty:

\DeclareSymbolFont{MnSyA} {U} {MnSymbolA}{m}{n}

For most math font packages, that's enough. But for MnSymbol, the font family MnSymbolA is also defined in MnSymbol.sty, we must copy it to the documents.

\DeclareFontFamily{U} {MnSymbolA}{}

\DeclareFontShape{U}{MnSymbolA}{m}{n}{
  <-6> MnSymbolA5
  <6-7> MnSymbolA6
  <7-8> MnSymbolA7
  <8-9> MnSymbolA8
  <9-10> MnSymbolA9
  <10-12> MnSymbolA10
  <12-> MnSymbolA12}{}
\DeclareFontShape{U}{MnSymbolA}{b}{n}{
  <-6> MnSymbolA-Bold5
  <6-7> MnSymbolA-Bold6
  <7-8> MnSymbolA-Bold7
  <8-9> MnSymbolA-Bold8
  <9-10> MnSymbolA-Bold9
  <10-12> MnSymbolA-Bold10
  <12-> MnSymbolA-Bold12}{}

Now, if we don't know \rightlsquigarrow is actually the 160th symbol, we can use a small test file to check the glyph table:

\documentclass{article}
\usepackage{fonttable}
\begin{document}
\fonttable{MnSymbolA10}
\end{document}

A picture for fonttable

After all of this, you know exactly what \rightlsquigarrow is, and you can use it as this:

enter image description here

\documentclass{article}

\DeclareFontFamily{U} {MnSymbolA}{}
\DeclareFontShape{U}{MnSymbolA}{m}{n}{
  <-6> MnSymbolA5
  <6-7> MnSymbolA6
  <7-8> MnSymbolA7
  <8-9> MnSymbolA8
  <9-10> MnSymbolA9
  <10-12> MnSymbolA10
  <12-> MnSymbolA12}{}
\DeclareFontShape{U}{MnSymbolA}{b}{n}{
  <-6> MnSymbolA-Bold5
  <6-7> MnSymbolA-Bold6
  <7-8> MnSymbolA-Bold7
  <8-9> MnSymbolA-Bold8
  <9-10> MnSymbolA-Bold9
  <10-12> MnSymbolA-Bold10
  <12-> MnSymbolA-Bold12}{}

\DeclareSymbolFont{MnSyA} {U} {MnSymbolA}{m}{n}

\DeclareMathSymbol{\rightlsquigarrow}{\mathrel}{MnSyA}{160}

\begin{document}

$\rightlsquigarrow$

\end{document}