emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG]: contradictory requirements between resolving links and noweb result block
@ 2024-02-02 17:43 gerard.vermeulen
  2024-02-02 20:12 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: gerard.vermeulen @ 2024-02-02 17:43 UTC (permalink / raw)
  To: Emacs orgmode, Ihor Radchenko

Hi,

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:

--- begin Org file ---
# -*- org-latex-prefer-user-labels: t -*- for easier understanding
Listing [[noop]], [[make-noweb]], and [[make-noweb-result]].
#+caption: NOOP
#+name: noop
#+begin_src latex :exports code
% I want to be in the LaTeX preamble above \author{}.
#+end_src
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: 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
--- end Org file ---

I realize that this way of doing is contrived.
What I like about it, is that the [[make-noweb-results]] is directly
visible.  I can probably also modify `org-latex-packages-alist' but
that is less visible.

Regards -- Gerard




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG]: contradictory requirements between resolving links and noweb result block
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-02-02 20:12 UTC (permalink / raw)
  To: gerard.vermeulen; +Cc: Emacs orgmode

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?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG]: contradictory requirements between resolving links and noweb result block
  2024-02-02 20:12 ` Ihor Radchenko
@ 2024-02-04 11:02   ` gerard.vermeulen
  2024-02-05 12:32     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: gerard.vermeulen @ 2024-02-04 11:02 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Emacs orgmode

[-- 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG]: contradictory requirements between resolving links and noweb result block
  2024-02-04 11:02   ` gerard.vermeulen
@ 2024-02-05 12:32     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-02-05 12:32 UTC (permalink / raw)
  To: gerard.vermeulen; +Cc: Emacs orgmode

gerard.vermeulen@posteo.net writes:

> * mwe-noweb-ok
>
> ...
> 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.

Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=f4414f5db

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-05 12:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-02-05 12:32     ` Ihor Radchenko

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).