HI Ihor,
I'm getting a bit worried that this conversation is going in circles that
only delay the real target, which should be having an alternative support
for font configuration in ox-latex.el that relieves the user from writing a
(longer) .tex file which needs to be included with
#+LATEX_HEADER: \include{font-config}
or by writing each and every line of this file in a bunch of
#+LATEX_HEADER: lines. Either solutions shy people away from trying Org
mode out for their needs.
Let me recap what has happened so far:
We got a user who wanted to add emojis and control a listing with lualatex
and I provided a patch with the fontspec part. This solved the issue raised
in the mailing list and guess what, I have been using this functionality
ever since in my lecture notes and slides, because that is 99.5% of what I
need. The other thing is adding a
#+LATEX_HEADER: \usepackage[spanish]{babel}
#+LATEX_HEADER: \usepackage[german]{babel}
or
#+LATEX_HEADER: \usepackage[german]{babel}
and lately (because that is what I was taught @ school and other powerful
reasons)
#+LATEX_HEADER: \usepackage[british]{babel}
and that's it. I have lost track of when I produced this patch. The
worrying part of it is that people keep asking how I manage to include
emojis in my beamer presentations using Org and my (only) answer is to
explain the whole process of installing the feature branch. This is shying
people away from using emacs+org-mode to do their presentations.
Now, let's try a completely different approach to explaining the
variables...
You look up in the Internet and find an example that matches your compiler
(lualatex or xelatex), your localisation package (polyglossia or babel) and
your language and you find your font configuration. For example, in
https://latex3.github.io/babel/guides/locale-greek.html you find that for a
document written in Greek, you only need.
\babelfont{rm}{NewComputerModern10}
The header would be
#+LANGUAGE: el
#+LATEX_MULTI_LANG: babel
Then you create your variable. In this case, as a loval variable, you can
go for
# org-latex-babel-font-config: '((nil :fonts (("rm" :font
"NewComputerModern10"))))
Now you happen to use \textsf{}[1] or you set your default font to be sf.
Then you can add ("sf" :font "<whatever font you love for sf>")
And if you have =tt text= or listings you add ("tt" :font "<your wonderul
mono font>" :props "Scale=MatchLowercase")
At this point, it might be advisable that you put the configurarion in a
.dir-locals.el in the same folder as the org file.
When you see that you have more than one document which tends to reuse the
same config, you might go and move this dir-locals. to a common parent
directory in your documents folder.
The org-latex-... variables I have included (hopefully) make it easy to map
what you see in the manuals and in this and other sites to your needs.
(At least easier than writing the whole stuff in LaTeX).
Best, /PA
Side note:
[1] It would be nice to add markup for sf
On Fri, 21 Nov 2025 at 19:31, Ihor Radchenko <[email protected]> wrote:
> Pedro Andres Aranda Gutierrez <[email protected]> writes:
>
> >>> For each language, again, font + features can be defined.
> >>> By default, given a language + font, that font will be used to
> >>> typeset everything in that language - main text, emphasis, and
> >>> monospaced fragments.
> >>>
> >> sf has nothing to do with emphasis ;-)
>
> Got it.
>
> >>> However, if :variant is provided (rm/sf/tt), user can specify
> >>> individual fonts for main text, emphasis, and monospaced fragments
> in
> >>> that language (is it really true?
> >>
> > Not completely... if your don't say anything, the font meant is the rm
> and
> > if you add a \textsf{}, lualatex will choke at your document.
>
> Looks like it is simply the default font?
> I tried
>
> % Intended LaTeX compiler: lualatex
> \documentclass[11pt]{article}
> \usepackage{fontspec}
> \usepackage{polyglossia}
> \usepackage{unicode-math}
> \setmainlanguage{english}
> \newfontfamily{\englishfont}{FreeSerif}
> \date{\today}
> \title{Hello}
> \begin{document}
> Test. \textsf{This is test}
> \end{document}
>
> >>> I think this is not how it works in
> >>> the code, but what I say here seems reasonable)
> >>>
> > lang+variant+font+(optional properties) would be the way to go to make
> > sure everything is there.
> > If you go back to the example I sent a couple of hours ago you see a
> config
> > for this in the second code block.
>
> But can you do multiple variants for polyglossia-font-config? Your
> example is for babel.
>
> >>> There is also :tag, but I do not quite understand its purpose. Can
> >>> you please explain? (Reading the manual did not help)
> >>>
> > That's an obscure feature mentioned in the manual. It should be the
> BCP-47
> > tag for the language.
> > I included it but you could consider it for FFS.
>
> This seems relevant
>
> If a specific sans serif or monospace (‘teletype’) font is needed for a
> particular script or language, it can be defined by means of ←
> \⟨script⟩fontsf or \⟨language⟩fontsf and \⟨script⟩fonttt or
> \⟨language⟩fonttt, respectively. Whenever a new language is activated,
> polyglossia will first check whether a font has been defined for that
> language. If this is not the case, it will check whether a font
> associated with the BCP-47 script tag of the current language is
> defined. If this also isn’t the case, polyglossia will finally check
> (but this only for languages in non-Latin scripts) whether there is a
> font associated with the OpenType script tag. If none of these fonts is
> defined, polyglossia will use the currently active font as defined by
> \setmainfont, \setsansfont or \setmonofont and – in the case of
> OpenType
> fonts – will attempt to turn on the appropriate OpenType tags for the
> script and language used, in case these are available in the font, by
> means of fontspec’s \addfontfeature. If the current font does not
> appear
> to support the script of that language, an error message is displayed.
>
> So, this simply appears to be alternative alias to language. Do we
> really need this? We already know the correct polyglossia language,
> don't we?
>
> >>> 3. org-latex-babel-font-config is similar to polyglossia-font-config.
> >>> It also maps language to font + features, but with a twist.
> >>> Unlike, polyglossia-font-config, you cannot just say - use the same
> >>> font famility for normal, emphasized, and monospaced text. You must
> >>> always specify individual font + features for each rm/sf/tt script.
> >>> In addition, it is possible to explicitly specify default font used
> >>> for languages other than with explicitly specified font settings.
> (is
> >>> this really accounteed for in the code?)
> >>>
> >> Yes... that is the nil in the language.
>
> Hmm. Looking at the code again, I think that my understanding was not
> 100% accurate. nil in the language is simply an alias to whatever main
> language is in the document.
>
> Also, looking into babel docs:
>
> Actually, there is no real need to use \babelfont in a monolingual
> document, if you set
> the language system in \setmainfont (or not, depending on what you
> want).
>
> So, it looks like for the actual default (when nothing is specified for
> a given language), fontspec config will do.
>
> --
> 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>
>
--
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler
"Sagen's Paradeiser" (ORF: Als Radiohören gefährlich war) => write BE!
Year 1 of the New Koprocracy