Hi Ihor,

yes, the patch is just a step towards consistency, but I think is is an important one, because it
makes org-mode not generate illegal/faulty LaTeX code. 

As for the photo-finish, I have been thinking the following that we can use the 'toc' document property.

Values nil and t work as intended in all backends. This means rewriting this part in ox-latex.el.
Additionally, we add a new value 'toc:latex'  to keep the current behaviour in ox-latex (at least, other backends could also implement it).

Coming from the LaTeX world, I lean towards the current ToC handling in ox-latex.el (once fixed). It is closer to what I have been doing for the last couple of decades ;-)

Once we agree on a way forward, I'll start coding.

Best, /PA

On Thu, 2 Jan 2025 at 18:09, Ihor Radchenko <yantar92@posteo.net> wrote:
Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:

>>    (1) At the moment, some export backends do not obey this
>> specification.  For example, LaTeX export excludes every unnumbered
>> headline from the table of contents.
>>
>
> But this happens because of the way LaTeX works...

Sure. But I thought that your patch is working around the LaTeX defaults
by adding \addcontentsline{toc}...

> So, ox-latex is technically not right when it ignores unnumbered
>> headings in TOC.
>>
>
> The basis is there... we might need to rewrite (org-latex-headings) a lot -
> I fear.

Doesn't your patch have everything needed to add unnumbered headings to
TOC? AFAIU, all we need ti simply adding \addcontentsline{toc}... not
just when there is ALT_TITLE attribute, but also when UNNUMBERED is t
(but not "notoc"). It is just that in the latter case we use actual
title in place of ALT_TITLE.

> BTW, since my patch produces correct LaTeX code vs. the current state,
> could you please apply it to avoid the error which triggered all this until
> we get something better.
> The documentation would need to modified slightly to

I can. I just feel that the patch is one step away from being fully
consistent with other export backends. Unless I miss something.

--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


--
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet