tags:

views:

658

answers:

4

I want to create a lab write-up with LaTeX in Ubuntu, however my text includes Scandinavian characters and at present I have to type them in using /"a and "/o etc. Is it possible to get the latex-compiler to read these special characters when they are typed in as is? Additionally, I would like vim to "read" Finnish: Now when I open a .tex-document containing Scandinavian characters, they are not displayed at all in vim. How can I correct this?

+4  A: 

For latex, use the inputenc option:

\usepackage[utf8]{inputenc}

Instead of utf8, you may use whatever else fits you, like latin1, as well.

Now the trick is to make your terminal run the same character encoding. It seems that it runs a character/input encoding that doesn't fit your input right now.

For this, refer to the "Locale" settings of your distribution. You can always check the locale settings in the terminal by issueing locale. These days, UTF8 locales are preferred as they work with every character imaginable. If your terminal's environment is set up correctly, vim should happily work with all your special characters without mourning.

ypnos
In the past, I have had some trouble getting inputenc to work with UTF-8 (using MiKTeX 2.7 on Windows, though). Latin-1 has always worked perfectly, so unless you intend to use the features of Unicode, I would start with Latin-1.
kquinn
Everything seems to work now. As I changed inputenc to utf-8, the LaTeX code worked fine with the scandinavian characters. As to the terminal encoding and vim, it seems that I had opened the LaTex template on another editor which couldn't handle the special characters and then saved it losing them.
Zequj
A: 

I use the UCS unicode support: http://iamleeg.blogspot.com/2007/10/nice-looking-latex-unicode.html

Graham Lee
+3  A: 

To find out in which encoding Vim thinks the document is, try:

:set enc

To set the encoding to UTF-8, try:

:set enc=utf8
Kaarel
'enc' is the encoding that is used by Vim to store internal data. To find out or set current buffer encoding you should use :set fenc
Paul
I tested with a file containing "ÕÄÖÜ". Setting "enc=utf8" shows these characters correctly, while "fenc=utf8" seems to have no effect. But I'm actually confused by the enc/fenc business. I've set the answer to community wiki.
Kaarel
+1  A: 

I can't help with vim, but for LaTeX I recommend you check out XeTeX, which is an extension of TeX that is designed to support Unicode input. XeTeX is now part of Texlive, so if you have TeX installed chances are you already have it.

Norman Ramsey