4

I would like to create a new binary operation by squaring a symbol. In this example I try to do it with \wr.

I use

\usepackage{graphics}
\usepackage{stackengine}
\newcommand{\SmallWr}{\scalebox{0.6}{\( \boldsymbol\wr \)}}
\newcommand{\WrSymbol}{
    \stackMath\stackinset{c}{0ex}{c}{0.05pt}{\SmallWr}{\square}
}
\newcommand{\SquaredWr}{
    \mathbin{\WrSymbol}
}

It works but not perfectly. I get some pdf aberrations where sometimes the \wr is placed too high in the square and sometimes placed too low. And this is also dependent on the zoom I use to look at the pdf.

enter image description here and enter image description here

How can I make this symbol more robust?

Edit: Thanks for the proposals. I still get the same aberrations when the PDF is zoomed out. As schtandard pointed out in their comment, this is likely not due to LaTeX and there are no solution apart from increasing the number of screen pixels.

Damien L
  • 621
  • 1
    The effect of the zoom of your PDF viewer is just an artifact of mapping the symbol to pixels. It is "not real", i.e. not part of your document but part of displaying it on your screen. You should zoom in quite a lot in order to see the "real" position of the \wr. If there are still problems, please post a picture showing that (in higher resolution) and complete your code snippet to be an MWE. – schtandard Jul 02 '20 at 09:10
  • I agree, after zooming in enough, the symbol stabilises and the effect is not present on printed paper. Is there anything one can do to mitigate the PDF viewer artefact? – Damien L Jul 02 '20 at 09:52
  • No, not that I know of. Maybe try a couple of different PDF viewers, but it's really just a problem of finite screen resolutions. You could buy a screen with a higher resolution, of course.. – schtandard Jul 02 '20 at 11:58

2 Answers2

5

Here's my proposal with \framebox:

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

\makeatletter \newcommand{\sqwr}{}% just to check it's undefined \DeclareRobustCommand{\sqwr}{\mathbin{\mathpalette\sqwr@\relax}} \newcommand{\sqwr@}[2]{% \begingroup \sbox\z@{$\m@th#1\mkern1mu$}% \sbox\tw@{$\m@th#1\bm{\wr}$}% \setlength{\fboxsep}{-\wd\z@}% \setlength{\fboxrule}{\wd\z@}% \framebox[\dimexpr\ht\tw@+\dp\tw@]{$\m@th#1\bm{\wr}$}% \endgroup } \makeatother

\begin{document}

$F\sqwr G+X_{F\sqwr G}$

\end{document}

enter image description here

egreg
  • 1,121,712
1

Unicode has an enclosing-square combining symbol, but the results are not that pretty out of the box. LaTeX doesn’t correctly measure the width of the enclosing symbol, but you can get around this by putting it in a box of set width. Then, the rendering inside the box depends on the current style, so I ended up using \mathchoice and adding a bit of negative space.

\documentclass{article}
\usepackage{unicode-math}

\setmathfont{STIX Two Math}[Scale=MatchLowercase]

\pagestyle{empty} % To suppress page numbers in this MWE.

\newcommand\squarewr% {\mathrel{\mathchoice% {\makebox[1em]{(\displaystyle\wr^^^^20de)}}% {\makebox[1em]{(\textstyle\wr^^^^20de)}}% {\makebox[1em]{(\scriptstyle\wr^^^^20de)}}% {\makebox[1em]{(\scriptscriptstyle\wr^^^^20de)}}% }!}

\begin{document} [ F \squarewr G_{F \squarewr G} ] \end{document}

STIX Two Math sample

You would need to tweak the width, horizontal centering, \kern values, etc. It’s definitely not the simplest approach.

Davislor
  • 44,045