
我想定義一個新的除法符號,類似於“/”,但它是一個旋轉 45 度的減號 (-),同樣\times
是一個 + 旋轉。我希望它具有與其他算術符號(+、- 和\times
)相同的屬性,我的意思是相同的間距等。
我嘗試做的事情如下。
% Inversa da multiplicação em anéis e grupos
\makeatletter
\providecommand{\newdiv}{%
\mathbin{
\hspace{-1.5pt}\mathpalette\@rotatinganeighth{-}\hspace{-1.5pt}
}
}
\newcommand*{\@rotatinganeighth}[2]{%
\rotatebox[origin=c]{45}{$\m@th#1#2$}%
}
\makeatother
結果看起來不錯,但我想要一些「更乾淨」的東西,我不喜歡輸入特定空間的事實\hspace{-1.5pt}
,我只是希望它表現為二元運算,如果可能的話,作為一元運算它前面沒有符號(與減號的行為相同)。
答案1
我建議\mathpalette
為了使符號在下標和上標中正確縮放。
減號的高度等於加號,因此我們需要將其粉碎並將其放置在與加號一樣寬的框中。垂直模型將確保正確的高度和深度。
\documentclass{article}
\usepackage{graphicx}
\makeatletter
\newcommand{\newdiv}{\mathbin{\mathpalette\@newdiv\relax}}
\newcommand{\@newdiv}[2]{%
\begingroup
\sbox\z@{$\m@th#1+$}%
\makebox[\wd\z@]{\smash{\rotatebox[origin=c]{45}{$\m@th#1-$}}}%
\vphantom{\usebox{\z@}}%
\endgroup
}
\makeatother
\setlength{\fboxsep}{0pt}\setlength{\fboxrule}{0.1pt}% just for the example
\begin{document}
$a+b$ \fbox{$a+b$}
$a\newdiv b$ \fbox{$a\newdiv b$}
$\scriptstyle a+b\newdiv c$
\end{document}