1

I'm writing up a paper in number theory, and there are a few number theorists from India whose work is relevant to it, and which I would hence like to reference to. Yet, even though I've managed to enable the Devanagari script by switching to the XeLaTeX enginge, I've been unable to make BibTeX get the initials right.

I've been able to make it work for the cyrillic script by using the xecyr package. So there has to be a way. I'd be grateful for a hint.

EDIT: I can't get Biber to work, so I'd be very interested in understanding the techniques used in xecyr.

And here is a bit of sample code:

@book{ramanujan,
    author = "\hi{श्रीनिवास} \hi{ऱामानूजन}",
    series = "Notebooks",
    volume = 4,
    year = 1920
}

along with

\newcommand{\hi}[1]{\begin{hindi}{#1}\end{hindi}}

and the "alpha" bibliography style.

igp
  • 3
  • can't you use biblatex? – Ulrike Fischer May 30 '20 at 16:07
  • I had been unaware of biblatex, but it might certainly work. I'll try it now. – AlgebraicsAnonymous May 30 '20 at 16:25
  • Apparently, I can't make it work on my computer. So I'd be very interested in an alternative. – AlgebraicsAnonymous May 30 '20 at 16:42
  • sorry but you didn't provide any code for testing. – Ulrike Fischer May 30 '20 at 16:44
  • ...added :-) @UlrikeFischer – AlgebraicsAnonymous May 30 '20 at 16:51
  • 3
    this is not something I can run directly and I have neither the time nor the will to extend this to a full document. – Ulrike Fischer May 30 '20 at 16:54
  • If that's necessary for you, you may well lack the background required in order to answer the question. Hence, you may feel free to refrain from posting further comments. – AlgebraicsAnonymous May 30 '20 at 17:11
  • I'm pretty sure you'll have a hard time getting BibTeX to generate correct initials automatically. Biber does it (see https://tex.stackexchange.com/q/507093/35864), but as far as I understand that involves actually understanding Unicode, which BibTeX (and also BibTeX8) don't do. You can use the old {\relax ...} trick to manually give the correct initial, though, that should even work with BibTeX (it did work for me in https://gist.github.com/moewew/9fb8ec18d78cef3216088dba241e0e6d, but for lack of a proper MWE I didn't test that with your example). – moewe May 30 '20 at 17:37
  • The problem is that I have to put the initials within a Hindi language bracket. I happen to have abbreviated this (ie. made into a macro) using the abbreviation "\hi", whence the letter "h" is being taken for the initial. (At least, I could get the correct Latin initials by choosing funny macro abbreviations.) But thanks a lot, @moewe – AlgebraicsAnonymous May 30 '20 at 20:41
  • I've also tried replacing the \relax tag by my \hi, but this caused the very same plethora of errors that also occured when using \hi within \relax. – AlgebraicsAnonymous May 30 '20 at 20:52
  • Hmm. Do you mind if I ask where you came across this spelling of ऱामानूजन? The dot at the start is wrong I would say, it should be रामानूजन and I'm a bit sceptical of the use of नू, I would say it should probably be नु. However I'm not saying you're wrong, possibly there are people who would spell it with नू I can't say for sure because you know that Ramanujan was a Tamilian from Erode? I'm not really an expert on him, but I trust you realise that in Tamil Nadu the general populace emphatically does not speak Hindi https://en.wikipedia.org/wiki/Anti-Hindi_agitations_of_Tamil_Nadu – Au101 Jun 01 '20 at 13:53
  • The influence of Bollywood in today's Tamil Nadu may have changed things a bit since the sixties, but certainly wasn't a factor when Ramanujan was born in 1887. I'm a bit confused what you're trying to achieve here to tell the truth? – Au101 Jun 01 '20 at 13:54
  • @Au101 I'm trying to use a standard script of India that I and others can (mostly) read. I really can't take into account any anti-Hindi sentiment. Hindi and Devanagari are official in India, and if you learn them, you can talk to a fair chunk of the population. Perhaps India should also think about foreigners and about the fact that they have limited time for learning languages. – AlgebraicsAnonymous Jun 01 '20 at 17:24

3 Answers3

1

Not an answer.

I do not know the "alpha" style.

There is nothing special about xecyr: it just uses the usual Unicode-aware packages and compilation method.

xecyr works by using (1) the article documentclass: (2) the packages polyglossia, fontspec, and natbib; (3) a font with Cyrillic glyphs: (4) and compiling with xelatex.

See the file rubibtex-ex-x.tex in the xecyr document folder. (Do texdoc xecyr for documentation.)

Swapping over to package biblatex instead of natbib required changing 3 lines of code in a 7-codeline file.

So: mapping the changes to Hindi (and making Russian not the main language any more) gives:

ramanujan

I put a title= field in, to show its location, borrowed a Russian bibentry from another question for comparison, and arbitrarily selected an authortitle style (initials can be set via the package options - see the manual).

Biblatex also auto-detects language settings from polyglossia and from babel, so hard-coding font switching in is not required.

This can be used as the starting point of your question, if you like.

If you use bibtex with its lack of ability, you will quickly find (if I may call it so) a "plethora" of convolutions waiting to greet you.

Whichever process you chose as the optimal path to the solution for your requirements, either bibtex or biblatex, will depend on constraints that you have not (yet) surfaced to anyone in a position to help.

MWE

\begin{filecontents*}{\jobname.bib}
@book{ramanujan,
    author = {श्रीनिवास ऱामानूजन},
    title={no title},
    series = {Notebooks},
    volume = {4},
    date = {1920},
    langid={hindi},
  hyphenation={hindi},
  }
@book{Baranov2001,
address = {Санкт-Петербугр},
author = {Баранов, Николай А},
title = {{Эволюция взглядов}},
year = {2001},
  langid={russian},
%  hyphenation={russian},
}

\end{filecontents*}


\documentclass{article}

\usepackage{fontspec}
\setmainfont{Noto Serif}
\newfontfamily\hindifont{Shobhika}
\newfontfamily\russianfont{Noto Serif}

\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguages{hindi, russian}


\usepackage[
    style=ext-authortitle-ibid,
    bibencoding=auto,
    autolang=other, 
    language=auto,
]{biblatex}
\addbibresource{\jobname.bib}

\begin{document}

Text text \parencite[14]{ramanujan} and \parencite[pp 15-16]{Baranov2001}.

\printbibliography
\end{document}
Cicada
  • 10,129
  • The styles are named differently in BibTeX and BibLaTeX. What I use corresponds to "alphabetic" in BibLaTex. (I'll now go though your answer and see if the information there can make me resolve the issue.) – AlgebraicsAnonymous Jun 01 '20 at 17:16
  • I now believe that the "problem" is that I need to change the language in order to display the glyphs. Luckily, my font does support the Cyrillic alphabet, because I shall have the occasion to reference a Russian paper as well (as I indicated in my post). Yet, it does not support Devanagari. Thus, if I had the ability to put everything into a single font, I might be successful. The thing is: I wouldn't want to use the Noto font, because I quite like the Gentium font that I'm using at this moment. – AlgebraicsAnonymous Jun 01 '20 at 17:19
  • By the way, do I understand you correctly if I assume that all that xecyr does when processing a command like "\cyra" is to replace it by the unicode sign it's supposed to represent? – AlgebraicsAnonymous Jun 01 '20 at 17:26
  • I've tried to emulate this, but now my XeLaTeX compiler says that there was a "forbidden control sequence" in my bibitem. Now the question would be: Why are the Russian glyphs allowed, but my own forbidden? – AlgebraicsAnonymous Jun 01 '20 at 17:35
  • Ah, the control sequence ceases to be "forbidden" when the "\begin{hindi}...\end{hindi}" tags are removed. Now, of course, it can't display the Devanagari. Instead, boxes are being displayed. – AlgebraicsAnonymous Jun 01 '20 at 17:39
  • If only there was a way to make XeLaTeX use the Devanagari font automatically, instead of having the need to summon it via the \begin{hindi} tag. – AlgebraicsAnonymous Jun 01 '20 at 17:45
  • Finally, I'd like to thank you a lot for formulating the request for more information in a friendly manner. I truly despise of the "i don't have time or will for answering" type of comments. – AlgebraicsAnonymous Jun 01 '20 at 17:47
  • 1
    @AlgebraicsAnonymous xecyr.sty provides babel definitions and loads xunicode package, then defines macros: `%%% Cyrillic letters defined as a continuous stretch %%% in Unicode and most common 8-bit encodings which define them:

    \DeclareUTFcharacter[\UTFencname]{x0410}{\CYRA} % А \DeclareUTFcharacter[\UTFencname]{x0430}{\cyra} % аetc. It is much easier these days to type in directly абвгकखगघ and use unicode fonts.natbibis from 1993-2010, which explains whyxecyrwas using it in the example files.biiblatex` is a complete re-write of the citation/bib mechanism.

    – Cicada Jun 02 '20 at 07:39
  • See https://tex.stackexchange.com/questions/25701/bibtex-vs-biber-and-biblatex-vs-natbib bibtex is an external program; biblatex is a latex package, which can run bibtex or biber (via the backend= option). natbib package can only run bibtex. – Cicada Jun 02 '20 at 07:47
  • @AlgebraicsAnonymous To switch the font, see the package ucharclasses . Babel with lualatex can do it, too. – Javier Bezos Jun 02 '20 at 12:09
1

The issue has been resolved by doing the following two things:

A) Using the answer given in

How can I use ucharclasses to change the font for a special script and then restore to what it was before?

EXCEPT for the important amendment that [Script=Devanagari] was added to the "hindifont" line

and

B) Emulating the xecyr package by using the commands

\DeclareUTFcharacter[\UTFencname]{x0931}{\derha}
\DeclareUTFcharacter[\UTFencname]{x093E}{\dea}
\DeclareUTFcharacter[\UTFencname]{x092E}{\dem}

\DeclareUTFcharacter[\UTFencname]{x094D}{\decon}
\DeclareUTFcharacter[\UTFencname]{x0936}{\desha}
\DeclareUTFcharacter[\UTFencname]{x0930}{\dera}
\DeclareUTFcharacter[\UTFencname]{x0940}{\deii}

along with

@book{ramanujan,
    author = "{\desha}{\decon}{\dera}{\deii}\hi{निवास} {\derha}{\dea}{\dem}\hi{नूजन}",
    series = "Notebooks",
    volume = 4,
    year = 1920
}

Thanks a lot to @JavierBezos and all the others who helped clarifying the issue, including @Cicada and @moewe.

0

I got a similar pb, with devanagari included in the title.

You must work in XeLaTeX.

\documentclass{article}

\usepackage{fontspec} \newfontfamily{\SA}[Script=Devanagari]{Annapurna SIL} %for devanagari

%bibliography \usepackage[style=apa]{biblatex} \addbibresource{xxx.bib} %Imports bibliography file

\begin{document}

Text (\cite{huet__2014})

\printbibliography

\end{document}

Then in your .bib, add: {\SA} before the text in devanagari:

@misc{huet__2014,
    title = {{\SA}संधि saṃdhi},
    url = {http://sanskrit.inria.fr/DICO/67.html#sandhi},
    language = {fra},
    number = {Version 3.05},
    urldate = {2018-04-09},
    journal = {Dictionnaire Héritage du Sanscrit},
    author = {Huet, Gérard},
    year = {2014}
}

And you get:

enter image description here

igp
  • 3