From b1ddcb292a30105b1092efbfab6a8a2ef8b8e8d1 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 31 Aug 2012 15:47:08 -0600 Subject: [PATCH] scribble: for Latex output, use `\Ssection', etc. for section A style override might change `\section' to `\chapter', etc. original commit: 7b2e18afc5859b6dfc71d83b1c57e647387d27b2 --- collects/scribble/latex-render.rkt | 15 ++++++------ collects/scribble/scribble.tex | 28 ++++++++++++++++++---- collects/scribblings/scribble/config.scrbl | 18 ++++++++++++++ 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/collects/scribble/latex-render.rkt b/collects/scribble/latex-render.rkt index df76e3b4..da8c11d6 100644 --- a/collects/scribble/latex-render.rkt +++ b/collects/scribble/latex-render.rkt @@ -157,19 +157,20 @@ ((length number) . > . 3)))]) (printf "\n\n\\~a~a~a" (case (+ (length number) (or (render-part-depth) 0)) - [(0 1) "sectionNewpage\n\n\\section"] - [(2) "subsection"] - [(3) "subsubsection"] - [else "subsubsection"]) + [(0 1) "sectionNewpage\n\n\\Ssection"] + [(2) "Ssubsection"] + [(3) "Ssubsubsection"] + [(4) "Ssubsubsubsection"] + [else "Ssubsubsubsubsection"]) (if (and (part-style? d 'hidden) (not no-number?)) "hidden" "") - (if no-number? "*" "")) + (if no-number? "star" "")) (when (not (or (part-style? d 'hidden) no-number?)) - (printf "[") + (printf "{") (parameterize ([disable-images #t] [escape-brackets #t]) (render-content (part-title-content d) d ri)) - (printf "]"))) + (printf "}"))) (printf "{") (render-content (part-title-content d) d ri) (printf "}") diff --git a/collects/scribble/scribble.tex b/collects/scribble/scribble.tex index 09016ba8..ceed5948 100644 --- a/collects/scribble/scribble.tex +++ b/collects/scribble/scribble.tex @@ -149,12 +149,30 @@ % Useful for some styles, such as sigalternate: \newcommand{\SNumberOfAuthors}[1]{} -% Used for parts with the 'hidden style variant: -\newcommand{\sectionhidden}[1]{\section{#1}} -\newcommand{\subsectionhidden}[1]{\subsection{#1}} -\newcommand{\subsubsectionhidden}[1]{\subsubsection{#1}} +% sections +\newcommand{\Ssection}[2]{\section[#1]{#2}} +\newcommand{\Ssubsection}[2]{\subsection[#1]{#2}} +\newcommand{\Ssubsubsection}[2]{\subsubsection[#1]{#2}} +\newcommand{\Ssubsubsubsection}[2]{{\bf #2}} +\newcommand{\Ssubsubsubsubsection}[2]{\Ssubsubsubsection{#1}{#2}} -\newcommand{\SSubSubSubSection}[1]{{\bf #1}} +\newcommand{\Ssectionstar}[1]{\section*{#1}} +\newcommand{\Ssubsectionstar}[1]{\subsection*{#1}} +\newcommand{\Ssubsubsectionstar}[1]{\subsubsection*{#1}} +\newcommand{\Ssubsubsubsectionstar}[1]{{\bf #1}} +\newcommand{\Ssubsubsubsubsectionstar}[1]{\Ssubsubsubsectionstar{#1}} + +\newcommand{\Ssectionhidden}[1]{\sectionhidden{#1}} +\newcommand{\Ssubsectionhidden}[1]{\subsectionhidden{#1}} +\newcommand{\Ssubsubsectionhidden}[1]{\subsubsectionhidden{#1}} +\newcommand{\Ssubsubsubsectionhidden}[1]{\subsubsubsectionhidden{#1}} +\newcommand{\Ssubsubsubsubsectionhidden}[1]{\Ssubsubsubsectionhidden{#1}} + +% Used for parts with the 'hidden style variant: +\newcommand{\sectionhidden}[1]{\Ssection{#1}} +\newcommand{\subsectionhidden}[1]{\Ssubsection{#1}} +\newcommand{\subsubsectionhidden}[1]{\Ssubsubsection{#1}} +\newcommand{\subsubsubsectionhidden}[1]{\Ssubsubsubsection{#1}} % For hidden parts with an empty title: \newcommand{\notitlesection}{\vspace{2ex}\phantomsection\noindent} diff --git a/collects/scribblings/scribble/config.scrbl b/collects/scribblings/scribble/config.scrbl index c47f6992..5ba2ead4 100644 --- a/collects/scribblings/scribble/config.scrbl +++ b/collects/scribblings/scribble/config.scrbl @@ -263,6 +263,24 @@ style: @item{@ltxd[2]{SecRefUC} --- like @ltx{BookRef}, but for @racket[Secref]. The default shows defers to @ltx{BookRef}.} + @item{@ltxd[2]{Ssection}, @ltxd[2]{Ssubsection}, + @ltxd[2]{Ssubsubsection}, @ltxd[2]{Ssubsubsubsection}, + @ltxd[2]{Ssubsubsubsubsection} --- for a top-level section, a + second-level section, etc., where the last variant is used for + all sections that are deeper than four levels. The first + argument corresponds to the optional argument to + @ltx{section}, which is used for the table of contents.} + + @item{@ltxd[1]{Ssectionstar}, @ltxd[1]{Ssubsectionstar}, + @ltxd[1]{Ssubsubsectionstar}, @ltxd[1]{Ssubsubsubsectionstar}, + @ltxd[1]{Ssubsubsubsubsectionstar} --- like @ltx{Ssection}, + etc., but for unnumbered sections.} + + @item{@ltxd[1]{Ssectionhidden}, @ltxd[1]{Ssubsectionhidden}, + @ltxd[1]{Ssubsubsectionhidden}, @ltxd[1]{Ssubsubsubsectionhidden}, + @ltxd[1]{Ssubsubsubsubsectionhidden} --- like @ltx{Ssection}, + etc., but for sections with the @racket['hidden] style property.} + ] @; ------------------------------------------------------------