52

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?

4
  • 3
    Very much related: Importing a Single Symbol From a Different Font
    – Werner
    Commented Nov 24, 2011 at 8:32
  • I think there is no explicit relation. The problem occurs very often and so we should provide a more generally answer for MnSymbol. Commented Nov 24, 2011 at 9:01
  • Which symbol of the MnSymbol package do you want to use?
    – Stephen
    Commented Nov 24, 2011 at 19:02
  • @MarcoDaniel: I don't think a good general answer exists. Moreover, MnSymbol is a bit different: it doesn't provides .fd files, but defines the font families in the .sty file. Then we must copy a lot of code from MnSymbol to the document.
    – Leo Liu
    Commented Nov 24, 2011 at 20:36

1 Answer 1

62

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}
8
  • 3
    Thanks for a very clear and useful answer! I hope the MnSybol would one day be re-written to allow importing single symbols, or not to ruin symbols from other packages.
    – Ran G.
    Commented Oct 1, 2013 at 9:55
  • Worth clarifying that you might need to use \mathord instead of \mathrel with \DeclareMathSymbol (if the symbol you are importing is not a relational symbol). Otherwise your spacing will go weird.
    – Roly
    Commented May 27, 2014 at 9:07
  • @Roly: An arrow is a relation symbol, right?
    – Leo Liu
    Commented May 27, 2014 at 10:41
  • 2
    @Roly: There can be \mathbin, \mathop, \mathopen, \mathclose, and \mathpunct too. What we do is to copy the definition from the font package, the font designer defines what the symbol should be.
    – Leo Liu
    Commented May 27, 2014 at 11:14
  • 2
    @LeoLiu Indeed. Your answer is very useful, but made even more so by this clarification. Otherwise one might think one can copy your solution modulo MnSy[A|B|C|...] and the character codes themselves, as I did, before I spotted that one also needs to consider which of \mathbin, \mathop, \mathopen, \mathclose, and \mathpunct one needs to pass to \DeclareMathSymbol.
    – Roly
    Commented May 27, 2014 at 11:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .