%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%        File: mnt.sty
%      Author: Oliver Corff
%        Date: December 24, 2004
%     Version: \VersionRelease
%   Copyright: Ulaanbaatar, Beijing, Berlin
%
% Description: The mnt style file provides access to all
%		commands necessary for writing Sino-Mongolian
%		text as in the "Secret History of the Mongols".
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This file contains utf8-encoded material. While editing it
% in non-Unicode environments may break the display of Chinese
% characters, the compile process is safe as all character-
% producing commands are expressed in ASCII-only form.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% -------------------     identification     -------------------
%
\newcommand{\MNTVersionDate}{2004/12/24}
\newcommand{\VersionRelease}{0.3}
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mnt}[\MNTVersionDate: Mongolyn Nuuc Towqoo Characters for LaTeX2e]
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% -------------------      initial code      -------------------
%
\input mntsbnum % Access characters by Sum`yaabaatar's number
\input mntbrnum % Access characters by Bayar's position
\input mntpycmd % Access characters by pinyin style command
%
\def\graphicfileextension{\ifx\pdfoutput\undefined .eps\else .pdf\fi}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ------------------- declaration of options -------------------
%
%\DeclareOption{<my mnt option>}{} % Nothing yet
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% -------------------  execution of options  -------------------
%
%\ProcessOptions
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% -------------------    package loading     -------------------
%
\RequirePackage{CJK} % For Chinese characters
\RequirePackage[\ifx\pdfoutput\undefined\else pdftex\fi]{graphicx}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% -------------------       main code        -------------------
%
% \MNT creates the MNT logo
%
\newcommand{\MNT}{M\textsc{n}T}
%
% The mnt environment is necessary for issuing Chinese characters.
%
\newenvironment{mnt}%
	{%			% at begin of environment
	 \begin{CJK}{UTF8}{}%	% load CJK in Unicode encoding
	 \makepycmdactive%	% Make Pinyin Input active
	} 
	{\end{CJK}} % at end of environment
%
% The mnt is used for small portions of Chinese characters.
%
\newcommand{\textmnt}[1]{%
	\begin{mnt}#1\end{mnt}}
%
\newcommand{\UC}[2]{\CJKchar[UTF8]{#1}{#2}}% prints normal hanzi
%
% The following prints characters stored as bitmaps
%
\DeclareGraphicsExtensions{\graphicfileextension}
\newcount\psvaluecount
\newlength\psscalebase
\newlength\psscalevalue
\def\lzero{0.} % leading zero
\newcommand{\gaiji}[1]{%
	\psscalevalue=\psscalebase
	\psscalevalue=\f@size\psscalevalue
	\psvaluecount\number\psscalevalue\relax
	\raisebox{-2pt}{\includegraphics[scale=\lzero\the\psvaluecount]{#1}}}%
%
\newcommand{\tchar}[1]{\raisebox{0.60ex}{\tiny#1\hspace{-0.15em}}}
%
\newcommand{\xel}{\tchar{\UC{130}{12}}}
\newcommand{\xooloi}{\tchar{\UC{78}{45}}}
\newcommand{\glossencoding}[1]{\def\glossencodingvalue{#1}}
\newcommand{\mntword}[3]{%
	\begin{tabular}{c}
		\textit{#3}\\		% Transliteration on top
		\textmnt{#1}\\		% Text in characters
		\hline			% horizontal line, of course
		\begin{CJK}{\glossencodingvalue}{}	% gloss encoding
		{\scriptsize#2}		% gloss
		\end{CJK}
	\end{tabular}
}
\newcommand\@mntcharerror[2]{%
	\@latex@error{Package MNT: Select between 1 and #2 for syllable #1.}\@ehb}
\newcommand\@mntnumerror{%
	\@latex@error{Package MNT: Number too large for this set of syllables.}\@ehb}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The \MnT\ package ends here.
