0

This question is related to ox-bibtex.

The snippet

#+BIBLIOGRAPHY: main abbrv

prints out an unnumbered section "Reference" excluded from the TOC in both LaTeX & html export.

Is there a portable & Org mode specific way to include bibliography as a section in the TOC?

  • Not with ox-bibtex AFAIK. – NickD Oct 8 at 23:24
1

There is no way to do this portably in Org mode AFAIK.

This is only for LaTeX - if I figure out the HTML export, I'll edit, but at this point that's unlikely.

ox-bibtex translates bibliography specs like this

#+BIBLIOGRAPHY: path/to/acm-comp-surveys.bib plain

to the following LaTeX code:

\bibliographystyle{plain}
\bibliography{/path/to/acm-comp-surveys.bib}

and when you run bibtex on that, you will produce a .bbl file which looks like this:

\begin{thebibliography}{1}

\bibitem{Finerman:1969:EN}
Aaron Finerman.
\newblock An editorial note.
\newblock {\em ACM Computing Surveys}, 1(1):1--1, March 1969.

\end{thebibliography}

If you look in the article.cls file, you find a definition of thebibliography environment that starts out like this:


 \newenvironment{thebibliography}[1]
     {\section*{\refname}%
     ...

i.e. an unnumbered section with name \refname, which happens to be defined like this:

\newcommand\refname{References}

That explains what you see.

But this means that all of this is under the control of LaTeX and not under the control of Org mode. So your only avenue of modifying things is to change the LateX and the easiest way to do that is to redefine thebibliography environment to do what you want - just copy the original definition into a file mybib.sty with a couple of modifications: first, use \renewenvironment since you are redefining an existing environment, second, use an unstarred section to make it numbered and third, change the title to whatever you want - I hardwire it to Bibliography here - the rest is copied verbatim:

\renewenvironment{thebibliography}[1]
     {\section{Bibliography}%
      \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}

Now add

#+LATEX_HEADER: \usepackage{mybib}

at the top of your Org mode file and export again. That's it.

| improve this answer | |
  • Thanks for the solution, I will find time to report it in the mailing list. – Firmin Martin Oct 8 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.