\newcommand
我已经看到了一些使用创建新数学符号的例子,例如,
\newcommand\indep{\protect\mathpalette{\protect\independenT}{\perp}} \def\independenT#1#2{\mathrel{\rlap{$#1#2$}\mkern2.5mu{#1#2}}}
但不幸的是,在我看来,这是模糊的废话。
我想创建一个新的数学符号,它很容易被形象化:类似于\oplus
但有一个较小的(居中的)圆圈,就像给出的那个\circ
,这样 + 的线就会延伸到圆圈外面。
如何才能做到这一点?
答案1
这里,\stackinset
将 a\circ
除以 a +
。使用scalerel
将其扩展到所有数学样式。
\documentclass{article}
\usepackage{stackengine,scalerel}
\stackMath
\newcommand\circplus{\mathbin{\ThisStyle{\ensurestackMath{%
\stackinset{c}{}{c}{\dimexpr.1pt-.4\LMpt}{\SavedStyle\circ}{\SavedStyle+}}}}}
\begin{document}
\[
1 + 2 \oplus 3 \circplus 4_{\circplus_{\circplus}}
\]
\end{document}
\oplus
对于适合线宽的东西:
\documentclass{article}
\usepackage{stackengine,scalerel,graphicx}
\def\pieceA{\scalebox{.8}{$\scriptscriptstyle{-}\kern3pt{-}$}}% THE 3pt CAN VARY ARM LENGTH
\savestack\Xoplus{%
\setbox0=\hbox{$\pieceA$}%
\ensurestackMath{%
\kern.5\wd0%
\makebox[0pt]{%
\stackinset{c}{}{c}{}%
{\rotatebox[origin=c]{90}{\copy0}}%
{\stackinset{c}{}{c}{}{\copy0}{\oplus}}%
}%
\kern.5\wd0
}%
}
%\newcommand\xoplus{\mathbin{\scalerel*{\Xoplus}{\oplus}}}% FOR SIMPLE, AS IS SCALING
% FOR TUNABLE SCALING using \xoplusscale
\newcommand\xoplusscale{1}
\newcommand\xoplus{\mathbin{\ThisStyle{\vcenter{\hbox{%
$\SavedStyle\scalerel*{\Xoplus}{\vstretch{\xoplusscale}{\oplus}}$}}}}}
\begin{document}
\[
1 + 2 \oplus 3 \xoplus 4_{\xoplus_{\xoplus}}
\]
\renewcommand\xoplusscale{1.5}
\vspace{-12pt}
\[
1 + 2 \oplus 3 \xoplus 4_{\xoplus_{\xoplus}}
\]
\end{document}
答案2
图片模式来救援!
\documentclass{article}
\usepackage{pict2e,picture}
\makeatletter
\newcommand{\cplus}{\mathbin{\mathpalette\pseudorandom@cplus\relax}}
\newcommand{\pseudorandom@cplus}[2]{%
\vcenter{\hbox{%
\sbox\z@{$\m@th#1+$}%
\setlength{\unitlength}{\dimexpr\ht\z@+\dp\z@}%
\linethickness{.06\unitlength}%
\begin{picture}(\wd\z@,1)
\put(0.5\wd\z@,0.5){\circle{0.5}}
\put(0,0){\raisebox{\depth}{\box\z@}}
\end{picture}%
}}%
}
\makeatother
\begin{document}
\begingroup % show the bounding boxes
\fboxsep=-0.1pt \fboxrule=0.1pt
\fbox{$+$}\fbox{$\cplus$}
\nointerlineskip
\fbox{$\cplus$}\fbox{$+$}
\endgroup
% test for the spacing and subscripts
$a+b\cplus c_{+\cplus}$
$a\cplus b+c_{+\cplus}$
\medskip
% test for larger size
{\LARGE$a\cplus b+c_{+\cplus}$}
\end{document}
适合较轻的笔触\oplus
:
\documentclass{article}
\usepackage{pict2e,picture}
\makeatletter
\newcommand{\cplus}{\mathbin{\mathpalette\pseudorandom@cplus\relax}}
\newcommand{\pseudorandom@cplus}[2]{%
\vcenter{\hbox{%
\sbox\z@{$\m@th#1+$}%
\setlength{\unitlength}{\dimexpr\ht\z@+\dp\z@}%
\linethickness{.06\unitlength}%
\begin{picture}(\wd\z@,1)
\put(0.5\wd\z@,0.5){\circle{0.5}}
\put(0,0){\raisebox{\depth}{\box\z@}}
\end{picture}%
}}%
}
\makeatother
\begin{document}
\fboxsep=-0.1pt \fboxrule=0.1pt
\fbox{$+$}\fbox{$\cplus$}
\nointerlineskip
\fbox{$\cplus$}\fbox{$+$}
$a+b\cplus c_{+\cplus}$
$a\cplus b+c_{+\cplus}$
\medskip
{\LARGE$a\cplus b+c_{+\cplus}$}
\end{document}