我想要使用带标签的 mapsto (具体来说,\xmapsto
来自\usepackage{mathtools}
),但带有两个垂直条(如\Vdash
来自\usepackage{amsmath,amssymb}
)。
我尝试改编答案这里,但我似乎无法正确对齐额外的垂直线(见下文)。
正确的做法是什么?我的目标是得到类似于图中最后一个命令的东西,但两条垂直线的高度和长度都相同。
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{trimclip,adjustbox}
\newcommand{\XmapstoA}[1]{%
\mathrel{\text{\clipbox{0pt {0.40\height} {.8\width} 0pt}{$\Vdash$}}\mkern.9mu}\xmapsto{#1}
}
\newcommand{\XmapstoB}[1]{%
\mathrel{
\text{\clipbox{0pt 0pt {.8\width} 0pt}{$\Vdash$}}
\mkern.9mu
\text{\adjustbox{width=.87\width,height=\height}{$\xmapsto{#1}$}}
}
}
\newcommand{\VDashA}{%
\mathrel{\text{\clipbox{0pt 0pt {.8\width} 0pt}{$\Vdash$}}\mkern.9mu}\vDash
}
\newcommand{\VDashB}{%
\mathrel{
\text{\clipbox{0pt 0pt {.8\width} 0pt}{$\Vdash$}}
\mkern.9mu
\text{\adjustbox{width=.87\width,height=\height}{$\vDash$}}
}
}
\begin{document}
\begin{align*}
\vDash && \text{\textbackslash vDash}\\
\Vdash && \text{\textbackslash VDash} \\
\xmapsto{abcdef} && \text{\textbackslash xmapsto\{abcdef\}} \\
\XmapstoA{abcdef} && \text{\textbackslash XmapstoA\{abcdef\}} \\
\XmapstoA{ABCDEFG_2^2} && \text{\textbackslash XmapstoA\{ABCDEFG\_2\textasciicircum{}2\}} \\
\XmapstoB{abcdef} && \text{\textbackslash XmapstoB\{abcdef\}} \\
\XmapstoB{abcdef^2} && \text{\textbackslash XmapstoB\{abcdef\textasciicircum{}2\}}
\end{align*}
\end{document}
答案1
\mapsto
\mapstochar
由和组成\rightarrow
。
这里我将其\mapstochar
与(伸缩箭头的中间部分)一起使用\relbar
,并进行了一些备份。
\documentclass{article}
\usepackage{amsmath,mathtools}
\newcommand{\mmapsto}{\mapstochar\relbar\mathrel{\mkern-12mu}\mapsto}
\newcommand{\xmmapsto}{\mapstochar\relbar\mathrel{\mkern-12mu}\xmapsto}
\begin{document}
$a\mmapsto b$
$a\xmmapsto{bcdefg} h$
\end{document}
使用箭头条仅从最右侧的垂直线开始:
\documentclass{article}
\usepackage{amsmath,mathtools,amssymb}
\usepackage{pict2e}
\makeatletter
\DeclareRobustCommand{\mmapstochar}{%
\mathrel{\mkern1mu\mathpalette\mmaps@to@char\relax\mkern0.5mu}%
}
\newcommand{\mmaps@to@char}[2]{%
\vcenter{\hbox{%
\setlength{\unitlength}{\mmaps@fd{#1}}%
\linethickness{\variable@rule{#1}}%
\begin{picture}(0,1)
\roundcap
\Line(0,-0.175)(0,1.17)
\end{picture}%
}}%
}
\newcommand{\mmaps@fd}[1]{%
\fontdimen22
\ifx#1\displaystyle\textfont\else
\ifx#1\textstyle\textfont\else
\ifx#1\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi2
}
\newcommand{\variable@rule}[1]{%
\fontdimen8
\ifx#1\displaystyle\textfont3\else
\ifx#1\textstyle\textfont3\else
\ifx#1\scriptstyle\scriptfont3\else
\scriptscriptfont3\relax
\fi\fi\fi
}
\makeatother
\newcommand{\mmapsto}{\mmapstochar\mapsto}
\newcommand{\xmmapsto}{\mmapstochar\xmapsto}
\begin{document}
$a\mapsto b$
$a\mmapsto b$
$a\xmmapsto{bcdefg} h$
$\scriptstyle a\mmapsto b$
\end{document}
答案2
Mathmode
以下是根据(§38 可扩展箭头)中的代码改编的解决方案:
\documentclass{article}
\usepackage{mathtools, amssymb}
\makeatletter
\newcommand\xVdasharrow[2][]{%
\ext@arrow 0099{\xVdasharrowfill@}{#1}{#2}}
\def\xVdasharrowfill@{%
\arrowfill@{\vcenter{\hbox{$\Vdash$}}}\relbar\rightarrow }
\makeatother
\begin{document}
\[ A\xVdasharrow[ \text{very long sentence}]{\text{This is a very very}}B \]%
\end{document}