mixed languages

From Wiki
Jump to navigation Jump to search

Introduction

Some users of ConTeXt (mainly in Humanities) are sometimes led to introduce different languages into a text mainly written in a Romance language (English, Spanish, French, Dutch, German, Italian, etc.). In a text in a European Latin language, the best way to switch from one language to another is to use the command :

\language


How to achieve it

Mainlanguage

If you want to use several languages, you need to ask ConTeXt which language you want to switch to for each of them. In the preamble, write the main language of the text and the languages you want to switch to. For example, our text is written mainly in English. We want to comment on a text in Ancient Greek, but in the course of the commentary we want to make references to texts in Arabic and Chinese. So, as a basic preamble, we would have something like this:

\setuplanguage[en][patterns={en,agr}]

As you see, English will be the main language of our text (or choose [fr], [ger], etc.); but along with Ancient Greek (agr).

Then, after the \setuplanguage command, you have to precise which main language you want to use. Here, this is English, which language is setup by this command :

\mainlanguage[en]

ConTeXt now understands that you will be using English and Ancient Greek. But you need to give it the right fonts to achieve this goal, bearing in mind that English and Ancient Greek do not use the same glyphs, even though some font families, such as TeX Gyre Pagella, are very versatile. So now you need to place the command for the Ancient Greek text. You will need to check that these fonts are available on your system. Refer to the Wiki page on installing and checking fonts, bearing in mind that installing them on your system from the Internet is not enough: they must also be supported by ConTeXt. You can pass the following command in a console, in order to list all the installed fonts on your system :

mtxrun --script fonts --list --all


Or, in order to find a particular font, say GFS Didot :


mtxrun --script fonts --list --pattern=gfsdidot --all


If you are sure to have previously installed some police, but you can see it, as a reminder, two commands are useful:

mtxrun --script cache --erase && mtxrun --generate


and this one :

mtxrun --script fonts --reload


Again, if you are a beginner, read some documentation like which are listed here [[1]]


Define a font for Ancient Greek

Use Theano Didot as Ancient Greek font

\definefallbackfamily[mainface][serif][Theano Didot][preset=range:greek,force=yes]

Define a font for Traditional Chinese (TC)

You can choose between several fonts. In order to test them, you can write your preamble as follow (the "%" is to comment the line) :

Choose between 'ipaexmincho' font and 'NotoSansTC' (Traditional Chinese) as follow :

\definefallbackfamily [mainface] [rm] [ipaexmincho] [range=cjkunifiedideographs]

\definefallbackfamily [mainface] [rm] [notosanstc] [range=cjkunifiedideographs]

Define a font for Arabic

Choose between two Arabic fonts

\definefallbackfamily[mainface] [serif] [nafeesnastaleeq] [range=arabic]

\definefallbackfamily[mainface] [serif] [hussaininastaleeq] [range=arabic]

Define the main text font

\definefontfamily[mainface] [serif] [GFS Didot]

\setupbodyfont[mainface]

An example of mixed languages

There is below an example of 5 pages printed mainly in English, where you can find Ancient Greek, Traditional Chinese and Arabic. This text is more than a MWE (Minimum Working Example), because it also contains footnotes, an header and a footer, as well as a framed text. But even if at first glance this page seems difficult for a beginner, you can practise with the code on this page. Details: the Arabic text is printed correctly, i.e. from right to left. You can adjust the size of the text with a number of commands concerning the number of lines per page, the font size, etc.


% We are writing an example of a text written in a Latin language, in which we want to print here and there some text in ancient Greek, Arabic and Chinese.(The sign '%' means that ConTeXT ignores the text or the command. It's a comment).

\setuplanguage[en][patterns={en,agr}]

\mainlanguage[en]

\setuplayout[backspace=40mm]

\setuppagenumbering[alternative=doublesided, location={header, inmargin}]

\setupmargindata[inmargin][location=inner, style={\ssx\setupinterlinespace[line=2.8ex]}]

\setupmarginframed[inmargin][align=right]

\setupbodyfontenvironment[default][em=italic]

% Use Theano Didot as Ancient Greek font

\definefallbackfamily[mainface][serif][Theano Didot][preset=range:greek, it={Old Standard Italic}, force=yes]

% Choose between Ipaexmincho font and NotoSansTC (Traditional Chinese)

%\definefallbackfamily [mainface] [rm] [ipaexmincho] [range=cjkunifiedideographs]

\definefallbackfamily [mainface] [rm] [notosanstc] [range=cjkunifiedideographs]


% Choose now between two Arabic fonts


%\\definefallbackfamily[mainface] [serif] [nafeesnastaleeq] [range=arabic]

\definefallbackfamily[mainface] [serif] [hussaininastaleeq] [range=arabic]

\definefontfamily [mainface] [serif] [GaramondNo8][sc=NewG8 Regular SC]

\definefontfamily [mainface] [sans] [FreeSans] [rscale=0.7]

\definefontfamily[mainface] [serif] [GFS Didot]

\setupbodyfont[mainface]

\setupindenting[1.5em]

\setupindenting[yes]

\setupcolors[state=start]


% Definition of the frame style (printed at the end of the document)

\defineframedtext

[MyFrame]
[before={\blank},
 after={\blank},
 frame=off,
 background=MyFrame,
 %width=\textwidth,
 width=max,
 height=fit,
 style=italic]

\definelabel

[Definition]
[headstyle=\bf\smallcaps]

% Using MPGraphic (MetaPost), with appropriate syntax

\startuseMPgraphic{MyFrame} path b; picture p; %p := textext.rt("\white\Définition"); p := textext.rt("\white\framedtextparameter{Title}"); %p := textext.rt("\white\getvariable{text}{text1}"); p := p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight); b := boundingbox p leftenlarged .5EmWidth rightenlarged .5EmWidth; fill OverlayBox withcolor lightgray; %\MPcolor{ fill b withcolor darkred; draw bottomboundary OverlayBox withpen pencircle scaled 1pt withcolor darkred; draw topboundary OverlayBox withpen pencircle scaled 1pt withcolor darkred; draw p; setbounds currentpicture to boundingbox currentpicture enlarged 2mm;

\stopuseMPgraphic

\defineoverlay [MyFrame][\useMPgraphic{MyFrame}]

\setupwhitespace[medium]

\setupinterlinespace[line=3.2ex]

\setuphead[title][header=empty]

\setupheader[style={\sc}]

\setupfooter[style={\itxx}]

\setupheadertexts[How to several languages in the same text with \ConTeXt][][][{\getmarking[section]}]

\setupfootertexts[][][][© Copyright — The reproduction of this text is under authorisation.]

\defineparagraphs[TwoColumns][n=2, align={hz, hanging}]

\setupparagraphs[TwoColumns][1][width=210pt, style=rm, align=left]}

\starttext

\title{\ConTeXt : or how to print non-roman languages}

\section {\sc Preamble}

% Main text in English

When it comes to submitting a document in a national language (as English, or German, or French), everything is fine. When it comes to writing a slightly complex document in any Romance language, but with quotations — or references — in another language, which in particular does not have the same requirements as your own Romance language, nor the same {\em diacritical marks}, we run into a few difficulties. Software suites such as Microsoft Office or LibreOffice are not lacking in power, but the truth is that as soon as we get into the requirements and detail of professional publishing, which consists of presenting a readable text enriched (with notes, etc.), the situation quickly becomes technically rather difficult. The most common situation we encounter in Philosophy, History, or and more generally in the Humanities, is that of a text in which there are quotations from Greek or Latin authors, with references in footnotes, which contain Greek, or even Arabic, or any other language. It could be something like this sample:

% The quotation in ancient Greek is in a narrower style

\blank\\startnarrower[1*left,1*right]\tfx\setupinterlinespace

\noindent

\quotation

{Ἔφη γάρ οἱ Σωκράτη ἐντυχεῖν λελουμένον τε καὶ τὰς βλαύτας ὑποδεδεμένον, ἃ ἐκεῖνος ὀλιγάκις ἐποίει· καὶ ἐρέσθαι αὐτὸν ὅποι ἴοι οὕτω καλὸς γεγενημένος. καὶ τὸν εἰπεῖν ὅτι· Ἐπὶ δεῖπνον εἰς Ἀγάθωνος. χθὲς γὰρ αὐτὸν διέφυγον τοῖς ἐπινικίοις, φοβηθεὶς τὸν ὄχλον· ὡμολόγησα δ᾽ εἰς τήμερον παρέσεσθαι. ταῦτα δὴ ἐκαλλωπισάμην, ἵνα καλὸς παρὰ καλὸν ἴω}.

\noindent

\quotation

{I met Socrates," he said, "coming out of the bath with sandals on his feet, which is hardly his custom, and I asked him where he was going looking so good. He replied: "I'm going to Agathon's for dinner. Yesterday I avoided the party he gave in honour of his victory, because I was afraid of the crowds; but I promised to come the next day: that's why I dressed up; I wanted to look good so I could come to a good-looking man's house".<\pre>}[[Command/\inmargin{Platon, {\em Symposium}, 174a}.|\\inmargin{Platon, {\em Symposium}, 174a}.]]

\stopnarrower

Editing could certainly be improved. For example, put the Greek text on the left and its translation on the right on the same page, which would look something like this:

\startnarrower[1*left,1*right]\tfx\setupinterlinespace

% Here below, the Greek text is on the left columns; the English translation is on the right columns

\startTwoColumns

\quotation

{Ἔφη γάρ οἱ Σωκράτη ἐντυχεῖν λελουμένον τε καὶ τὰς βλαύτας ὑποδεδεμένον, ἃ ἐκεῖνος ὀλιγάκις ἐποίει· καὶ ἐρέσθαι αὐτὸν ὅποι ἴοι οὕτω καλὸς γεγενημένος. καὶ τὸν εἰπεῖν ὅτι· Ἐπὶ δεῖπνον εἰς Ἀγάθωνος. χθὲς γὰρ αὐτὸν διέφυγον τοῖς ἐπινικίοις, φοβηθεὶς τὸν ὄχλον· ὡμολόγησα δ᾽ εἰς τήμερον παρέσεσθαι. ταῦτα δὴ ἐκαλλωπισάμην, ἵνα καλὸς παρὰ καλὸν ἴω}.

\\TwoColumns

\\quotation{I met Socrates," he said, "coming out of the bath with sandals on his feet, which is hardly his custom, and I asked him where he was going looking so good. He replied: "I'm going to Agathon's for dinner. Yesterday I avoided the party he gave in honour of his victory, because I was afraid of the crowds; but I promised to come the next day: that's why I dressed up; I wanted to look good so I could come to a good-looking man's house.}

\stopTwoColumns

\stopnarrower

\section{Éditing with ConTeXT as an alternative to LaTeX}

%Note : if you want to transcript the words TeX, LaTeX and other TeX in the appropriate face, add a backslash before the word, like that : \LaTeX; \ConTeXt.

Readers familiar with this type of language will have recognised from the previous paragraphs the brand name and technique used in the TeX language. However, the use of this software relies on a fairly large set of declarations and it takes a great deal of practice to be able to play with, if not the power, at least the finesse of LaTeX. There are a great many commands, and it is often necessary to refer to a manual to remember the subtleties that have made it possible to achieve a particular printed result. Of course, there is commercial software to help with professional publishing in the Humanities sector. But on the one hand they are not free and are relatively expensive for an individual, not to mention the cost of licences for professional groups of teachers and researchers.

Given this state of affairs, we can turn to ConTeXt, which is not an alternative to LaTeX, but a more synthetic (or even more elegant) way of using LaTeX. ConTeXt, like LaTeX, is a software suite which contains the macros of LaTeX, the routines of the {\em Perl} language, as well as the macros of LuaTeX. It is therefore possible to define just about everything that is required for professional publishing, without going into the technical knowledge of the LaTeX language. Of course, there are a number of technical issues to be addressed if you want to work with this type of tool: for mathematicians, perfect presentation and editing of complex equations, diagrams and tables requires a fairly advanced apprenticeship. This is also true for users who come from the humanities, who know their field, and who want to write a simple document, a journal article, or even entire chapters of an academic work. Very often, it is the publishers who take care of the layout of the document you want to publish, based on a Word style sheet. But sometimes, if it is a dossier of several articles, or even an edition with financial support for publication, you would like to have control over the quality of the printed document.

This is one of the reasons why you might want to control the editorial chain, not just to do without an editor, but to have an overview of your own work, or a collective work.

% Here below a paragraph which contains Chinese text and Arabic

\section{How to get Greek, Chinese and Arabic to coexist on the same page?}

It is not a common habit to read in the same document text in English, in which we find a reference in Greek; for example, when in the {\em Timaeus}, Plato indicates that the most difficult thing is to begin with a beginning that is natural (κατὰ φύσιν ἀρχήν)\inmargin{Plato, {\em Timaeus}, 29b. }, an indication of the name of the Chinese philosopher Chouang Tseu (in {\em pinyin}\footnote{The {\em pinyin} (classical Chinese 漢語拼音, literally "to assemble the sounds of the language of the Han"), is a romanisation of the Chinese language, which is written in the Latin alphabet. So instead of writing 漢語拼音 (Zhuangzi, Tchouang Tseu) in traditional Chinese, or 汉语拼音 in simplified Chinese, we will write the name in Pīnyīn ({\em Hànyù Pīnyīn}), thus: Zhuangzi; and in classical and simplified Chinese: 莊周 or 庄周}), could add to this difficulty, given that \quotation{while most people understand the usefulness of what is useful, few understand the usefulness of what is useless}. Which is here below :

\startnarrower[1*left,1*right]\tfx\setupinterlinespace

惠子謂莊子曰。

子言無用。莊子曰。

知無用。而始可與言用矣。

夫地。非不廣且大也。

人之所用容足耳。

然則廁足而墊之致黃泉。

人尚有用乎。惠子曰。無用。莊子曰。

然則無用之為用也亦明矣。

\stopnarrower

\quotation{Huizi said to Zhuangzi, “Your words are useless!”

   Zhuangzi said, “A man has to understand the useless before you can talk to him about the useful. The earth is certainly vast and broad, though a man uses no more of it than the area he puts his feet on. If, however, you were to dig away all the earth from around his feet until you reached the Yellow Springs, then would the man still be able to make use of it?”
   “No, it would be useless,” said Huizi.
   “It is obvious, then,” said Zhuangzi, “that the useless has its use.\\footnote{{\em External Things}, Zhuangzi, trans. Burton Watson.}}
   

We are certainly a long way from the thinking of the 10th century Arab philosopher Farabi. Farabi was a commentator on Plato's and Aristotle's philosophy; here we return to the beginning. Then we add to this throughout the text a reference to the Arabo-Persian philosopher Farabi\footnote{Al-Fārābī is named in medieval Arabic philosophy {\em the second master}: (ضابط), the first being Aristotle. } Al-Fārābī ( فارابي), a tenth-century Persian philosopher, by means of a clarification on Plato, and Aristotle (see his commentary on the {\em Peri Hermeneias}), entitled شرح الفارابي لكتاب أرسطوطاليس في العبارة / الفارابي] ; عني بنشره وقدم له ولهام كوتش وستانلي مارو\footnote{The Aristotle's text Περὶ Ἑρμηνείας ({\em peri hermeneias}) is one of the work named {\em Organon}. It his the second work of the {\em Organon}, and well-known because of its Chapter 9, on the {\em future contingents}. } with indications on his name in Arabic, we will have come round to some of the difficulties that present themselves to those who would like to carefully establish somewhat demanding documents.


% Here the conclusion is within a frame

\showframe

\startMyFrame[Title=Conclusion]

To edit a complex text, with several non-Romanic languages used occasionally, you can use \ConTeXt. This appears to be a wise choice: for mathematicians, presenting and editing complex equations, diagrams and tables in the best possible way requires a fairly extensive learning curve, which can be solved by a number of macros that automate the tasks. The code is reusable, and this is also true for users who come from the multiple horizons of the {\em Humanities}, who know their area of expertise and want to write a simple document, a magazine article, or even entire chapters of a book.

\stopMyFrame

\stoptext


See also