diff --git a/collects/scribble/book/lang.rkt b/collects/scribble/book/lang.rkt new file mode 100644 index 00000000..800fd01a --- /dev/null +++ b/collects/scribble/book/lang.rkt @@ -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)) diff --git a/collects/scribble/book/lang/reader.rkt b/collects/scribble/book/lang/reader.rkt new file mode 100644 index 00000000..ada58ad9 --- /dev/null +++ b/collects/scribble/book/lang/reader.rkt @@ -0,0 +1,3 @@ +#lang s-exp scribble/base/reader +scribble/book/lang +#:wrapper1 (lambda (t) (cons 'doc (t))) diff --git a/collects/scribble/book/style.tex b/collects/scribble/book/style.tex new file mode 100644 index 00000000..f70c1f21 --- /dev/null +++ b/collects/scribble/book/style.tex @@ -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}} + diff --git a/collects/scribble/latex-render.rkt b/collects/scribble/latex-render.rkt index b433889b..4c39f9bd 100644 --- a/collects/scribble/latex-render.rkt +++ b/collects/scribble/latex-render.rkt @@ -292,9 +292,9 @@ (let* ([dest (resolve-get part ri (link-element-tag e))] [number (and dest (vector-ref dest 2))]) (printf "\\~aRef~a{" - (case (and dest (length number)) + (case (and dest (number-depth number)) [(0) "Book"] - [(1) "Chap"] + [(1) (if (string? (car number)) "Part" "Chap")] [else "Sec"]) (if (let ([s (element-style e)]) (and (style? s) (memq 'uppercase (style-properties s)))) diff --git a/collects/scribble/report/lang.rkt b/collects/scribble/report/lang.rkt new file mode 100644 index 00000000..90dbae9b --- /dev/null +++ b/collects/scribble/report/lang.rkt @@ -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)) diff --git a/collects/scribble/report/lang/reader.rkt b/collects/scribble/report/lang/reader.rkt new file mode 100644 index 00000000..51db5d66 --- /dev/null +++ b/collects/scribble/report/lang/reader.rkt @@ -0,0 +1,3 @@ +#lang s-exp scribble/base/reader +scribble/report/lang +#:wrapper1 (lambda (t) (cons 'doc (t))) diff --git a/collects/scribble/scribble.tex b/collects/scribble/scribble.tex index 34a58fd9..b957fc45 100644 --- a/collects/scribble/scribble.tex +++ b/collects/scribble/scribble.tex @@ -30,10 +30,12 @@ \newcommand{\BookRef}[2]{\emph{#2}} \newcommand{\ChapRef}[2]{\SecRef{#1}{#2}} \newcommand{\SecRef}[2]{section~#1} +\newcommand{\PartRef}[2]{part~#1} % Generated by `Secref': \newcommand{\BookRefUC}[2]{\BookRef{#1}{#2}} \newcommand{\ChapRefUC}[2]{\SecRefUC{#1}{#2}} \newcommand{\SecRefUC}[2]{Section~#1} +\newcommand{\PartRefUC}[2]{Part~#1} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Fonts diff --git a/collects/scribblings/scribble/book.scrbl b/collects/scribblings/scribble/book.scrbl new file mode 100644 index 00000000..34a768a1 --- /dev/null +++ b/collects/scribblings/scribble/book.scrbl @@ -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.} diff --git a/collects/scribblings/scribble/generic.scrbl b/collects/scribblings/scribble/generic.scrbl index 2522c260..33f6c243 100644 --- a/collects/scribblings/scribble/generic.scrbl +++ b/collects/scribblings/scribble/generic.scrbl @@ -7,6 +7,8 @@ @include-section["base.scrbl"] @include-section["manual-stub.scrbl"] +@include-section["book.scrbl"] +@include-section["report.scrbl"] @include-section["sigplan.scrbl"] @include-section["jfp.scrbl"] @include-section["lncs.scrbl"] diff --git a/collects/scribblings/scribble/jfp.scrbl b/collects/scribblings/scribble/jfp.scrbl index 24eca1c9..da23c2eb 100644 --- a/collects/scribblings/scribble/jfp.scrbl +++ b/collects/scribblings/scribble/jfp.scrbl @@ -10,7 +10,7 @@ @title{JFP Paper Format} @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 file. The class file is not included with Scribble due to license issues, but if the file is not manually installed into the diff --git a/collects/scribblings/scribble/lncs.scrbl b/collects/scribblings/scribble/lncs.scrbl index f7a899c8..eeb9883e 100644 --- a/collects/scribblings/scribble/lncs.scrbl +++ b/collects/scribblings/scribble/lncs.scrbl @@ -12,7 +12,7 @@ @defmodulelang[scribble/lncs #:use-sources (scribble/lncs/lang)]{ 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 file. The class file is not included with Scribble due to license issues, but if the file is not manually installed into the diff --git a/collects/scribblings/scribble/report.scrbl b/collects/scribblings/scribble/report.scrbl new file mode 100644 index 00000000..a7b8c98b --- /dev/null +++ b/collects/scribblings/scribble/report.scrbl @@ -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.} diff --git a/collects/scribblings/scribble/sigplan.scrbl b/collects/scribblings/scribble/sigplan.scrbl index 6ce80f15..761a3164 100644 --- a/collects/scribblings/scribble/sigplan.scrbl +++ b/collects/scribblings/scribble/sigplan.scrbl @@ -4,7 +4,7 @@ @title{SIGPLAN Paper Format} @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 file that is included with Scribble.}