LaTeX forum ⇒ MiKTeX and proTeXtUTF-8 support in miktex

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

UTF-8 support in miktex

Postby tuoni » Wed Jul 23, 2008 6:12 pm

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:

\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
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

UTF-8 support in miktex

Postby localghost » Thu Jul 31, 2008 9:34 am

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.
\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¹
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

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

UTF-8 support in miktex

Postby T3. » Thu Jul 31, 2008 10:03 am

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.
\begin{equation}
  \alpha=\sin^{-1}\frac{1}{q}
\end{equation}
I think the whole point of this exercise is that OP wants to use
α instead of \alpha.
At least that's my guess.

Cheers,

Tomek

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

UTF-8 support in miktex

Postby localghost » Thu Jul 31, 2008 10:12 am

T3. wrote:I think the whole point of this exercise is that OP wants to use
α instead of \alpha.
At least that's my guess. [...]

But this is not a valid control sequence. I thought I made that clear.
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

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

UTF-8 support in miktex

Postby T3. » Thu Jul 31, 2008 11:00 am

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

Postby Ted » Thu Jul 31, 2008 12:51 pm

localghost wrote:
T3. wrote:I think the whole point of this exercise is that OP wants to use
α 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

Postby Ted » Thu Jul 31, 2008 1:20 pm

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:
\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

Postby Ted » Thu Jul 31, 2008 2:30 pm

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:
\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:
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:
\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

Postby vga » Sat Aug 16, 2008 2:48 pm

Use XeTeX with unicode-math.


Return to “MiKTeX and proTeXt”

Who is online

Users browsing this forum: No registered users and 2 guests