5

I want to write following formula in Latex:

Formula

The problem is the "i" underneath "x". It is not a regular fraction. It means that value "x" will be replaced with "i". How can I write this one in Latex? Additionally, the underlines are longer than the regular one which is used by typing "_". How can I modify the lenght of the underline?

    \documentclass[12pt, a4paper]{article}
    \usepackage[T1]{fontenc}                
    \usepackage[utf8]{inputenc}             
    \usepackage[english,ngerman]{babel} 
    \usepackage{amsmath,amsfonts,amssymb,amstext} 

    \begin{document}
    $\langle x\,\,\underline{\,\,\,}\rangle_{k}\,\,\langle \underline{\,\,}\,\,x \mapsto i\,\,\underline{\,\,\,}\rangle_{state}$
    \end{document}

Hopefully, you can help me.

Edit:

Thanks for your help! I have copied your extension and pasted it into my align environment.

\begin{align}
\centerline{Computational rules}
\[
p[\tabbedShortunderstack{
\udash{l_1}&,&\udash{l_2}&,&\dots&,&\udash{l_n}\\
r_1        & & r_2       & &     & & r_n
}]
\]
\centerline{Structural rules}
\[
p[\tabbedShortunderstack{
\uddash{l_1}&,&\uddash{l_2}&,&\dots&,&\uddash{l_n}\\
r_1         & & r_2        & &     & & r_n
}]
\]
\end{align}

If I try to run it, process stops with following error:

Bad math environment delimiter. \end{align}

What does that mean?

  • 1
    Welcome to TeX.SE! Please show us the code you have so far ... – Kurt Oct 28 '18 at 22:59
  • Welcome! TikZ... do your work!! – manooooh Oct 28 '18 at 23:09
  • I have edited my first post. There is the code. – user2379123 Oct 28 '18 at 23:13
  • 1
    @user2379123 Can you undelete your previous question? – egreg Oct 29 '18 at 0:25
  • Seeing your deleted comment (that was given as an answer), I have provided a supplement to my answer to provide dashed lines. I am not sure your gist of "not predefining any commands." This is the purpose of macros, to save on typing. One could always take the macro and replace it with definition of the macro...but why? – Steven B. Segletes Nov 2 '18 at 12:55
5

Here's one idea. In the MWE, you can adjust the .7em specification to change the size of both the underscore and the \mygap.

\documentclass{article}
\usepackage{tabstackengine,amssymb}
\stackMath
\newcommand\udash[2][\hrulefill]{\stackunder{#2}{\makebox[.7em]{#1}}}
\newcommand\mygap{\udash[]{}}
\begin{document}
\[
\langle\tabbedShortunderstack{
  \udash{x}&\mygap&\udash{}\\ i&&}\rangle_k 
  \langle\udash{}\mygap x \mapsto i\mygap\udash{}\rangle_{\mathrm{state}}
\]
\end{document}

enter image description here

SUPPLEMENT

Seeing the OP's deleted answer, I have extended the result to include line dashing. Also, here, \udash and \uddash will extend to the width of the argument (plus a little buffer), but with a minimum width of .7em.

\documentclass{article}
\usepackage{tabstackengine,amssymb}
\stackMath
\newlength\replength
\newcommand\ruleht{0pt}% ELEVATION OF RULE
\newcommand\repfrac{.6}% SOLID FRACTION OF DASH LINE [0->1] (USE 1 FOR SOLID)
\replength=.2em\relax% PERIOD OF DASHED RULE
\newcommand\rulewidth{.4pt}% THICKNESS OF RULE
\newcommand\drulefill{\leavevmode\dashfill\hfil%
  \kern\dimexpr\repfrac\replength-\replength\relax}
\newcommand\dashfill[1][\repfrac]{\cleaders\hbox to \replength{%
  \smash{\rule[\ruleht]{\repfrac\replength}{\rulewidth}}}\hfill}

\newcommand\udash[2][\hrulefill]{%
  \setbox0=\hbox{\stackon{\kern.7em}{\,#2\,}}%
  \stackunder{#2}{\makebox[\wd0]{#1}}}
\newcommand\uddash[1]{\udash[\drulefill]{#1}}
\newcommand\mygap{\hspace{.7em}}
\begin{document}
\[
\langle\tabbedShortunderstack{
  \udash{x}&\mygap&\udash{}\\ i&&}\rangle_k 
  \langle\udash{}\mygap x \mapsto i\mygap\udash{}\rangle_{\mathrm{state}}
\]
\centerline{Computational rules}
\[
 p[\tabbedShortunderstack{
   \udash{l_1}&,&\udash{l_2}&,&\dots&,&\udash{l_n}\\
   r_1        & & r_2       & &     & & r_n
 }]
\]
\centerline{Structural rules}
\[
 p[\tabbedShortunderstack{
   \uddash{l_1}&,&\uddash{l_2}&,&\dots&,&\uddash{l_n}\\
   r_1         & & r_2        & &     & & r_n
 }]
\]
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.