Saturday, August 19, 2017

Mini edition environment for LaTeX

When writing an article or book using the LaTeX document preparation system, Indologists sometimes want to have a śloka or two printed on the page with some text-critical notes.  A famous example of this kind of layout is Wilhelm Rao's 1977 edition of the Vākyapadīya that edits the whole text this way, in each verse having its own mini-critical-edition format.

Here is a simple way to get this kind of layout in LaTeX.  I create a new environment called "miniedition":

\newenvironment{miniedition}
    {\addtolength{\textwidth}{-\rightmargin} % width of the quote environment
    \begin{quote} 
    \begin{minipage}{\textwidth}
    \itshape 
    \let\footnoterule\relax}
    {\end{minipage}
    \end{quote}}

This puts a minipage environment inside a quote environment, switches on italics and switches off the footnote rule.  It's pretty simple.  The clever bit is done by the minipage environment itself, that makes footnotes inside its own box, not at the bottom of the page.  The footnote numbers are lowercase alphabetical counters, to avoid confusion with footnotes outside the environment.
Here's how you would use it, and the result:

\begin{miniedition}
pāraṃparyād \emph{ṛte ’pi}\footnote{N: \emph{upataṃ}?} svayam 
\emph{anubhavanād}\footnote{My conjecture; both manuscripts are one syllable 
short. K: 
\emph{anubhavad}; N: \emph{anubhavād}.} granthajārthasya samyak\\
pūrṇābdīyaṃ phalaṃ sadgrahagaṇitavidāṃ \emph{aṃhrireṇoḥ}\footnote{N: 
\emph{aṅghri-}, 
with identical meaning.} \emph{prasādāt}\footnote{N: \emph{prasādaḥ}.}||
\end{miniedition}

Output (with added text before and after:
The miniedition text is indented left and right, and followed immediately by the critical notes.  The footnotes at the bottom of the page are a separate series.  In both the main body text and the miniedition, you just use \footnote{} for your notes; LaTeX does the right thing by itself according to context. 
The miniedition environment does not break across pages, it is meant for for short fragments of text, one or two ślokas. 
This example is taken from Gansten 2017.

Monday, July 24, 2017

Biblatex, citations and bibliography sorting

"I want to sort in-text citations by year, but bibliography by name."  So begins one of the questions at a Stackexchange.  That's just what I want too.

I want to put multiple references in a \cite{} command without caring about their sequence, and have them automatically print in year-order.  Then, I want my bibliography to be ordinary, i.e., printed in author-date order.

The discussion at the above site is tricky, but the answer by moewe works.

In a nutshell here's what you actually do:
\begin{document}
\usepackage[sorting=ynt,sortcites=true]{biblatex}
\AtBeginDocument{\assignrefcontextentries[]{*}}
\begin{document}
Hello world!\footcites{ref1,ref3,ref0,ref4}
\newrefcontext[sorting=nyt]
\printbibliography

\end{document}
This will print your footnoted citations in ascending order of year, and your bibliography in ascending order of author.

Sunday, June 18, 2017

Expanded Devanāgarī font comparison

In 2012 I posted a comparison of some Devanāgarī fonts that were around at the time.

Here's an update, with some more fonts and more concise TeX code:

\documentclass{article}
\usepackage{polyglossia}
\defaultfontfeatures{Script=Devanagari,Language=Sanskrit}

% set up a font, print its name, and typeset the test text:
\newcommand{\FontTrial}[1]{ %
    \setmainfont[Mapping=RomDev]{#1}
    \newfontfamily\eng{#1}
    % print the font name:
    {\eng #1} \TestText }

\newcommand{\TestText}{ = शक्ति, kārtsnyam ṣaṭtriṃśad;
{\addfontfeatures{Language=Hindi} Hindī =
        शक्ति कार्त्स्न्यम्}\par}

\begin{document}

\FontTrial{FreeSerif}
\FontTrial{FreeSans}
\FontTrial{Sanskrit 2003}

\setmainfont[FakeStretch=1.08,Mapping=RomDev]{Sanskrit 2003}
\newfontfamily\eng[FakeStretch=1.08,Language=English]{Sanskrit 2003}
{\eng Sanskrit 2003+} \TestText

\FontTrial{Nakula}
\FontTrial{Sahadeva}
\FontTrial{Murty Hindi}
\FontTrial{Murty Sanskrit}
\FontTrial{Shobhika}
% ... etcetera

\end{document}

Output:


Lessons learned:
  • Only Sanskrit 2003, Murty Sanskrit, Chandas, Uttara, Siddhanta, and Shobhika do a full conjunct consonant in ṣaṭtriṃśad.  The others fake it with a virāma.
  • Akshar Unicode's "prasanna" has a lazy horizontal conjunct.
  • Free Sans and Free Serif are the only fonts that distinguish Sanskrit and Hindi (see kārtsnyam).
  • Nakula, Sahadeva, Murty Hindi, Shobhika, Annapurna, Akshar Unicode, Kalimati, and Santipur do a lazy, horizontal conjunct consonant in kārtsnyam.
  • There's a special issue affecting FreeSans and FreeSerif.  I described this in a post in 2012.  The publicly distributed version of the fonts fails to make some important conjunct consonants, like त्रि and प्र correctly.  Unfortunately this issue has not changed in the intervening five years. The examples shown here use a fresh compilation of the fonts, based on downloading and compiling the development version at the Savannah repository (June 2017).  (Here's a link to my compiled fonts.)  This Savannah development version works better for  Devanagari, but has problems elsewhere, according to their author Stevan White.

Thursday, June 15, 2017

Preserve the Mess

Many years ago, I attended a Digital Humanities conference, Toronto 1989 I think it was, and heard a paper by Jocelyn Small about using digital tools to manage large datasets.  She was talking about images, but her ideas applied to any data.

One of her key slogans was, "Preserve the Mess."  This approach is now completely normalized by Google search, Google Mail, etc., and we all take it for granted.  But it's worth remembering that this was a major conceptual breakthrough.

Before this approach, everyone thought that the way to find stuff was to use subject indexes.  And subject indexing is expensive, difficult, subjective and structurally imperfect.  What subject headings would you use for the Mahābhārata, for example? I think most people would agree that it is difficult to impossible to arrive at a simple statement of the subject matter of the Mbh that is actually worth having.  Of course, we can all play nothing-buttery, "the Mbh is nothing but a family quarrel," but that's not a serious approach to the problem.  If we pervade the epic with our keywords and subject index terms, we are trying to make the text more accurate than it is, and our exercise is culture-bound and subjective.

"Preserving the mess" means that we leave the data alone.  Rather, we put the intelligence and power into our tools for accessing the data.  We use fuzzy-matching, pattern recognition, machine learning, but all applied to the raw data which is not itself manipulated or changed.

A published version of Small's ideas appeared in 1991:

As she says, p. 52,
Thus Principle Number One is Aristotelian: "Do not make your datum more accurate than it is. This principle may be rephrased as, "Preserve the Mess."

Tuesday, June 13, 2017

Del latitude xinput settings

See https://askubuntu.com/questions/688270/mouse-speed-too-fast

Put the following commands in a file (foobar.sh), make the file executable (chmod +x foobar.sh), and then run it.

#!/bin/sh
xinput --set-prop "AlpsPS/2 ALPS DualPoint Stick" "Device Accel Constant Deceleration" 8
xinput --set-prop "AlpsPS/2 ALPS DualPoint Stick" "Device Accel Velocity Scaling" .8
xinput --set-prop "AlpsPS/2 ALPS DualPoint Stick" "Device Accel Adaptive Deceleration" 8


You can run this command on startup from the Startup Applications menu.

Friday, June 09, 2017

Lining or Oldstyle numerals in math typesetting?

The classic work,


has the following remarks in paragraph 95, p. 63:
Relative size of numerals in tables.-- André says on this point: "In certain numerical tables, as those of
 Schrön, all numerals are of the same height. In certain other tables, as those of Lalande, of Callet, of Houël, of Dupuis, they have unequal heights: the 7 and 9 are prolonged downward; 3, 4, 5, 6 and 8 extend upward; while 1 and 2 do not reach above nor below the central body of the writing.... The unequal numerals, by their very inequality, render the long train of numerals easier to read; numerals of uniform height are less legible." (D. André, Des notations mathématiques (Paris, 1909), p .9).

Thursday, May 18, 2017

YAAC ("yet again about copyright")

Some sensible remarks from the Director of UofA's copyright office.  Importantly, the UofA relinquishes its rights to the copyright of work written by faculty members.  Faculty members own the copyright of their writings.