emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: gerard.vermeulen@posteo.net
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Emacs orgmode <emacs-orgmode@gnu.org>
Subject: Re: [BUG]: contradictory requirements between resolving links and noweb result block
Date: Sun, 04 Feb 2024 11:02:14 +0000	[thread overview]
Message-ID: <6d9db4be5d42236391d5c4e530250ee1@posteo.net> (raw)
In-Reply-To: <87ttmqsjzq.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 2135 bytes --]



On 02.02.2024 21:12, Ihor Radchenko wrote:
> gerard.vermeulen@posteo.net writes:
> 
>> I want to have a kind of dynamic RESULTS: noweb block to select what
>> other block to put in the LaTeX  preamble on LaTeX export.
>> I can get it working, but in this case links to the RESULTS: noweb 
>> block
>> are not resolved.  I found no way to get the links resolved without
>> breaking Noweb.  See my MWE with instructions below:
> 
> May you please provide more detailed information about your MWE?
> What exactly are the steps? What did you expect to happen? What
> happened instead?

I have turned my MWE into two almost identical MWE's (attached,
including a diff), so that LaTeX export output shows the problem.
I start with my expectations and then I explain what contains the
LaTeX output for mwe-noweb-ok.org and mwe-links-ok.org.

* LaTeX export objectives

Noweb should work, meaning that the LaTeX output preamble should
contain (above \author) the line:
#+begin_src latex
% Should go to the LaTeX preamble above \author{}.
#+end_src

Resolving links should work, meaning that the LaTeX output should
contain (below \tableofcontents) the line
#+begin_src latex
Listing \ref{noop}, \ref{make-noweb}, and \ref{make-noweb-result}.
#+end_src
where all links have user labels.

* mwe-noweb-ok

Export of mwe-noweb-ok.org to LaTeX shows that noweb works
Noweb works, because the preamble contains:
#+begin_src latex
% Should go to the LaTeX preamble above \author{}.
#+end_src

Resolving the last link fails, because it has an org-id
#+begin_src latex
Listing \ref{noop}, \ref{make-noweb}, and \ref{orgd105392}.
#+end_src
while the caption of the linked listing has a user label.

* mwe-links-ok

Noweb fails, because the LaTeX output preamble does contain
#+begin_src latex
\usepackage{hyperref}
\author{Gerard Vermeulen}
#+end_src
without the LaTeX comment.

Resolving links works, because the LaTeX output contains
#+begin_src latex
Listing \ref{noop}, \ref{make-noweb}, and \ref{make-noweb-result}.
#+end_src

* Problem

I can find no configuration where noweb and resolving the link
to the noweb block works.

Regards -- Gerard

[-- Attachment #2: mwe-noweb-ok.org --]
[-- Type: application/octet-stream, Size: 1068 bytes --]

# -*- org-latex-prefer-user-labels: t; org-latex-src-block-backend: listings -*-
Listing [[noop]], [[make-noweb]], and [[make-noweb-result]].

BUG: contradictory requirements for listing [[make-noweb-result]]:
1. Noweb works only in case [[make-noweb]] wraps [[make-noweb-result]] with
   *:exports both*.
2. Resolving links works only in case [[make-noweb]] wraps
   [[make-noweb-result]] with *:exports code*.

#+caption: NOOP
#+name: noop
#+begin_src latex :exports code
% Should go to the LaTeX preamble above \author{}.
#+end_src

#+caption: Change after 1st :exports "both" to "code" and vice versa.
#+caption: Execute this block after changing, but before LaTeX export.
#+header: :wrap "src latex -n :exports both :noweb yes :results raw"
#+name: make-noweb
#+begin_src emacs-lisp :exports both :eval no-export
"#+latex_header: <<noop>>"
#+end_src

#+caption: I try to put listing [[noop]] body in the LaTeX preamble.
#+name: make-noweb-result
#+RESULTS: make-noweb
#+begin_src latex -n :exports both :noweb yes :results raw
,#+latex_header: <<noop>>
#+end_src

[-- Attachment #3: mwe-links-ok.org --]
[-- Type: application/octet-stream, Size: 1068 bytes --]

# -*- org-latex-prefer-user-labels: t; org-latex-src-block-backend: listings -*-
Listing [[noop]], [[make-noweb]], and [[make-noweb-result]].

BUG: contradictory requirements for listing [[make-noweb-result]]:
1. Noweb works only in case [[make-noweb]] wraps [[make-noweb-result]] with
   *:exports both*.
2. Resolving links works only in case [[make-noweb]] wraps
   [[make-noweb-result]] with *:exports code*.

#+caption: NOOP
#+name: noop
#+begin_src latex :exports code
% Should go to the LaTeX preamble above \author{}.
#+end_src

#+caption: Change after 1st :exports "both" to "code" and vice versa.
#+caption: Execute this block after changing, but before LaTeX export.
#+header: :wrap "src latex -n :exports code :noweb yes :results raw"
#+name: make-noweb
#+begin_src emacs-lisp :exports both :eval no-export
"#+latex_header: <<noop>>"
#+end_src

#+caption: I try to put listing [[noop]] body in the LaTeX preamble.
#+name: make-noweb-result
#+RESULTS: make-noweb
#+begin_src latex -n :exports code :noweb yes :results raw
,#+latex_header: <<noop>>
#+end_src

[-- Attachment #4: mwe.diff --]
[-- Type: application/octet-stream, Size: 815 bytes --]

--- mwe-noweb-ok.org	2024-02-04 10:37:47.910099748 +0100
+++ mwe-links-ok.org	2024-02-04 10:44:45.280318649 +0100
@@ -15,7 +15,7 @@
 
 #+caption: Change after 1st :exports "both" to "code" and vice versa.
 #+caption: Execute this block after changing, but before LaTeX export.
-#+header: :wrap "src latex -n :exports both :noweb yes :results raw"
+#+header: :wrap "src latex -n :exports code :noweb yes :results raw"
 #+name: make-noweb
 #+begin_src emacs-lisp :exports both :eval no-export
 "#+latex_header: <<noop>>"
@@ -24,6 +24,6 @@
 #+caption: I try to put listing [[noop]] body in the LaTeX preamble.
 #+name: make-noweb-result
 #+RESULTS: make-noweb
-#+begin_src latex -n :exports both :noweb yes :results raw
+#+begin_src latex -n :exports code :noweb yes :results raw
 ,#+latex_header: <<noop>>
 #+end_src

  reply	other threads:[~2024-02-04 11:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 17:43 [BUG]: contradictory requirements between resolving links and noweb result block gerard.vermeulen
2024-02-02 20:12 ` Ihor Radchenko
2024-02-04 11:02   ` gerard.vermeulen [this message]
2024-02-05 12:32     ` Ihor Radchenko

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=6d9db4be5d42236391d5c4e530250ee1@posteo.net \
    --to=gerard.vermeulen@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --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).