jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.35k stars 242 forks source link

Bibliography is not exported if the last included org file ends with ``:noexport:`` tagged section. #1111

Closed pradyparanjpe closed 3 months ago

pradyparanjpe commented 3 months ago

Description

Consider a case where a chapter is included in an article as shown in illustrative files (below). The last heading of chapter1.org is tagged with :noexport:. Bibliography never gets exported for article.org, perhaps because the LaTeX exporter never saw the links, thanks to the inherited :noexport: from * Hidden heading of chapter1.org. This forces me use one of the following workarounds:

Bibliography Style naturemag

The bibliography style naturemag adds the heading References by itself. (There may be other styles that do this as well.) An org heading * References placed before org ref's bibliography links gets exported as another redundant section named References before the one added by naturemag.

**References**  <!-- exported by org -->
  **References**  <!-- added by bibliographystyle -->

Hence, at least when using naturemag style, bibliography links have to be added without their separate org heading.

Illustrative pseudo files

chapter1.org

#+TITLE: An included Chapter

* Introduction
Some text with citations such as this[[cite:&Dominik201408]] cited by org-ref.

* Hidden         :noexport:
These are some interesting thoughts, silenced during one of the draft revisions.
We may want to include them in this chapter later.

# Local variables:
# eval: (wc-mode 1)
# End:

article.org

#+TITLE: Article that includes all chapters

* Chapter 1
#+INCLUDE: "chapter1.org" :lines "3-"

<<bibliographystyle link>>
bibliographystyle:naturemag

<<bibliography link>>
bibliography:org-ref.bib

Not strictly an org-ref issue

This is not strictly an issue.

This hardship has to be dealt with only when

You may close this issue as not worthy if you reckon the fix not useful for sufficiently many.

jkitchin commented 3 months ago

I don't think there is anything to fix in org-ref here. You can't export a bibliography in a section tagged :noexport:. That is a feature of org-mode. In this case, you should not put a bibliography link at the end of such a section. You should instead put the bibliography link above this section, and I think the problem is solved right?

You might alternatively make this section an inline task, e.g.

#+TITLE: An included Chapter

* Introduction
Some text with citations such as this [[cite:&dominik-2010-org-mode]] cited by org-ref.

*************** Hidden                                             :noexport:
These are some interesting thoughts, silenced during one of the draft revisions.
We may want to include them in this chapter later.
*************** END

bibliographystyle:unsrt
[[bibliography:/Users/jkitchin/Dropbox/emacs/bibliography/master.bib]]

# Local variables:
# eval: (wc-mode 1)
# End:

Another alternative is to change the bibliography name like this:

#+TITLE: An included Chapter
#+options: num:0

* Introduction
Some text with citations such as this [[cite:&dominik-2010-org-mode]] cited by org-ref.

* Hidden                                             :noexport:
These are some interesting thoughts, silenced during one of the draft revisions.
We may want to include them in this chapter later.

* References                                                      

\renewcommand{\section}[2]{}
 bibliographystyle:naturemag
[[bibliography:/Users/jkitchin/Dropbox/emacs/bibliography/master.bib]]

# Local variables:
# eval: (wc-mode 1)
# End:
pradyparanjpe commented 3 months ago
I don't think there is anything to fix in org-ref here. You can't export a bibliography in a section tagged :noexport:. That is a feature of org-mode.

Yes. I guessed that while I was writing the issue description.

I still don't want to include bibliography below each chapter. I want it at the end of the article. So I unfortunately can't follow your suggestions to bibliography in the chapter file.

But well, inspired by your suggestions, I found an easy workaround. I simply moved my :noexport: to the head of chapter1. That solves everythin: the hidden section is retained, bibliography appears at the end of article, and I don't need a separate section * References before bibliography link.

So now, my included chapter looks like this. (The final section doesn't carry :noexport: along)

#+TITLE: An included Chapter

* Hidden         :noexport:
These are some interesting thoughts, silenced during one of the draft revisions.
We may want to include them in this chapter later.

* Introduction
Some text with citations such as this[[cite:&Dominik201408]] cited by org-ref.

# Local variables:
# eval: (wc-mode 1)
# End:

Thanks for suggestions. In hind-sight, it was foolish on my part to raise this issue here...

jkitchin commented 3 months ago

No problem, glad you found a solution.