4

I am looking for a filled-in version of the \diamond (⬦) command. More specifically, I'd like a filled-in version that is

  1. the same size as \diamond,
  2. centered vertically in the same way as \diamond.

I think the Unicode symbol I am looking for is 02B25 (⬥), but since I am not using XeLaTeX, I couldn't find a way to load this symbol. I couldn't get \DeclareUnicodeCharacter to do what I wanted it to do, but this may be due to my ignorance of how to use the command.

Note that the 'diamond' talked about in the accepted answer here is not what I'm looking for, as that diamond shape is different (⬧). There is an answer at the bottom of that page that seems to do what I want, but running that code gives me an error, as I commented there.

I tried the following ugly workaround:

\documentclass{article}
\usepackage{graphicx}
\usepackage{amssymb}

\newcommand{\blackdiamond}{\rotatebox[origin=c]{45}{$\vcenter{\hbox{$\scriptscriptstyle\blacksquare$}}$}}
\begin{document}

\[
    \diamond \blackdiamond
\]

\end{document}

The result is close, but not exactly what I wanted, due to the resulting symbol being slightly larger.

result2

I'm sure there must be a better way of shrinking the symbol down in a less hacky way than I did above, which should be more flexible to give what I want too.

2
  • 1
    Actually \diamond can be used without load amssymb or any other package.
    – Fran
    Commented Jul 10 at 9:18
  • Ah, I didn't know that! Edited :)
    – SvanN
    Commented Jul 10 at 9:31

3 Answers 3

3

The \diamond symbol, as defined by amssymb is an operation symbol, but apparently you want it as an ordinary symbol.

\documentclass{article}
\usepackage{graphicx}
\usepackage{amssymb}

\newcommand{\whitediamond}{\mathord{\diamond}}

\newcommand{\blackdiamond}{%
  \mathord{%
    \sbox0{$\diamond$}%
    \resizebox{!}{1.125\ht0}{%
      \raisebox{\depth}{\rotatebox[origin=c]{45}{$\blacksquare$}}%
    }%
  }%
}


\begin{document}

\[
{-} \whitediamond \blackdiamond {-}
\]

\end{document}

output

Should you want both to be binary operation or relation symbols, change accordingly \mathord.

This can be adapted if you also need the black symbol also in superscripts or subscripts.

Alternatively, you can import the single symbols from stix2.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}

%%% from stix2.sty
%\DeclareSymbolFont{symbols4}{LS1}{stix2bb}{m}{it}
%\stix@MathSymbol{\mdblkdiamond}{\mathord}{symbols4}{"E0}
%\stix@MathSymbol{\mdwhtdiamond}{\mathord}{symbols4}{"E1}
\DeclareFontEncoding{LS1}{}{}
\DeclareFontSubstitution{LS1}{stix2}{m}{n}

\newcommand{\blackdiamond}{{\text{\usefont{LS1}{stix2bb}{m}{it}\symbol{"E0}}}}
\newcommand{\whitediamond}{{\text{\usefont{LS1}{stix2bb}{m}{it}\symbol{"E1}}}}


\begin{document}

\begin{gather*}
{-} \whitediamond \blackdiamond {-}
\\
\scriptstyle {-} \whitediamond \blackdiamond {-}
\end{gather*}

\end{document}

output stix2

1
  • Perfect, this is just what I wanted! And thank you for also showing how to import the symbols from stix2 :)
    – SvanN
    Commented Jul 10 at 8:46
5

The stix2 package splits the Unicode Stix two math font in to Pdftex compatible fonts and gives them TeX names compatible with unicode-math.

The unicode math names for U+2B25 and U+2B26 are \mdblkdiamond and \mdwhtdiamond

\documentclass{article}

\usepackage{stix2}

\begin{document}

$\mdblkdiamond + \mdwhtdiamond$

\end{document}

enter image description here

1
  • That looks good, but stix2 seems to also change a lot of fonts, and in particular gives an error when I load it with the default packages in my template. Is there a way to import only these symbols? The symbols are also a bit bigger than the \diamond command, and I'm having some trouble resizing it while also keeping it centred the way it is originally.
    – SvanN
    Commented Jul 10 at 7:16
2

A poor man's solution could be not rotate \square but a framed color box and to avoid any difference with \diamond, make the white diamond also with a rotated framed color box.

With the default font, the result could be almost identical with most font sizes, although with tiny fonts the fake diamonds are a bit smaller, and with huge fonts you can notice that are sharper, as showed in the MWE below.

Also, with other fonts you will need adjust the xy rotation to control the vertical position, but well, on the other hand, you can make blue diamonds, which are much more expensive. ;)

mwe

\documentclass{article}
\usepackage{graphicx,xcolor}

\newcommand{\newdiamond}{%
\mathbin{\rotatebox[x=0ex,y=1ex]{45}{%
\resizebox{.8ex}{!}{\fboxrule.3pt\fboxsep1pt%
\fcolorbox{blue}{cyan!30}{}}}}}

\newcommand{\blackdiamond}{%
\mathbin{\rotatebox[x=0ex,y=1ex]{45}{%
\resizebox{.8ex}{!}{\fboxrule.3pt\fboxsep1pt%
\fcolorbox{black!30!blue}{blue}{}}}}}

\begin{document}

\fontsize{5pt}{5pt}\selectfont \({-} \diamond\newdiamond\blackdiamond {-} \)\par
\fontsize{10pt}{5pt}\selectfont \({-} \diamond\newdiamond\blackdiamond {-} \)\par
\fontsize{15pt}{10pt}\selectfont \({-} \diamond\newdiamond\blackdiamond {-} \)\par
\fontsize{30pt}{10pt}\selectfont \({-} \diamond\newdiamond\blackdiamond {-} \)\par


\end{document}

You must log in to answer this question.

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