点积中自动产生令人愉悦的间距

点积中自动产生令人愉悦的间距

后续行动转置和点上标间距向量/矩阵转置的最佳符号是什么?删除符号和其后的上标之间的无用空格 \top以及类似的:

同时,是否有一个包可以自动处理点积(即规范标量积)结构前后\top的间距以及垂直位置,例如\top

v^{\top} \tilde w

取决于实际要增加的东西?

我当前的解决方案是

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{xparse}
\usepackage{amsmath}

\ExplSyntaxOn
%% \transpose{stuff} typesets ⊤ as a right superscript of stuff.
%% \transpose{stuff}[-5mu] typesets ⊤ as a right superscript of stuff, shifting ⊤ by 5mu to the left.
%% Both versions try to do the right kerning between stuff and ⊤.
\NewDocumentCommand{\transpose}{m O{0mu}}{
 #1^{\mathchoice
     {\transposeAux{#1}{#2}{\displaystyle}}
     {\transposeAux{#1}{#2}{\textstyle}}
     {\transposeAux{#1}{#2}{\scriptstyle}}
     {\transposeAux{#1}{#2}{\scriptscriptstyle}}
    }
}
\NewDocumentCommand{\transposeAux}{mmm}{%
  \str_case:nnT {#1}
    {{A}{\mkern-2mu}    {B}{\mkern-1mu}    {C}{\mkern-1mu}    {D}{\mkern-1mu}
     {G}{\mkern-1mu}    {L}{\mkern-2mu}    {M}{\mkern-2mu}    {O}{\mkern-1mu}
     {P}{\mkern-1mu}    {Q}{\mkern-1mu}    {R}{\mkern-1mu}    {S}{\mkern-1mu}
     {V}{\mkern-1mu}    {W}{\mkern-1mu}
     {a}{\mkern-2mu}    {b}{\mkern-2mu}    {c}{\mkern-2mu}    {d}{\mkern-1mu}
     {e}{\mkern-2mu}    {f}{\mkern-1mu}    {g}{\mkern-2mu}    {h}{\mkern-2mu}
     {i}{\mkern-2mu}    {j}{\mkern-2mu}    {k}{\mkern-2mu}    {l}{\mkern-1mu}
     {m}{\mkern-2mu}    {n}{\mkern-2mu}    {o}{\mkern-2mu}    {p}{\mkern-2mu}
     {q}{\mkern-2mu}    {r}{\mkern-2mu}    {s}{\mkern-2mu}    {t}{\mkern-1mu}
     {u}{\mkern-3mu}    {v}{\mkern-2mu}    {w}{\mkern-2mu}    {x}{\mkern-2mu}
     {y}{\mkern-2mu}    {z}{\mkern-2mu}    {0}{\mkern-3mu}
     {\bar c}{\mkern-2mu}    {\bar u}{\mkern-2mu}
     {\check u}{\mkern-2mu}
     {\hat u}{\mkern-3mu}
     {\tilde c}{\mkern-2mu}
     {c'}{\mkern-2mu}
    }
    {\mkern-1mu}
  \mkern#2
  \str_case:nnTF {#1}
    {{a}{\raisebox{-.3ex}{\(#3\top\)}}    {b}{\raisebox{-.1ex}{\(#3\top\)}}
     {c}{\raisebox{-.3ex}{\(#3\top\)}}    {e}{\raisebox{-.3ex}{\(#3\top\)}}
     {g}{\raisebox{-.3ex}{\(#3\top\)}}    {h}{\raisebox{-.3ex}{\(#3\top\)}}
     {i}{\raisebox{-.3ex}{\(#3\top\)}}    {j}{\raisebox{-.3ex}{\(#3\top\)}}
     {k}{\raisebox{-.3ex}{\(#3\top\)}}    {m}{\raisebox{-.3ex}{\(#3\top\)}}
     {n}{\raisebox{-.3ex}{\(#3\top\)}}    {o}{\raisebox{-.3ex}{\(#3\top\)}}
     {p}{\raisebox{-.3ex}{\(#3\top\)}}    {q}{\raisebox{-.3ex}{\(#3\top\)}}
     {r}{\raisebox{-.3ex}{\(#3\top\)}}    {s}{\raisebox{-.3ex}{\(#3\top\)}}
     {u}{\raisebox{-.3ex}{\(#3\top\)}}    {v}{\raisebox{-.3ex}{\(#3\top\)}}
     {w}{\raisebox{-.3ex}{\(#3\top\)}}    {x}{\raisebox{-.3ex}{\(#3\top\)}}
     {y}{\raisebox{-.3ex}{\(#3\top\)}}    {z}{\raisebox{-.3ex}{\(#3\top\)}}
     {0}{\raisebox{-.1ex}{\(#3\top\)}}
     {\bar c}{\raisebox{-.1ex}{\(#3\top\)}}
     {\bar u}{\raisebox{-.1ex}{\(#3\top\)}}
     }
    {} {#3\top}
}
\NewDocumentCommand{\dotProduct}{ m m }{
  \transpose{#1}
  \str_case:nnTF {#2}
    {{a}{\mkern-2mu}    {b}{\mkern-1mu}    {c}{\mkern-2mu}    {d}{\mkern-2mu}
     {e}{\mkern-2mu}    {f}{\mkern-2mu}    {g}{\mkern-2mu}    {h}{\mkern-1mu}
     {i}{\mkern-2mu}    {j}{\mkern-2mu}    {k}{\mkern-1mu}    {l}{\mkern-1mu}
     {m}{\mkern-2mu}    {n}{\mkern-2mu}    {o}{\mkern-2mu}    {p}{\mkern-2mu}
     {q}{\mkern-2mu}    {r}{\mkern-2mu}    {s}{\mkern-2mu}    {t}{\mkern-2mu}
     {u}{\mkern-2mu}    {v}{\mkern-2mu}    {w}{\mkern-2mu}    {x}{\mkern-2mu}
     {y}{\mkern-2mu}    {z}{\mkern-2mu}
  }
  {}{}
  #2
}     
\ExplSyntaxOff
\begin{document}
\[\dotProduct{v}{\tilde w} = \dotProduct{\tilde v}{w} = \dotProduct{V}{\tilde W} = \dotProduct{\tilde V}{W} = \dotProduct{W}{\tilde V} = \dotProduct{\tilde W}{V}\]
\end{document}

里面的代码\dotProduct本质上包含大量大小写分割(可能没有办法解决)。例如,为了令人愉快地排版,v^{\top}\tilde w您实际上想要发出类似这样的代码v^{\mkern-2mu\raisebox{-.3ex}{\top}}\mkern-1mu \tilde w。但对V^{\top} W您来说,最好不要引入任何负面的垂直变化,只引入微小的水平变化。我的版本并不详尽,非常不系统,临时的,自制的,并且从主观上来说,绝对非常令人厌恶。也许有人已经完成了这个繁琐的练习,可以分享他/她的代码,哪个比我的更好?

我使用的是 downtack 符号(这种偏好的原因不在本问题范围内,接受它就好)。生成的字体是 T1。如果能有比 T1 更多的解决方案就好了,但就目前而言,我首先对 T1 就很满意了。

答案1

这不是实际答案,而是一个建议)为了简化代码,您可以这样做,例如:

\NewDocumentCommand \dotProduct { m m }
 {
  \transpose{#1}
  \tl_if_in:nnT { #2 } { bhkl                   } { \mkern -1mu }
  \tl_if_in:nnT { #2 } { acdefgijmnopqrstuvwxyz } { \mkern -2mu }
  #2
 }

理想情况下您会嵌套\tl_if_in:nnTF { .. } { .. } { .. } { \tl_if_in:nnTF .. },但我写了答案来简化代码,并且我认为低效版本不会造成太大危害。

相关内容