* Ignore, skip, omit headline when exporting to LaTeX
@ 2022-07-07 20:00 edgar
2022-07-08 5:04 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: edgar @ 2022-07-07 20:00 UTC (permalink / raw)
To: Org Mode List
Firstly, do tell me if I am breaking the nettiquete.
I found someone asking online how to ignore a headline when exporting
to LaTeX. This e-mail is to avoid creating an account on that forum
and to provide a solution.
(require 'ox-extra)
(defun org-export-ignore-headlines-latex (data backend info)
"Hack of `org-export-ignore-headlines' for LaTeX: add a
conditional for the latex backend and replace 'ignore' with 'ignoreltx'"
(when (org-export-derived-backend-p backend 'latex)
(org-element-map data 'headline
(lambda (object)
(when (member "ignoreltx" (org-element-property :tags object))
(let ((level-top (org-element-property :level object))
level-diff)
(mapc (lambda (el)
;; recursively promote all nested headlines
(org-element-map el 'headline
(lambda (el)
(when (equal 'headline (org-element-type el))
(unless level-diff
(setq level-diff (-
(org-element-property :level el)
level-top)))
(org-element-put-property
el
:level (- (org-element-property :level el)
level-diff)))))
;; insert back into parse tree
(org-element-insert-before el object))
(org-element-contents object)))
(org-element-extract-element object)))
info nil)
data))
(push '(ignore-latex-headlines
org-export-ignore-headlines-latex
org-export-filter-parse-tree-functions)
ox-extras)
(ox-extras-activate '(latex-header-blocks ignore-headlines
ignore-latex-headlines))
-------------------------------------------------
This free account was provided by VFEmail.net - report spam to abuse@vfemail.net
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ignore, skip, omit headline when exporting to LaTeX
2022-07-07 20:00 Ignore, skip, omit headline when exporting to LaTeX edgar
@ 2022-07-08 5:04 ` Ihor Radchenko
2022-07-08 8:51 ` edgar
2022-07-14 15:29 ` Max Nikulin
0 siblings, 2 replies; 4+ messages in thread
From: Ihor Radchenko @ 2022-07-08 5:04 UTC (permalink / raw)
To: edgar; +Cc: Org Mode List
edgar@openmail.cc writes:
> Firstly, do tell me if I am breaking the nettiquete.
This is on topic and can be useful for others without knowing the
context of the mentioned discussion. So, there should be no issue with
posting this here, especially if you provide sufficient context.
> I found someone asking online how to ignore a headline when exporting
> to LaTeX. This e-mail is to avoid creating an account on that forum
> and to provide a solution.
>
> (require 'ox-extra)
>
> (defun org-export-ignore-headlines-latex (data backend info)
> "Hack of `org-export-ignore-headlines' for LaTeX: add a
> conditional for the latex backend and replace 'ignore' with 'ignoreltx'"
> (when (org-export-derived-backend-p backend 'latex)
> (org-element-map data 'headline
> (lambda (object)
> (when (member "ignoreltx" (org-element-property :tags object))
> ...
> (org-element-extract-element object)))
> info nil)
> data))
Note that this modified version of the function is derived from
org-export-ignore-headlines from ox-extra.el [1]
However, a part of the original function code is omitted.
AFAIU, this version also discards the headline contents, in addition to
the headline itself (unlike what org-export-ignore-headlines does).
Note that discarding headline + contents is also supported using
:NOEXPORT: tag.
[1] https://git.sr.ht/~bzg/org-contrib
Best,
Ihor
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ignore, skip, omit headline when exporting to LaTeX
2022-07-08 5:04 ` Ihor Radchenko
@ 2022-07-08 8:51 ` edgar
2022-07-14 15:29 ` Max Nikulin
1 sibling, 0 replies; 4+ messages in thread
From: edgar @ 2022-07-08 8:51 UTC (permalink / raw)
To: Org Mode List
On 2022-07-08 05:04, Ihor Radchenko wrote:
> edgar@openmail.cc writes:
>
> <snip>
> This is on topic and can be useful for others <snip> So, there should
> be no issue with
> posting this here <snip>
Thanks!
> Note that this modified version of the function is derived from
> org-export-ignore-headlines from ox-extra.el [1]
Thank you for the link.
> However, a part of the original function code is omitted.
> AFAIU, this version also discards the headline contents, in addition to
> the headline itself (unlike what org-export-ignore-headlines does).
Sorry, I just had the version from 2014! :P As mentioned in the comment
of the new function, I just added a conditional and replaced "ignore"
with "ignoreltx". As a suggestion, it could be possible to replace
"ignore" with a variable and use another variable such that the headline
is omitted when other export types (latex, html, etc.) are used.
In any case: Thanks for almost 20 years!
<snip>
> [1] https://git.sr.ht/~bzg/org-contrib
>
> Best,
> Ihor
To you too!
-------------------------------------------------
This free account was provided by VFEmail.net - report spam to abuse@vfemail.net
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ignore, skip, omit headline when exporting to LaTeX
2022-07-08 5:04 ` Ihor Radchenko
2022-07-08 8:51 ` edgar
@ 2022-07-14 15:29 ` Max Nikulin
1 sibling, 0 replies; 4+ messages in thread
From: Max Nikulin @ 2022-07-14 15:29 UTC (permalink / raw)
To: emacs-orgmode
On 08/07/2022 12:04, Ihor Radchenko wrote:
> edgar@openmail.cc writes:
>
>> (defun org-export-ignore-headlines-latex (data backend info)
>> "Hack of `org-export-ignore-headlines' for LaTeX: add a
>> conditional for the latex backend and replace 'ignore' with 'ignoreltx'"
>> (when (org-export-derived-backend-p backend 'latex)
>> (org-element-map data 'headline
>> (lambda (object)
>> (when (member "ignoreltx" (org-element-property :tags object))
>> ...
>> (org-element-extract-element object)))
>> info nil)
>> data))
>
> Note that this modified version of the function is derived from
> org-export-ignore-headlines from ox-extra.el [1]
> ...
> [1] https://git.sr.ht/~bzg/org-contrib
It looks like almost verbatim copy of
https://orgmode.org/worg/org-faq.html#org11adb66 FAQ: 18.1. How do I
ignore a headline?
added in 2014 (eb56c1ab34)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-14 15:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-07 20:00 Ignore, skip, omit headline when exporting to LaTeX edgar
2022-07-08 5:04 ` Ihor Radchenko
2022-07-08 8:51 ` edgar
2022-07-14 15:29 ` Max Nikulin
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).