TransWikia.com

Devanagari typesetting in Windows (TexMaker + MikTeX)

TeX - LaTeX Asked by ki-ang on April 13, 2021

I have looked at several answers on how to write Devanagari text in LaTeX. What I understand is that I need to preprocess the file using either skt or dn (dn seems to create some problems for me, where it generates some weird characters elsewhere in the document, so I would like to stick with skt). How do I do this using the Windows terminal? I am using TexMaker + MikTeX (pdflatex). Any help is greatly appreciated.

In fact, I just need one sentence in my document –
वसुधैव कुटुम्बकम्
If someone can generate the tex parsable format for use with skt, that would be super useful. Thanks in advance!

2 Answers

I managed to find a solution.

  1. Following this answer, I downloaded the skt.c file from here.
  2. Since I am using Windows, I downloaded MinGW from here to get the gcc compiler.
  3. On the windows command line, update the path following this answer.
  4. Create a sample.skt file as shown below with a simple transliteration of the devanagari sentence. I had to consult the transliteration scheme on page 19 (१९) of the skt documentation to write some special letters such as "टु". I had to write ".t" instead of "t" or "T" or "th".

    documentclass[12pt]{article}
    pagestyle{plain}
    usepackage[margin=1.8cm]{geometry}
    geometry{a4paper}
    usepackage[parfill]{parskip}
    usepackage{amsmath}
    usepackage{skt}
    
    begin{document}
    
    {skt vasudhaiva ku.tumbakam}
    
    end{document}
    
  5. Place the .skt file in the same path as skt.c file, run command prompt, write gcc -v to confirm the installation of MinGW, then simply type:

     skt sample.skt sample.tex
    
  6. A file named sample.tex should be generated in the same path. Below is the generated .tex file.

    documentclass[12pt]{article}
    pagestyle{plain}
    usepackage[margin=1.8cm]{geometry}
    geometry{a4paper}
    usepackage[parfill]{parskip}
    usepackage{amsmath}
    usepackage{skt}
    
    begin{document}
    
    {skt va;sua;DEa;va kZH{-12}{u}+:fZH{-12}{u};m1ba;k+:m,a}
    
    end{document}
    
  7. And finally the output should look like this: enter image description here

The font quality is not great as mentioned by Ulrike Fischer in one of the comments to my original question. So you might be well off adding a high-resolution image instead. But if someone wants to add more text, this could be a possible way.

Answered by ki-ang on April 13, 2021

If you can use either XeLaTeX or LuaLaTeX instead of PDFLaTeX, you could enter Devanagari in Unicode, with either babel or polyglossia.

Otherwise, if you just need to insert a single short passage, you could compile it to a stand-alone PDF and include that.

If you first compile this file in XeLaTeX or a version of LuaLaTeX that supports HarfBuzz:

%% This document requires LuaLaTeX 1.12.0 or higher, or XeLaTeX.
tracinglostchars=2 % Warn if the current font lacks a character.
documentclass{standalone}
usepackage{polyglossia}

ifLuaTeX
  defaultfontfeatures{ Scale=MatchUppercase, Renderer=HarfBuzz }
else
  defaultfontfeatures{Scale=MatchUppercase}
fi

setdefaultlanguage{sanskrit}
newfontfamilysanskritfont{Shobhika}[
  Script = Devanagari,
  Language = Sanskrit]

begin{document}
वसुधैव कुटुम्बकम्
end{document}

You get the following PDF as output:

Vasudhaiva

Save this as vasudhaiva.pdf, and you can now make a new PDF that complies with PDFLaTeX:

documentclass{article}
usepackage[paperwidth=10cm,
            paperheight=3cm]{geometry} % Solely to format the MWE for TeX.SX.
usepackage{cmap} % For copying from PDF.
usepackage{graphicx} % For includegraphics
usepackage{lmodern} % Or your font of choice.

newlength{Hheight}

newcommandvasudhaiva{%
settoheight{Hheight}{H}% Not quite enough, because of ascenders.
includegraphics[height=1.25Hheight]{vasudhaiva.pdf}}

begin{document}
textit{Vasudhaiva Kutumbakam}
(vasudhaiva)
is Sanskrit for, “The World is one family.”footnote{Footnote size: vasudhaiva.}

end{document}

Vasudhaiva

You can use any OpenType font that supports Devanagari, it will be scalable, and you can even copy and paste the text from the PDF.

Since this is a single image, you do not get any line breaking. If you’re willing to put up with more of a headache to be able to word-wrap, you could create PDF files for each individual word and include each of them, separated by . If you do this, you might want to throw in a vphantom{सुधै} to ensure that the PDF files have the same height and depth.

Answered by Davislor on April 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP