6 Star 37 Fork 2

李文威/AlJabr-1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
myarrows.sty 3.56 KB
一键复制 编辑 原始数据 按行查看 历史
Wen-Wei Li 提交于 2020-06-30 15:09 . Changed the naming of boxes
% Copyright 2018 李文威 (Wen-Wei Li).
% Permission is granted to copy, distribute and/or modify this
% document under the terms of the Creative Commons
% Attribution 4.0 International (CC BY 4.0)
% http://creativecommons.org/licenses/by/4.0/
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{myarrows}[2018/02/20 Package for extendable arrows]
\RequirePackage{amsmath}
\RequirePackage{tikz-cd}
% 以下用 tikz 定义可伸缩箭头, 不用 amsmath 和 extarrows 的版本以免 unicode-math 产生问题. 代码借自 Antal Spector-Zabusky
% 重定义 \xrightarrow[below]{above}
\makeatletter
\newbox\xratbelow
\newbox\xratabove
\renewcommand{\xrightarrow}[2][]{%
\setbox\xratbelow=\hbox{\ensuremath{\scriptstyle #1}}%
\setbox\xratabove=\hbox{\ensuremath{\scriptstyle #2}}%
\pgfmathsetlengthmacro{\xratlen}{max(\wd\xratbelow, \wd\xratabove) + .6em}%
\mathrel{\tikz [->, baseline=-.75ex]
\draw (0,0) -- node[below=-2pt] {\box\xratbelow}
node[above] {\box\xratabove}
(\xratlen,0) ;}}
% 重定义 \xlefttarrow[below]{above}
\renewcommand{\xleftarrow}[2][]{%
\setbox\xratbelow=\hbox{\ensuremath{\scriptstyle #1}}%
\setbox\xratabove=\hbox{\ensuremath{\scriptstyle #2}}%
\pgfmathsetlengthmacro{\xratlen}{max(\wd\xratbelow, \wd\xratabove) + .6em}%
\mathrel{\tikz [<-, baseline=-.75ex]
\draw (0,0) -- node[below] {\box\xratbelow}
node[above] {\box\xratabove}
(\xratlen,0) ;}}
% 重定义 \xleftrightarrow[below]{above}
\renewcommand{\xleftrightarrow}[2][]{%
\setbox\xratbelow=\hbox{\ensuremath{\scriptstyle #1}}%
\setbox\xratabove=\hbox{\ensuremath{\scriptstyle #2}}%
\pgfmathsetlengthmacro{\xratlen}{max(\wd\xratbelow, \wd\xratabove) + .6em}%
\mathrel{\tikz [<->, baseline=-.75ex]
\draw (0,0) -- node[below] {\box\xratbelow}
node[above] {\box\xratabove}
(\xratlen,0) ;}}
% 重定义 \xhookrightarrow[below]{above}, 使用 tikz-cd 的 hookrightarrow
\renewcommand{\xhookrightarrow}[2][]{%
\setbox\xratbelow=\hbox{\ensuremath{\scriptstyle #1}}%
\setbox\xratabove=\hbox{\ensuremath{\scriptstyle #2}}%
\pgfmathsetlengthmacro{\xratlen}{max(\wd\xratbelow, \wd\xratabove) + .6em}%
\mathrel{\tikz [baseline=-.75ex]
\draw (0,0) edge[commutative diagrams/hookrightarrow] node[below] {\box\xratbelow}
node[above] {\box\xratabove}
(\xratlen,0) ;}}
% 重定义 \xhooklefttarrow[below]{above}, 使用 tikz-cd 的 hookleftarrow
\renewcommand{\xhookleftarrow}[2][]{%
\setbox\xratbelow=\hbox{\ensuremath{\scriptstyle #1}}%
\setbox\xratabove=\hbox{\ensuremath{\scriptstyle #2}}%
\pgfmathsetlengthmacro{\xratlen}{max(\wd\xratbelow, \wd\xratabove) + .6em}%
\mathrel{\tikz [baseline=-.75ex]
\draw (0,0) edge[commutative diagrams/hookleftarrow] node[below] {\box\xratbelow}
node[above] {\box\xratabove}
(\xratlen,0) ;}}
% 重定义 \xmapsto[below]{above}, 使用 tikz-cd 的 mapsto
\renewcommand{\xmapsto}[2][]{%
\setbox\xratbelow=\hbox{\ensuremath{\scriptstyle #1}}%
\setbox\xratabove=\hbox{\ensuremath{\scriptstyle #2}}%
\pgfmathsetlengthmacro{\xratlen}{max(\wd\xratbelow, \wd\xratabove) + .6em}%
\mathrel{\tikz [baseline=-.75ex]
\draw (0,0) edge[commutative diagrams/mapsto] node[below] {\box\xratbelow}
node[above] {\box\xratabove}
(\xratlen,0) ;}}
% 定义 \xlongequal[below]{above}, 使用 tikz-cd 的等号
\newcommand{\xlongequal}[2][]{%
\setbox\xratbelow=\hbox{\ensuremath{\scriptstyle #1}}%
\setbox\xratabove=\hbox{\ensuremath{\scriptstyle #2}}%
\pgfmathsetlengthmacro{\xratlen}{max(\wd\xratbelow, \wd\xratabove) + .6em}%
\mathrel{\tikz [baseline=-.75ex]
\draw (0,0) edge[commutative diagrams/equal] node[below] {\box\xratbelow}
node[above] {\box\xratabove}
(\xratlen,0) ;}}
\makeatother
\endinput
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wen-wei-li/AlJabr-1.git
[email protected]:wen-wei-li/AlJabr-1.git
wen-wei-li
AlJabr-1
AlJabr-1
master

搜索帮助