Scribble and plot/pict doesn't know about pi?

I'm experimenting with Scribble and wanted to see about including function plots.

Something like this:

#lang scribble/base
@(require scribble/manual)
@(require plot/pict)

@title{Plots in Scribble}

The sine function:

@(plot (function sin (- pi) pi #:label "y = sin(x)"))

gives me:

scribble-plot-test.scrbl:9:24: pi: unbound identifier
  in: pi
  location...:
   scribble-plot-test.scrbl:9:24
  context...:
   /usr/share/racket/pkgs/scribble-lib/scribble/run.rkt:175:26: go
   .../private/map.rkt:40:19: loop
   .../racket/cmdline.rkt:191:51
   body of "/usr/share/racket/pkgs/scribble-lib/scribble/run.rkt"

In DrRacket, that works fine. It seems like the pi constant is defined in base Racket. I know I'm not using #lang racket, but I was expecting that to work.

I can of course define it, but it seems like I should be able to do import/require.

If I try to (require math), I get:

scribble-plot-test.scrbl:3:10: module: identifier already required
  at: ::
  in: math
  also provided by: scribble/manual

What should I do here?

If you look at the documentation for pi, you will see that it is “provided by the racket/math and racket libraries, but not racket/base”. (In addition to the note at the top of a section, you can find what libraries export a given binding by hovering over its name in the blue box or by looking at the search results page.)

Your example is using #lang scribble/base, which is documented to extend racket/base, as opposed to racket, so it does not provide pi.

The simplest solution would be to add (require racket/math) (which is different from math!).

Also, it’s unusual to use #lang scribble/base together with (require scribble/manual): scribble/manual provides everything from scribble/base, so typically you would just use #lang scribble/manual. (Strictly speaking, the one difference is that this would use the manual rendering style, but that is generally an improvement.)

Thanks for the explanation -- I was basically cargo-culting my way through, trying random things. I have a better understanding of require and friends now.