mcveat
mcveat

Reputation: 1416

Latex directives in template are causing `error in unicode escape`

I want to include some LaTEX code in play framework 2.0 template, namely:

\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}

Of course play complains with error in unicode escape error message because of \us... parts.

How should I escape those pieces of text, so play compiles the template and I get verbatim LaTeX code in result? Tried my luck with @Html(), but it doesn't work either...

Upvotes: 0

Views: 239

Answers (2)

ndeverge
ndeverge

Reputation: 21564

Or, based on @biesior answer, create a latex.scala.html file containing:

@(latexStatement:String)

@{
    "\\" + latexStatement
}

To use it:

@latex("usepackage[T1]{fontenc}")
@latex("usepackage[latin9]{inputenc}")
@latex("usepackage{babel}")

Upvotes: 1

biesior
biesior

Reputation: 55798

Create an method ie in Application.java controller:

public static String latex(String s){
    return "\\"+s;
}

So you can use it in the view:

@Application.latex("usepackage[T1]{fontenc}")
@Application.latex("usepackage[latin9]{inputenc}")
@Application.latex("usepackage{babel}")

Upvotes: 2

Related Questions