# How to create a custom relation symbol with letters on top and below

How would you create the following relation symbol?

My current solution:

So far I've found a code which puts a letter on top of the \vdash symbol. But it's not exactly what I want:

\documentclass{article}
\newcommand{\xvdash}[1]{%
\vdash^{\mkern-10mu\scriptscriptstyle\rule[-.9ex]{0pt}{0pt}#1}%
}

\begin{document}
$A \xvdash{W} x$
\end{document}


In the end it will look like this:

Are there better ways or packages to do this? How would you increase the size (mostly the width) of the \vdash slightly? Or is there a way to draw a \vdash-like symbol? How would you put a character on top and below? Is there a way to reduce the size of the character?

• Out of curiosity: what dudes this symbol mean? – Martin Thoma Oct 4 '15 at 5:31
• We use this symbol in our theoretical computer science course to denote a relation between two configurations of finite state machines. – ndrizza Oct 4 '15 at 7:50
• $(q,w)$ represent a configuration in a finite state machine (FSM), where $q$ is the current state and $w$ is the word it's processing. The relation symbol (without a star) means that if the FSM evaluates $w$ in state $q$ it will get to the next configuration $(p,u)$ where $q$ is the new state and $u$ is just like the word $w$, except that the first character has been removed (processed). The relation symbol with the star just means that the FSM can get from $(p,w)$ to $(q,u)$ in a finite amount of steps (in this case $u$ may be shorter than $w$ by more than one character. – ndrizza Oct 4 '15 at 7:50

Is this similar to what you want?

\documentclass{article}
\usepackage{pict2e,amsmath,relsize}

\DeclareRobustCommand{\xvdash}[2][]{\mathrel{\drawxvdash{#1}{#2}}}

\newcommand{\drawxvdash}[2]{%
\vcenter{\hbox{%
\setlength{\unitlength}{1em}%
\begin{picture}(1,1)
\roundcap
\put(0,0){\line(0,1){1}}
\put(0,0.5){\line(1,0){1}}
\put(0.5,0){\makebox[0pt]{\text{\smaller$\scriptscriptstyle#2$}}}
\put(0.5,0.6){\makebox[0pt]{\text{\smaller$\scriptscriptstyle#1$}}}
\end{picture}%
}}%
}

\begin{document}

$(q,w)\xvdash[*]{M}(p,u)$

\end{document}


A solution with the \stackinset command, from stackengine:

\documentclass[a4paper, 12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{stackengine}
\newcommand\Mvdash{\mathrel{\stackMath\stackinset{r}{0.1em}{c}{0.15ex}{\setstackgap{L}{1.1ex}\everymath{\scriptscriptstyle}\Vectorstack[c]{* M}}{\vdash\mkern-15mu\raisebox{0.23ex}{$\relbar$}}}}

\begin{document}

$A \Mvdash B$%

\end{document}