有非交换分数的符号吗?我知道\holter
,\polter
(这里),但它们非常丑陋(侧线对我来说太长了)
编辑:我所说的非交换分数是指非交换竞赛中的除法;例如在非交换乘法群中,我们有两种可能的除法,即ab^{-1}
和 b^{-1}a
,因此,为了区分它们,我们不能写\frac ab
,而是\holter ab
或\polter ab
。
答案1
这里提供了可设置的\holter
和版本\polter
。可设置的参数包括\strutheight
,支柱的高度(+深度)\strutdepth
,,支柱的深度,,\strutpad
相对于最长参数添加到水平规则的额外长度,以及\strutrule
,规则线的粗细。我将规则高度设为固定长度,但如果您希望\strutheight
和\strutdepth
与参数高度和深度相匹配,也可以这样做。
\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\stackMath
\newlength\strutrule
%HERE ARE YOUR SETTABLE PARAMETERS
\def\strutheight{2.7ex}
\def\strutdepth{-.8ex}
\def\strutpad{2pt}
\setlength\strutrule{.1ex}
%
% From egreg's answer at
% http://tex.stackexchange.com/questions/145306/cramped-style-again-working-simple-code
\def\cramped#1{%
\kern-\nulldelimiterspace\radical0{#1}
}
\def\xolterstrut{\rule[\strutdepth]{\strutrule}{\strutheight}}
\newlength\xolterlen
\newcommand\holter[2]{%
\setlength\xolterlen{\maxof{\widthof{$#1$}}{\widthof{$#2$}}}%
\addtolength\xolterlen{\strutpad}%
\stackon[-.8\strutrule]{%
\stackanchor[-.8\strutrule]{\rule{\xolterlen}{\strutrule}}{%
\makebox[\xolterlen]{$\cramped{#2}$}\xolterstrut}%
}{\xolterstrut\makebox[\xolterlen]{$#1$}}%
}
\newcommand\polter[2]{%
\setlength\xolterlen{\maxof{\widthof{$#1$}}{\widthof{$#2$}}}%
\addtolength\xolterlen{\strutpad}%
\stackon[-.8\strutrule]{%
\stackanchor[-.8\strutrule]{\rule{\xolterlen}{\strutrule}}{%
\xolterstrut\makebox[\xolterlen]{$\cramped{#2}$}}%
}{\makebox[\xolterlen]{$#1$}\xolterstrut}%
}
\begin{document}
$x = \holter{abcg}{deg}$,
$y = \polter{abcg}{deg^2}$
\end{document}
答案2
我担心,有了这样的符号,就谈不上优雅了。
\documentclass{article}
\usepackage{mathtools}
\newcommand{\holter}[2]{%
\mathinner{
\sbox0{$\textstyle\,\cramped{#2}\,$}%
\sbox2{\copy0\vrule height\ht\strutbox}
\raise\dimexpr-\ht2-\dp2-2pt+\fontdimen22\textfont2\relax\vbox{
\offinterlineskip
\ialign{%
##\cr
\vrule\hfil$\textstyle\,#1\,\mathstrut$\hfil\cr
\vrule height 1pt\hfil\cr
\noalign{\hrule}
\hfil\vrule height1pt\cr
\hfil\box0\hfil\vrule height\ht\strutbox\cr
\hfil\vrule height1pt\cr
}
}%
}
}
\newcommand{\polter}[2]{%
\mathinner{
\sbox0{$\textstyle\,\cramped{#2}\,$}%
\sbox2{\copy0\vrule height\ht\strutbox}
\raise\dimexpr-\ht2-\dp2-2pt+\fontdimen22\textfont2\relax\vbox{
\offinterlineskip
\ialign{%
##\cr
\hfil$\textstyle\,#1\,\mathstrut$\hfil\vrule\cr
\hfil\vrule height1pt\cr
\noalign{\hrule}
\vrule height1pt\hfil\cr
\vrule height\ht\strutbox\hfil\box0\hfil\cr
\vrule height1pt\hfil\cr
}
}%
}
}
\begin{document}
\[
\frac{g}{g}\holter{a}{b}\holter{g}{g}\quad\polter{a}{b}\quad\holter{x}{y^2}
\]
\end{document}
分数是为了表明分数线垂直放置在正确的位置。