2

This example shows know how to import a symbol from MnSymbol. I find the code quite long and complex and wonder if some more elegant way exist. Also, possibly, a way that does not require “wasting a precious math alphabet resource”.

This post suggests one (though not applied to MnSymbol). AFAIU this alternative approach is especially well suited when the font “provides .fd files”. What does that mean? Does MnSymbol provide .fd files? Otherwise, how hard would it be to create those files, so that symbols can be imported using fewer lines of code? In which cases should one use the pifont approach to import fonts, rather than the one that does not use any package (illustrated in my first link)?

Is there another package that is especially suited to import symbols? This FAQ recommends yagusylo, but it hasn’t been updated since 2009 and does not seem to be much used.

I am especially interested in importing from MnSymbol, and more specifically, importing symbols such as \ntriplesim, \nlessgtr, \ngtreqlessslant and the like, but if this question can be answered in general (for any font), the better, of course.

  • 2
    Can you tell about what symbols you'd like to import? – egreg Dec 21 '18 at 18:26
  • in the first reference you cite, it says that MnSymbol does not provide .fd files, but defines all the information usually found in .fd files instead in the .sty file. it should not be difficult to extract that into .fd files, using as a model the method used for mathabx. but that certainly wouldn't avoid "wasting a precious math alphabet resource". – barbara beeton Dec 23 '18 at 02:51
  • @egreg I added examples of specific symbols I’m interested in. – Olivier Cailloux Dec 24 '18 at 07:58

1 Answers1

2

Here are the three symbols you mention:

enter image description here

\documentclass{article}
\usepackage{amsmath}

\DeclareRobustCommand{\frommnsymbol}[3]{%
  %1 = atom type, #2 = mnsymbol font, #3 = character
  #1{\text{\usefont{U}{MnSymbol#2}{m}{n}\symbol{#3}}}%
}

%\DeclareFontFamily{U}{MnSymbolA}{}
%\DeclareFontFamily{U}{MnSymbolB}{}
%\DeclareFontFamily{U}{MnSymbolC}{}
\DeclareFontFamily{U}{MnSymbolD}{}
%\DeclareFontFamily{U}{MnSymbolF}{}

%\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}{MnSymbolB}{m}{n}{
%    <-6>  MnSymbolB5
%   <6-7>  MnSymbolB6
%   <7-8>  MnSymbolB7
%   <8-9>  MnSymbolB8
%   <9-10> MnSymbolB9
%  <10-12> MnSymbolB10
%  <12->   MnSymbolB12}{}
%\DeclareFontShape{U}{MnSymbolC}{m}{n}{
%    <-6>  MnSymbolC5
%   <6-7>  MnSymbolC6
%   <7-8>  MnSymbolC7
%   <8-9>  MnSymbolC8
%   <9-10> MnSymbolC9
%  <10-12> MnSymbolC10
%  <12->   MnSymbolC12}{}
\DeclareFontShape{U}{MnSymbolD}{m}{n}{
    <-6>  MnSymbolD5
   <6-7>  MnSymbolD6
   <7-8>  MnSymbolD7
   <8-9>  MnSymbolD8
   <9-10> MnSymbolD9
  <10-12> MnSymbolD10
  <12->   MnSymbolD12}{}
%\DeclareFontShape{U}{MnSymbolF}{m}{n}{
%    <-6>  MnSymbolF5
%   <6-7>  MnSymbolF6
%   <7-8>  MnSymbolF7
%   <8-9>  MnSymbolF8
%   <9-10> MnSymbolF9
%  <10-12> MnSymbolF10
%  <12->   MnSymbolF12}{}

\newcommand{\ntriplesim}{\frommnsymbol{\mathrel}{D}{"7E}}
\newcommand{\nlessgtr}{\frommnsymbol{\mathrel}{D}{"C0}}
\newcommand{\ngtreqlessslant}{\frommnsymbol{\mathrel}{D}{"C7}}

\begin{document}

$a\ntriplesim b$ $a\nlessgtr b$ $a\ngtreqlessslant b$

$X_{a\ntriplesim b}$ $X_{a\nlessgtr b}$ $X_{a\ngtreqlessslant b}$

\end{document}

I commented out the unused fonts.

The font declarations are directly borrowed from MnSymbol.sty. How are the letter and code determined?

I looked in MnSymbol.sty for the three symbols

\Decl@Mn@Char\ntriplesim             {MnSyD}{\mathrel}
\Decl@Mn@Char\nlessgtr               {MnSyD}{\mathrel}
\Decl@Mn@Char\ngtreqlessslant        {MnSyD}{\mathrel}

This determines the letter to use. Unfortunately, MnSymbol doesn't use explicit codes for the symbols, but there's a trick for getting them without counting in the file: latexdef -p MnSymbol followed by the symbols' names will show the necessary codes.

> latexdef -p MnSymbol ntriplesim nlessgtr ngtreqlessslant

\ntriplesim:
\mathchar"377E

\the\ntriplesim:
14206

\nlessgtr:
\mathchar"37C0

\the\nlessgtr:
14272

\ngtreqlessslant:
\mathchar"37C7

\the\ngtreqlessslant:
14279

Thus I can supply as character code the last two digit in the \mathchar representation.

egreg
  • 1,121,712