Changes

Jump to navigation Jump to search
m
fix command error
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 :
{{cmd|\definefallbackfamilylanguage}}
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:
{{cmd|\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 {{cmd|\setuplanguage}} command, you have to precise which main language you want to use. Here, this is English, which language is setup by this command :
{{cmd|\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 :
{{cmdcode|mtxrun}} --script fonts --list --all
Or, in order to find a particular font, say GFS Didot :
{{cmdcode|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:
{{cmdcode|mtxrun}} --script cache --erase && mtxrun --generate
and this one {{cmdcode|mtxrun}} --script fonts --reload
Again, if you are a beginner, read some documentation like which are listed here [[https://wiki.contextgarden.net/Documentation]]
Use Theano Didot as Ancient Greek font
{{cmd|\definefallbackfamily}}[mainface][serif][Theano Didot][preset=range:greek,force=yes]
=== Define a font for Traditional Chinese (TC) ===
Choose between Ipaexmincho font and NotoSansTC (Traditional Chinese)
{{cmd|\definefallbackfamily}} [mainface] [rm] [ipaexmincho] [range=cjkunifiedideographs]
{{cmd|\definefallbackfamily}} [mainface] [rm] [notosanstc] [range=cjkunifiedideographs]
Choose between two Arabic fonts
{{cmd|\definefallbackfamily}}[mainface] [serif] [nafeesnastaleeq] [range=arabic]
{{cmd|\definefallbackfamily}}[mainface] [serif] [hussaininastaleeq] [range=arabic]
===Define the main text font ===
{{cmd|\definefontfamily}}[mainface] [serif] [GFS Didot]{{cmd|\setupbodyfont}}[mainface]
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, a header and a footer, as well as boxed 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.
>Note : for some reason, each command here begin with 2 anti-slash backslashes : one is enough ...
% We are writing an example of a text written in a Latin language, in which we want to print here and there text in ancient Greek, Arabic and Chinese.(The sign '%' means that ConTeXT ignores the text or the command. It's a comment).
{{cmd|\setuplanguage}}[en][patterns={en,agr}]
{{cmd|\mainlanguage}}[en]
{{cmd|\setuplayout}}[backspace=40mm]
{{cmd|\setuppagenumbering}}[alternative=doublesided, location={header, inmargin}]
{{cmd|\setupmargindata}}[inmargin][location=inner, style={\ssx\setupinterlinespace[line=2.8ex]}]
{{cmd|\setupmarginframed}}[inmargin][align=right]
{{cmd|\setupbodyfontenvironment}}[default][em=italic]
% Use Theano Didot as Ancient Greek font
{{cmd|\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]<\pre>
{{cmd|\definefallbackfamily}} [mainface] [rm] [notosanstc] [range=cjkunifiedideographs]
% Choose between two Arabic fonts
%{{cmd|\definefallbackfamily}}[mainface] [serif] [nafeesnastaleeq] [range=arabic]
{{cmd|\definefallbackfamily}}[mainface] [serif] [hussaininastaleeq] [range=arabic]
{{cmd|\definefontfamily}} [mainface] [serif] [GaramondNo8][sc=NewG8 Regular SC]
{{cmd|\definefontfamily}} [mainface] [sans] [FreeSans] [rscale=0.7]
{{cmd|\definefontfamily}}[mainface] [serif] [GFS Didot]
{{cmd|\setupbodyfont}}[mainface]
{{cmd|\setupindenting}}[1.5em]
{{cmd|\setupindenting}}[yes]
{{cmd|\setupcolors}}[state=start]
{{cmd|\defineframedtext}}
[MyFrame]
[before={\blank},
style=italic]
{{cmd|\definelabel}}
[Definition]
[headstyle=\bf\smallcaps]
{{cmd|\startuseMPgraphic}}{MyFrame}
path b;
picture p;
setbounds currentpicture to boundingbox currentpicture enlarged 2mm;
{{cmd|\stopuseMPgraphic}}
{{cmd|\defineoverlay}} [MyFrame][\useMPgraphic{MyFrame}]
{{cmd|\setupwhitespace}}[medium]
{{cmd|\setupinterlinespace}}[line=3.2ex]
{{cmd|\setuphead}}[title][header=empty]
{{cmd|\setupheader}}[style={\sc}]
{{cmd|\setupfooter}}[style={\itxx}]
{{cmd|\setupheadertexts}}[How to several languages in the same text with \ConTeXt][][][{\getmarking[section]}]
{{cmd|\setupfootertexts}}[][][][© Copyright — The reproduction of this text is under authorisation.]
{{cmd|\defineparagraphs}}[TwoColumns][n=2, align={hz, hanging}]
{{cmd|\setupparagraphs}}[TwoColumns][1][width=210pt, style=rm, align=left]}
{{cmd|\starttext}}
{{cmd|\title}}{\ConTeXt : or how to print non-roman languages}
{{cmd|\section}} {\sc Preamble}
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:
{{cmd|\blank}}{{cmd|\startnarrower}}[1*left,1*right]\tfx\setupinterlinespace
{{cmd|\noindent}}
{{cmd|\quotation}}
{Ἔφη γάρ οἱ Σωκράτη ἐντυχεῖν λελουμένον τε καὶ τὰς βλαύτας ὑποδεδεμένον, ἃ ἐκεῖνος ὀλιγάκις ἐποίει· καὶ ἐρέσθαι αὐτὸν ὅποι ἴοι οὕτω καλὸς γεγενημένος. καὶ τὸν εἰπεῖν ὅτι· Ἐπὶ δεῖπνον εἰς Ἀγάθωνος. χθὲς γὰρ αὐτὸν διέφυγον τοῖς ἐπινικίοις, φοβηθεὶς τὸν ὄχλον· ὡμολόγησα δ᾽ εἰς τήμερον παρέσεσθαι. ταῦτα δὴ ἐκαλλωπισάμην, ἵνα καλὸς παρὰ καλὸν ἴω}.
{{cmd|\noindent}}
{{cmd|\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>}{{cmd|\inmargin{Platon, {\em Symposium}, 174a}.}}
{{cmd|\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:
{{cmd|\startnarrower}}[1*left,1*right]\tfx\setupinterlinespace
% Here below, the Greek text is on the left columns; the translation is on the right columns
{{cmd|\startTwoColumns}}
{{cmd|\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.}
{{cmd|\stopTwoColumns}}
{{cmd|\stopnarrower}}
{{cmd|\section}}{Éditing with \TeX : \ConTeXt — an alternative}
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.
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.
{{cmd|\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 :
{{cmd|\startnarrower}}[1*left,1*right]\tfx\setupinterlinespace
惠子謂莊子曰。
然則無用之為用也亦明矣。
{{cmd|\stopnarrower}}
{{cmd|\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?”
% Here the conclusion is within a frame
{{cmd|\showframe}}
{{cmd|\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.
{{cmd|\stopMyFrame}}
{{cmd|\stoptext}}

Navigation menu