racket/scribble

autobib citation breaks separate compilation of sections

Closed this issue · 2 comments

Normally when writing in Scribble, I have each section in a separate file, included into the main paper with @include-section. This is handy for organization and allows me to separately build just the section I'm working on.

However, this doesn't work if the section uses autobib, because the autobib style files are included only when generate-bibliography is called, and without those style files, Autobibref etc are undefined. This can't really be called in every section.

Consider the 3-file example below. When scribble --pdf paper.scrbl is built, everything is fine, but scribble --pdf section.srcbl fails. If the citation is removed, scribble --pdf section.scrbl builds correctly.

There's a simple fix, but I'm not sure what the implications are. We simply change

(make-style "Autobibref" '())
to include autobib-style-extras in the style properties. I've done this locally, and separate compilation is restored. I'm happy to submit a patch if there are no side-effect that I'm missing.

(I'm wary because I've had trouble with using the same properties list in multiple places before, so there's some semantics I don't understand. It seems style files are loaded once per object identity. If so, as long as the same (point equality) style property is used multiple times, then the style file will not be loaded multiple times, but "the same" (structural equality) style property used multiple times will load the style file multiple times, causing issues.)

defs.rkt

#lang racket/base

(require
  scriblib/autobib)

(provide (all-defined-out))

(define-cite ~cite citet generate-bibliography)

(define plt-tr1
   (make-bib
    #:title    "Reference: Racket"
    #:author   (authors "Matthew Flatt" "PLT")
    #:date     "2010"
    #:location (techrpt-location #:institution "PLT Inc."
                                 #:number "PLT-TR-2010-1")
    #:url      "http://racket-lang.org/tr1/"))

paper.scrbl

#lang scribble/base

@(require "defs.rkt")

@include-section{section.scrbl}

@(generate-bibliography)

section.scrbl

#lang scribble/base

@(require "defs.rkt")
@title{Section}

@~cite[plt-tr1] is cool stuff.

This sounds right to me.

I'm not sure myself how multiple additions are merged, but it looks like it's based on equal? for the path or bytes in an addition. I'll have to investigate more to document that properly, but it seems clear that autobib-style-extras is supposed to work any number of times (except zero, which is the problem here).