Fonts & Character SetsProblem with output unicode letters

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
eiterorm
Posts: 24
Joined: Fri Dec 25, 2009 6:40 pm

Problem with output unicode letters

Post by eiterorm »

Hi!
My situation is very similar to this guy's situation, but the answers in that topic was not sufficient. I, too, use TeXnicCenter and MiKTeX 2.7.

I wish to write a lower-case omega in an otherwise french document. After reading the topic mentioned above, I tried using the command \char"03C9 to write the unicode character, but this only gave me an error message.

Apparently, the pdflatex compiler doesn't support unicode, so instead I changed the compiler to xelatex, and the output profile to LaTeX => PS => PDF. I added the xunicode package in preamble, and tried again. This time, I got no error messages, but the output PDF file is blank.

My code is shown below:

Code: Select all

\documentclass[11pt, a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ae,aeguill}
\usepackage{xunicode}

\begin{document}

\char"03C9

\end{document}
What am I doing wrong?

Thanks!
Last edited by eiterorm on Mon Jan 04, 2010 11:52 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Problem with output unicode letters

Post by frabjous »

There's absolutely no need to resort to unicode or XeLaTeX if you only want a single omega in your document. Just use $\omega$.

If you want an uninitalicized omega, load the upgreek package, and use $\upomega$.

So for (pdf)latex:

Code: Select all

\documentclass[11pt, a4paper]{article}
\usepackage{upgreek}
\begin{document}

$\omega$ is in italics.

$\upomega$ is not.
\end{document}
But just for the record, I'll take a look at your XeLaTeX code in a second...

EDIT:
The problem with the XeLaTeX code is just the simple one that you haven't specified a font that has a UNICODE character map that includes omega, so there's no character for it to print. This works:

Code: Select all

\documentclass[11pt, a4paper]{article}
\usepackage{ae,aeguill}
\usepackage{fontspec}
\usepackage{xunicode}

\begin{document}

\fontspec{Linux Libertine O} \char"03C9

\end{document}
(Of course, you have to have Linux Libertine O installed--substitute some other font name you have installed that has an omega in the correct place in its character map and see the fontspec documentation for more info.)

Also, you shouldn't use the inputenc package with XeLaTeX--though that wasn't the problem.
eiterorm
Posts: 24
Joined: Fri Dec 25, 2009 6:40 pm

Re: Problem with output unicode letters

Post by eiterorm »

Thanks!

To me, it looks like both your first solutions are using the math environment, but letters inside a math environment look quite misplaced in the middle of other text in a text environment. (I didn't know about the upgreek package, though, so that was a nice tip I'll remember for use in different situations. ;-] )

Your second solution works nicely, though. I substituted your font with Bookman Old Style, and the greek letters no longer look misplaced. Thanks!

However, why should I not use the inputenc package in XeLaTeX? This package gives me the ability to write é, è, ë, etc., which I need. Is there perhaps an alternative I could use?

And by the way: Do you know a where I can find a list of roman-style unicode fonts?
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Problem with output unicode letters

Post by frabjous »

eiterorm wrote:Thanks!

To me, it looks like both your first solutions are using the math environment, but letters inside a math environment look quite misplaced in the middle of other text in a text environment.
Math mode is necessary, since these are math codes designed for use as variables in math. Frequently, however, variables are mentioned in the middle of a paragraph, and using inline math mode $...$, I haven't noticed them looking at all odd there, but it may depend on the particular use in question, and what font packages you have loaded.
However, why should I not use the inputenc package in XeLaTeX? This package gives me the ability to write é, è, ë, etc., which I need. Is there perhaps an alternative I could use?
XeLaTeX is designed for use with UNICODE (UTF8) source, and defaults to it, so no package is needed (well, except xunicode). Feel free to use é, è, ë, etc., without a package. I doubt you'd need ae or aeguill either if your font has guillemets anyway.

Actually if you try to use inputenc with XeLaTeX, you get this warning:
*** you should *not* be loading the inputenc package
*** XeTeX expects the source to be in UTF8 encoding
*** some features of other encodings may conflict, resulting in poor output.
...which is how I know about it.

The only trick is that unless you're using a newer alpha release, TeXnicCenter won't allow you to use UNICODE characters outside of a fairly narrow range -- so either use a different editor, or stick with \char codes.
And by the way: Do you know a where I can find a list of roman-style unicode fonts?
There's a nice list of UNICODE-rich fonts on Alan Wood's UNICODE website. Unifont.org is a good site, especially if you're looking for free fonts.

The mathspec package provides a pretty quick way however of specifying different fonts for Greek letters as opposed to Roman letters with XeLaTeX, which opens things up quite a bit.
eiterorm
Posts: 24
Joined: Fri Dec 25, 2009 6:40 pm

Re: Problem with output unicode letters

Post by eiterorm »

Thank you for the links, and thanks again for all the help. =)
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Re: Problem with output unicode letters

Post by phi »

Also avoid the ae and aeguill packages, they are obsolete. Use inputenc + fontenc + babel + some font package like lmodern + microtype for pdfLaTeX, and fontspec + xunicode + xltxtra + polyglossia for XeLaTeX.
Post Reply