packages feed

marxup-1.0.0: examples/LaTeX.hs

{-# OPTIONS_GHC -XTypeSynonymInstances -XOverloadedStrings -XDoRec -pgmF marchup -F #-}

import MarXup.Latex
import MarXup.Tex
import MarXup.DerivationTrees
import Control.Applicative

preamble :: Tex ()
preamble = do
  usepackage ["mathletters"] "ucs"
  usepackage ["utf8x"] "inputenc"


someTree = derivationTree $ Node (rule (mbox "who knows?") "A → B") []

(∶) = binop ":"
γ = cmd "Gamma" nil
(⊢) = binop $ cmd "vdash" nil

x = Tex "x"
y = Tex "y"
a = Tex "a"
b = Tex "b"

(≜) = binop "="

main = render $ latexDocument "article" ["11pt"] preamble $ @"
@section{Markup}

At-syntax is used to call a Haskell function. 

Here comes @sf{some sans-serif text with @em{emphasis}!}

Note that arguments put in braces are markup.
Arguments in parenthesis contain regular Haskell code.
So, we could also write it
@em(text "like this").


@someSection<-section{References}

The result of a call can be bound.
For example, the @sf{section} command returns a label that can be used
for references.

This is section @xref(someSection). Note that cross-references are checked
at ``compile-time''. Forward references also work (see
sec. @xref(concl)).



@section{Math}

Haskell syntax is somewhat more convenient than markup to 
write math. Combined with unicode,
this can make writing all sorts of mathy stuff rather pleasant. For
example: @math(γ ⊢ x ∶ a).

The operators are overloaded to work on text as well:
@displayMath(b ≜ sqrt (a + x/y))
However you must insert parentheses yourself
(until the math sub-DSL is implemented):
@displayMath((x+x)*x)


@concl<-section{Conclusion}


Marχup is awesome. :)

@"