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.

I'm trying to use inference from semantic package to describe static semantics of a language.

I would like to separate nonterminals in inference rules with spaces without inserting them by hand.

Is there a way to automatically separate the words SimpleExpr_1 RelOper SimpleExpr_2 from following code with spaces, as if it was written as SimpleExpr_1\ RelOper\ SimpleExpr_2 ?

\inference
  {\Gamma \vdash Expr_1 : \textsc{Integer} \quad 
   \Gamma \vdash Expr_2 : \textsc{Integer}}
  {\Gamma \vdash SimpleExpr_1 RelOper SimpleExpr_2 : \textsc{Boolean}}

Edit: I should add, that I tried solution presented here: Making mathmode obey spaces , but for reasons unknown to me it doesn't seem to apply to inference. Any ideas?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

I see you are already using \quad, the other spacing command in math mode are:

\, thin space

\: medium space

\; thicker space

\quad thicker

\qquad and thicker

\! negative thin space

share|improve this answer
add comment

One way is to redefine \predicatebegin to define spaces in math mode as not ignored. A subtle point, though, is that the tokens have already been read, so spaces already have catcode 10. This can be reverted using \scantokens. I thought it would be best to only scan tokens from |- to :, but this can easily be changed.

\documentclass{article}
\usepackage{semantic}

\begingroup\catcode`\ =\active%
\gdef\mathobeyspaces{\catcode`\ =\active\let =\ }%
\endgroup

\def\predicatebegin#1|-#2:#3\predicateend
  {$#1|-\mathobeyspaces \scantokens{#2}:#3$}%

\begin{document}
\inference
  {\Gamma |-Expr_1:\textsc{Integer} \quad 
   \Gamma |-Expr_2: \textsc{Integer}}
  {\Gamma |-SimpleExpr_1 RelOper SimpleExpr_2: \textsc{Boolean}}
\end{document}
share|improve this answer
add comment

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.