Creating a custom math symbol from scratch

I want to use a special symbol from the Com­pre­hen­sive LaTeX Sym­bol List called \diamondtimes. Unfortunately, when I include the MnSymbol package that provides this symbol, it also affects how other things look like. Since I need only this single symbol, is there any way to design it from scratch so that I don't have to include any extra packages?

Maybe it can be build by adding something on top of the standard \diamond symbol? In fact, I want the diamond produced by \diamondtimes to be the same size as \diamond, since I plan to use both.

Update: Since it has such a simple shape, I would prefer to make it from scratch (or put something on top of \diamond). Here is the original code from Sym-Geometric.mf:

beginoperator(med_op_size#, 1); "medium diamond times";
pickup rule_pen;
r := w/2 - side_bearing;
draw square(centre, r / sqrt(2), 45);
draw (centre + sqrt .5 * r * dir  45) -- (centre + sqrt .5 * r * dir 225);
draw (centre + sqrt .5 * r * dir 135) -- (centre + sqrt .5 * r * dir 315);
endchar;


What language is this in and can I just reuse this somehow?

-
See tex.stackexchange.com/questions/132453/… for how to get a MNSymbol into your font –  Steven B. Segletes Dec 4 '13 at 16:44
I just found this post: tex.stackexchange.com/questions/36006/… and I'm trying to follow the instructions. –  Māris Ozols Dec 4 '13 at 16:52
BTW: the "language" is MetaFont –  karlkoeller Dec 4 '13 at 18:34
The language is indeed metafont, but this extract contains commands that are not in standard metafont. Presumably these are macros defined in some file in the MnSymbol package. However, it is easy to deduce what is going on if one knows metafont: A square is drawn, rotated 45 degrees, and then the two crossing lines are drawn. –  Dan Dec 5 '13 at 2:10

2 Answers

Rotate \boxplus by 45 degrees:

\documentclass{article}
\usepackage{graphicx,amsmath,amssymb}
\DeclareRobustCommand{\diamondtimes}{%
\mathbin{\text{\rotatebox[origin=c]{45}{$\boxplus$}}}%
}

\begin{document}
$a\diamondtimes b$

$a\times b$
\end{document}


For a smaller version and an empty diamond (note that \diamond already exists, but gives a much smaller symbol):

\documentclass{article}
\usepackage{graphicx,amsmath,amssymb}
\DeclareRobustCommand{\diamondtimes}{%
\mathbin{\text{\scalebox{.75}{\rotatebox[origin=c]{45}{$\boxplus$}}}}%
}
\DeclareRobustCommand{\bdiamond}{%
\mathbin{\text{\scalebox{.75}{\rotatebox[origin=c]{45}{$\Box$}}}}%
}
\begin{document}
$a\diamondtimes b$

$a\bdiamond b$
\end{document}


-
Is there a way to make it a bit smaller and also to have a \diamond symbol of the same size? –  Māris Ozols Dec 4 '13 at 17:10
A beautiful solution. But might it not be better to define the new symbol once, store it in a box register (or several, using \mathchoice for various sizes) and then \copy the box each time the symbol is used? –  jvarilly Dec 4 '13 at 19:12
@jvarilly: I'm not familiar with these commands. Could you give some pointer on how to use them? –  Māris Ozols Dec 4 '13 at 23:09
@jvarilly With the box approach the symbol wouldn't change size according to \small, \footnotesize and the like. –  egreg Dec 4 '13 at 23:11

Mimicing the procedure depicted at Typing Following notation in Latex, I was able to determine that \diamondtimes was part of MnSymbolC font set. Then, using the fonttable package (uncomment 2 lines in MWE), I found the symbol number to be 125. Then, I just changed the name and numbers from that example to get this one.

\documentclass{article}

\DeclareFontFamily{U} {MnSymbolC}{}

\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}{MnSymbolC}{b}{n}{
<-6> MnSymbolC-Bold5
<6-7> MnSymbolC-Bold6
<7-8> MnSymbolC-Bold7
<8-9> MnSymbolC-Bold8
<9-10> MnSymbolC-Bold9
<10-12> MnSymbolC-Bold10
<12-> MnSymbolC-Bold12}{}

\DeclareSymbolFont{MnSyC} {U} {MnSymbolC}{m}{n}
%\Decl@Mn@Char\diamondtimes             {MnSyC}{\mathbin}
\DeclareMathSymbol{\diamondtimes}{\mathbin}{MnSyC}{125}

%\usepackage{fonttable}
\begin{document}
%\fonttable{MnSymbolC10}
$a \diamondtimes b$
\end{document}


-