MiKTeX and proTeXtUTF-8 support in miktex

Information and discussion about MikTeX distribution for Windows and the related proTeXt: Installing, updating, configuring
Post Reply
tuoni
Posts: 1
Joined: Wed Jul 23, 2008 6:10 pm

UTF-8 support in miktex

Post by tuoni »

Does anyone know how to use UTF-8 in miktex? I've been going at it for over an hour now, reading all kinds of documents, but to no avail. all I get is "! Undefined control sequence."

Even with such a simple test as this:

Code: Select all

\documentclass[10pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\begin{document}

\begin{equation}
α = sin^{-1} \frac{1}{q}
\end{equation}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

UTF-8 support in miktex

Post by localghost »

Should not be a big problem, provided that your editor also supports unicode. Actually the error is caused by the piece of code for the equation. Hence it should be modified.

Code: Select all

\begin{equation}
  \alpha=\sin^{-1}\frac{1}{q}
\end{equation}
The error message is a little bit more precise than only to say "! Undefined control sequence". The compiler gives the exact line where this error occurs and which expression is the cause.


Best regards
Thorsten¹
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

UTF-8 support in miktex

Post by T3. »

localghost wrote:Should not be a big problem, provided that your editor also supports unicode. Actually the error is caused by the piece of code for the equation. Hence it should be modified.

Code: Select all

\begin{equation}
  \alpha=\sin^{-1}\frac{1}{q}
\end{equation}
I think the whole point of this exercise is that OP wants to use

Code: Select all

α instead of \alpha.
At least that's my guess.

Cheers,

Tomek
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

UTF-8 support in miktex

Post by localghost »

T3. wrote:I think the whole point of this exercise is that OP wants to use

Code: Select all

α instead of \alpha.
At least that's my guess. [...]
But this is not a valid control sequence. I thought I made that clear.
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

UTF-8 support in miktex

Post by T3. »

localghost wrote:But this is not a valid control sequence. I thought I made that clear.
I admit that I'm largely ignorant of input encodings in modern TeX systems. I try to stick to traditional methods for maximal compatibility.

Originally TeX was designed with 7-bit (not even 8-bit!) character representation, so I suspect that some of those limitations stayed with us to this day. Otherwise, I don't see any reason why Unicode alpha character couldn't be mapped to \alpha glyph in the font table.

Anyway, until mainstream TeX engines will come with native support for Unicode it's probably not such a good idea to attempt such tricks.

Cheers,

Tomek
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

UTF-8 support in miktex

Post by Ted »

localghost wrote:
T3. wrote:I think the whole point of this exercise is that OP wants to use

Code: Select all

α instead of \alpha.
At least that's my guess. [...]
But this is not a valid control sequence. I thought I made that clear.
It's true that the character alpha is not a valid control sequence, but the use of inputenc is supposed to take care of converting this character on the fly.

Perhaps the OP should check out the updated inputenx package and its documentation. It has added some characters to the original UTF8 support in inputenc.
-- Ted [home/blog]
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

UTF-8 support in miktex

Post by Ted »

tuoni wrote:Does anyone know how to use UTF-8 in miktex? I've been going at it for over an hour now, reading all kinds of documents, but to no avail. all I get is "! Undefined control sequence."
tuoni wrote:

Code: Select all

\usepackage[utf8x]{inputenc}
\begin{equation}
α = sin^{-1} \frac{1}{q}
\end{equation}
Take a look at the inputenx documentation:
inputenx documentation wrote:The current philosophy of LATEX/package inputenc is not to declare characters for math only. Instead there is a experimental package inpmath that extends package inputenc, to change the behaviour of input characters if used in math mode. File ix-math.def provides some definitions of math characters.
I found inpmath at It should extend inputenc so that you can use it in math environments. Also note that inputenx comes with a ix-utf8enc.dfu file that is supposed to extend the UTF8 from inputenc. I'm not sure how you're supposed to use it, but I know that the standard utf8enc.dfu is pulled in by the standard utf8 definitions file. Maybe you copy the ix- version to your home directory and it uses it instead? That seems wrong.

[ Note that the ix-math.def seems to be pulled in automatically if you load inputenx with the math option. That also appears to load the inpmath package automatically. ]

Alternatively, do you have a TeX editor that can automatically substitute the LaTeX equivalents for you? The argument behind not using the LaTeX equivalents is that it makes things like spellchecking a little messy in main text, but in mathematics mode, there's not so much of an excuse (especially when there are good editors that can do the substitutions for you). Thoughts?
-- Ted [home/blog]
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

UTF-8 support in miktex

Post by Ted »

tuoni wrote:Does anyone know how to use UTF-8 in miktex? I've been going at it for over an hour now, reading all kinds of documents, but to no avail. all I get is "! Undefined control sequence."
After further investigation, it appears like your problem has nothing to do with UTF-8 at all.

This works for me:

Code: Select all

\documentclass[10pt,a4paper]{article}
\usepackage[utf8x,math]{inputenx}
\usepackage[LGR, T1]{fontenc}

\begin{document}

\begin{equation}
α = \sin^{-1} \frac{1}{q}
\end{equation}

\end{document}
In other words, ucs defines \textalpha as an LGR font. So LaTeX was bugging out when it was trying to find a definition for \textalpha. My fontinc line puts you in LGR mode, and everything works. (note: you don't NEED the T1 line if you're OK with your entire document being in LGR, but I'm guessing that you're not okay with that :) ).

Note that I had to use inputenx with the math option. Otherwise the "alpha" would turn into an "a" and I'd get a warning about \textalpha not being valid in math mode. That also requires me to have the inpmath.sty installed in the same directory (or in LaTeX's include path) as my source. Find the experimental impmath package at:
Unzip it into your working directory and run:

Code: Select all

latex inpmath.ins
to generate the required inpmath.sty file.

NOTE: If you don't like using LGR, you'll have to define \textalpha yourself. Perhaps you could use:

Code: Select all

\newcommand\textalpha{\ensuremath{\alpha}}
Then you can get rid of the fontenc line. In fact, if you define \textalpha this way, I think you can go back to using inputenc without the math option (i.e., you won't need inpmath.sty anymore either). The downside is that you'll probably have to manually define every \text* equivalent that you need.
-- Ted [home/blog]
vga
Posts: 1
Joined: Sat Aug 16, 2008 2:47 pm

Re: UTF-8 support in miktex

Post by vga »

Use XeTeX with unicode-math.
Post Reply