Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I discovered that if I use some Unicode characters inside .rst files, I will loose them when I convert the documentation to pdf using Sphinx.

Example chars: "șț".

When I run make latexpdf I get a document without these Unicode characters.

share|improve this question

migrated from stackoverflow.com Jun 7 '11 at 13:58

This question came from our site for professional and enthusiast programmers.

2  
this answer from sphinx-dev mailing list can be helpful: groups.google.com/d/topic/sphinx-dev/kUeROyCyX9w/discussion –  marcin Jul 3 '11 at 17:28
    
An option (which I used) is to run xelatex on file produced by Sphinx, though you have to adjust preamble in the config file. –  eudoxos Jul 30 '11 at 18:24
    
@marcin: That link is no longer available. Could you perhaps find it again and include the key points in an answer? –  Macke Feb 19 '13 at 8:11
add comment

2 Answers

Currently You can use xelatex manually for that. Add

latex_elements = {
    'inputenc': '',
    'utf8extra': '',
    'preamble': '''

\usepackage{fontspec}
\setsansfont{Arial}
\setromanfont{Arial}
\setmonofont{DejaVu Sans Mono}
''',
}

to conf.py, make latex code, and run the xelatex manually:

sphinx-build -b latex -d _build/doctrees . _build/xetex && cd _build/xetex; xelatex *.tex
share|improve this answer
add comment

I don't know about Sphinx, but the problem seems to be in the fact that the option utf8 to inputenc doesn't know about the comma below used in Romanian.

You can solve the problem by using the utf8x option or adding to the preamble for LaTeX compilation the following incantation

\makeatletter
\ProvideTextCommandDefault\textcommabelow[1]
  {\hmode@bgroup\ooalign{\null#1\crcr\hidewidth\raise-.31ex
   \hbox{\check@mathfonts\fontsize\ssf@size\z@
   \math@fontsfalse\selectfont,}\hidewidth}\egroup}
\makeatother
\usepackage{newunicodechar}
\newunicodechar{Ș}{\textcommabelow S}
\newunicodechar{ș}{\textcommabelow s}
\newunicodechar{Ț}{\textcommabelow T}
\newunicodechar{ț}{\textcommabelow t}

The code between \makeatletter and \makeatother is from uni-global.def of the ucs package.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.