emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Choosing a LaTeX Compiler (my predilection for LuaTeX)
@ 2021-04-05 20:48 Juan Manuel Macías
  2021-04-05 21:17 ` Dr. Arne Babenhauserheide
  2021-04-07 14:16 ` Diego Zamboni
  0 siblings, 2 replies; 14+ messages in thread
From: Juan Manuel Macías @ 2021-04-05 20:48 UTC (permalink / raw)
  To: orgmode

Hi all,

There have been some threads recently about exporting to LaTeX, but I
think something that I consider interesting for novice Org/LaTeX users
has not been commented: the choice of the TeX engine. I think this is
important because although people often say they "use LaTeX", what they
actually use is TeX via the La-TeX format. What TeX engine to choose? I
would dare to say the following: unless you want to maintain some
backward compatibility with old documents, I highly recommend using
LuaTeX or XeTeX, especially LuaTeX. Although pdfTeX is very popular
among average or veterans LaTeX users, I think using it nowadays doesn't
make much sense (IMHO). LuaTeX is the natural evolution of pdfTeX and
adds the great advantage of accesing the TeX internals through Lua
scripting.

(What follows is specially intended for those Org users who haven't used
XeTeX or LuaTeX yet).

LuaTeX and XeTeX are *100% Unicode-based* and you can use your system
fonts (open type, true type, etc.) in your documents in a simple way
through the fontspec (https://www.ctan.org/pkg/fontspec) package, which
provides a very neat interface and manages all OpenType features (LuaTeX
and XeTeX use HarfBuzz as otf rendering engine). In LuaTeX also you can
use any font that is not installed in your system: just indicate the
path to the fonts files. This is very useful to test new fonts without
installing them... In all modern word processing systems the user has
always been able to pick a font easily, and that has been historically
quite complex, hard and complicated in the (La)TeX ecosystem.

For example, if we want to use globally the Palatino Linotype family in
our LuaLaTeX document:

\setmainfont{Palatino Linotype}

We can add some OpenType features, like old style numbering:

\setmainfont{Linux Libertine O}[Numbers=LowerCase]

And if we want to use another font for italics, with certain properties
(color[1] and scaling):

\setmainfont{Crimson}
[Numbers=Lowercase,
ItalicFont=MinionPro-It.otf,
ItalicFeatures={Color=red,
Scale=MatchLowercase}]

([1] Requires the xcolor package)

We can also define our own family with its properties (for example, with
upper case numbers and letters tracking):

\newfontfamily\myfamily{crimson}
[Numbers=Lining,LetterSpace=3.0]

Furthermore (for more advanced users), in LuaTeX we can define new
opentype features on the fly, both positional and of substitution (as
long as the typeface includes the glyphs needed to replace). For
example, if I use the Crimson typeface, a contextual substitution for
character Q + u can be defined, by including some Lua code through the
LuaTeX primitive `directlua':

\directlua{
   fonts.handlers.otf.addfeature{
    name = "mycontextual",
    type = "chainsubstitution",
    lookups = {
      {
        type = "substitution",
        data = {
          ["Q"] = "Q.alt01",
        },
      },
    },
    data = {
      rules = {
        {
          after  = { { "u" } },
          current = { { "Q" } },
          lookups = { 1 },
        },
      },
    },
  }
}

... And add anywhere in the text:

\addfontfeature{RawFeature=+mycontextual}

If I had to choose, finally, between XeTeX and LuaTeX, I would choose
LuaTeX, for things like these and many other reasons. In addition, there
are emerging cool new packages that only work with LuaTeX.

Anyway, XeTeX is another very good option too, especially for users who
prefer something that works more "out of the box" and is less esotheric
than LuaTeX.

To export to PDF always with LuaTeX we can put in our ~ /.emacs:

(setq org-latex-pdf-process
      '("lualatex -shell-escape -interaction nonstopmode -output-directory %o %f"
        "lualatex -shell-escape -interaction nonstopmode -output-directory %o %f"
        "lualatex -shell-escape -interaction nonstopmode -output-directory %o %f"))

Or with latexmk, which will take care of compiling as many times as
necessary for indexes, bibliographies, etc .:

(setq org-latex-pdf-process
      '("latexmk -lualatex -e '$lualatex=q/lualatex %%O -shell-escape %%S/' %f"))

Best regards,

Juan Manuel


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Choosing a LaTeX Compiler (my predilection for LuaTeX)
@ 2021-04-06 20:44 Ypo
  0 siblings, 0 replies; 14+ messages in thread
From: Ypo @ 2021-04-06 20:44 UTC (permalink / raw)
  To: maciaschain, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 836 bytes --]

Thanks, Juan Manuel, if LuaTeX just solved the "symbols problem" it 
would be a great feature.

But.., why nothing in TeX seems to be easy?! ;D

    lualatex: security risk: running with elevated privileges
    This is LuaHBTeX, Version 1.12.0 (MiKTeX 20.11)
      system commands enabled.

    lualatex: file not writable for security reasons: .log
    ! I can't write on file `.log'.
    Please type another transcript file name
    ! Emergency stop
    !  ==> Fatal error occurred, no output PDF file produced!


Probably a Windowz problem, don't care. Just moaning ;D

But I take your advise and save it.

Best regards


> *From*: 	Juan Manuel Macías
> *Subject*: 	Choosing a LaTeX Compiler (my predilection for LuaTeX)
> *Date*: 	Mon, 05 Apr 2021 22:48:48 +0200
> *User-agent*: 	Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
>


[-- Attachment #2: Type: text/html, Size: 2455 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-04-07 19:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-05 20:48 Choosing a LaTeX Compiler (my predilection for LuaTeX) Juan Manuel Macías
2021-04-05 21:17 ` Dr. Arne Babenhauserheide
2021-04-05 21:36   ` Juan Manuel Macías
2021-04-06 19:03     ` physiculus
2021-04-06 19:13       ` Juan Manuel Macías
2021-04-07 16:57         ` physiculus
2021-04-07 17:26           ` Juan Manuel Macías
2021-04-07 17:53             ` physiculus
2021-04-07 19:52               ` Juan Manuel Macías
2021-04-06 19:46       ` tomas
2021-04-06 20:09         ` Juan Manuel Macías
2021-04-07 14:16 ` Diego Zamboni
2021-04-07 15:29   ` Juan Manuel Macías
  -- strict thread matches above, loose matches on Subject: below --
2021-04-06 20:44 Ypo

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).