4

My question is very short and it is not a duplicate because I want the symbol \square with a better position using mtpro2 package which it is not perfect. Infact if I use the symbol \square for the Dalambertian operator with this MWE,

\documentclass{article}
\usepackage{mathtools,amssymb}
\usepackage{newtxtext}
\usepackage{newtxmath}

\begin{document}
\[
L'=L+\mu_{0}\square\cdot (fX)
\]
\end{document}

enter image description here

the square symbol (\square) is small because I'm using \usepackage{newtxmath}, but is a bit far from the \cdot symbol but is in line with all the characters. Obviously I could insert a negative space before \cdot but I would like to avoid doing so. But using the package \usepackage[lite]{mtpro2}, the symbol \square change but it's bigger than the previous symbol and different.

How is it possible to have a square symbol (better centered) that aesthetically fits better as a Dalambertian operator and is closer to the dot of \cdot?

\documentclass{article}
\usepackage{mathtools,amssymb}
\usepackage{newtxtext}
\usepackage[lite]{mtpro2}
\begin{document}
\[
L'=L+\mu_{0}\square\cdot (fX)
\]
\end{document}

enter image description here

Sebastiano
  • 54,118

3 Answers3

3

You can create your own square symbol with a definable size very easily by using \fbox, you can adjust it to your liking by changing the \fboxrule thickness and the size of the \phantomed \rule.

With this definition the size of the symbol doesn't change in sub or super script.

\documentclass[]{article}

\newlength\mysquaresize
\newcommand\mysquare
  {%
    \begingroup
    \fboxrule=.12ex
    \mysquaresize=1ex
    \fboxsep=-\fboxrule
    \vcenter{\hbox{\fbox{\phantom{\rule{\mysquaresize}{\mysquaresize}}}}}%
    \endgroup
  }

\begin{document}
\[
L'=L+\mu_{0}\mysquare\cdot (fX)
\]
\end{document}

enter image description here

A version in which you can also define sizes in the different math modes:

\documentclass[border=3.14,11pt]{standalone}

\newlength\mysquaresize
\newcommand\mysquare
  {%
    \mathchoice
      {\mysquareaux{.12ex}{1ex}}
      {\mysquareaux{.12ex}{1ex}}
      {\mysquareaux{.11ex}{.8ex}}
      {\mysquareaux{.10ex}{.7ex}}%
  }
  \newcommand\mysquareaux[2]
  {%
    \begingroup
    \fboxrule=#1
    \mysquaresize=#2
    \fboxsep=-\fboxrule
    \vcenter{\hbox{\fbox{\phantom{\rule{\mysquaresize}{\mysquaresize}}}}}%
    \endgroup
  }

\begin{document}
$
\displaystyle
L'=L+\mu_{0}\mysquare\cdot (fX)
$
\end{document}
Skillmon
  • 60,462
3

You can import a symbol from another font. But the space after the square is not triggered by the square but by the binary symbol. If you would change the definition of \square to suppress this space it would give bad results if ordinary symbols are after the square:

\documentclass{article}
\usepackage{mathtools,amssymb}
\usepackage{newtxtext}
\usepackage[lite]{mtpro2}
\DeclareSymbolFont{AMSm}{U}{ntxsym}{m}{n}
\DeclareMathSymbol{\ntxsquare} {\mathord}{AMSm}{131}

\begin{document}
\[
L'=L+\mu_{0}\ntxsquare\cdot (fX)
\]


\[
L'=L+\mu_{0}\ntxsquare\mathpunct{\cdot} (fX)
\]


\[
L'=L+\mu_{0}\ntxsquare\!\cdot (fX)
\]

\[
L'=L+\mu_{0}\ntxsquare\! x (fX) %bad
\]

\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • Very nice answer. Excuse me very much but I have taken the shorter answer with the check green. Always thank you. – Sebastiano Apr 17 '19 at 10:57
3

Maybe just writing {\cdot} rather than \cdot gives you the desired spacing. I don't have mtpro2, so this is with your original code:

Sample output

\documentclass{article}
\usepackage{mathtools,amssymb}
\usepackage{newtxtext}
\usepackage{newtxmath}

\begin{document}
\[
L'=L+\mu_{0}\square{\cdot} (fX)
\]
\end{document}
Andrew Swann
  • 95,762