Skip to content

Commit

Permalink
wip formatting part 2 (#89)
Browse files Browse the repository at this point in the history
* wip formatting part 2

* reformat chapter 2

* reformat chapter 6

* reformat chapter 7

* update

* wip

* reformat chapter 7

* wip reformat chapter 8

* fixes in chapter 8

* minor changes to part 1

* wip

* minor corrections

* wip start reformatting chapter 9

* wip filterable chapter

* wip reformatting

* remove weird footnote

* wip some corrections in applicative chapter

* wip filterable chapter

* wip reformatting chapter 9

* finish reformatting chapter 9

* wip reformatting chapter 10

* update tex

* wip reformatting chapter 10

* fix error with non-disjunctive product

* reformat chapter 10

* wip changes from older notes

* wip

* changes from the ipad

* remove wrap floats

* wip

* responding to comments from Andreas, and adding declarativity essay

* wip

* fix broken labels

* update script to include lulu.com hyperlinks

* add random-pages pictures

* final corrections in part 1

* wip

* fix last undefined reference

* update pdf
  • Loading branch information
winitzki authored Feb 17, 2024
1 parent f955603 commit e6e130a
Show file tree
Hide file tree
Showing 34 changed files with 6,908 additions and 6,531 deletions.
2 changes: 1 addition & 1 deletion sofp-src/book_cover/sofp-cover-parameters.tex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
% -- Ingram: page count MUST be divisible by 2.
% -- Blurb : page count MUST be divisible by 6.
% Add blank pages as needed in final PDF generations!
\pgfmathsetmacro\TotalPageCount{1235}% Must be manually entered
\pgfmathsetmacro\TotalPageCount{1258}% Must be manually entered
\pgfmathsetmacro\PaperWidthPt{7.444in}%
\pgfmathsetmacro\PaperHeightPt{9.68in}%

Expand Down
73 changes: 38 additions & 35 deletions sofp-src/prepare_volume.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Prepare the printable PDF file of volume v of the book. v = 1, 2, 3.
# The files are designed for printing and will have no PDF hyperlinks.
# The files are designed for printing and will have no color in the PDF hyperlinks.

function pdfPages {
local file="$1"
Expand Down Expand Up @@ -32,6 +32,9 @@ cd $dir

tar jxf ../sofp-src.tar.bz2
mv sofp-src/* .
# Special handling for random-pages files.
mkdir random-pages
mv random-pages*png random-pages/

cp ../sofp*.tex ../sofp.* .
cp ../book_cover/* ./book_cover/
Expand Down Expand Up @@ -74,66 +77,66 @@ function get_chapter {
case $v in
1)
firstchapter=$(get_chapter ../sofp-nameless-functions.aux)
echo "Detected previous chapter $firstchapter, first page $firstpage, previous part number $firstpart"
cat sofp.tex | remove_part2 | remove_part3 > $name.tex
sed -i.bak -e 's|\(of Functional Programming\)|\1, Part I|; s|\(\\part{.*}\)|\\setcounter{page}{'$firstpage'}\\setcounter{part}{'$firstpart'}\\setcounter{chapter}{'$firstchapter'}\1|;' $name.tex
sed -i.bak -e 's|% End of title.|\\vspace{0.2in}\\centerline{\\fontsize{20pt}{20pt}\\selectfont{Part I: Introductory level}}|' book_cover/sofp-cover-page-no-bg.tex
sed -i.bak -e 's|\(of Functional Programming\)|\1, Part I|;' book_cover/sofp-spine.tex

# Replace ISBN information.
echo "Using volume $v ISBN '$vol1_ISBN'"
sed -i.bak -e 's|\({\\footnotesize{}\)ISBN: [^}]*\(}\\\\\)|\1'"$vol1_ISBN"'\2|;' $name.tex
# Add barcode to back cover.
sed -i.bak -e 's|%\(.*\){barcode}.*|\1{'$vol1_ISBN_barcode'}|' book_cover/sofp-back-cover-no-bg.tex
;;
title1="Part I"
title2="Part I: Introductory level"
url="$vol1_url"
isbn="$vol1_ISBN"
barcode="$vol1_ISBN_barcode"
;;

2)
firstchapter=$(get_chapter ../sofp-functors.aux)
echo "Detected previous chapter $firstchapter, first page $firstpage, previous part number $firstpart"
cat sofp.tex | remove_part1 | remove_part3 > $name.tex

sed -i.bak -e 's|\(of Functional Programming\)|\1, Part II|; s|\(\\part{.*}\)|\\setcounter{page}{'$firstpage'}\\setcounter{part}{'$firstpart'}\\setcounter{chapter}{'$firstchapter'}\1|;' $name.tex
sed -i.bak -e 's|% End of title.|\\vspace{0.2in}\\centerline{\\fontsize{20pt}{20pt}\\selectfont{Part II: Intermediate level}}|' book_cover/sofp-cover-page-no-bg.tex
sed -i.bak -e 's|\(of Functional Programming\)|\1, Part II|;' book_cover/sofp-spine.tex

# Replace ISBN information.
echo "Using volume $v ISBN '$vol2_ISBN'"
sed -i.bak -e 's|\({\\footnotesize{}\)ISBN: [^}]*\(}\\\\\)|\1'"$vol2_ISBN"'\2|;' $name.tex
# Add barcode to back cover.
sed -i.bak -e 's|%\(.*\){barcode}.*|\1{'$vol2_ISBN_barcode'}|' book_cover/sofp-back-cover-no-bg.tex
;;
title1="Part II"
title2="Part II: Intermediate level"
url="$vol2_url"
isbn="$vol2_ISBN"
barcode="$vol2_ISBN_barcode"
;;

3)
firstchapter=$(get_chapter ../sofp-free-type.aux)
echo "Detected previous chapter $firstchapter, first page $firstpage, previous part number $firstpart"
cat sofp.tex | remove_part1 | remove_part2 > $name.tex
title1="Part III"
title2="Part III: Advanced level"
url="$vol3_url"
isbn="$vol3_ISBN"
barcode="$vol3_ISBN_barcode"
;;

esac

echo "Detected previous chapter $firstchapter, first page $firstpage, previous part number $firstpart"

sed -i.bak -e 's|\(of Functional Programming\)|\1, Part III|; s|\(\\part{.*}\)|\\setcounter{page}{'$firstpage'}\\setcounter{part}{'$firstpart'}\\setcounter{chapter}{'$firstchapter'}\1|;' $name.tex
sed -i.bak -e 's|% End of title.|\\vspace{0.2in}\\centerline{\\fontsize{20pt}{20pt}\\selectfont{Part III: Advanced level}}|' book_cover/sofp-cover-page-no-bg.tex
sed -i.bak -e 's|\(of Functional Programming\)|\1, Part III|;' book_cover/sofp-spine.tex
sed -i.bak -e 's|\(of Functional Programming\)|\1, '"$title1"'|; s|\(\\part{.*}\)|\\setcounter{page}{'$firstpage'}\\setcounter{part}{'$firstpart'}\\setcounter{chapter}{'$firstchapter'}\1|;' $name.tex
sed -i.bak -e 's|% End of title.|\\vspace{0.2in}\\centerline{\\fontsize{20pt}{20pt}\\selectfont{'"$title2"'}}|' book_cover/sofp-cover-page-no-bg.tex
sed -i.bak -e 's|\(of Functional Programming\)|\1 - '"$title1"'|;' book_cover/sofp-spine.tex

# Replace lulu.com hyperlink.
sed -i.bak -e 's|{https://www.lulu.com/[^}]*}{\(Print on demand[^}]*\)}|{'"$url"'}{\1}|;' $name.tex

# Replace ISBN information.
echo "Using volume $v ISBN '$vol3_ISBN'"
sed -i.bak -e 's|\({\\footnotesize{}\)ISBN: [^}]*\(}\\\\\)|\1'"$vol3_ISBN"'\2|;' $name.tex
echo "Using volume $v ISBN '$isbn'"
sed -i.bak -e 's|\({\\footnotesize{}\)ISBN: [^}]*\(}\\\\\)|\1'"$isbn"'\2|;' $name.tex
# Add barcode to back cover.
sed -i.bak -e 's|%\(.*\){barcode}.*|\1{'$vol3_ISBN_barcode'}|' book_cover/sofp-back-cover-no-bg.tex
;;

esac
sed -i.bak -e 's|%\(.*\){barcode}.*|\1{'"$barcode"'}|' book_cover/sofp-back-cover-no-bg.tex

cp book_cover/* .

mv $name.tex sofp.tex

# Disable PDF hyperlinks and remove covers.
LC_ALL=C sed -i.bak -e 's|colorlinks=true|colorlinks=false|; s|\\input{sofp-cover-page}||; s|\\input{sofp-back-cover-page}||; ' sofp.tex

echo "Starting to prepare volume $v"
pdflatex --interaction=batchmode sofp
makeindex sofp.idx
cp ../*.aux . # Enable references to other chapters.
pdflatex --interaction=batchmode sofp

mv sofp.pdf ../$name.pdf
echo "Volume $v is prepared in $name.pdf"

bash ../prepare_cover.sh ../$name.pdf "$pdftk"
mv book_cover/sofp-3page-cover.pdf ../$name-3page-cover.pdf
echo "Cover for volume $v is prepared in $name-3page-cover.pdf"
Loading

0 comments on commit e6e130a

Please sign in to comment.