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!
I managed to find a solution.
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}
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
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}
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:
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}
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
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP