Scribble Abbrevs
1 General Scribble Utilities
add-commas
authors
authors*
oxfordize
sf
parag
format-url
integer->word
Integer->word
natural->roman-numeral
roman-numeral->natural
natural->roman-symbol*
roman-symbol?
x-axes
y-axes
x-axis
y-axis
etal
2 La  Te  X Renderer Utilities
appendix
noindent
sc
exact
$
definition
Section-ref
section-ref
3 Documentation Renderer Utilities
tech/  guide
tech/  reference
racketfile
4 Pict Utilities
codeblock-pict/  numbers
add-border
8.12

Scribble Abbrevs🔗ℹ

Ben Greenman

Helpers for making Scribble documents. The scribble-abbrevs module provides all the bindings documented on this page.

1 General Scribble Utilities🔗ℹ

General utilities, for any Scribble document.

procedure

(add-commas r)  string?

  r : real?
Similar to number->string, but adds commas to numbers with more than three digits.

Examples:
> (add-commas 42)

"42"

> (add-commas 42000)

"42,000"

procedure

(authors s ...)  (or/c string? element?)

  s : string?
Renders a sequence of author names (with Oxford comma).

Examples:
> (authors "Charles Darwin")

"Charles Darwin"

> (authors "Thomas Jefferson" "Alexander Hamilton")

'("Thomas Jefferson" " and " "Alexander Hamilton")

> (authors "Ed" "Ed" "Eddy")

'("Ed" ", " "Ed" ", and " "Eddy")

Always use the Oxford comma. Remember the Maine truck drivers! (settlement)

procedure

(authors* s*)  element?

  s* : (listof string?)

procedure

(oxfordize s*)  element?

  s* : (listof string?)
Same as (apply authors s*).

procedure

(sf x)  element?

  x : pre-content?
Renders the given content in "sfstyle" (serif-style).

procedure

(parag s ...)  element?

  s : string?
Renders the given strings as a paragraph title.

procedure

(format-url url)  element?

  url : string?
Renders a clickable URL. Strips prefixes like "www." and "http://".

procedure

(integer->word i [#:title? title?])  string?

  i : exact-integer?
  title? : boolean? = #false
Returns the English word for the given integer.

Examples:
> (integer->word 0)

"zero"

> (integer->word 42)

"forty-two"

> (integer->word -8675309)

"negative-eight-million-six-hundred-seventy-five-thousand-three-hundred-nine"

The current implementation fails unless (abs i) is less than 1 quadrillion.

procedure

(Integer->word i)  string?

  i : exact-integer?
Alias for (integer->word i #:title? #true).

Wikipedia: roman numeral

Converts a positive number to a roman numeral in the standard subtractive form.

Examples:

Converts a roman numeral to a natural number. Accepts subtractive or additive numbers, and the strings "nulla" and "N".

Examples:

Convert a positive number to a sequence of roman symbols.

Example:
> (natural->roman-symbol* 44)

'(X L I V)

procedure

(roman-symbol? x)  boolean?

  x : any/c
Predicate for symbols that correspond to a roman numeral value.

Examples:
> (roman-symbol? 'I)

#t

> (roman-symbol? 'II)

#f

> (andmap roman-symbol? '(I V X L C D M))

#t

> (roman-symbol? 17)

#f

syntax

x-axes

syntax

y-axes

syntax

x-axis

syntax

y-axis

syntax

etal

Each identifier id renders like the string "id", except that it might be prettier (avoid bad line breaks, bad spacing).

2 LaTeX Renderer Utilities🔗ℹ

Utilities for Scribble code that generates LaTeX output.

syntax

appendix

Typesets \appendix in a paragraph with the 'pretitle style. In LaTeX, this marks the current "section" as the start of an appendix.

syntax

noindent

Typesets as \noindent{}. Good for suppressing LaTeX paragraph indentation.

.... end of previous paragraph.

 

@|noindent|Beginning of un-indented paragraph.

procedure

(sc x)  element?

  x : pre-content?
Renders the given content in small caps style.

procedure

(exact s ...)  element?

  s : string?
Renders the given strings as-is in the output.

Example:
> (exact  "\\frac{2}{3}")

(element (style "relax" '(exact-chars)) '("\\frac{2}{3}"))

procedure

($ s ...)  element?

  s : string?
Same as (exact "$" s ... "$").

procedure

(definition term def-elem* ...)  paragraph?

  term : string?
  def-elem* : pre-content?
Renders an un-numbered definition for a technical term.

Example:
> (definition "rose"  "A rose is a rose is a rose is a rose.")

(paragraph

 (style #f '())

 (list

  (element (style "relax" '(exact-chars)) '("\\vspace{1ex}\n"))

  (element 'bold '("Definition"))

  (list

   (element #f (list " (" (element 'emph '("rose")) ") "))

   "A rose is a rose is a rose is a rose.")

  (element (style "relax" '(exact-chars)) '("\\vspace{1ex}\n"))))

This usually looks good to me.

procedure

(Section-ref tag)  element?

  tag : string?

procedure

(section-ref tag)  element?

  tag : string?

NOTE: This function is deprecated; use secref, instead.

Renders the section number for tag prefixed with the word "Section" (respectively, "section").

These functions assume that the following LaTeX command appears somewhere between the definition of Scribble’s SecRef (see Base Latex Macros) and the first occurrence of section-ref:

\renewcommand{\SecRef}[2]{#1}

3 Documentation Renderer Utilities🔗ℹ

Utilities for Scribble code that generates Racket documentation.

procedure

(tech/guide pre-content ...)  element?

  pre-content : pre-content?
Similar to tech, but links to The Racket Guide.

procedure

(tech/reference pre-content ...)  element?

  pre-content : pre-content?
Similar to tech, but links to The Racket Reference.

procedure

(racketfile filename)  element?

  filename : path-string?
Typesets the contents of the given file as if its contents were wrapped in a racketblock.

4 Pict Utilities🔗ℹ

 (require scribble-abbrevs/pict) package: scribble-abbrevs

procedure

(codeblock-pict/numbers code    
  #:title title    
  #:start start    
  #:keep-lang-line? keep-lang)  pict?
  code : string?
  title : #f
  start : 1
  keep-lang : #t
Similar to codeblock, but with line numbers.

Examples:
> (require scribble-abbrevs/pict)
> (codeblock-pict/numbers
    (string-join '("#lang racket/base"
                   "(require scribble-abbrevs/pict)"
                   "(codeblock-pict/numbers \"(+ 2 \n3)\")")
                 "\n"))

image

procedure

(add-border p    
  #:margin-top margin-top    
  #:margin-bottom margin-bottom    
  #:margin-left margin-left    
  #:margin-right margin-right)  pict?
  p : pict?
  margin-top : 2
  margin-bottom : 2
  margin-left : 2
  margin-right : 2
Adds a thin black border around the given pict.

See also frame.