>>>>>>> El 03/04/2021 a las 18:00, emacs-orgmode-request@gnu.org escribió:

Message: 34
Date: Sun, 04 Apr 2021 00:31:24 +1100
To: emacs-orgmode@gnu.org
Subject: Re: First steps exporting to tex
Message-ID: <871rbr7ag1.fsf@gmail.com>
Content-Type: text/plain; charset=utf-8


Why do you think you need any of this for your 'first steps'. Start by
just writing your org file and exporting it to LaTeX or pdf. Then, once
you have your first document, see what you think needs changing and come
back and ask advice on what you need to do to make the changes you want.
In your first document, don't use any LaTeX commands, header options or
anything else - just write your document using standard org mode. 

Org already sets up a reasonable starting default. Once you know what
the default is, then we can discuss what you may need to change. For
many documents, you may not need to change much at all and you may not
need any templates - for example, you will likely want to change the
margin sizes (this is a common request) or you may want to see what some
of the other 'standard' LaTeX document classes are like. All of this can
be achieved with just minor configuration of org mode.

The org export to LaTeX only needs to be as complicated as you need it
to be. Org has variables which can be used to add/remove things from the
preamble and once you have those configured, you don't have to put
anything in the org file itself. Start simple and add as you find a need
rather than try to start with something complex which might not be
necessary.

-- Tim Cross

Hi Tim

I have been exporting from orgmode to PDF time ago, but very basic PDFs, playing with some basic options of orgmode. When I tried to produce a meeting minute with a logo in the heading, I decided that I should learn better a way of exporting, because the minute meeting was a first challenge, but many more would come. For example, for that task I started with this code, which I think it goes far beyond what the "LaTeX Defaults" can offer (I must yet "play around" a lot with it):

#+BEGIN_SRC

#+options: toc:nil
#+options: num:1
#+options: d:nil
#+export_file_name: BORRAR
#+options: broken-links:mark

#+LaTeX_header_extra: \usepackage{fancyhdr}

#+begin_export LaTeX
\thispagestyle{fancy}
\lhead{\includegraphics[width=4cm]{//192.168.1.2/f/LOGO-IMAGEN CORPORATIVA/IMAGEN CORPORATIVA 2018/DEFINITIVO ANAGRAMAS/SELLO1_grueso.png}}
\rhead{Student Name: John Doe\\
Student ID: 1234\\
Course: IDB 601 (Fall 2020)}
#+end_export
#+END_SRC

The buffer I exported my meeting notes from has much more information which is not related with meetings nor with the logo. So I foresaw 3 things:

  1. A fast cluttering of the buffers with LaTeX headings would happen, as I will learn more about LaTeX and I will want to add more and more packages.
  2. A need for flexibility to be able to export different kinds of documents from the same buffer, ideally achieved just by changing a line (or few lines) in the buffer. Although, from my example, it seems that ~#+begin_export...~ contents can't be added in that way.
  3. A great potential if it were possible to use already existing, and well curated, LaTeX templates frictionless through orgmode.

I find quite useful to analyse the default generated TeX file though.

Best regards


>>>>>>> El 03/04/2021 a las 12:15, Martin Steffen escribió:

Good morning, Martin

For the "preamble" of a latex document, the general setup that comes
_before_ \begin{document} and before any output is generated, I use
native latex using  instructions like

#+BEGIN_SRC
#+latex_header: \input{switches}
#+latex_header: \input{preamble}
#+latex_header: \input{style/style-common}
#+latex_header: \input{macros}
#+END_SRC

Thanks for your input. I'll keep with that.

As far controlling input is concerned, I also rely on latex-specific
setting (outside org, also outside emacs), things like environment
settings like $TEXINPUT, a path-specification, where one can control
where LaTeX finds (additional) stylefiles, outside of the standard
``load-path''.

Thus, I often try to avoid to use hardcoded things, like

>>> \input{~//export//template.tex}

I would use \input{template} (".tex" is not needed) and I make sure, the
templatex.tex file is included in the $TEXINPUTS-path. Typically, the
current directory "./"  should be included by default (and stuff from
the latex-installation is also routinely found)
Thanks. But I can read in this post:

https://tex.stackexchange.com/questions/93712/definition-of-the-texinputs-variable

that ~$TEXINPUT~ could give some problems with LuaLaTeX, could it be? It seems important, since LuaLaTeX is the safe recommendation of our mailing list pal Juan Manuel Macías [maciaschain@...].


>>>>>>> El 03/04/2021 a las 12:43, Dr. Arne Babenhauserheide escribió:

A pleasure, Arne.

Alternatively you can use #+INCLUDE: template.org
to grab more than just the org-setup.
And there you show me a different way: ~#+INCLUDE,~ "competing" with ~\input{}~. What would be the difference?


Have a look at \DeclareUnicodeCharacter:
https://www.draketo.de/light/english/emacs/char-not-setup-latex
Does that mean that some symbols must be declared one by one in order to be exported using LaTeX?


>>>>>>> El 03/04/2021 a las 14:10, Juan Manuel Macías escribió:

Hi, Juan Manuel :-)

The correct way is \input{~/export/template.tex}
I've already tried that. But it doesn't seem to understand the HOME directory ~~/~. At least at Windows.


A *.sty file is what is known in LaTeX jargon as a "package", and it
would come to be the equivalent of what is a *.el file in Emacs,
/mutatis mutandis/. In a sty file you can put whatever you want, but a
different syntax must be used and these files are subject to a series of
good practices. Therefore, a sty file is more indicated to introduce
'heavy' code that you want reuse in other documents (defined commands
and macros, etc.). In short, what comes to be a package ;-) At the user
level, and unless you want to write your own package (see:
https://www.overleaf.com/learn/latex/Writing_your_own_package), it is
almost never necessary.
So I will keep myself far away from .sty by now.

Great care must be taken here. One thing is a LaTeX class, which is
something laborious and complex to write, and another thing what Org
understands for a LaTeX class :-) Classen and the class concept are a
essential component for LaTeX, as a class is the first thing you must
declare in a preamble with the command \documentclass{}. There are the
standard classes (article, book and others) and other ones, more
specialized. A class changes globally the behavior of the document and
all LaTeX commands as \section, \subsection and many more, and add its
own commands.

A 'LaTeX class' for Org is a light translation of the above. It is
actually "what type of LaTeX document you want to get".

You can easily define your own LaTeX 'classes' for Org documents. For
example: I have an 'empty class', to be able to add the entire preamble,
without Org charging me anything before the \begin{document}
(add-to-list 'org-latex-classes
      '("empty"
         "[NO-DEFAULT-PACKAGES]
         [PACKAGES]
         [EXTRA]"
         ("\\section{%s}" . "\\section*{%s}")
         ("\\subsection{%s}" . "\\subsection*{%s}")
         ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
         ("\\paragraph{%s}" . "\\paragraph*{%s}")
         ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

And I have in my ~/.emacs:

(setq org-latex-default-class "empty")
(setq org-latex-default-packages-alist nil)
(setq org-latex-packages-alist nil)
(setq org-latex-hyperref-template nil)
Thanks for your class. I suppose that "nulls" the orgmode LaTeX export defaults, so you can control it completely.


Thank you all