Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

📚 The CoCalc Library - books, templates and other resources

Views: 96155
License: OTHER
1
#! /bin/bash
2
3
# Sage and Linear Algebra Worksheets #
4
# Robert A. Beezer #
5
# Copyright 2017 License: CC BY-SA #
6
# See COPYING for more information #
7
8
# Sage for Linear Algebra worksheets
9
#
10
# History
11
#
12
# 2017-01-12 Initiated
13
14
##############
15
# Instructions
16
##############
17
18
# 1. Make this script executable
19
# 2. Check prerequisite binaries below
20
21
# Prerequisite binaries/executables
22
# $ which <name> will return path if available
23
#
24
# install
25
# xsltproc
26
# A LaTeX installation
27
# texfot - utility to restrict output
28
# xelatex - preferable for Unicode characters
29
# MathBook XML distribution
30
31
declare ROOT=${HOME}/books/fcla/sla
32
declare OUTPUT=${ROOT}/worksheets
33
declare SCRATCH=/tmp/sla
34
declare MBX=${HOME}/mathbook/mathbook
35
declare LATEX="texfot xelatex"
36
37
# With output in a repository, dates in files is a bad idea
38
declare NODATE="-stringparam debug.datedfiles no"
39
40
# FCLA sections that have worksheets, in order
41
ALLSECTIONS=(RREF NM SS MISLE CRS FS B PDM EE SD LT ILT SLT IVLT VR MR CB)
42
43
# http://stackoverflow.com/questions/12303974/assign-array-to-variable
44
# assignment array variable b=( "${a[@]}" )
45
if [ "X${1}" == "X" ] ; then
46
echo "Output will be copied into repo, work on a branch"
47
echo "Provide the string 'all' or a section acronym"
48
exit
49
elif [ "${1}" == "all" ] ; then
50
declare SECTIONS=( "${ALLSECTIONS[@]}" );
51
else
52
declare SECTIONS=(${1})
53
fi
54
55
# Create/use temp/scratch directory
56
install -d ${SCRATCH}
57
cd ${SCRATCH}
58
59
echo "*******************"
60
echo "Processing Overview"
61
echo "*******************"
62
# Overview HTML, LaTeX
63
xsltproc -xinclude ${NODATE} ${MBX}/xsl/mathbook-html.xsl ${ROOT}/worksheets/overview.xml
64
xsltproc -xinclude -o overview.tex ${NODATE} ${MBX}/xsl/mathbook-latex.xsl ${ROOT}/worksheets/overview.xml
65
${LATEX} overview.tex
66
${LATEX} overview.tex
67
cp -a overview.html overview.pdf ${OUTPUT}
68
69
for SEC in ${SECTIONS[*]}
70
do
71
echo "*****************"
72
echo "Processing "${SEC}
73
echo "*****************"
74
###############################
75
# PDF, process twice with LaTeX
76
###############################
77
xsltproc -stringparam numbering.theorems.level 0 ${NODATE} -xinclude \
78
-o ${SEC}.tex ${MBX}/xsl/mathbook-latex.xsl ${ROOT}/worksheets/${SEC}/${SEC}.xml
79
${LATEX} ${SEC}.tex
80
${LATEX} ${SEC}.tex
81
######
82
# HTML
83
######
84
xsltproc -stringparam numbering.theorems.level 0 -stringparam chunk.level 0 \
85
-stringparam html.knowl.exercise.inline no ${NODATE} -xinclude \
86
${MBX}/xsl/mathbook-html.xsl ${ROOT}/worksheets/${SEC}/${SEC}.xml
87
###############
88
# SageMathCloud
89
###############
90
xsltproc -stringparam numbering.theorems.level 0 -stringparam chunk.level 0 ${NODATE} -xinclude \
91
${MBX}/xsl/mathbook-smc.xsl ${ROOT}/worksheets/${SEC}/${SEC}.xml
92
#########
93
# Jupyter
94
#########
95
xsltproc -stringparam numbering.theorems.level 0 -stringparam chunk.level 0 ${NODATE} -xinclude \
96
${MBX}/xsl/mathbook-jupyter.xsl ${ROOT}/worksheets/${SEC}/${SEC}.xml
97
cp -a ${SEC}.pdf ${SEC}.html ${SEC}.sagews ${SEC}.ipynb ${OUTPUT}/${SEC}
98
done
99
100
# restore working directory
101
cd - > /dev/null
102