1

I have used a hack to output :

% WTF: LaTeX has no € symbol!
% See here: http://en.wikibooks.org/wiki/LaTeX/Special_Characters#Euro_.E2.82.AC_currency_symbol
\usepackage[utf8]{inputenc}             % The input file is in utf-8
\usepackage{marvosym}                   % This package provides some symbols. The € is \EUR{}
\DeclareUnicodeCharacter{20AC}{\EUR{}}  % Now we link the € symbol to the escape sequence

Which is bad enough. Now I am trying to output the ° character, but no idea how to do that. Is there a generic method to output any unicode character supported by the font?

  • latex has \texteuro – David Carlisle Jan 31 '14 at 20:06
  • ° is \textdegree – David Carlisle Jan 31 '14 at 20:08
  • 1
    You can use XeLaTeX, or use \usepackage{newunicodechar}\newunicodechar{€}{\texteuro}. – Manuel Jan 31 '14 at 20:08
4

Note that classic TeX (or pdftex) does not use unicode fonts at all, so you (or the author of the package you are loading) needs to know the encoding used by the font, and to define appropriate commands. The two symbols that you mention, Euro and degree do have standard commands in the base distribution (despite the comment in your example suggesting otherwise).

If you want a generic mapping from Unicode fonts then you are better to use xelatex or lualatex where you may use the system opentype fonts and just enter the unicode text directly.

  • It seems I have no luck :( Using xelatex, lualatex or any-other-latex seems to me a risky proposition: who knows what other issues I will find with those tools. And finding lualatex/xelatex specific solutions to future problems seems like a daunting task. And using latex-specific codes for unicode characters is also a very bad solution: the text in my invoices is going to come from a database, with strings encoded in utf-8. I imagine I could pre-parse those strings to produce the right latex escape sequences (like \textdegree), but this seems a lot of work. – dangonfast Feb 3 '14 at 13:14
  • And I assume there are unicode characters without a corresponding latex escape string, which means those characters can not be displayed by latex at all. No idea how people are solving this problem. And this seems like a very common issue: once you are doing anything in any non-english language, you are going to have to deal with utf-8 (or any other encoding). Are people solving this with XeLaTeX? Is it 100% LaTeX (+ unicode support)? or can I expect XeLaTeX specific issues? – dangonfast Feb 3 '14 at 13:18
  • @gonvaled it's difficult to answer your comment as you seem to be making a lot of incorrect assumptions, and the system doesn't support lengthy discussion in chat. Using xelatex/luatex you can use unicode fonts directly. As I comment in my answer classic TeX uses different font encodings so you need some package support, but people have been doing that for 30 years and Chinese, Japanese, Arabic, Hebrew, Cyrillic, Greek, and all European diacritic letters have good latex support. If you have a specific problem with some specific input please ask a new question on that point, rather than comment – David Carlisle Feb 3 '14 at 13:34
  • @gonvaled The above comment already had to be truncated to fit within the system, which is why a new question is preferable. – David Carlisle Feb 3 '14 at 13:34
  • Thanks David, but my comment stands, and this is the right question for it: "any unicode character". The problem is simple: I have a utf-8 encoded string, which I need to output with latex. I can not do manual processing, so I need an automatic way of displaying any utf-8 string. According to your answer, there seems to be two solutions: use something other than LaTeX (xelatex, ...), or use specific escape strings in LaTeX. Both solutions seem to me suboptimal. The first option would be good if and only if xelatex/lualatex is 100% LaTeX (which I doubt) – dangonfast Feb 3 '14 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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