# Labelled mapsto with two vertical bars

I would like to use a labeled mapsto (specifically, \xmapsto from \usepackage{mathtools}), but with two vertical bars (as in \Vdash from \usepackage{amsmath,amssymb}).

I tried to adapt the answer from here, but I cannot seem to align the additional vertical line correctly (see below).

What is the correct way to do this? My goal is to have something like the last command in the figures, but with both vertical lines at the same height, and of the same length.

\documentclass[a4paper]{article}

\usepackage[english]{babel}

\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}

\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}


\mapsto is composed with \mapstochar and \rightarrow.

Here I use \mapstochar together with \relbar (the middle part of extendable arrows) with some backing up.

\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}


With the arrow bar only from the rightmost vertical line:

\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}


• Awesome, this is almost exactly what I was looking for. It would be slightly better if the horizontal line would only go up to the right vertical line, instead of up to the left one (like for \VDash). Is there an easy fix for this? If not, I can make due... – Peter Aug 21 '18 at 16:18
• @Peter Not really easy, I'm afraid: \mapstochar has a small outdent but also has zero width, so some guess work is needed. Do you plan to use such symbol also in subscripts or superscripts? – egreg Aug 21 '18 at 16:29
• I don't expect to use the symbol itself in subscripts/superscripts (I will have superscripts/subscripts in the labels though). But if there is no simple solution, that is fine. Your current solution is quite nice. – Peter Aug 21 '18 at 16:34
• @Peter Added the required variant – egreg Aug 21 '18 at 17:17

Here is a solution adapted from a code found in Mathmode (§ 38 Extensible arrows):

\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}


• This is very nice an clean. However, it does not seem to work for short texts (e.g., t), or empty texts. – Peter Aug 22 '18 at 7:40
• @Peter: I didn't think of testing this, and I have no idea why it doesn't work. However, in the case of empty texts, just add a \quad as one of the arguments. If both arguments exists and are too short, you can put one of them in a \makebox[1em]{...}. I suppose this could be coded, but it would make the code much longer, and I'm not sure it's worth the effort. – Bernard Aug 22 '18 at 9:00