Scribble: add scribble/book' and scribble/report' languages

These languages set the default class for Latex rendering, and also
adjust Latex commands so that top-level sections are chapters, etc.

original commit: 09d4aa3d79066e73e93727fd18a5805873e63acf
This commit is contained in:
Matthew Flatt 2013-02-01 10:07:27 -08:00
parent 1c5b304b1b
commit 8f81da3aa9
13 changed files with 119 additions and 5 deletions

View File

@ -0,0 +1,20 @@
#lang racket/base
(require scribble/doclang
scribble/base
"../private/defaults.rkt"
scribble/latex-prefix)
(provide (except-out (all-from-out scribble/doclang) #%module-begin)
(all-from-out scribble/base)
(rename-out [module-begin #%module-begin]))
(define-syntax-rule (module-begin id . body)
(#%module-begin id (post-process) () . body))
(define ((post-process) doc)
(add-defaults doc
(string->bytes/utf-8 (string-append "\\documentclass{book}\n"
unicode-encoding-packages))
(scribble-file "book/style.tex")
null
#f))

View File

@ -0,0 +1,3 @@
#lang s-exp scribble/base/reader
scribble/book/lang
#:wrapper1 (lambda (t) (cons 'doc (t)))

View File

@ -0,0 +1,47 @@
% This style file is used both for `book' and `report' modes
\renewcommand{\ChapRef}[2]{chapter~#1}
\renewcommand{\ChapRefUC}[2]{Chapter~#1}
% sections
\renewcommand{\Spart}[2]{\part[#1]{#2}}
\renewcommand{\Ssection}[2]{\chapter[#1]{#2}}
\renewcommand{\Ssubsection}[2]{\section[#1]{#2}}
\renewcommand{\Ssubsubsection}[2]{\subsection[#1]{#2}}
\renewcommand{\Ssubsubsubsection}[2]{\subsubsection[#1]{#2}}
\renewcommand{\Ssubsubsubsubsection}[2]{{\bf #2}}
% "star" means unnumbered and not in ToC:
\renewcommand{\Spartstar}[1]{\part*{#1}}
\renewcommand{\Ssectionstar}[1]{\chapter*{#1}}
\renewcommand{\Ssubsectionstar}[1]{\section*{#1}}
\renewcommand{\Ssubsubsectionstar}[1]{\subsection*{#1}}
\renewcommand{\Ssubsubsubsectionstar}[1]{\subsubsection*{#1}}
\renewcommand{\Ssubsubsubsubsectionstar}[1]{\Ssubsubsubsubsection{#1}}
% "starx" means unnumbered but in ToC:
\renewcommand{\Spartstarx}[2]{\Spartstar{#2}\addcontentsline{toc}{part}{#1}}
\renewcommand{\Ssectionstarx}[2]{\Ssectionstar{#2}\addcontentsline{toc}{chapter}{#1}}
\renewcommand{\Ssubsectionstarx}[2]{\Ssubsectionstar{#2}\addcontentsline{toc}{section}{#1}}
\renewcommand{\Ssubsubsectionstarx}[2]{\Ssubsubsectionstar{#2}\addcontentsline{toc}{subsection}{#1}}
\renewcommand{\Ssubsubsubsectionstarx}[2]{\Ssubsubsubsectionstar{#2}\addcontentsline{toc}{subsubsection}{#1}}
\renewcommand{\Ssubsubsubsubsectionstarx}[2]{\Ssubsubsubsubsectionstar{#2}}
% "grouper" is for the 'grouper style variant:
\renewcommand{\Ssubsectiongrouper}[2]{\setcounter{GrouperTemp}{\value{section}}\Ssubsectionstarx{#1}{#2}\setcounter{section}{\value{GrouperTemp}}}
\renewcommand{\Ssubsubsectiongrouper}[2]{\setcounter{GrouperTemp}{\value{subsection}}\Ssubsubsectionstarx{#1}{#2}\setcounter{subsection}{\value{GrouperTemp}}}
\renewcommand{\Ssubsubsubsectiongrouper}[2]{\setcounter{GrouperTemp}{\value{subsubsection}}\Ssubsubsectionstarx{#1}{#2}\setcounter{subsubsection}{\value{GrouperTemp}}}
\renewcommand{\Ssubsubsubsubsectiongrouper}[2]{\Ssubsubsubsubsectionstarx{#1}{#2}}
\renewcommand{\Ssubsectiongrouperstar}[1]{\setcounter{GrouperTemp}{\value{section}}\Ssubsectionstar{#1}\setcounter{section}{\value{GrouperTemp}}}
\renewcommand{\Ssubsubsectiongrouperstar}[1]{\setcounter{GrouperTemp}{\value{subsection}}\Ssubsubsectionstar{#1}\setcounter{subsection}{\value{GrouperTemp}}}
\renewcommand{\Ssubsubsubsectiongrouperstar}[1]{\setcounter{GrouperTemp}{\value{subsubsection}}\Ssubsubsectionstar{#1}\setcounter{subsubsection}{\value{GrouperTemp}}}
\renewcommand{\Ssubsubsubsubsectiongrouperstar}[1]{\Ssubsubsubsubsectionstar{#1}}
% To increments section numbers:
\renewcommand{\Sincpart}{\stepcounter{part}}
\renewcommand{\Sincsection}{\stepcounter{chapter}}
\renewcommand{\Sincsubsection}{\stepcounter{section}}
\renewcommand{\Sincsubsubsection}{\stepcounter{subsection}}
\renewcommand{\Sincsubsubsubsection}{\stepcounter{subsubsection}}

View File

@ -292,9 +292,9 @@
(let* ([dest (resolve-get part ri (link-element-tag e))] (let* ([dest (resolve-get part ri (link-element-tag e))]
[number (and dest (vector-ref dest 2))]) [number (and dest (vector-ref dest 2))])
(printf "\\~aRef~a{" (printf "\\~aRef~a{"
(case (and dest (length number)) (case (and dest (number-depth number))
[(0) "Book"] [(0) "Book"]
[(1) "Chap"] [(1) (if (string? (car number)) "Part" "Chap")]
[else "Sec"]) [else "Sec"])
(if (let ([s (element-style e)]) (if (let ([s (element-style e)])
(and (style? s) (memq 'uppercase (style-properties s)))) (and (style? s) (memq 'uppercase (style-properties s))))

View File

@ -0,0 +1,20 @@
#lang racket/base
(require scribble/doclang
scribble/base
"../private/defaults.rkt"
scribble/latex-prefix)
(provide (except-out (all-from-out scribble/doclang) #%module-begin)
(all-from-out scribble/base)
(rename-out [module-begin #%module-begin]))
(define-syntax-rule (module-begin id . body)
(#%module-begin id (post-process) () . body))
(define ((post-process) doc)
(add-defaults doc
(string->bytes/utf-8 (string-append "\\documentclass{report}\n"
unicode-encoding-packages))
(scribble-file "book/style.tex")
null
#f))

View File

@ -0,0 +1,3 @@
#lang s-exp scribble/base/reader
scribble/report/lang
#:wrapper1 (lambda (t) (cons 'doc (t)))

View File

@ -30,10 +30,12 @@
\newcommand{\BookRef}[2]{\emph{#2}} \newcommand{\BookRef}[2]{\emph{#2}}
\newcommand{\ChapRef}[2]{\SecRef{#1}{#2}} \newcommand{\ChapRef}[2]{\SecRef{#1}{#2}}
\newcommand{\SecRef}[2]{section~#1} \newcommand{\SecRef}[2]{section~#1}
\newcommand{\PartRef}[2]{part~#1}
% Generated by `Secref': % Generated by `Secref':
\newcommand{\BookRefUC}[2]{\BookRef{#1}{#2}} \newcommand{\BookRefUC}[2]{\BookRef{#1}{#2}}
\newcommand{\ChapRefUC}[2]{\SecRefUC{#1}{#2}} \newcommand{\ChapRefUC}[2]{\SecRefUC{#1}{#2}}
\newcommand{\SecRefUC}[2]{Section~#1} \newcommand{\SecRefUC}[2]{Section~#1}
\newcommand{\PartRefUC}[2]{Part~#1}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Fonts % Fonts

View File

@ -0,0 +1,9 @@
#lang scribble/manual
@(require "utils.rkt")
@title{Book Format}
@defmodulelang[scribble/book]{The @racketmodname[scribble/book]
language is like @racketmodname[scribble/base], but configured with
Latex style defaults to use the standard @tt{book} class. Top-level
sections are rendered as Latex chapters.}

View File

@ -7,6 +7,8 @@
@include-section["base.scrbl"] @include-section["base.scrbl"]
@include-section["manual-stub.scrbl"] @include-section["manual-stub.scrbl"]
@include-section["book.scrbl"]
@include-section["report.scrbl"]
@include-section["sigplan.scrbl"] @include-section["sigplan.scrbl"]
@include-section["jfp.scrbl"] @include-section["jfp.scrbl"]
@include-section["lncs.scrbl"] @include-section["lncs.scrbl"]

View File

@ -10,7 +10,7 @@
@title{JFP Paper Format} @title{JFP Paper Format}
@defmodulelang[scribble/jfp]{The @racketmodname[scribble/jfp] @defmodulelang[scribble/jfp]{The @racketmodname[scribble/jfp]
language is like @racketmodname[scribble/manual], but configured with language is like @racketmodname[scribble/base], but configured with
Latex style defaults to use the @filepath{jfp1.cls} class Latex style defaults to use the @filepath{jfp1.cls} class
file. The class file is not included with Scribble due to license file. The class file is not included with Scribble due to license
issues, but if the file is not manually installed into the issues, but if the file is not manually installed into the

View File

@ -12,7 +12,7 @@
@defmodulelang[scribble/lncs #:use-sources (scribble/lncs/lang)]{ @defmodulelang[scribble/lncs #:use-sources (scribble/lncs/lang)]{
The @racketmodname[scribble/lncs] The @racketmodname[scribble/lncs]
language is like @racketmodname[scribble/manual], but configured with language is like @racketmodname[scribble/base], but configured with
Latex style defaults to use the @filepath{llncs.cls} class Latex style defaults to use the @filepath{llncs.cls} class
file. The class file is not included with Scribble due to license issues, file. The class file is not included with Scribble due to license issues,
but if the file is not manually installed into the but if the file is not manually installed into the

View File

@ -0,0 +1,8 @@
#lang scribble/manual
@(require "utils.rkt")
@title{Report Format}
@defmodulelang[scribble/report]{The @racketmodname[scribble/report]
language is like @racketmodname[scribble/book], but configured with
Latex style defaults to use the standard @tt{report} class.}

View File

@ -4,7 +4,7 @@
@title{SIGPLAN Paper Format} @title{SIGPLAN Paper Format}
@defmodulelang[scribble/sigplan]{The @racketmodname[scribble/sigplan] @defmodulelang[scribble/sigplan]{The @racketmodname[scribble/sigplan]
language is like @racketmodname[scribble/manual], but configured with language is like @racketmodname[scribble/base], but configured with
Latex style defaults to use the @filepath{sigplanconf.cls} class Latex style defaults to use the @filepath{sigplanconf.cls} class
file that is included with Scribble.} file that is included with Scribble.}