Devnagari  Pre-processor for LaTeX

I have written my own TeX preprocessor in which phonetic language is translated into kruti ramingaton form of hindi typing.  Follow the given steps to install this package.


Create a root directory of any name.  My TeX package directory has root directory `p2k'. `p2k' has all required files.


Now we are ready to install the package p2k in TeX distribution system. My system is MikTeX. Copy the package where you want to place it. Find the MikTeX Admin from MikTeX and open it. Select the Roots tab, use the Add button to add the package directory, move it to the top location by the Up button. Update database pushing the Refresh FNDB button. Find the updmap.cfg file and add the following line at the end of file:


MixedMap KDevPFB.map


Run following command to update mapped font list:


initexmf --mkmaps


Now, the package is ready to use.  Each time you add new fonts, run  initexmf --mkmaps   command.



Go to the bin directory of the p2k root directory. Open p2k.exe.  Give input file ./doc/input.hi and give output file ./doc/output.tex names.  The phonetic contents is converted into the kruti contents. We can run this as commandline mode as


p2k.exe input.hi output.tex


Run above converted .tex file with following commands.  The .pdf file shall show the result in english as well as devanagari scripts. The compilation commands are:


latex -interaction=nonstopmode hi.tex

dvips -o hi.ps hi.dvi

mgs -sDEVICE=pdfwrite -o hi.pdf hi.ps


The input.hi file codes are given below for compilation.


\PassOptionsToPackage{table}{xcolor}\documentclass{book}% \usepackage{kdev} \usepackage{float}\def\Lcs#1{\texttt{{\footnotesize\textbackslash}#1}} %latex command string\begin{document}  
The synopsis of devnagari command is like \Lcs{dn}\{phonetic contents\}.

We can use devnagari command as explained below \begin{enumerate}\item \Lcs{dn} for normal texts. For example \Lcs{dn}\{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789\} is converted like \dn{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789}. 

\item \Lcs{dnbf} for bold face texts. For example \Lcs{dnbf}\{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789\} is converted like \dnbf{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789}
\item Other are \Lcs{dnit} for italic texts. For example \Lcs{dnit}\{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789\} is converted like  \dnit{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789}
\item \Lcs{dnbi} for bold italic fonts. For example \Lcs{dnbi}\{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789\} is converted like  \dnbi{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789} 

\item \Lcs{dncf} compress fonts. For example \Lcs{dncf}\{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789\} is converted like  \dncf{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789} 

\item \Lcs{dnwf} for wide fonts. For example \Lcs{dnwf}\{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789\} is converted like  \dnwf{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789}
\item \Lcs{dntf} for tight fonts. For example \Lcs{dntf}\{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789\} is converted like  \dntf{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789}\end{enumerate}
We can use \Lcs{dn} and other commands like \Lcs{dn}[ff=bf,ft=10]\{\} too. Here other font face are it, wf, cf, tf, bi etc and font type are 30 and 50.  For example \Lcs{dn}[ff=nf,ft=10]\{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789\} is converted like  \dn[ff=nf,ft=10]{desh yaa raaShTRa ke liye hame kuchh achchhaa karanaa chaahiye.M. sa.Mkhyaa 0123456789}%%%
This devnagari contents also accepts math contents within itself too. For example, \Lcs{dn}\{meraa pratham gaNit suutra $y=mx^2$.\} is converted as \dn{meraa pratham gaNit suutra $y=mx^2$.} \Lcs{dn}\{\Lcs{Large} meraa pratham gaNit suutra $y=mx^2$.\} is converted as \dn{\Large meraa pratham gaNit suutra $y=mx^2$.}
\begin{table}[H]\centering\definecolor{lightgray}{gray}{0.9}\rowcolors{1}{}{lightgray}\setlength{\tabcolsep}{30pt}\renewcommand{\arraystretch}{1.5}\begin{tabular}{lll}\hlineHindi & \dn{hindii} & 30  \\\hline\end{tabular}\caption{\protect\dn{merii saaraNii}}\end{table}
Use \Lcs{protect} keyword if \Lcs{dn} command is used within scope of other command. 
We can use the kruti fonts directory using \Lcs{df}[ff=bf,ft=10]\{\} command. The preprocessor does not process contents written inside this command.  The user must be familiar about kruti typing.  For example \Lcs{df}[ff=nf,ft=10]\{\Lcs{char170} \Lcs{char171}\} is converted like \df[ff=nf,ft=10]{{ }\char170\char171 }

\begin{table}[H]\centering\definecolor{lightgray}{gray}{0.9}\rowcolors{1}{}{lightgray}\setlength{\tabcolsep}{10pt}\renewcommand{\arraystretch}{1.25}\begin{tabular}{lllllllll}\hlinea &  \df{}  & \df{v}  & jh &  \df{>}  & \df{>}  & Gy &  \df{}  & \df{K} \\aa &  \df{k}  & \df{vk}  & \char126 y &  \df{{\char229}}  & \df{{\char180}}  & shr &  \df{{\char139}}  & \df{J} \\A &  \df{k}  & \df{vk}  & T &  \df{V\char126}  & \df{V}  & ao &  \df{}  & \df{{\char183}} \\i &  \df{f}  & \df{b}  & Th &  \df{B\char126}  & \df{B}  & dbh &  \df{}  & \df{{\char246}} \\ee &  \df{h}  & \df{{\char195}}  & D &  \df{M\char126}  & \df{M}  & ddh &  \df{}  & \df{)} \\ii &  \df{h}  & \df{{\char195}}  & Dh &  \df{<\char126}  & \df{<}  & dv &  \df{{\char125}}  & \df{{\char125}} \\I &  \df{h}  & \df{{\char195}}  & N &  \df{.}  & \df{.k}  & dy &  \df{}  & \df{|} \\u &  \df{q}  & \df{m}  & t &  \df{R}  & \df{r}  & DD &  \df{}  & \df{{\char236}} \\uu &  \df{w}  & \df{{\char197}}  & th &  \df{F}  & \df{Fk}  & DDh &  \df{}  & \df{{\char239}} \\U &  \df{w}  & \df{{\char197}}  & d &  \df{n\char126}  & \df{n}  & hm &  \df{}  & \df{{\char227}} \\oo &  \df{w}  & \df{{\char197}}  & dh &  \df{/}  & \df{/k}  & h.R &  \df{{\char226}}  & \df{{\char226}} \\e &  \df{s}  & \df{,}  & n &  \df{U}  & \df{u}  & hy &  \df{}  & \df{{\char225}} \\ai &  \df{S}  & \df{,s}  & p &  \df{I}  & \df{i}  & pr &  \df{{{\kern1.5pt{\kern-1.5ptI}\kern1.5ptz}\kern-1.5pt}}  & \df{iz} \\Ai &  \df{S}  & \df{,s}  & ph &  \df{Q\char126}  & \df{Q}  & kt &  \df{{\char217}}  & \df{{\char228}} \\o &  \df{ks}  & \df{vks}  & b &  \df{C}  & \df{c}  & nn &  \df{{\char153}}  & \df{{\char233}} \\au &  \df{kS}  & \df{vkS}  & bh &  \df{H}  & \df{Hk}  & ru &  \df{}  & \df{\#} \\.M &  \df{a}  & \df{a}  & m &  \df{E}  & \df{e}  & rU &  \df{}  & \df{:} \\.N &  \df{{\char161}}  & \df{{\char161}}  & y &  \df{{\char184}}  & \df{;}  & TR &  \df{}  & \df{V{\char170}} \\: &  \df{\%}  & \df{\%}  & r &  \df{j}  & \df{j}  & TT &  \df{}  & \df{{\char205}} \\Ri &  \df{\_}  & \df{\_}  & .r &  \df{z}  & \df{az}  & TTh &  \df{}  & \df{{\char206}} \\Li &  \df{G}  & \df{G}  & R &  \df{Z}  & \df{}  & ThTh &  \df{}  & \df{{\char240}} \\k &  \df{D}  & \df{d}  & .R &  \df{{{\char096}\kern-7.5pt}}  & \df{}  & ' &  \df{}  & \df{*} \\k.R &  \df{d{{\kern-1.5pt\char096}\kern-6pt}}  & \df{d{{\kern-1.5pt\char096}\kern-6pt}}  & l &  \df{Y}  & \df{y}  & `` &  \df{}  & \df{{\char223}} \\k.r &  \df{d{{\kern-1.5ptz}\kern1.5pt}}  & \df{d{{\kern-1.5ptz}\kern1.5pt}}  & v &  \df{O}  & \df{o}  & " &  \df{}  & \df{{\char222}} \\kh &  \df{[}  & \df{[k}  & w &  \df{O}  & \df{o}  & -- &  \df{}  & \df{\&} \\g &  \df{X}  & \df{x}  & s &  \df{L}  & \df{l}  & .. &  \df{}  & \df{A} \\gh &  \df{?}  & \df{?k}  & Sh &  \df{{\char034}}  & \df{{\char034k}}  & / &  \df{}  & \df{@} \\\char126 g &  \df{{\char179\char126}}  & \df{{\char179}}  & sh &  \df{'}  & \df{'k}  & , &  \df{}  & \df{]} \\ch &  \df{P}  & \df{p}  & h &  \df{}  & \df{g}  & . &  \df{}  & \df{-} \\chh &  \df{}  & \df{N}  & ksh &  \df{\{ }  & \df{\{k }  & ; &  \df{}  & \df{(} \\j &  \df{T}  & \df{t}  & tr &  \df{{\char171}}  & \df{=}  & ( &  \df{}  & \df{{\char188}} \\  &          &          &   &                      &          & ) &     & \df{{\char189}} \\\hline\end{tabular}\caption{\protect\dn{akshar saaraNii}}\end{table}

Disclaimer : the Kruti font is property of respective developers.  The p2k script is influenced by Frans Velthuis' preprocessor for Devanagari text.   Other trademarks, or scripts if found similar to this package are not claimed as IPR by me.  Fonts other than true type fonts are created with help of fontforge software.
\end{document}

Download the utility from here.  The output of this utility is shown in below figures.