11

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.

  • 1
    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 at 13:44
15

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}
| improve this answer | |
  • 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 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 at 14:15
13

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} 

enter image description here

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):

enter image description here

\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.

enter image description here

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, ⬢ ⬢

⬣, Horizontal, Black Hexagon, ⬣ ⬣

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}

enter image description here

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

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}

enter image description here

| improve this answer | |
8

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

\font\marvosym=umvs

{\marvosym\char146}
| improve this answer | |
7

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}}

in your document preamble.

enter image description here

| improve this answer | |
7

The unicode-math package includes all the math symbols in Unicode, under the same names as stix and stix2. You can import them with

\setmathfont[ range={\hexagonblack,\varhexagonblack},
              Scale=MatchUppercase
            ]{STIX Two Math}

XITS Math is a fork of the STIX 1 font, and other fonts might or might not have these symbols.

| improve this answer | |

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.