From 73057fc06990f861468c397c94b7076d025acbc8 Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Fri, 8 Sep 2023 19:33:25 +0200 Subject: [PATCH] ox-latex.el: Fixes and improvements in `org-latex-language-alist'. * (org-latex-language-alist): Fix a language code (`de-de') removed when `org-latex-babel-language-alist' and `org-latex-polyglossia-language-alist' were merged. To allow language codes that can have a similar translation in `babel' or `polyglossia' now in each element of `org-latex-language-alist' car can also be a list of language codes. New admitted properties: `:babel-ini-alt', `:script' and `:script-tag'. Add language code for ancient Greek. Fix Afrikaans (was previously removed). New languages: Chinese Simplified and Traditional. Correction of some typos, errors and inaccuracies. `let' bindings suggested by Ihor Radchenko. * (org-latex-guess-babel-language): Some necessary modifications. --- lisp/ox-latex.el | 197 ++++++++++++++++++++++++++--------------------- 1 file changed, 109 insertions(+), 88 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 241ef603a..14105c7cc 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -177,94 +177,105 @@ ;;; Internal Variables (defconst org-latex-language-alist - '(("am" :babel-ini-only "amharic" :polyglossia "amharic" :lang-name "Amharic") - ("ar" :babel "arabic" :polyglossia "arabic" :lang-name "Arabic") - ("ast" :babel-ini-only "asturian" :polyglossia "asturian" :lang-name "Asturian") - ("bg" :babel "bulgarian" :polyglossia "bulgarian" :lang-name "Bulgarian") - ("bn" :babel-ini-only "bengali" :polyglossia "bengali" :lang-name "Bengali") - ("bo" :babel-ini-only "tibetan" :polyglossia "tibetan" :lang-name "Tibetan") - ("br" :babel "breton" :polyglossia "breton" :lang-name "Breton") - ("ca" :babel "catalan" :polyglossia "catalan" :lang-name "Catalan") - ("cop" :babel-ini-only "coptic" :polyglossia "coptic" :lang-name "Coptic") - ("cs" :babel "czech" :polyglossia "czech" :lang-name "Czech") - ("cy" :babel "welsh" :polyglossia "welsh" :lang-name "Welsh") - ("da" :babel "danish" :polyglossia "danish" :lang-name "Danish") - ("de" :babel "ngerman" :polyglossia "german" :polyglossia-variant "german" :lang-name "German") - ("de-at" :babel "naustrian" :polyglossia "german" :polyglossia-variant "austrian" :lang-name "German") - ("dsb" :babel "lsorbian" :polyglossia "sorbian" :polyglossia-variant "lower" :lang-name "Lower Sorbian") - ("dv" :babel-ini-only "divehi" :polyglossia "divehi" :lang-name "Divehi") - ("el" :babel "greek" :polyglossia "greek" :lang-name "Greek") - ("el-polyton" :babel "polutonikogreek" :polyglossia "greek" :polyglossia-variant "polytonic" :lang-name "Polytonic Greek") - ("en" :babel "american" :polyglossia "english" :polyglossia-variant "usmax" :lang-name "English") - ("en-au" :babel "australian" :polyglossia "english" :polyglossia-variant "australian" :lang-name "English") - ("en-gb" :babel "british" :polyglossia "english" :polyglossia-variant "uk" :lang-name "English") - ("en-nz" :babel "newzealand" :polyglossia "english" :polyglossia-variant "newzealand" :lang-name "English") - ("en-us" :babel "american" :polyglossia "english" :polyglossia-variant "usmax" :lang-name "English") - ("eo" :babel "esperanto" :polyglossia "esperanto" :lang-name "Esperanto") - ("es" :babel "spanish" :polyglossia "spanish" :lang-name "Spanish") - ("es-mx" :babel "spanishmx" :polyglossia "spanish" :polyglossia-variant "mexican" :lang-name "Spanish") - ("et" :babel "estonian" :polyglossia "estonian" :lang-name "Estonian") - ("eu" :babel "basque" :polyglossia "basque" :lang-name "Basque") - ("fa" :babel "farsi" :polyglossia "farsi" :lang-name "Farsi") - ("fi" :babel "finnish" :polyglossia "finnish" :lang-name "Finnish") - ("fr" :babel "french" :polyglossia "french" :lang-name "French") - ("fr-ca" :babel "canadien" :polyglossia "french" :polyglossia-variant "canadian" :lang-name "French") - ("fur" :babel "friulan" :polyglossia "friulan" :lang-name "Friulian") - ("ga" :babel "irish" :polyglossia "irish" :lang-name "Irish") - ("gd" :babel "scottish" :polyglossia "scottish" :lang-name "Scottish Gaelic") - ("gl" :babel "galician" :polyglossia "galician" :lang-name "Galician") - ("he" :babel "hebrew" :polyglossia "hebrew" :lang-name "Hebrew") - ("hi" :babel "hindi" :polyglossia "hindi" :lang-name "Hindi") - ("hr" :babel "croatian" :polyglossia "croatian" :lang-name "Croatian") - ("hsb" :babel "uppersorbian" :polyglossia "sorbian" :polyglossia-variant "upper" :lang-name "Upper Sorbian") - ("hu" :babel "magyar" :polyglossia "magyar" :lang-name "Magyar") - ("hy" :babel-ini-only "armenian" :polyglossia "armenian" :lang-name "Armenian") - ("ia" :babel "interlingua" :polyglossia "interlingua" :lang-name "Interlingua") - ("id" :babel-ini-only "bahasai" :polyglossia "bahasai" :lang-name "Bahasai") - ("is" :babel "icelandic" :polyglossia "icelandic" :lang-name "Icelandic") - ("it" :babel "italian" :polyglossia "italian" :lang-name "Italian") - ("kn" :babel-ini-only "kannada" :polyglossia "kannada" :lang-name "Kannada") - ("la" :babel "latin" :polyglossia "latin" :lang-name "Latin") - ("la-classic" :babel "classiclatin" :polyglossia "latin" :polyglossia-variant "classic" :lang-name "Classic Latin") - ("la-medieval" :babel "medievallatin" :polyglossia "latin" :polyglossia-variant "medieval" :lang-name "Medieval Latin") - ("la-ecclesiastic" :babel "ecclesiasticlatin" :polyglossia "latin" :polyglossia-variant "ecclesiastic" :lang-name "Ecclesiastic Latin") - ("lo" :babel-ini-only "lao" :polyglossia "lao" :lang-name "Lao") - ("lt" :babel "lithuanian" :polyglossia "lithuanian" :lang-name "Lithuanian") - ("lv" :babel "latvian" :polyglossia "latvian" :lang-name "Latvian") - ("ml" :babel-ini-only "malayalam" :polyglossia "malayalam" :lang-name "Malayalam") - ("mr" :babel-ini-only "maranthi" :polyglossia "maranthi" :lang-name "Maranthi") - ("nb" :babel "norsk" :polyglossia "norwegian" :polyglossia-variant "bokmal" :lang-name "Norwegian Bokmål") - ("nl" :babel "dutch" :polyglossia "dutch" :lang-name "Dutch") - ("nn" :babel "nynorsk" :polyglossia "norwegian" :polyglossia-variant "nynorsk" :lang-name "Norwegian Nynorsk") - ("no" :babel "norsk" :polyglossia "norsk" :lang-name "Norwegian") - ("oc" :babel "occitan" :polyglossia "occitan" :lang-name "Occitan") - ("pl" :babel "polish" :polyglossia "polish" :lang-name "Polish") - ("pms" :babel "piedmontese" :polyglossia "piedmontese" :lang-name "Piedmontese") - ("pt" :babel "portuges" :polyglossia "portuges" :lang-name "Portuges") - ("pt-br" :babel "brazilian" :polyglossia "brazilian" :lang-name "Portuges") - ("rm" :babel-ini-only "romansh" :polyglossia "romansh" :lang-name "Romansh") - ("ro" :babel "romanian" :polyglossia "romanian" :lang-name "Romanian") - ("ru" :babel "russian" :polyglossia "russian" :lang-name "Russian") - ("sa" :babel-ini-only "sanskrit" :polyglossia "sanskrit" :lang-name "Sanskrit") - ("sk" :babel "slovak" :polyglossia "slovak" :lang-name "Slovak") - ("sl" :babel "slovene" :polyglossia "slovene" :lang-name "Slovene") - ("sq" :babel "albanian" :polyglossia "albanian" :lang-name "Albanian") - ("sr" :babel "serbian" :polyglossia "serbian" :lang-name "Serbian") - ("sv" :babel "swedish" :polyglossia "swedish" :lang-name "Swedish") - ("syr" :babel-ini-only "syriac" :polyglossia "syriac" :lang-name "Syriac") - ("ta" :babel-ini-only "tamil" :polyglossia "tamil" :lang-name "Tamil") - ("te" :babel-ini-only "telugu" :polyglossia "telugu" :lang-name "Telugu") - ("th" :babel "thai" :polyglossia "thai" :lang-name "Thai") - ("tk" :babel "turkmen" :polyglossia "turkmen" :lang-name "Turkmen") - ("tr" :babel "turkish" :polyglossia "turkish" :lang-name "Turkish") - ("uk" :babel "ukrainian" :polyglossia "ukrainian" :lang-name "Ukrainian") - ("ur" :babel-ini-only "urdu" :polyglossia "urdu" :lang-name "Urdu") - ("vi" :babel "vietnamese" :polyglossia "vietnamese" :lang-name "Vietnamese")) + (let ((de-default-plist '(:babel "ngerman" :babel-ini-alt "german" :polyglossia "german" :polyglossia-variant "german" :lang-name "German" :script "latin" :script-tag "latn")) + (zh-default-plist '(:babel-ini-only "chinese" :polyglossia "chinese" :polyglossia-variant "simplified" :lang-name "Chinese Simplified" :script "hans" :script-tag "hans"))) + `(("af" :babel "afrikaans" :polyglossia "afrikaans" :lang-name "Afrikaans" :script "latin" :script-tag "latn") + ("am" :babel-ini-only "amharic" :polyglossia "amharic" :lang-name "Amharic" :script "ethiopic" :script-tag "ethi") + ("ar" :babel-ini-only "arabic" :polyglossia "arabic" :lang-name "Arabic" :script "arabic" :script-tag "arab") + ("ast" :babel-ini-only "asturian" :polyglossia "asturian" :lang-name "Asturian" :script "latin" :script-tag "latn") + ("bg" :babel "bulgarian" :polyglossia "bulgarian" :lang-name "Bulgarian" :script "cyrillic" :script-tag "cyrl") + ("bn" :babel-ini-only "bengali" :polyglossia "bengali" :lang-name "Bengali" :script "bengali" :script-tag: "beng") + ("bo" :babel-ini-only "tibetan" :polyglossia "tibetan" :lang-name "Tibetan" :script "tibetan" :script-tag "tib") + ("br" :babel "breton" :polyglossia "breton" :lang-name "Breton" :script "latin" :script-tag "latn") + ("ca" :babel "catalan" :polyglossia "catalan" :lang-name "Catalan" :script "latin" :script-tag "latn") + ("cop" :babel-ini-only "coptic" :polyglossia "coptic" :lang-name "Coptic" :script "coptic" :script-tag "copt") + ("cs" :babel "czech" :polyglossia "czech" :lang-name "Czech" :script "latin" :script-tag "latn") + ("cy" :babel "welsh" :polyglossia "welsh" :lang-name "Welsh" :script "latin" :script-tag "latn") + ("da" :babel "danish" :polyglossia "danish" :lang-name "Danish" :script "latin" :script-tag "latn") + ("de" ,@de-default-plist) + ("de-de" ,@de-default-plist) + ("de-at" :babel "naustrian" :babel-ini-alt "german-austria" :polyglossia "german" :polyglossia-variant "austrian" :lang-name "German" :script "latin" :script-tag "latn") + ("dsb" :babel "lowersorbian" :babel-ini-alt "lsorbian" :polyglossia "sorbian" :polyglossia-variant "lower" :lang-name "Lower Sorbian" :script "latin" :script-tag "latn") + ("dv" :polyglossia "divehi" :lang-name "Dhivehi" :script "latin" :script-tag "latn") + ("el" :babel "greek" :polyglossia "greek" :lang-name "Greek" :script "greek" :script-tag "grek") + ("el-polyton" :babel "polutonikogreek" :babel-ini-alt "polytonicgreek" :polyglossia "greek" :polyglossia-variant "polytonic" :lang-name "Polytonic Greek" :script "greek" :script-tag "grek") + ("grc" :babel "greek.ancient" :babel-ini-alt "ancientgreek" :polyglossia "greek" :polyglossia-variant "ancient" :lang-name "Ancient Greek" :script "greek" :script-tag "grek") + ("en" :babel "english" :polyglossia "english" :polyglossia-variant "usmax" :lang-name "English" :script "latin" :script-tag "latn") + ("en-au" :babel "australian" :polyglossia "english" :polyglossia-variant "australian" :lang-name "English" :script "latin" :script-tag "latn") + ("en-ca" :babel "canadian" :polyglossia "english" :polyglossia-variant "canadian" :lang-name "English" :script "latin" :script-tag "latn") + ("en-gb" :babel "british" :polyglossia "english" :polyglossia-variant "uk" :lang-name "English" :script "latin" :script-tag "latn") + ("en-nz" :babel "newzealand" :polyglossia "english" :polyglossia-variant "newzealand" :lang-name "English" :script "latin" :script-tag "latn") + ("en-us" :babel "american" :polyglossia "english" :polyglossia-variant "usmax" :lang-name "English" :script "latin" :script-tag "latn") + ("eo" :babel "esperanto" :polyglossia "esperanto" :lang-name "Esperanto" :script "latin" :script-tag "latn") + ("es" :babel "spanish" :polyglossia "spanish" :lang-name "Spanish" :script "latin" :script-tag "latn") + ("es-mx" :babel "spanishmx" :polyglossia "spanish" :polyglossia-variant "mexican" :lang-name "Spanish" :script "latin" :script-tag "latn") + ("et" :babel "estonian" :polyglossia "estonian" :lang-name "Estonian" :script "latin" :script-tag "latn") + ("eu" :babel "basque" :polyglossia "basque" :lang-name "Basque" :script "latin" :script-tag "latn") + ("fa" :babel "persian" :polyglossia "persian" :lang-name "Persian" :script "arabic" :script-tag "arab") + ("fi" :babel "finnish" :polyglossia "finnish" :lang-name "Finnish" :script "latin" :script-tag "latn") + ("fr" :babel "french" :polyglossia "french" :lang-name "French" :script "latin" :script-tag "latn") + ("fr-ca" :babel "canadien" :babel-ini-alt "canadian" :polyglossia "french" :polyglossia-variant "canadian" :lang-name "French" :script "latin" :script-tag "latn") + ("fur" :babel "friulian" :polyglossia "friulian" :lang-name "Friulian" :script "latin" :script-tag "latn") + ("ga" :babel "irish" :polyglossia "gaelic" :polyglossia-variant "irish" :lang-name "Irish Gaelic" :script "latin" :script-tag "latn") + ("gd" :babel "scottish" :polyglossia "gaelic" :polyglossia-variant "scottish" :lang-name "Scottish Gaelic" :script "latin" :script-tag "latn") + ("gl" :babel "galician" :polyglossia "galician" :lang-name "Galician" :script "latin" :script-tag "latn") + ("he" :babel "hebrew" :polyglossia "hebrew" :lang-name "Hebrew" :script "hebrew" :script-tag "hebr") + ("hi" :babel "hindi" :polyglossia "hindi" :lang-name "Hindi" :script "devanagari" :script-tag "deva") + ("hr" :babel "croatian" :polyglossia "croatian" :lang-name "Croatian" :script "latin" :script-tag "latn") + ("hsb" :babel "uppersorbian" :polyglossia "sorbian" :polyglossia-variant "upper" :lang-name "Upper Sorbian" :script "latin" :script-tag "latn") + ("hu" :babel "magyar" :polyglossia "magyar" :lang-name "Magyar" :script "latin" :script-tag "latn") + ("hy" :babel-ini-only "armenian" :polyglossia "armenian" :lang-name "Armenian" :script "armenian" :script-tag "armn") + ("ia" :babel "interlingua" :polyglossia "interlingua" :lang-name "Interlingua" :script "latin" :script-tag "latn") + ("id" :babel "indonesian" :polyglossia "malay" :polyglossia-variant "indonesian" :lang-name "Indonesian" :script "latin" :script-tag "latn") + ("is" :babel "icelandic" :polyglossia "icelandic" :lang-name "Icelandic" :script "latin" :script-tag "latn") + ("it" :babel "italian" :polyglossia "italian" :lang-name "Italian" :script "latin" :script-tag "latn") + ("kn" :babel-ini-only "kannada" :polyglossia "kannada" :lang-name "Kannada" :script "kannada" :script-tag "knda") + ("la" :babel "latin" :polyglossia "latin" :lang-name "Latin" :script "latin" :script-tag "latn") + ("la-classic" :babel "classiclatin" :polyglossia "latin" :polyglossia-variant "classic" :lang-name "Classic Latin" :script "latin" :script-tag "latn") + ("la-medieval" :babel "medievallatin" :polyglossia "latin" :polyglossia-variant "medieval" :lang-name "Medieval Latin" :script "latin" :script-tag "latn") + ("la-ecclesiastic" :babel "ecclesiasticlatin" :polyglossia "latin" :polyglossia-variant "ecclesiastic" :lang-name "Ecclesiastic Latin" :script "latin" :script-tag "latn") + ("lo" :babel-ini-only "lao" :polyglossia "lao" :lang-name "Lao" :script "lao" :script-tag "lao") + ("lt" :babel "lithuanian" :polyglossia "lithuanian" :lang-name "Lithuanian" :script "latin" :script-tag "latn") + ("lv" :babel "latvian" :polyglossia "latvian" :lang-name "Latvian" :script "latin" :script-tag "latn") + ("ml" :babel-ini-only "malayalam" :polyglossia "malayalam" :lang-name "Malayalam" :script "malayalam" :script-tag "mlym") + ("mr" :babel-ini-only "marathi" :polyglossia "marathi" :lang-name "Marathi" :script "devanagari" :script-tag "deva") + ("ms" :babel "malay" :polyglossia "malay" :polyglossia-variant "malaysian" :lang-name "Malay" :script "latin" :script-tag "latn") + ("nb" :babel "norsk" :polyglossia "norwegian" :polyglossia-variant "bokmal" :lang-name "Norwegian Bokmål" :script "latin" :script-tag "latn") + ("nl" :babel "dutch" :polyglossia "dutch" :lang-name "Dutch" :script "latin" :script-tag "latn") + ("nn" :babel "nynorsk" :polyglossia "norwegian" :polyglossia-variant "nynorsk" :lang-name "Norwegian Nynorsk" :script "latin" :script-tag "latn") + ("no" :babel "norsk" :polyglossia "norsk" :lang-name "Norwegian" :script "latin" :script-tag "latn") + ("oc" :babel "occitan" :polyglossia "occitan" :lang-name "Occitan" :script "latin" :script-tag "latn") + ("pl" :babel "polish" :polyglossia "polish" :lang-name "Polish" :script "latin" :script-tag "latn") + ("pms" :babel "piedmontese" :polyglossia "piedmontese" :lang-name "Piedmontese" :script "latin" :script-tag "latn") + ("pt" :babel "portuges" :polyglossia "portuges" :lang-name "Portuges" :script "latin" :script-tag "latn") + ("pt-br" :babel "brazilian" :polyglossia "brazilian" :lang-name "Portuges" :script "latin" :script-tag "latn") + ("rm" :babel-ini-only "romansh" :polyglossia "romansh" :lang-name "Romansh" :script "latin" :script-tag "latn") + ("ro" :babel "romanian" :polyglossia "romanian" :lang-name "Romanian" :script "latin" :script-tag "latn") + ("ru" :babel "russian" :polyglossia "russian" :lang-name "Russian" :script "cyrillic" :script-tag "cyrl") + ("sa" :babel-ini-only "sanskrit" :polyglossia "sanskrit" :lang-name "Sanskrit" :script "devanagari" :script-tag "deva") + ("sk" :babel "slovak" :polyglossia "slovak" :lang-name "Slovak" :script "latin" :script-tag "latn") + ("sl" :babel "slovene" :polyglossia "slovene" :lang-name "Slovene" :script "latin" :script-tag "latn") + ("sq" :babel "albanian" :polyglossia "albanian" :lang-name "Albanian" :script "latin" :script-tag "latn") + ("sr" :babel "serbian" :polyglossia "serbian" :lang-name "Serbian" :script "latin" :script-tag "latn") + ("sr-cyrl" :babel-ini-only "serbian-cyrl" :polyglossia "serbian" :lang-name "Serbian" :script "cyrillic" :script-tag "cyrl") + ("sr-latn" :babel-ini-only "serbian-latin" :polyglossia "serbian" :lang-name "Serbian" :script "latin" :script-tag "latn") + ("sv" :babel "swedish" :polyglossia "swedish" :lang-name "Swedish" :script "latin" :script-tag "latn") + ("syr" :babel-ini-only "syriac" :polyglossia "syriac" :lang-name "Syriac" :script "syriac" :script-tag "syrc") + ("ta" :babel-ini-only "tamil" :polyglossia "tamil" :lang-name "Tamil" :script "tamil" :script-tag "taml") + ("te" :babel-ini-only "telugu" :polyglossia "telugu" :lang-name "Telugu" :script "telugu" :script-tag "telu") + ("th" :babel "thai" :polyglossia "thai" :lang-name "Thai" :script "thai" :script-tag "thai") + ("tk" :babel "turkmen" :polyglossia "turkmen" :lang-name "Turkmen" :script "latin" :script-tag "latn") + ("tr" :babel "turkish" :polyglossia "turkish" :lang-name "Turkish" :script "latin" :script-tag "latn") + ("uk" :babel "ukrainian" :polyglossia "ukrainian" :lang-name "Ukrainian" :script "cyrillic" :script-tag "cyrl") + ("ur" :babel-ini-only "urdu" :polyglossia "urdu" :lang-name "Urdu" :script "arabic" :script-tag "arab") + ("vi" :babel "vietnamese" :polyglossia "vietnamese" :lang-name "Vietnamese" :script "latin" :script-tag "latn") + ("zh" ,@zh-default-plist) + ("zh-cn" ,@zh-default-plist) + ("zh-tw" :babel-ini-only "chinese-traditional" :polyglossia "chinese" :polyglossia-variant "traditional" :lang-name "Chinese Traditional" :script "hant" :script-tag "hant"))) "Alist between language code and its properties for LaTeX export. -In each element of the list car is always the code of the -language and cdr is a property list. Valid keywords for this -list can be: +In each element of the list car is always the language code and +cdr is a property list. Valid keywords for this list can be: - `:babel' the name of the language loaded by the Babel LaTeX package @@ -275,9 +286,17 @@ list can be: exclusively through the new ini files method. See `http://mirrors.ctan.org/macros/latex/required/babel/base/babel.pdf' +- `:babel-ini-alt' an alternative language name when it is loaded + using ini files + - `:polyglossia-variant' the language variant loaded by Polyglossia -- `:lang-name' the actual name of the language.") +- `:lang-name' the actual name of the language + +- `:script' the script name + +- `:script-tag' the script otf tag.") + (defconst org-latex-line-break-safe "\\\\[0pt]" "Linebreak protecting the following [...]. @@ -1660,6 +1679,7 @@ Return the new header." (assoc language-code org-latex-language-alist))) (language (plist-get plist :babel)) (language-ini-only (plist-get plist :babel-ini-only)) + (language-ini-alt (plist-get plist :babel-ini-alt)) ;; If no language is set, or Babel package is not loaded, or ;; LANGUAGE keyword value is a language served by Babel ;; exclusively through ini files, return HEADER as-is. @@ -1691,7 +1711,8 @@ Return the new header." (replace-regexp-in-string (format "\\(\\\\babelprovide\\[.*\\]\\)\\({\\)%s}" prov) (format "\\1\\2%s}" - (or language language-ini-only)) + (if language-ini-alt language-ini-alt + (or language language-ini-only))) header t) header))))) -- 2.42.0