Hi Ihor, Thanks! A lot to digest ;-) First reactions inline. On Sat, 17 May 2025 at 15:07, Ihor Radchenko <yanta...@posteo.net> wrote:
> Pedro Andres Aranda Gutierrez <paag...@gmail.com> writes: > > > @Ihor: do we want this integrated in the existing sections, or does a new > > section of multi-lingual for LaTeX make sense? > > I believe that we need a new subsection explaining about multilingual > export. That section should also absorb the existing paragraphs > explaining about polyglossia and babel. > OK, That'll take some time > > Before I push too much, I'd also ask for a code/documentation review, > > knowing that the polyglossia configuration additions need to be > documented > > in the manual. > > > +*** Controlling the font configuration for LuaLaTeX and XeLaTeX > > + > > +The LaTeX templates in =org= have been enriched by a new keyword, > > +=[FONTSPEC]=, which act as a placeholder for font specification > > +code. This feature is currently supported for LuaLaTeX and XeLaTex. > > +(c.f. [[#lualatex-fontspec][below]]). An empty string will be > > +generated for PDFLaTeX. > > We should not mention "new" in the manual. Manual describes the existing > state of affairs, and it makes little sense to discuss new/old additions > there. > > Also, your writing is a bit too heavily-focused on technical aspect of > LaTeX output. It may be confusing for users not familiar with latex, > especially as the opening paragraph. > > I suggest explaining *why* font configuration is needed in latex and > which users should pay attention to this section. > Right! > > +**** Controlling the font configuration for LuaLaTeX > > +:PROPERTIES: > > +:custom_id: lualatex-fontspec > > +:description: Using org-latex-fontspec-config > > +:END: > > +#+cindex: LuaLaTeX font configuration > > Isn't it the same for xelatex/lualatex? > I'll make sure we have XeLaTex mentioned too when needed. > +Org mode uses the variable ~org-latex-fontspec-config~ to map your > > +document's fonts to the fonts used in the document. To familiarise > > +yourself with fonts and options, read the > > +[[ > http://mirrors.ctan.org/macros/unicodetex/latex/fontspec/fontspec.pdf][~fontspec~ > > +package manual]] Part II. This variable be set in your Emacs > > +initialisation code, in the file local variables or in the [[ > https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html][directory > > +local variable file]] ~.dir-locals.el~ . > > This reveals the awkwardness of forcing people to use a variable. > We need to use keywords in addition to variable. > Leave that as a TODO FTMB. > I think that we can take inspiration from > https://tecosaur.github.io/emacs-config/config.html#font-collections > and introduce an idea of font collections. > The font collections are named font presets that can be selected as a > whole. (and potentially contributed by users) > In using a variable, I'm following the approach of eglot. > Then, we can introduce a #+LATEX_FONT: collection-name > keyword so that users can set it per-document. Wouldn't that mean a lot of user centric configuration. I think we can share documents better if we have the document and the .dir-locals.el distributed. So it might be more reproducible, because it would not depend so much on the local user configurations. I see a lot of resistance in people WRT 2 things: 1.- if they have to start creating a "giant" Emacs configuration, vs. they get a zip file with everything and they can start working on the doc 2.- if the document header starts to grow too much with too many things users need to learn. > We can then easily introduce #+LATEX_FONT as the entry point for people interested in customization. > > ... > #+LATEX_FONT: main "TeX Gyre Termes[Scale=MatchLowercase]" > As long as this "writes" org-latex-fontspec-config, why not. So let's discuss the use of this keyword and how we would map the fallback mechanism. > > +If do not want or need any specific configuration for the ~fontspec~ > > +package, set ~org-latex-fontspec-config~ to ~nil~. This is the > > +default value. This is normally the se when exporting to =beamer=, > > +where you most probably want to use the fonts defined in the template. > > + > > +~org-latex-fontspec-config~ maps the font name used in the > > +=\set...font{}= commands defined by the =fontspec= package with the > > +font name and optional font features. > > .. > > This sounds advanced. I'd rather move this to > `org-latex-fontspec-config' docstring, so that people can read it only > when interested in fine-tuning things. No problem, WIll be done when reorganising the manual. > > +You can also add fallback fonts for specific font names for specific > +character scripts. These are detected by Emacs during the export > > +process. > > ... > > +#+BEGIN_SRC elisp > > +("main" :font "TeX Gyre Termes" > > + :fallback (("emoji" . "Noto Color Emoji:mode=harf") > > + ("han" . "Noto Serif CJK JP:") > > + ("kana" . "Noto Serif CJK JP:"))) > > +#+END_SRC > > +if Emacs detects characters belonging to the ~emoji~ character set, it > > +will include the following fallback definition for the =main= > font[fn:49]: > > This sounds like something intersecting polyglossia, or maybe I miss > something? No, this is the fallback mechanism for fontspec only. The "emoji", "han", etc. are detected with Juan Manuel's code. Then the fallback configuration using the luaotfoffload mechanism is generated for the scripts that are detected *and* defined in the font configuration. If it is related, maybe we can make use of > `org-latex-language-alist' names instead of forcing people to figure out > the character set names? > I have a TODO in the code exactly for that, in the additions to the polyglossia configurations. > > +*Notes* > > +- You may use any font name used in the ~\set..font{}~ command by the > > + ~fontspec~ package. For example, when using XeLaTeX, you can > > + compose Chinese, Japanese or Korean test using the ~xeCJK~ and > > + ~xpinyin~ packages. These packages define the ~\\setCKJmainfont{}~, > > + ~\\setCJKsansfont{}~ and ~\\setCJKmonofnt{}~ commands. Use the > > + ~CJKmain~, ~CJKsans~ and ~CJK mono~ definitions in your documents to > > + customise them: > > + #+BEGIN_SRC elisp :results none :exports code > > +((org-mode . > > + ((org-latex-fontspec-config . > > + (("main" :font "Noto Serif") > > + ("sans" :font "Noto Sans") > > + ("mono" :font "Noto Sans Mono") > > + ("CJKmain" :font "Noto Serif CJK SC") > > + ("CJKsans" :font "Noto Sans CJK SC") > > + ("CJKmono" :font "Noto Sans Mono CJK SC")))))) > > + #+END_SRC > > + > > I think we can automatically load xeCJK/xpinyin when CJKmain/sans/mono > are specified and the relevant scripts are detected in the document. > Yet another TODO ;-) You are right > > -- > Ihor Radchenko // yantar92, > Org mode maintainer, > Learn more about Org mode at <https://orgmode.org/>. > Support Org development at <https://liberapay.com/org-mode>, > or support my work at <https://liberapay.com/yantar92> > Again, please go through the examples I attached as a ZIP to my message in the hope that they would show what I want to achieve from the document layout point of view. Best, /PA -- Fragen sind nicht da, um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler Sagen's Paradeiser, write BE! Year 1 of the New Koprocracy