escaping backslash in twirl

30 views
Skip to first unread message

Ambrose Kofi Laing

unread,
Mar 25, 2016, 6:59:46 PM3/25/16
to play-framework
Hi all,

I am trying to use twirl to generate a LaTeX source file (which is just a text file).  The view file is called app/views/myfilename.scala.txt.

Everything works except the following line:

\usepackage{apackagename}

I get an error message for this line saying "error in unicode escape."

So I tried this:

@\usepackage{apackagename}

and get an error message saying "Invalid '@' symbol".

Finally I tried this:

\\usepackage{apackagename}

and scala compiles it fine, but the generated text still has two backslashes, and the latex compiler rejects that.

How can I get twirl to generate the substring "\usepackage" with a single backslash, without any unicode error?

scala 2.11.6 and play 2.3.4

Thanks,

Ambrose




Ambrose Kofi Laing

unread,
Mar 25, 2016, 7:15:58 PM3/25/16
to play-framework
Ok I solved it: I used:

\u005Cusepackage{apackagename}

which uses unicode to encode the backslash.  Other backslashes which are not followed by a "u" do not need to be written this way.

Pavel Shapkin

unread,
Jan 19, 2017, 7:29:23 AM1/19/17
to Play Framework
Hi, I found another solution here: you can just turn off \u escaping completely by setting -Xno-uescape scala compiler option.

I'm also trying to use Scala and Twirl for LaTeX processing :)
Reply all
Reply to author
Forward
0 new messages