emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* #+latex_header blocks, or, managing lots of LaTeX headers
@ 2022-04-12  0:46 William Denton
  2022-04-12  2:51 ` Vikas Rawal
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: William Denton @ 2022-04-12  0:46 UTC (permalink / raw)
  To: emacs-orgmode

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

I have another question related to managing a book I'm doing building for export 
to LaTeX:  what do people do for managing all of the headers?

I have about 30 #+latex_header lines in the project I'm working on, and I'm 
still just working on it as a basic article.  When I'm ready to do more 
formatting I'll use the memoir class and then there will be more commands.  I 
imagine some of you have huge headers with custom commands and more.

It would be great if there was a way to manage these lines as LaTeX, for example 
in a "#+begin_export latex" block, but as far as I can tell, there isn't a way 
(unless once again I overlooked something).

The idea came up about seven years ago, and Nicolas mentioned the possibility of 
a "#+begin_export latex :header t" implementation.

https://lists.gnu.org/archive/html/emacs-orgmode/2015-05/msg00538.html

It's possible to add a new class to the org-latex-classes variable, and in the 
documentation on it I see there are options ([NO-DEFAULT-PACKAGES], 
[NO-PACKAGES], [NO-EXTRA]) that allow one to trim away all the default headers. 
That makes it easy to take away, but not to add in lines I want, short of 
managing them in my init file.

What sorts of practices do people have for managing lots of LaTeX headers? 
Juan Manuel Macías, you mentioned something like this---literate programming in 
Org to export LaTeX source---may I ask how you do it?

Thanks,

Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada

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

* Re: #+latex_header blocks, or, managing lots of LaTeX headers
  2022-04-12  0:46 #+latex_header blocks, or, managing lots of LaTeX headers William Denton
@ 2022-04-12  2:51 ` Vikas Rawal
  2022-04-12 14:34   ` Kaushal Modi
  2022-04-12  6:16 ` Tim Cross
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Vikas Rawal @ 2022-04-12  2:51 UTC (permalink / raw)
  To: William Denton; +Cc: org-mode mailing list

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

For a major project like this, I would just put these in a separate file,
and include it using #+INCLUDE:

Vikas


On Tue, 12 Apr 2022 at 06:37, William Denton <wtd@pobox.com> wrote:

> I have another question related to managing a book I'm doing building for
> export
> to LaTeX:  what do people do for managing all of the headers?
>
> I have about 30 #+latex_header lines in the project I'm working on, and
> I'm
> still just working on it as a basic article.  When I'm ready to do more
> formatting I'll use the memoir class and then there will be more
> commands.  I
> imagine some of you have huge headers with custom commands and more.
>
> It would be great if there was a way to manage these lines as LaTeX, for
> example
> in a "#+begin_export latex" block, but as far as I can tell, there isn't a
> way
> (unless once again I overlooked something).
>
> The idea came up about seven years ago, and Nicolas mentioned the
> possibility of
> a "#+begin_export latex :header t" implementation.
>
> https://lists.gnu.org/archive/html/emacs-orgmode/2015-05/msg00538.html
>
> It's possible to add a new class to the org-latex-classes variable, and in
> the
> documentation on it I see there are options ([NO-DEFAULT-PACKAGES],
> [NO-PACKAGES], [NO-EXTRA]) that allow one to trim away all the default
> headers.
> That makes it easy to take away, but not to add in lines I want, short of
> managing them in my init file.
>
> What sorts of practices do people have for managing lots of LaTeX headers?
> Juan Manuel Macías, you mentioned something like this---literate
> programming in
> Org to export LaTeX source---may I ask how you do it?
>
> Thanks,
>
> Bill
>
> --
> William Denton
> https://www.miskatonic.org/
> Librarian, artist and licensed private investigator.
> Toronto, Canada

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

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

* Re: #+latex_header blocks, or, managing lots of LaTeX headers
  2022-04-12  0:46 #+latex_header blocks, or, managing lots of LaTeX headers William Denton
  2022-04-12  2:51 ` Vikas Rawal
@ 2022-04-12  6:16 ` Tim Cross
  2022-04-12  8:02 ` Timothy
  2022-04-12  8:55 ` Juan Manuel Macías
  3 siblings, 0 replies; 6+ messages in thread
From: Tim Cross @ 2022-04-12  6:16 UTC (permalink / raw)
  To: William Denton; +Cc: emacs-orgmode


William Denton <wtd@pobox.com> writes:

> I have another question related to managing a book I'm doing building for export to LaTeX:
> what do people do for managing all of the headers?
>

I only use the #+latex_headers or #+latext-headers-extra lines for 'one
off' type documents. If I'm going to be writing lots of documents where
those packages are needed, I define a new org-latex-classes entry.

> It's possible to add a new class to the org-latex-classes variable, and in the documentation on
> it I see there are options ([NO-DEFAULT-PACKAGES], [NO-PACKAGES], [NO-EXTRA]) that allow one to
> trim away all the default headers. That makes it easy to take away, but not to add in lines I
> want, short of managing them in my init file.

The org-latex-classes 'placeholder' macros allow you to add or remove
the headers defined in either the default-packages or packages alist or
headers added via latex_headers/latex_headers_extra. However, the point
to note is that this 'value' is just a string, so you can just put in
exactly what you want - you don't have to use the placeholder macros
(though I almost always do - at least the [default-packages] macro, but
usually the [packages] one as well). The value isn't just restricted to
\usepackage lines either - you can put anything there which makes sense
in the latgex header.

>
> What sorts of practices do people have for managing lots of LaTeX headers? Juan Manuel Macías,
> you mentioned something like this---literate programming in Org to export LaTeX source---may I
> ask how you do it?
>

If I find myself using lots of #+latex_headers lines, this tells me
either

1. I need to update/add to the packages alist variable. This is
especially likely if I'm adding the same headers to every document. Just
add it to the packages alist. I tend to leave the default-packages alist
alone.

2. There is a specific 'style' of document I write often and all
documents of this style have the same additional headers. For this, I
create a new entry in org-latex-classes.

I think adding headers via #+latex_headers and #+latext_headers_extra
should be avoided as much as possible. It is a great escape hatch or for
doing 'on-offs', but not the right approach for doing something like
writing a book.

Consider the situation where you have been adding headers to load
language support or a particular code listing package or whatever. You
writing a book and it will have many org files (perhaps one per
chapter). You add these #+latex_header lines to add the packages. Later,
you find the listing package isn't suitable or you need to modify the
language encoding - now you have to edit every org file which makes up
the book.

Alternatively, you define a new org-latex-classes entry call 'my-book'
and use that to add the language encoding and code listing packages
(along with some other 'tweaks' you typically put in the header, maybe
even add a few custom commands etc). Now when you find it necessary to
change the language encoding, code listing package or whatever, you just
have that one definition to change and only need to edit one file.


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

* Re: #+latex_header blocks, or, managing lots of LaTeX headers
  2022-04-12  0:46 #+latex_header blocks, or, managing lots of LaTeX headers William Denton
  2022-04-12  2:51 ` Vikas Rawal
  2022-04-12  6:16 ` Tim Cross
@ 2022-04-12  8:02 ` Timothy
  2022-04-12  8:55 ` Juan Manuel Macías
  3 siblings, 0 replies; 6+ messages in thread
From: Timothy @ 2022-04-12  8:02 UTC (permalink / raw)
  To: William Denton; +Cc: emacs-orgmode

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

Hi William,

> I have another question related to managing a book I’m doing building for export
> to LaTeX:  what do people do for managing all of the headers?

Generally, I don’t like thinking about what LaTeX headers I need. That’s why I
developed <https://tecosaur.github.io/emacs-config/config.html#cleverer-preamble>.

In the one case I’ve had where I /did/ need to write a lot of LaTeX, I did it like
so:

┌────
│ #+latex_header: \include{extras.tex}
│ 
│ #+begin_src LaTeX :tangle extras.tex
│ % latex here
│ #+end_src
└────

Hope that helps,
Timothy

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

* Re: #+latex_header blocks, or, managing lots of LaTeX headers
  2022-04-12  0:46 #+latex_header blocks, or, managing lots of LaTeX headers William Denton
                   ` (2 preceding siblings ...)
  2022-04-12  8:02 ` Timothy
@ 2022-04-12  8:55 ` Juan Manuel Macías
  3 siblings, 0 replies; 6+ messages in thread
From: Juan Manuel Macías @ 2022-04-12  8:55 UTC (permalink / raw)
  To: William Denton; +Cc: orgmode

Hi William,

William Denton writes:

> What sorts of practices do people have for managing lots of LaTeX
> headers? Juan Manuel Macías, you mentioned something like
> this---literate programming in Org to export LaTeX source---may I ask
> how you do it?

When it comes to a large project, for example the typesetting of a book,
I usually generate all the configuration for LaTeX in a *.tex document or
a *.sty document from Org, using literate programming[1]. I include there all
the LaTeX packages I use, their configuration, my own LaTeX or Lua code
(because I use LuaTeX to compile), etc. Here is a screenshot of a  part of
the configuration I wrote for the Hispanic Dictionary of the Classical
Tradition:

https://i.imgur.com/fwonZtT.png

I also have an 'empty' class added to the org-latex-classes list, and then
load my LaTeX configuration via \input. When it comes to large books I
also use org-publish, which makes it easier for me to work with complex
projects and multi-part/chapter books.

Another possibility, to avoid adding many lines with 'LaTeX_Header:', is
to use blocks and the noweb keyword. For example: you can create a
non-exportable node in your document, and put all the necessary
configuration there. You include all the LaTeX preamble in a block:

* Configuration           :noexport:

#+NAME: preamble
#+begin_src latex :exports none
a lot of LaTeX code
#+end_src

And in another block you add this:

#+begin_src latex :noweb yes :results raw
,#+LaTeX_HEADER: <<preamble>>
#+end_src

(in this thread you can find an org document attached with this procedure:
https://list.orgmode.org/87sfwvlp56.fsf@posteo.net/)
----------------------------

[1] In fact, Org is much more powerful and simpler for doing these
things than the docstript suite itself that is 'officially' used in the
(La)TeX ecosystem to generate packages code and documentation:
https://ctan.org/pkg/docstrip?lang=en

Best regards,

Juan Manuel 


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

* Re: #+latex_header blocks, or, managing lots of LaTeX headers
  2022-04-12  2:51 ` Vikas Rawal
@ 2022-04-12 14:34   ` Kaushal Modi
  0 siblings, 0 replies; 6+ messages in thread
From: Kaushal Modi @ 2022-04-12 14:34 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: William Denton, org-mode mailing list

On Mon, Apr 11, 2022 at 10:53 PM Vikas Rawal <vikasrawal@gmail.com> wrote:
>
> For a major project like this, I would just put these in a separate file, and include it using #+INCLUDE:

Org has a special keyword for the purpose of including *just the setup
stuff*: #+setupfile

See (org) Export Settings.

#+include is useful when you want to include setup stuff mixed with Org content.

#+setupfile will include only the setup stuff. I think that would mean
only the Org keywords (lines beginning with #+) will be imported.
Additionally, #+setupfile keyword can accept either a file path or a
web URL.

So I have this at the top of many of my Org files:

#+setupfile: https://cdn.rawgit.com/kaushalmodi/.emacs.d/master/misc/org-setupfile.org

That file has my common setup stuff like LaTeX headers, Org macros, etc.


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

end of thread, other threads:[~2022-04-12 14:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12  0:46 #+latex_header blocks, or, managing lots of LaTeX headers William Denton
2022-04-12  2:51 ` Vikas Rawal
2022-04-12 14:34   ` Kaushal Modi
2022-04-12  6:16 ` Tim Cross
2022-04-12  8:02 ` Timothy
2022-04-12  8:55 ` Juan Manuel Macías

Code repositories for project(s) associated with this 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).