Yesterday I started installing TexLive 2009 (http://code.google.com/p/freebsd-texlive/)
Finally today it was finished, so I had a chance to test my test.tex file
Problem
I'm native Latvian speaker so I need Latvian character (Ä“Å«Ä«ÄšģķļžÄņ) support in my UTF-8 tex files. I was battling this for few hours. *tex just didn't want to cooperate.
The real problem is that LaTeX don't have proper fonts to render my characters, or it has, but I don't know how to load them (yet)
Solution 1
So I figured 1st way around:
I figure, if latex can compose characters lets use sed to translate Latvian UTF-8 characters to codes, that latex understands.
lv-uft8.sed
so now I could
and it worked. The solution is far from perfect, but this will work with any older latex realisation. It will also work, if you don't have proper fonts to render correct characters (this doesn't work for Chinese however )
PROS:
* Will work probably on any LaTeX, even on old ones
CONS:
* works only for latin
* hyphenation won't work for word, where "special" characters are used
Solution 2 - recommended
About hour later I found the real solution to the problem.
I found out, that If I add
to preamble (before begin{document} after \documentclass ...) and use xelatex to compile my tex file, it works I could see my native characters on resulting pdf. As I understand this lets xelatex use system fonts to render characters
for hyphenation use \usepackage[latvian]{polyglossia} {replace latvian with your lang}
Resources:
http://wiki.lyx.org/LyX/XeTeX
See also:
http://en.wikibooks.org/wiki/LaTeX/Accents
http://spectroscopy.mps.ohio-state.edu/symposium_53/latexinstruct.html
Finally today it was finished, so I had a chance to test my test.tex file
Problem
I'm native Latvian speaker so I need Latvian character (Ä“Å«Ä«ÄšģķļžÄņ) support in my UTF-8 tex files. I was battling this for few hours. *tex just didn't want to cooperate.
The real problem is that LaTeX don't have proper fonts to render my characters, or it has, but I don't know how to load them (yet)
Solution 1
So I figured 1st way around:
I figure, if latex can compose characters lets use sed to translate Latvian UTF-8 characters to codes, that latex understands.
lv-uft8.sed
Code:
# Ar Å¡Ä« faila un sed komandas palÄ«dzÄ«bu var vienkÄrÅ¡Ä veidÄ piespiest
# LaTeX saprast latvieÅ¡u simbolus failÄ ar UTF-8 kodÄ“jumu
# Lietošanas piemērs
# sed -f lv-uft8.sed in.tex > out.tex
# Pēc komandas izpildīšanas, out.tex var nodot LaTeXam
#
# Izveidoja: Aldis Berjoza <aldis@bsdroot.lv>
# Datums: 30.05.2010
s/Ä“/\\={e}/g
s/Å«/\\={u}/g
s/Ä«/\\={\\i}/g
s/Ä/\\={a}/g
s/Å¡/\\v{s}/g
s/Ä£/\\v{g}/g
s/Ä·/\\c{k}/g
s/ļ/\\c{l}/g
s/ž/\\v{z}/g
s/Ä/\\v{c}/g
s/ņ/\\c{n}/g
s/Ä’/\\={E}/g
s/Ū/\\={U}/g
s/Ī/\\={I}/g
s/Ä€/\\={A}/g
s/Å /\\v{S}/g
s/Ä¢/\\c{G}/g
s/Ķ/\\c{K}/g
s/Ä»/\\c{L}/g
s/Ž/\\v{Z}/g
s/Č/\\v{C}/g
s/Å…/\\c{N}/g
Code:
$ sed -f lv-uft8.sed in.tex > out.tex
$ pdflatex out.tex
PROS:
* Will work probably on any LaTeX, even on old ones
CONS:
* works only for latin
* hyphenation won't work for word, where "special" characters are used
Solution 2 - recommended
About hour later I found the real solution to the problem.
I found out, that If I add
Code:
\usepackage{xltxtra}
for hyphenation use \usepackage[latvian]{polyglossia} {replace latvian with your lang}
Resources:
http://wiki.lyx.org/LyX/XeTeX
See also:
http://en.wikibooks.org/wiki/LaTeX/Accents
http://spectroscopy.mps.ohio-state.edu/symposium_53/latexinstruct.html