Is there a way to set the UNNUMBERED
property only to the current heading but not to the children headings?
My desired headings are:
1 Part one
1.1 Chapter one
Appendixes (unnumbered)
A Appendix one (numbered)
B Appendix two (numbered)
leaving apart the letters for Appendixes (see "EXTRA" below), I can get this result with:
* Part one
** Chapter one
* Appendixes
:PROPERTIES:
:UNNUMBERED: t
:END:
** Appendix one
:PROPERTIES:
:UNNUMBERED: nil
:END:
** Appendix two
:PROPERTIES:
:UNNUMBERED: nil
:END:
but repeating the UNNUMBERED: nil
for each appendix is boring and not so good for future changes, so I tried to group appendix in a phantom header (with (ox-extras-activate '(ignore-headlines))
):
* Part one
** Chapter one
* Appendixes
:PROPERTIES:
:UNNUMBERED: t
:END:
** core :ignore:
:PROPERTIES:
:UNNUMBERED: nil
:END:
*** Appendix one
*** Appendix two
but with this I get:
1 Part one
1.1 Chapter one
Appendixes
Appendix one
Appendix two
so it does not ignore the heading only, but also its properties.
I am exporting both to LaTeX and HTML/ePub, so a solution involving LaTeX custom export is not possible.
UPDATE
As suggested by @NickD I checkd the variable org-use-property-inheritance
was set to nil. It was, so maybe the UNNUMBERED
property has forced inheritance like other properties.
* Part one
Lorem Ipsum
** Chapter one
Dolor sit amet
* Appendixes
:PROPERTIES:
:UNNUMBERED: t
:END:
Lorem Ipsum
** Appendix one
Dolor sit amet
** Appendix two
Lorem Ipsum
with org-use-property-inheritance
equal to nil
generates
% Created 2021-08-23 lun 09:46
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{minted}
\usepackage{tikz}
\usepackage{bookmark}
\author{Davide Peressoni}
\date{\today}
\title{}
\hypersetup{
pdfauthor={Davide Peressoni},
pdftitle={},
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 27.2 (Org mode 9.5)},
pdflang={English}}
\begin{document}
\tableofcontents
\section{Part one}
\label{sec:orgd36625b}
Lorem Ipsum
\subsection{Chapter one}
\label{sec:orgc5dae8d}
Dolor sit amet
\section*{Appendixes}
\label{sec:orgf878691}
Lorem Ipsum
\subsection*{Appendix one}
\label{sec:org0d45b16}
Dolor sit amet
\subsection*{Appendix two}
\label{sec:org848be4e}
Lorem Ipsum
\end{document}
EXTRA
If someone is interested I'm using this function to achieve the same numbering of LaTeX in HTML (parts in roman, chapters continuous among parts and appendix chapters in alpha):
(defun org-export-get-headline-number (headline info)
"Return numbered HEADLINE numbering as a list of numbers.
INFO is a plist holding contextual information."
(and (org-export-numbered-headline-p headline info)
(let* (
(nums (cdr (assq headline (plist-get info :headline-numbering))))
(root-heading (let ((parent headline)(temp)) (while (and (setq temp (org-element-property :parent parent)) (eq 'headline (org-element-type temp))) (setq parent temp)) parent))
(appendix (member "appendix" (org-element-property :tags root-heading))))
(if (eq 1 (length nums))
;; if it's a part get roman numbers
(list (nth (car nums) '("Z" "I" "II" "III" "IV" "V" "VI" "VII" "VIII" "IX" "X")))
(let ((nums (cdr nums))) ; remove part number
(cons (if appendix
;; appendix chapters in alpha
(byte-to-string (- (+ ?A (car nums)) 1))
(+ (car nums) ; sum chapters of previous parts
(-count 'identity
(org-element-map (org-element-property :parent root-heading) 'headline
(lambda (el)
(and
(eq 2 (org-element-property :level el))
(< (org-element-property :begin el) (org-element-property :begin root-heading))))))))
(cdr nums))
)))))
(defun number-to-string (number)
(format "%s" number))
)
org-use-property-inheritance
in the buffer? Ift
, do you need it to be so? If not, set it tonil
.(eval (if org-use-property-inheritance "t" "nil"))
inside an org-macro returns that it is set tonil
. I tried also to reset it to nil with this code, but, obviously, nothing changed: ``` #+BEGIN_SRC elisp :exports results :results none :eval export (setq org-use-property-inheritance nil) #+END_SRC ```C-h v org-use-property-inheritance
(or whatever other variable you want to see the value of) in the buffer of interest: that will give you the buffer-local value of the variable much more easily. If it is not set, then inheritance should not be active for properties, so you should not have to set the property in each individual appendix (at least that's the theory - practice may be different :-) )org-export-numbered-headline-p
I found it uses(org-export-get-node-property :UNNUMBERED headline t)
and the lastt
tells to force using inheritance. So a "solution" could be to override this function.