I'm using the devanagari package to typeset Hindi/Sanskrit alphabet in LaTeX.
I have defined commands like \newcommand{\S}{{\dn saa}}, \newcommand{\R}{{\dn re}} etc.
From a usage point of view, I would like to use these commands in the following way:
\S\Rshould be formatted without space between the two characters:
\S \Rshould be formatted with space between the two characters:
First one works just fine, but the second one doesn't.
I know writing it as \S{} \R{} would do the job, but I'm trying to avoid writing the two extra braces.
Similarly, writing it as \S\ \R\ is what I'm currently doing right now, but it would be ideal if there is a way to get read of the trailing backslashes.
Furthermore, I have looked at using the xspace package, but it doesn't seem to work with the devanagari package.
A very basic working example is as follows:
\documentclass{article}
\usepackage{devanagari}
\newcommand{\S}{{\dn saa}}
\newcommand{\R}{{\dn re}}
\begin{document}
\S\R \\ % output expected as #1
\S \R \\ % output expected as #2
\end{document}
To run the above snippet:
- Save the file as
sample.dn - Run
devnag sample.dnin the terminal, this generates a filesample.tex - Run
pdflatex sample.texin the terminal to generate the PDF
Is there any way to format \S \R as shown in #2 above?
devanagaripackage instead of using XeTeX / LuaTeX which give you access to any Devanagari font you like, and your input can be more straightforward too (just UTF-8 Devanagari in your file, instead of\dnwith an input convention)? – ShreevatsaR Mar 16 '18 at 19:18\S\ \R,{\S} \R,\S{} \R. – barbara beeton Mar 16 '18 at 19:19\S\Rand\S \Rare equivalent is very fundamental to TeX — when TeX encounters the backslash and then the S, it skips ahead past any spaces, and then encounters\R, exactly the same as if you'd typed\S\R. So you need to find an alternative solution. (BTW, see here for the direct Unicode way instead of\dn.) – ShreevatsaR Mar 16 '18 at 19:25