[Tex/LaTex] How to use unicode symbols in TeX source

unicode

I've tried using \usepackage[utf8]{inputenc}, but that throws an error:

Package inputenc Error: Unicode char µ (U+B5)
(inputenc)                not set up for use with LaTeX.

Whatever I do, unicode character in the source either do not appear, or do not appear and throw an error. I would like to use both Russian and mathematical symbols in my source code.

How can I do this?

Best Answer

Probably this will miss more complex scenarios, but from here:

%%
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\DeclareUnicodeCharacter{B5}{\ifmmode\mu\else\textmu\fi}
%
% use http://shapecatcher.com/ to find the char
% or https://w3c.github.io/xml-entities/unicode-names.html

\begin{document}

This is a textmode µ and this a math mode one: $µ_µ$.

\end{document}

Output from above

If you do not want to define everything, you need to switch to a native unicode TeX engine, like for example xelatex. If you compilte with xelatex the following code:

%%
\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
%
% use http://shapecatcher.com/ to find the char
% or https://w3c.github.io/xml-entities/unicode-names.html

\begin{document}

Is the character ẁ used in some language?

This is a textmode µ and this a math mode one: $𝜇_𝜇$. 
(But be careful, math mu is a different unicode codepoint,
\texttt{1D707}.)

\end{document}

to obtain:

enter image description here

Where I am using the unicode-math package; I found the mathmode µ codepoint at shapcatcher.