Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How to create an equation like in the image below. I tried to use \cfraq and \hline but with no success. I am asking for the layout only, not the formulae.

enter image description here

share|improve this question
    
What should be the rule governing the separator lines in the left column? –  egreg Sep 3 '13 at 12:57
    
@egreg I am afraid I do no understand the question, could you paraphrase ? They should be as long as the equation below them. –  tdi Sep 3 '13 at 13:01
    
That was the question. ;-) –  egreg Sep 3 '13 at 13:01
    
@egreg I can easily recreate this with align I just do not know how to add these lines. –  tdi Sep 3 '13 at 13:03
    
Why don't you post the code that you have to this point, for us to use a starting point? –  Steven B. Segletes Sep 3 '13 at 13:52

1 Answer 1

up vote 4 down vote accepted

Something like this?

\documentclass{article}
\usepackage{amsmath,array,booktabs,collcell}

\newenvironment{productions}
 {\begin{equation*}
  \begin{array}{
    >{\collectcell\firstcolumn}c<{\endcollectcell}
    >{\displaystyle}l
  }
 }
 {\end{array}
  \global\firstcelltrue
  \end{equation*}}

\newif\iffirstcell
\firstcelltrue

\newcommand{\firstcolumn}[1]{%
  \begin{tabular}[b]{c}
  \iffirstcell
    \global\firstcellfalse
  \else
    \addlinespace[2ex]\midrule\addlinespace[2ex]
  \fi
  $\displaystyle#1$
  \end{tabular}
}

\begin{document}

\begin{productions}
b \xrightarrow{b} \surd &
  (\frac{}{v\xrightarrow{v}\surd},
   \quad v:=b) \\

a+b \xrightarrow{b} \surd &
  (\frac{y\xrightarrow{v}\surd}{x+y\xrightarrow{v}\surd},
   \quad v:=b, x:=a, y:=b) \\

(a+b)\cdot c \xrightarrow{b} c &
  (\frac{x\rightarrow{v}\surd}{x\cdot y\xrightarrow{v}y},
   \quad v:=b, x:=a+b, y:=c) \\

((a+b)\cdot c)\cdot d \xrightarrow{b} c\cdot d &
  (\frac{x\rightarrow{v}x'}{x\cdot y\xrightarrow{v}x'\cdot y},
   \quad \!
   \begin{aligned}[t]
   & v:=b, x:=(a+b)\cdot c, \\
   & x':=c, y:=d) \\
   \end{aligned}
\end{productions}
\end{document}

enter image description here

share|improve this answer
    
WOW, you are a tex machine :) –  tdi Sep 3 '13 at 17:19
    
@tdi The Joy of TeX! –  egreg Sep 3 '13 at 17:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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