* ox-latex: help: LATEX_HEADER from different subtrees collision
@ 2024-09-02 22:09 pinmacs
2024-09-03 22:50 ` Rudolf Adamkovič
0 siblings, 1 reply; 5+ messages in thread
From: pinmacs @ 2024-09-02 22:09 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1.1: Type: text/plain, Size: 1663 bytes --]
Hi,
** The context
I found a way to export subtrees to PDF and I liked that idea a lot, I
use it, for example, to generate with an org-capture an invoice, and
export to PDF, etc.
The invoice is part of my journal.
My journal is structured for the whole year (year, week, day). That
file has a lot of lines: 3247 the active 2024, and 179487 the archived
2024; the archived part is out of the org-agenda).
Then I wanted to add a weekly report, which extracts some properties
of some entries, generates some tables, and I wanted to be exported
them to PDF in the same way.
** The problem
I discovered that the LATEX_HEADER of a different subtree produce
collisions, when I discovered this I felt weird, because
~org-latex-export-to-pdf~ docstring says that it respects the
narrowing or the region [1], but I can reproduce how this is not
true. Or let me know what I am doing wrong, if LATEX_HEADER is buffer
scope (which would make sense), then, what is the equivalent in case
you want to specify a LATEX_HEADER in subtree scope
Find attached a file (ox-latex-problem.org) that produce [2] a clash
of latex headers [3], particularly, with geometry (landscape vs
portrait). That if you comment one or the other, it applies to the
whole buffer. Can you modify that file to make it work? Or is it a bug
on ox-latex?
Thanks for your attention,
pinmacs
[1]
If narrowing is active in the current buffer, only export its
narrowed part.
If a region is active, export that region.
[2] ~emacs -Q~ with orgmode 9.7.10 part of emacs-30 branch with commit
44c2614
[3] ! LaTeX Error: Option clash for package geometry.
[-- Attachment #1.1.2: ox-latex-problem.org --]
[-- Type: text/org, Size: 1670 bytes --]
* ox-latex-problem
** [2024-09-02 Mon]
*** report #1 (landscape)
:PROPERTIES:
:EXPORT_LANGUAGE: en
:EXPORT_TITLE:
:EXPORT_SUBTITLE:
:EXPORT_AUTHOR:
:EXPORT_DATE:
:EXPORT_OPTIONS: toc:nil timestamp:nil num:nil
:EXPORT_TOC: headlines 2
:EXPORT_FILE_NAME: /tmp/report2.pdf
:CLICK_TO_SEE_REPORT: file:/tmp/report2.pdf
:END:
#+name: sourceblock_created_2024-09-02_23-36-05
#+begin_src emacs-lisp :exports none :results none
(defun my/export-pdf ()
"renders the PDF"
(org-narrow-to-subtree)
(org-show-subtree)
(org-latex-export-to-pdf nil t t nil)
(widen)
)
(my/export-pdf)
#+end_src
# if you uncomment this, both reports are in landscape
#+LATEX_HEADER: \usepackage[a4paper, landscape, margin=0.5cm]{geometry}
**** My report #2
***** Introduction
Introduction text
***** The report #2
Report #2 text
***** Conclusions
Conclusions text
** [2024-09-01 Sun]
*** report #2 (portrait)
:PROPERTIES:
:EXPORT_LANGUAGE: ca
:EXPORT_TITLE:
:EXPORT_SUBTITLE:
:EXPORT_AUTHOR:
:EXPORT_DATE:
:EXPORT_OPTIONS: toc:nil timestamp:nil num:nil
:EXPORT_TOC: headlines 2
:EXPORT_FILE_NAME: /tmp/report1.pdf
:CLICK_TO_SEE_REPORT: file:/tmp/report1.pdf
:END:
#+name: sourceblock_created_2024-09-02_23-36-07
#+begin_src emacs-lisp :exports none :results none
(defun my/export-pdf ()
"renders the PDF"
(org-narrow-to-subtree)
(org-show-subtree)
(org-latex-export-to-pdf nil t t nil)
(widen)
)
(my/export-pdf)
#+end_src
# if you uncomment this, both reports are in portrait
#+LATEX_HEADER: \usepackage[a4paper, margin=3cm]{geometry}
**** My report #1
***** Introduction
Introduction text
***** The report #1
Report #1 text
***** Conclusions
Conclusions text
[-- Attachment #1.1.3: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3323 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ox-latex: help: LATEX_HEADER from different subtrees collision
2024-09-02 22:09 ox-latex: help: LATEX_HEADER from different subtrees collision pinmacs
@ 2024-09-03 22:50 ` Rudolf Adamkovič
2024-09-04 10:21 ` Pedro
0 siblings, 1 reply; 5+ messages in thread
From: Rudolf Adamkovič @ 2024-09-03 22:50 UTC (permalink / raw)
To: pinmacs, emacs-orgmode
pinmacs@cas.cat writes:
I am unsure I understand the problem, as the reproduction file is not
minimal, and I do not have much time on my hands now. That said, the
file says:
> # if you uncomment this, both reports are in landscape
> #+LATEX_HEADER: \usepackage[a4paper, landscape, margin=0.5cm]{geometry}
That is correct. Export settings apply to the entire file, no matter
where you write them. But, they also have a property form, which is
prefixed with `EXPORT_'. For example:
**** My report #1
:PROPERTIES:
:EXPORT_LATEX_HEADER: \usepackage[a4paper, landscape, margin=0.5cm]{geometry}
:END:
Rudy
--
"Mathematics takes us still further from what is human into the region
of absolute necessity, to which not only the actual world, but every
possible world, must conform." --- Bertrand Russell, 1902
Rudolf Adamkovič <rudolf@adamkovic.org> [he/him]
http://adamkovic.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ox-latex: help: LATEX_HEADER from different subtrees collision
2024-09-03 22:50 ` Rudolf Adamkovič
@ 2024-09-04 10:21 ` Pedro
2024-09-04 13:24 ` pinmacs
2024-09-04 17:28 ` Rudolf Adamkovič
0 siblings, 2 replies; 5+ messages in thread
From: Pedro @ 2024-09-04 10:21 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1.1: Type: text/plain, Size: 864 bytes --]
Hi Rudy,
You nailed it!! Using property EXPORT_LATEX_HEADER exactly solves my
problem, thank you very much. For completeness, I will re-attach the
file with the solution
How did you know that, should that be mentioned in the corresponding
section? (I could not find another one) [1] [2]. Maybe that two links
together should be more linked and more explained the subtree case.
Serve at least this discussion as a pre-documentation
Regarding the attached file: I thought it was minimal enough, 94 lines
that runs on vanilla emacs (emacs-30 branch); but maybe I missed a
little summary: it is two subtree exports handled with a ~#+begin_src
emacs-lisp~, and there was a clash using the LATEX_HEADER
Cheers,
Pedro
[1] https://orgmode.org/manual/LaTeX-header-and-sectioning.html
[2] https://orgmode.org/manual/Export-Settings.html
[-- Attachment #1.1.2: ox-latex-solution.org --]
[-- Type: text/org, Size: 1822 bytes --]
* ox-latex-problem
** [2024-09-02 Mon]
*** report #1 (landscape)
:PROPERTIES:
:EXPORT_LANGUAGE: en
:EXPORT_TITLE:
:EXPORT_SUBTITLE:
:EXPORT_AUTHOR:
:EXPORT_DATE:
:EXPORT_OPTIONS: toc:nil timestamp:nil num:nil
:EXPORT_TOC: headlines 2
:EXPORT_FILE_NAME: /tmp/report2.pdf
:EXPORT_LATEX_HEADER: \usepackage[a4paper, landscape, margin=0.5cm]{geometry}
:CLICK_TO_SEE_REPORT: file:/tmp/report2.pdf
:END:
#+name: sourceblock_created_2024-09-02_23-36-05
#+begin_src emacs-lisp :exports none :results none
(defun my/export-pdf ()
"renders the PDF"
(org-narrow-to-subtree)
(org-show-subtree)
(org-latex-export-to-pdf nil t t nil)
(widen)
)
(my/export-pdf)
#+end_src
# do not use this LATEX_HEADER because is buffer scoped!
# #+LATEX_HEADER: \usepackage[a4paper, landscape, margin=0.5cm]{geometry}
**** My report #2
***** Introduction
Introduction text
***** The report #2
Report #2 text
***** Conclusions
Conclusions text
** [2024-09-01 Sun]
*** report #2 (portrait)
:PROPERTIES:
:EXPORT_LANGUAGE: ca
:EXPORT_TITLE:
:EXPORT_SUBTITLE:
:EXPORT_AUTHOR:
:EXPORT_DATE:
:EXPORT_OPTIONS: toc:nil timestamp:nil num:nil
:EXPORT_TOC: headlines 2
:EXPORT_FILE_NAME: /tmp/report1.pdf
:CLICK_TO_SEE_REPORT: file:/tmp/report1.pdf
:EXPORT_LATEX_HEADER: \usepackage[a4paper, margin=3cm]{geometry}
:END:
#+name: sourceblock_created_2024-09-02_23-36-07
#+begin_src emacs-lisp :exports none :results none
(defun my/export-pdf ()
"renders the PDF"
(org-narrow-to-subtree)
(org-show-subtree)
(org-latex-export-to-pdf nil t t nil)
(widen)
)
(my/export-pdf)
#+end_src
# do not use this LATEX_HEADER because is buffer scoped!
# #+LATEX_HEADER: \usepackage[a4paper, margin=3cm]{geometry}
**** My report #1
***** Introduction
Introduction text
***** The report #1
Report #1 text
***** Conclusions
Conclusions text
[-- Attachment #1.1.3: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3323 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ox-latex: help: LATEX_HEADER from different subtrees collision
2024-09-04 10:21 ` Pedro
@ 2024-09-04 13:24 ` pinmacs
2024-09-04 17:28 ` Rudolf Adamkovič
1 sibling, 0 replies; 5+ messages in thread
From: pinmacs @ 2024-09-04 13:24 UTC (permalink / raw)
To: emacs-orgmode
Hey!
And this is trivial, but it took me a while to figure it out
Of course, if you want to use more than one EXPORT_LATEX_HEADER for that
subtree export, you need to use multi-value property [0]:
:PROPERTIES:
:EXPORT_LATEX_HEADER: \usepackage{bookmark}
:EXPORT_LATEX_HEADER+: \usepackage{nopageno}
:EXPORT_LATEX_HEADER+: \usepackage{siunitx}
:EXPORT_LATEX_HEADER+: \usepackage{colortbl}
:EXPORT_LATEX_HEADER+: \usepackage{xcolor}
:EXPORT_LATEX_HEADER+: \usepackage[a4paper, margin=3cm]{geometry}
:EXPORT_LATEX_HEADER+: \usepackage[none]{hyphenat}
:END:
Debugging [1] I also found that once there is one property
EXPORT_LATEX_HEADER, subsequent `#+LATEX_HEADER` are ignored, that's smart!
Cheers,
pinmacs
[0]
If you want to add to the value of an existing property, append a ‘+’
to the property name. The following results in the property ‘var’ having
the value ‘foo=1 bar=2’.
#+PROPERTY: var foo=1
#+PROPERTY: var+ bar=2
src https://orgmode.org/manual/Property-Syntax.html
[1] near the .pdf you have the .tex to debug, and you can export again
outside emacs with ~pdflatex~
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ox-latex: help: LATEX_HEADER from different subtrees collision
2024-09-04 10:21 ` Pedro
2024-09-04 13:24 ` pinmacs
@ 2024-09-04 17:28 ` Rudolf Adamkovič
1 sibling, 0 replies; 5+ messages in thread
From: Rudolf Adamkovič @ 2024-09-04 17:28 UTC (permalink / raw)
To: Pedro, emacs-orgmode
Pedro <pinmacs@cas.cat> writes:
> How did you know that, should that be mentioned in the corresponding
> section? (I could not find another one) [1] [2].
It is written at the bottom of [2]:
When exporting subtrees, special node properties can override the
above keywords. These properties have an ‘EXPORT_’ prefix. For
example, ‘DATE’ becomes, ‘EXPORT_DATE’ when used for a specific
subtree. Except for ‘SETUPFILE’, all other keywords listed above have
an ‘EXPORT_’ equivalent.
Rudy
--
"I love deadlines. I love the whooshing noise they make as they go by."
--- Douglas Adams, The Salmon of Doubt, 2002
Rudolf Adamkovič <rudolf@adamkovic.org> [he/him]
http://adamkovic.org
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-04 17:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-02 22:09 ox-latex: help: LATEX_HEADER from different subtrees collision pinmacs
2024-09-03 22:50 ` Rudolf Adamkovič
2024-09-04 10:21 ` Pedro
2024-09-04 13:24 ` pinmacs
2024-09-04 17:28 ` Rudolf Adamkovič
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.