# How to get a black hexagon symbol?

I am looking for a filled version of \hexagon.

I found \Steelhexagon from "marvosym", but in the template that I am using it seems to render as an arrow and I get conflicts because of other symbols in "marvosym". I wonder if there is a black hexagon symbol in a more common latex package.

• As always on the site please provide a full (but minimal) example that others can copy and test as is. Otherwise we cannot help much. Also note that there are a lot of bad templates out there. – daleif Jul 10 '20 at 13:44

As for most unicode symbols, there are filled hexagons in the STIX font.

They can be imported without importing the whole font.

\documentclass{article}
\DeclareFontEncoding{LS1}{}{}
\DeclareFontSubstitution{LS1}{stix}{m}{n}
\DeclareSymbolFont{symbols4}{LS1}{stixbb}{m}{it}
\DeclareMathSymbol{\varhexagonblack}{\mathord}{symbols4}{"DD}
\DeclareMathSymbol{\hexagonblack}   {\mathord}{symbols4}{"DE}
\begin{document}
\verb|\hexagonblack|: $$\hexagonblack$$

\verb|\varhexagonblack|: $$\varhexagonblack$$
\end{document}
• How did you calculate the DD and DE? I the stix documentation I see four hexdigit codes and they seem to have nothing to do with the codes in your snippet. – allo Jul 31 '20 at 8:41
• @allo The four hexdigit codes you see in the documentation are the codes of the unicode symbols, and are not directly related to the font. To find the location of the symbols in the font (by that I mean these "DD and "DE codes), you can look in the file stix.sty, and search for the line defining the symbol you're looking for. You should find a line \DeclareMathSymbol... like those in my answer. – Vincent Jul 31 '20 at 14:15

Just it is a bit complex but I had used thus how I have written in the image a combination between tikz and \usetikzlibrary{shapes} that get the hexagon symbol: regular polygon sides=6. After I have used \mathord like suggested by user @Thruston in the recent comment.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{xcolor}

\newcommand{\bhexagon}{\mathord{\raisebox{0.6pt}{\tikz{\node[draw,scale=.65,regular polygon, regular polygon sides=6,fill=black](){};}}}}

\begin{document}
\verb|tikz package with shapes|
$\triangle+\bhexagon=\square$
\end{document}

Remember that STIX font change also the font of the text. Thus with the previous code you have always (for example) the font computer modern with the default symbol of amssymb.

ADDENDUM: It is possibile to have another hexagon symbol with the package oplotsymbl (using graphicx+rotatebox you can have the classic hexagon):

\documentclass[a4paper,12pt]{article}
\usepackage{oplotsymbl}
\usepackage{amssymb}
\begin{document}
Another option
$\hexagofill+\diamond=\blacksquare$
\end{document}

ADDENDUM 2: Now I have seen that exist also a new package called dbnsymb rev. 7 Mar. 2, 2020 that it give us also the symbol \hexagon. It is important to have dbnsymb.sty to use this package.

I think that using xcolor package this symbol can be coloured.

ADDENDUM 3: Surely you can directly to use the symbol using XeLaTeX or LuaLaTeX (Unicode characters) with fontspec:

Symbol, Title/Description   Unicode Code / HTML Code

⬢, Black Hexagon, &#11042; &#x2B22;

⬣, Horizontal, Black Hexagon, &#11043; &#x2B23;

ADDENDUM 4: using unicode-math + XITS Math

\documentclass[12pt]{article}
\usepackage{unicode-math}
\setmathfont{XITS Math}
\newcommand{\vbh}{\mathbin{\varhexagonblack}}
\newcommand{\hb}{\mathbin{\hexagonblack}}

\begin{document}
First $\hb+\vbh=\triangle$ second
\end{document}

• Would it be better to use \mathord instead of \mathbin here? – Thruston Jul 11 '20 at 12:47
• @Thruston I have edited my MWE: Thank you very much for your feedback. – Sebastiano Jul 11 '20 at 15:25
• Hello Sebastiano!! Amazing result, congrats 👏. – manooooh Jul 11 '20 at 17:39
• @manooooh Weeeeeeeeeeeeeeeeeee ahahhahah 👀👀👀. Always kind with me. – Sebastiano Jul 11 '20 at 18:52

The STIX font also has two versions of the symbol (in different rotations). For pdfLaTeX you can use the stix2 package. Downside is that STIX becomes the font for your entire document.

\documentclass{article}
\usepackage{stix2}
\begin{document}
$$a+b=\varhexagonblack$$.

$$b+a=\hexagonblack$$.
\end{document}

You can print this symbol without any package from the font MarVoSym.ttf:

\font\marvosym=umvs

{\marvosym\char146}

The symbols in marvosym are meant to be used in text.

\documentclass{article}
\usepackage{amsmath}
\usepackage{marvosym}

\begin{document}

Wrong: \verb|$a=\HexaSteel$| $\to$ $a=\HexaSteel$

Right: \verb|$a=\text{\HexaSteel}$| $\to$ $a=\text{\HexaSteel}$

\end{document}

Of course, if you plan to use this as a math symbol, you can do

\newcommand{\hexagon}{\text{\HexaSteel}}