2

I want to use the \squareulblack symbol (or others) from the unicode-math package, but I have to keep compiling with pdfLaTex (since the document has evolved always using this compiler and it would be a paint to now make it work with XeLaTex).

How can I do this?

1
  • open with texdoc symbols the large symbol list and look if some package provide your symbol. Nov 22, 2022 at 14:04

2 Answers 2

4

The symbol is provided by stix2, but you probably don't want to change your fonts to the Times based STIX2 font.

In stix2.sty we find

\stix@MathSymbol{\squareulblack}{\mathord}{arrows3}{"88}
\stix@MathSymbol{\squarelrblack}{\mathord}{arrows3}{"89}

so we know that we need to find the definition of the math symbol font arrows3

\DeclareSymbolFont{arrows3}{LS2}{stix2tt}{m}{n}

so we need to declare the LS2 encoding

\DeclareFontEncoding{LS2}{}{\noaccents@}
\DeclareFontSubstitution{LS2}{stix2}{m}{n}

The \noaccents@ declaration is irrelevant for our purposes. Now we can import the symbols. However, the first attempt does not really mix with \square.

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

\DeclareFontEncoding{LS2}{}{}
\DeclareFontSubstitution{LS2}{stix2}{m}{n}

\newcommand{\stixtwottsymbol}[1]{%
  \text{\usefont{LS2}{stix2tt}{m}{n}\symbol{#1}}%
}

\DeclareRobustCommand{\squareulblack}{%
  \mathord{% or \mathrel or \mathbin
    \stixtwottsymbol{"88}%
  }%
}
\DeclareRobustCommand{\squarelrblack}{%
  \mathord{% or \mathrel or \mathbin
    \stixtwottsymbol{"89}%
  }%
}

\begin{document}

\vrule depth 0.1pt height 0.1pt width 3pt $\squareulblack \square \squarelrblack$

\end{document}

enter image description here

The symbols are larger and don't sit on the baseline. Let's fix the issues.

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

\DeclareFontEncoding{LS2}{}{}
\DeclareFontSubstitution{LS2}{stix2}{m}{n}

\newcommand{\stixtwottsymbol}[1]{%
  \text{%
    \settoheight{\dimen0}{$\square$}%
    \resizebox{!}{\dimen0}{%
      \raisebox{\depth}{\usefont{LS2}{stix2tt}{m}{n}\symbol{#1}}%
    }%
  }%
}

\DeclareRobustCommand{\squareulblack}{%
  \mathord{% or \mathrel or \mathbin
    \stixtwottsymbol{"88}%
  }%
}
\DeclareRobustCommand{\squarelrblack}{%
  \mathord{% or \mathrel or \mathbin
    \stixtwottsymbol{"89}%
  }%
}

\begin{document}

\vrule depth 0.1pt height 0.1pt width 3pt $\squareulblack \square \squarelrblack$

$\scriptstyle \squareulblack \square \squarelrblack$

$\scriptscriptstyle \squareulblack \square \squarelrblack$

\end{document}

The result is much better, isn't it?

enter image description here

Also the previous version scales well in the other math styles.

2
  • disaster! You got the tick. See comments under my answer. Nov 22, 2022 at 21:46
  • @DavidCarlisle Working crystal ball…
    – egreg
    Nov 22, 2022 at 22:09
2

The stix2 package has more or less the full set of unicode-math names for pdflatex

\documentclass{article}
\usepackage{stix2}
\begin{document}

$\squareulblack$

\end{document}

enter image description here

3
  • Thanks for this answer. I am indeed able to use the symbol now. However, the font of the whole document is also automatically changed, which I don't want. When I set the notext and nomath option of the package, to avoid that, the symbol is not available anymore. How can I only import this specific symbol (or any other) from the stix2 package?
    – stollenm
    Nov 22, 2022 at 20:06
  • @stollenm much as it pains me to suggest it, see egreg's answer Nov 22, 2022 at 20:13
  • Oupps, somehow this answer didn't show up until now. I should have refreshed the browser. Thanks.
    – stollenm
    Nov 22, 2022 at 20:15

You must log in to answer this question.

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