From: gerard.vermeulen@posteo.net
To: Ihor Radchenko <yantar92@posteo.net>
Cc: "Juan Manuel Macías" <maciaschain@posteo.net>,
"Pedro Andres Aranda Gutierrez" <paaguti@gmail.com>,
Timothy <orgmode@tec.tecosaur.net>,
"Emacs orgmode" <emacs-orgmode@gnu.org>
Subject: Re: [BUG] ox-latex produces broken references to src code listings without caption (was: [BUG] org-lint tells to move #+name to wrong place in results block)
Date: Fri, 26 Jan 2024 11:04:25 +0000 [thread overview]
Message-ID: <1516db648e4c36ce803c8388b70ea0d3@posteo.net> (raw)
In-Reply-To: <87r0i5lh4r.fsf@localhost>
On 25.01.2024 13:41, Ihor Radchenko wrote:
> gerard.vermeulen@posteo.net writes:
>
>> I have found that CAPTION keywords in the "name-result-example" in
>> the
>> manual are essential to produce correct links.
>
> It should not be essential. What you demonstrated is two bugs in Org
> mode.
>
>> In case the relevant blocks have e.g. ":exports both", Org handles
>> this, but:
>> 1. HTML export requires captions to produce links with unequivocal
>> "link texts" which are numbers in the HTML output.
>
> Fixed, on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ea529007d
I confirm that it is fixed.
>
>> 2. LaTeX export requires captions to produce captions with labels like
>> =\caption{\label{path}desc}=.
>
> `org-latex-link' assumes that it is safe to use
> \ref{<org-latex--label ...>} in order to refer to an existing src
> block.
> However, it is not true.
>
> `org-latex-src-block--engraved', `org-latex-src-block--minted',
> and `org-latex-src-block--listings' only produce a label when src block
> has a caption.
>
> We should generally not need to put a caption in order to refer to a
> source block listing. At least, it does not look like we need it from
> https://tex.stackexchange.com/questions/438260/referencing-without-captions-appearing-but-keeping-numbering
>
> Thoughts? Ideas?
I do not see how to put the LaTeX hypertarget inside listings where it
is
needed, because those listings are not floating.
I looked at `org-latex-src-block--verbatim' that uses the LaTeX
captionof macro, by exporting
--- begin narrow lines below ---
#+caption: caption or comment
#+name: name
#+begin_src emacs-lisp
(+ 1 2)
#+end_src
Link \ref{name}.
--- end narrow lines above
But, I cannot get the captionof macro working after:
exporting the snippet above using `org-latex-src-block--listings'
without caption and adding the captionof macro by hand
(LuaLaTeX does not compile).
>
>> Tested on example below:
>> Produced by listing [[IN]].
>>
>> #+name: OUT
>> #+RESULTS: IN
>> #+begin_src emacs-lisp :exports code
>> 6
>> #+end_src
>>
>> #+header: :wrap "src emacs-lisp :exports code"
>> #+name: IN
>> #+begin_src emacs-lisp :exports both
>> 6
>> #+end_src
>>
>> Listing [[IN]] produces listing [[OUT]].
>>
>> From inspecting HTML or LaTeX output using this example
>> for the difference between with and without captions it is
>> easy to see that only with captions the output is correct.
Regards -- Gerard
prev parent reply other threads:[~2024-01-26 11:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-22 17:47 [BUG] org-lint tells to move #+name to wrong place in results block gerard.vermeulen
2024-01-22 18:15 ` Ihor Radchenko
2024-01-22 18:50 ` gerard.vermeulen
2024-01-22 18:59 ` Ihor Radchenko
2024-01-23 8:34 ` [PATCH] Make an org-lint warning more helpful gerard.vermeulen
2024-01-24 15:49 ` Ihor Radchenko
2024-01-23 13:55 ` [BUG] org-lint tells to move #+name to wrong place in results block gerard.vermeulen
2024-01-25 12:41 ` [BUG] ox-latex produces broken references to src code listings without caption (was: [BUG] org-lint tells to move #+name to wrong place in results block) Ihor Radchenko
2024-01-26 11:04 ` gerard.vermeulen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1516db648e4c36ce803c8388b70ea0d3@posteo.net \
--to=gerard.vermeulen@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=maciaschain@posteo.net \
--cc=orgmode@tec.tecosaur.net \
--cc=paaguti@gmail.com \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).