5

I want to use MnSymbol (to get various sorts of down arrows), but I don't like its \approx symbol. I'd like to use the basic one instead. I've tried using savesym (as below), but this still outputs the mnsymbol version. Any suggestions?

\documentclass{article}
\usepackage[english]{babel}

\usepackage{savesym}
\savesymbol{approx}

\usepackage{MnSymbol}

\restoresymbol{approx}{amssymb}

\begin{document}

$\approx$

\end{document}

Edit -- Additional Question

@Steven B. Segletes's answer works perfectly for the problem as I asked it. But, I've found that there are a bunch of other symbols that I'd like to prevent MnSymbol from changing around. So, I wonder if there might be a solution coming from the other direction: can we prevent MnSymbol from introducing any new definitions except for the specific symbols we want to add? (The ones I specifically want are \ndownarrow, \ndasheddownarrow, and \dasheddownarrow.)

...I now see that @Steven B. Segletes has answered this already (Standard AMS-Sum Operator using MnSymbols?). But like I said in a comment below, I'm a total layman and get scared looking at all this font changing stuff. So if anyone has a solution of a different sort, that would be helpful.

5

REVISION (at GuM's suggestion)

GuM, who clearly knows more about LaTeX font usage than I, improves my answer immensely, by tying into the encoding of cmsy already known to LaTeX (OMS) and thus avoids the need to declare a new font family and shape. GuM further calls out the right incantation to provide bold support, as well.

\documentclass{article}
%\usepackage[english]{babel}
\usepackage{MnSymbol,bm}
\DeclareSymbolFont{Xsymbols}{OMS}{cmsy}{m}{n}
\SetSymbolFont{Xsymbols}{bold}{OMS}{cmsy}{b}{n}
\DeclareMathSymbol{\Xapprox}{\mathrel}{Xsymbols}{25}

\begin{document}
$a\Xapprox b \bm{\Xapprox} c$

$a \approx b \bm{\approx} c$
\end{document}

enter image description here

ORIGINAL ANSWER

Here, I declare the CM symbol font (cmsy, see The TeXbook, p. 431) as a new font family with \DeclareFontFamily. Then, with \DeclareFontShape, I tell which glyph sizes to use, based on the desired point size (e.g., any thing bigger than 12 points is a scaled version of the cmsy12 glyphs). I then declare a new symbol font Xcmsy that uses the cmsy font family. Finally, I employ \DeclareMathSymbol to extract the right glyph from the Xcmsy symbol font and call it \Xapprox . I make sure sure it is employed as a \mathrel type, and it uses slot 25 ('031 octal, "19 hex) of that Symbol font, which corresponds to the \approx symbol.

\documentclass{article}
%\usepackage[english]{babel}
\usepackage{MnSymbol}
\DeclareFontFamily{U} {cmsy}{}

\DeclareFontShape{U}{cmsy}{m}{n}{
  <-6> cmsy5
  <6-7> cmsy6
  <7-8> cmsy7
  <8-9> cmsy8
  <9-10> cmsy9
  <10-12> cmsy10
  <12-> cmsy12}{}

\DeclareSymbolFont{Xcmsy} {U} {cmsy}{m}{n}

\DeclareMathSymbol{\Xapprox}{\mathrel}{Xcmsy}{25}
\begin{document}
$a\Xapprox b$

$a \approx b$
\end{document}

enter image description here

  • 1
    This works! For total laymen like me, would you be able to summarize what this solution is doing? – Sam Zukoff Jul 3 '17 at 19:24
  • 1
    @SamZukoff See edited answer. I hope this helps. Even I have to look it up to refresh my memory of the syntax. – Steven B. Segletes Jul 3 '17 at 19:34
  • 2
    1. Why not just \DeclareSymbolFont{Xcmsy}{OMS}{cmsy}{m}{n}, and let that the size functions defined in omscmsy.fd (which are pretty different from yours) be used? 2. Why not to add support for the bold math version by adding \SetSymbolFont{Xcmsy}{bold}{OMS}{cmsy}{b}{n} (omscmsy.fd does define a suitable font shape)? – GuM Jul 3 '17 at 21:48
  • 1
    I took the liberty to reorganize slightly your code for the sake of logical order. Good answer, anyway! :-) – GuM Jul 4 '17 at 16:25
4

There's no way for saving \approx with savesym. No symbol defined with \DeclareMathSymbol can.

The savesym package can only work with commands defined with \newcommand (provided the command has no optional argument); it won't do if the command is defined with \DeclareRobustCommand for reasons described in the documentation of letltxmacro (see also https://tex.stackexchange.com/a/47372/4427).

Let’s see what happens. If you use the correct syntax, that is

\usepackage{savesym}

\show\approx

\savesymbol{approx}
\usepackage{MnSymbol}
\restoresymbol{mn}{approx}

\show\approx
\show\mnapprox

(the \show lines are just for debugging) you will get, on the terminal,

> \approx=\mathchar"3219.

> \approx=\mathchar"3219.

> \mnapprox=\mathchar"3704.

Instead of mn you might use any string you like better (for commands that work with savesym, of course, not this one).

This means that \approx is a relation symbol (3), from the font in math group 2, slot "19.

However, when the document starts, MnSymbol assigns \U/MnSymbolF/m/n/10 to the font in math group 2, which corresponds to MnSymbolF10. The relevant part of the font table is shown here:

enter image description here

and indeed, your document will print

enter image description here

which isn't very much like an approx symbol. Indeed in MnSymbol.sty we find

\DeclareSymbolFont{symbols}{U}{MnSymbolF}{m}{n}

which overrides the standard declaration for the symbols font, corresponding to math group 2. The assignments of operators to math group 0, letters to math group 1, symbols to math group 2 and largesymbols to math group 3 are mandatory. Later on, the 25th line (25 decimal is 19 hexadecimal) after line 1446 (where a counter is reinitialized to zero for defining the symbols from the symbols font) has

\Decl@Mn@Char\dbigdoublecurlywedge{symbols}{\mathop}

which confirms the “unexpected” symbol you see instead of \approx. It must be said that MnSymbol uses very obscure code. Indeed, as shown by the value of \mnapprox, the “approximates” symbol in MnSymbol is from the font in math group 7, slot "04.

The only way to go is with a \DeclareSymbolFont strategy as described in Steven’s fine answer.

2

Edit:

I read the commands of savesymbol and restore symbol.

When you save the "approx" then the "origapprox is created"

When you restore "approx" by the command:

\restore{last}{approx}

then the "approx" has to become again the same as "origapprox" that have been saved and "lastapprox" will become the last value of approx before restoring.

So if we have the next code:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{savesym}
\savesymbol{approx}


\usepackage{MnSymbol}

\restoresymbol{UnwantedChanged}{approx}


\begin{document}

$\approx$


$\origapprox$


$\UnwantedChangedapprox$
\end{document}

we are expecting an approx with the symbol of MnSymbol an origapprox with the symbol before load of MnSymbol and a UnwantedChangedapprox with MnSymbol loaded

but the code above gives the real approx symbol only in the last row.

By removing the last line of printing and the restore command, I saw that the savesymbol command had already restored the symbol and was printing as approx the old approx and as origapprox the last one...

This means that to solve your problem you has to just remove the restore commant... I don't know why... may be the code in savesym has been changed and restores automatically after loading a new symbol or may be MnSymbol does this trick

Old Answer: (to understand the first -fair- comment of @StevenB.Segletes)

You wrote the command with opposite arguments. Try:

\restoresymbol{approx}{amssymb}
  • 1
    This succeeded in printing an approx symbol, but it's the mnsymbol one. – Sam Zukoff Jul 3 '17 at 18:41
  • 1
    Your suggestion uses improper syntax for \restoresymbol, and thus not only does not solve the problem, but can mislead readers. – Steven B. Segletes Jul 3 '17 at 18:56
  • 1
    @StevenB.Segletes thanks... I reading the "documentation" of savesymbol to find how it works – koleygr Jul 3 '17 at 19:12
  • 2
    Good point. I'll fix the post. – Sam Zukoff Jul 3 '17 at 19:15

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.