├── GunterCh2.pdf ├── Lambda2_1.pdf ├── Lambda5_3.pdf ├── Lambda5_4.pdf ├── README.md ├── ScottDTL1976.pdf ├── all.bib ├── d-infinity.rkt ├── hw1.md ├── hw2.md ├── hw3.md ├── hw4.md ├── hw5.md ├── hw6.md ├── hw7.md ├── hw8.md ├── notes.tex ├── scribbles.txt ├── topology.tex ├── tufte-common.def └── tufte-handout.cls /GunterCh2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsiek/B629-denotational/4f3376a65f226e05944d2d072803721561a65a3a/GunterCh2.pdf -------------------------------------------------------------------------------- /Lambda2_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsiek/B629-denotational/4f3376a65f226e05944d2d072803721561a65a3a/Lambda2_1.pdf -------------------------------------------------------------------------------- /Lambda5_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsiek/B629-denotational/4f3376a65f226e05944d2d072803721561a65a3a/Lambda5_3.pdf -------------------------------------------------------------------------------- /Lambda5_4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsiek/B629-denotational/4f3376a65f226e05944d2d072803721561a65a3a/Lambda5_4.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # B629 Topics in PL: Denotational Semantics 3 | 4 | Indiana University, Spring 2018 5 | 6 | In this course we shall study the denotational semantics of 7 | programming languages, including the classic domain-theoretic models 8 | as well as elementary models based on functions-as-graphs and 9 | intersection types. The course assignments will include readings from 10 | selected chapters and papers, written homework, presentations, and 11 | some programming. 12 | 13 | ## Instructor 14 | 15 | **Jeremy Siek** Luddy 3016 [jsiek@indiana.edu](mailto:jsiek@indiana.edu) 16 | 17 | ## Lectures 18 | 19 | 9:30-10:45am MW in Luddy Hall Room 3069 (not BH 305!), 20 | backup location Luddy Hall Room 4069. 21 | 22 | The lecture notes are in progress at: 23 | 24 | [https://github.com/jsiek/B629-denotational/notes.pdf](notes.pdf). 25 | 26 | ## Office Hours 27 | 28 | - 11:00am-12 Thursdays in my office Luddy 3016, 29 | 30 | - or by appointment 31 | 32 | ## Assignments 33 | 34 | There will be a homework (reading and some exercises) each week and a 35 | written report and presentations at the end of the semester. Also, 36 | roughly each week, one student will give a 30 minute presentation of a 37 | paper that the class has read. 38 | 39 | - [Homework 1](hw1.md) is due January 15 40 | - [Homework 2](hw2.md) is due January 22. 41 | - [Homework 3](hw3.md) is due January 29. 42 | - [Homework 4](hw4.md) is due February 14. 43 | - [Homework 5](hw5.md) is due February 28. 44 | - [Homework 6](hw6.md) is due March 26. 45 | - [Homework 7](hw7.md) is due April 11. 46 | - [Homework 8](hw8.md) is due TBD. 47 | 48 | ## Week-by-week Schedule 49 | 50 | 1. Basics of denotational semantics 51 | 2. Fixed point semantics 52 | 3. Semantics of the simply-typed lambda calculus 53 | 4. Semantics of the untyped lambda calculus 54 | 5. Scott and Engeler's graph models 55 | 6. Plotkin's graph model 56 | 7. Filter models of the untyped lambda calculus 57 | 8. More on filter models 58 | 9. D-infinity model of the untyped lambda calculus 59 | 10. Category-theoretic solutions to domain equations 60 | 11. More on category-theoretic solutions to domain equations 61 | 12. Semantics of PCF 62 | 13. Full abstraction 63 | 14. Semantics for imperative languages 64 | 15. Monads and effect-handlers 65 | 16. Student Presentations 66 | 67 | 68 | ## Representative Readings 69 | 70 | - [Denotational semantics: a methodology for language development](http://people.cs.ksu.edu/~schmidt/text/densem.html), Schmidt 1986. 71 | - [Outline of a Mathematical Theory of Computation](https://www.cs.ox.ac.uk/publications/publication3720-abstract.html), Scott 1970. 72 | - [The Denotational Semantics of Programming Languages](https://doi.org/10.1145/360303.360308), Tennent 1976. 73 | - Simply Typed Lambda Calculus 74 | - Chapter 2 of Semantics of Programming Languages: Structures and Techniques. 75 | Gunter 1992. 76 | - [A Certified Type-Preserving Compiler from Lambda Calculus to Assembly Language](https://doi.org/10.1145/1273442.1250742). Chlipala 2007. **Chaitanya Koparkar, April 16** 77 | - [Cartesian closed categories and typed λ-calculi](https://doi.org/10.1007/3-540-17184-3_44). J. Lambek 1985. **Jiawei Tang, February 28** 78 | - The Lambda Calculus: its Syntax and Semantics, Barendregt 1984. 79 | - [Lambda-Calculus And Combinators In The 20th Century](https://doi.org/10.1016/S1874-5857(09)70018-4). Cardone and Hindley, 2009. **Yuquan Fu, April 23** 80 | (aka. History of Lambda-calculus and Combinatory Logic, 2006) 81 | - Graph Models of the Lambda Calculus 82 | - [Data Types as Lattices](https://www.dropbox.com/s/ikfyrwkizooah3q/data_types_as_lattices.pdf?dl=1), Scott 1976. 83 | - [Set-theoretical and other elementary models of the lambda-calculus](https://doi.org/10.1016/0304-3975(93)90094-A), 84 | Plotkin 1993. 85 | - [Algebras and combinators](https://doi.org/10.1007/BF02483849), Engeler 1981. 86 | - [Revisiting Elementary Denotational Semantics](https://arxiv.org/abs/1707.03762), Siek 2017. 87 | - Filter Models of the Lambda Calculus 88 | - [Functional characterization of some semantic equalities 89 | inside lambda-calculus](https://doi.org/10.1007/3-540-09510-1_11). Coppo, Dezani-Ciancaglini, Salle 1979. 90 | - [A filter lambda model and the completeness of type assignment](https://www.jstor.org/stable/2273659). 91 | Barendregt, Coppo, Dezani-Ciancaglini 1983. 92 | - [Intersection Types and Lambda Models](https://doi.org/10.1016/j.tcs.2006.01.004). 93 | Alessi, Barbanera, Dezani-Ciancaglini 2006. 94 | - PCF 95 | - [A type-theoretic alternative to ISWIM, CUCH, OWHY](https://doi.org/10.1016/0304-3975(93)90095-B), Scott 1993. 96 | - [LCF considered as a programming language](https://doi.org/10.1016/0304-3975(77)90044-5), Plotkin 1977. 97 | - The D∞ model of the λ-calculus 98 | - [Lecture notes](http://www.cs.cornell.edu/courses/cs6110/2011sp/lectures/lecture24.pdf) from Nate Foster's CS 6110 course 99 | 100 | - [Fixed point constructions in order-enriched categories](https://doi.org/10.1016/0304-3975(79)90053-7). Wand 1979. 101 | - [The category-theoretic solution of recursive domain equations](http://homepages.inf.ed.ac.uk/gdp/publications/Category_Theoretic_Solution.pdf), 102 | Smyth and Plotkin, 1982. 103 | - [The Essence of Algol](https://www.cs.cmu.edu/~crary/819-f09/Reynolds81.ps), Reynolds 1981. 104 | - [Notions of computation and monads](https://doi.org/10.1016/0890-5401(91)90052-4), Moggi 1991. 105 | - Full Abstraction 106 | - [Observable sequentiality and full abstraction](https://doi.org/10.1145/143165.143232), 107 | Cartwright, Felleisen 1992. **Ryan Scott, April 11** 108 | - [Full abstraction for the second order subset of an Algol-like language](https://doi.org/10.1016/S0304-3975(96)00066-7). 109 | Kurt Sieber, 1996. 110 | - [Full Abstraction for PCF](https://arxiv.org/abs/1311.6125). 111 | Samson Abramsky, Radha Jagadeesan, Pasquale Malacaria 2000. 112 | 113 | -------------------------------------------------------------------------------- /ScottDTL1976.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsiek/B629-denotational/4f3376a65f226e05944d2d072803721561a65a3a/ScottDTL1976.pdf -------------------------------------------------------------------------------- /d-infinity.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | (require rackunit) 3 | (require racket/match) 4 | 5 | (define app 6 | (lambda (f x) 7 | (cond [(assoc x f) => cdr] 8 | [else 9 | (error 'bad-app "argument ~s not found in ~s" x f)]))) 10 | ; (cdr (assoc x f)))) 11 | 12 | (define build-function 13 | (lambda (dom rng) 14 | (cond [(null? dom) (list '())] 15 | [else 16 | (let ([x (car dom)]) 17 | (for*/list ([y rng] 18 | [f (build-function (cdr dom) rng)]) 19 | (cons (cons x y) f)))]))) 20 | 21 | (define D 22 | (lambda (n) 23 | (cond [(equal? n 0) 24 | '(bot top)] 25 | [else 26 | (let ([prev-D (D (- n 1))]) 27 | (filter (monotonic? prev-D (D-less-eq? (- n 1)) 28 | (D-less-eq? (- n 1))) 29 | (build-function prev-D prev-D)))]))) 30 | 31 | (define pointwise-less-eq? 32 | (lambda (rng-less-eq? dom) 33 | (lambda (f g) 34 | (for/and ([d dom]) 35 | (rng-less-eq? (app f d) (app g d)))))) 36 | 37 | (define D-less-eq? 38 | (lambda (n) 39 | (cond [(equal? n 0) 40 | (lambda (a b) 41 | (or (and (eq? a 'bot) (eq? b 'top)) 42 | (eq? a b)))] 43 | [else 44 | (let ([rng-less-eq? (D-less-eq? (- n 1))]) 45 | (pointwise-less-eq? rng-less-eq? (D (- n 1))))]))) 46 | 47 | (define D-join 48 | (lambda (n) 49 | (cond [(equal? n 0) 50 | (lambda (a b) 51 | (match `(,a ,b) 52 | [`(top top) 'top] 53 | [`(top bot) 'top] 54 | [`(bot top) 'top] 55 | [`(bot bot) 'bot]))] 56 | [else 57 | (lambda (f g) 58 | (let ([D-join-prev (D-join (- n 1))]) 59 | (for/list ([d (D (- n 1))]) 60 | (cons d (D-join-prev (app f d) (app g d))))))]))) 61 | 62 | (define D-inf-join 63 | (lambda (d1 d2) 64 | (for/list ([n '(0 1 2)]) 65 | ((D-join n) (list-ref d1 n) (list-ref d2 n))))) 66 | 67 | (define monotonic? 68 | (lambda (dom dom-less-eq? rng-less-eq?) 69 | (lambda (f) 70 | (for/and ([d1 dom]) 71 | (for/and ([d2 dom]) 72 | (cond [(dom-less-eq? d1 d2) 73 | (rng-less-eq? (app f d1) (app f d2))] 74 | [else #t])))))) 75 | 76 | (define check-fun 77 | (lambda (fun dom rng) 78 | (for/and ([p fun]) 79 | (and (if (member (car p) dom) #t #f) 80 | (if (member (cdr p) rng) #t #f))))) 81 | 82 | ;;(display (D 1))(newline) 83 | ;;(display (D 2))(newline) 84 | ;; (D 3) runs out of memory! 85 | ;; (display (D 3))(newline) 86 | (define D0 (D 0)) 87 | (define D1 (D 1)) 88 | (define D2 (D 2)) 89 | 90 | (for ([f D1]) 91 | (check-equal? (check-fun f D0 D0) #t)) 92 | (for ([f D2]) 93 | (check-equal? (check-fun f D1 D1) #t)) 94 | 95 | (define embed 96 | (lambda (n) 97 | (if (and (< n 2) (<= 0 n)) '() (error 'embed "out of bounds, n = ~s" n)) 98 | (cond [(equal? n 0) 99 | (lambda (d) 100 | (map (lambda (x) (cons x d)) (D 0)))] 101 | [else 102 | (lambda (d) 103 | (map (lambda (x) 104 | (cons x ((embed (- n 1)) (app d ((project (- n 1)) x))))) 105 | (D n)))]))) 106 | 107 | (define project 108 | (lambda (n) 109 | (if (and (< n 2) (<= 0 n)) '() (error 'project "out of bounds, n = ~s" n)) 110 | (cond [(equal? n 0) 111 | (lambda (d) 112 | (app d 'bot))] 113 | [else 114 | (lambda (d) 115 | (map (lambda (x) 116 | (cons x ((project (- n 1)) (app d ((embed (- n 1)) x))))) 117 | (D (- n 1))))]))) 118 | 119 | (define d0 ((embed 0) 'bot)) 120 | (define d1 '((bot . bot) (top . top))) 121 | (define d2 ((embed 0) 'top)) 122 | 123 | (define d000 ((embed 1) d0)) 124 | (define d002 ((embed 1) d1)) 125 | (define d012 `((,d0 . ,d0) (,d1 . ,d1) (,d2 . ,d2))) 126 | (define d111 `((,d0 . ,d1) (,d1 . ,d1) (,d2 . ,d1))) 127 | (define d112 `((,d0 . ,d1) (,d1 . ,d1) (,d2 . ,d2))) 128 | (define d222 ((embed 1) d2)) 129 | 130 | (check-equal? ((project 0) ((embed 0) 'bot)) 'bot) 131 | (check-equal? ((project 0) ((embed 0) 'top)) 'top) 132 | 133 | (check-equal? (check-fun ((embed 1) d1) D1 D1) #t) 134 | 135 | (check-equal? ((project 1) d000) d0) 136 | (check-equal? ((project 1) d002) d1) 137 | (check-equal? ((project 1) d012) d1) 138 | (check-equal? ((project 1) d111) d0) 139 | (check-equal? ((project 1) d112) d1) 140 | (check-equal? ((project 1) d222) d2) 141 | 142 | (check-equal? ((D-join 0) 'bot 'bot) 'bot) 143 | (check-equal? ((D-join 0) 'bot 'top) 'top) 144 | (check-equal? ((D-join 1) d0 d0) d0) 145 | (check-equal? ((D-join 1) d0 d1) d1) 146 | (check-equal? ((D-join 1) d1 d2) d2) 147 | (check-equal? ((D-join 1) d2 d2) d2) 148 | (check-equal? ((D-join 2) d000 d000) d000) 149 | (check-equal? ((D-join 2) d002 d111) d112) 150 | 151 | (define project-from-inf 152 | (lambda (n) 153 | (lambda (d) 154 | (list-ref d n)))) 155 | 156 | (define embed-to-inf 157 | (lambda (n) 158 | (lambda (d) 159 | (for/list ([i '(0 1 2)]) 160 | (cond [(< i n) 161 | (for/fold ([x d]) ([j (range 0 (- n i))]) 162 | (values ((project (- n j 1)) x)))] 163 | [(= i n) 164 | d] 165 | [(> i n) 166 | (for/fold ([x d]) ([j (range 0 (- i n))]) 167 | (values ((embed (+ n j)) x)))]))))) 168 | 169 | (check-equal? ((embed-to-inf 0) 'bot) `(bot ,d0 ,d000)) 170 | (check-equal? ((embed-to-inf 1) d0) `(bot ,d0 ,d000)) 171 | 172 | (define abstr 173 | (lambda (f) 174 | (foldl D-inf-join `(bot ,d0 ,d000) 175 | (for/list ([n '(0 1)]) 176 | ;(display n)(newline) 177 | (let ([dom (D n)]) 178 | ;(pretty-print dom)(newline) 179 | (let ([g (for/list ([d dom]) 180 | (let ([d1 ((embed-to-inf n) d)]) 181 | ;(display 'd1)(display d1)(newline) 182 | (let ([d2 (f d1)]) 183 | ;(display 'd2)(display d2)(newline) 184 | (let ([d3 ((project-from-inf n) d2)]) 185 | ;(display 'd3)(display d3)(newline) 186 | (cons d d3)))))]) 187 | ;(pretty-print g)(newline) 188 | ((embed-to-inf (+ n 1)) g))))))) 189 | 190 | (define apply 191 | (lambda (rator) 192 | (lambda (rand) 193 | (foldl D-inf-join `(bot ,d0 ,d000) 194 | (for/list ([n '(0 1)]) 195 | ((embed-to-inf n) (app (list-ref rator (+ n 1)) (list-ref rand n)))))))) 196 | 197 | ;; problem 1 198 | (check-equal? (abstr (lambda (x) x)) `(bot ,d1 ,d012)) 199 | 200 | ;; problem 2 201 | (check-equal? (abstr (lambda (d) `(bot ,d1 ,d012))) `(bot ,d0 ,d111)) 202 | 203 | ;; problem 3 204 | (check-equal? (abstr (lambda (d) (abstr (lambda (d2) d)))) `(bot ,d1 ,d002)) 205 | 206 | ;; problem 4 207 | (check-equal? ((apply `(bot ,d1 ,d012)) `(bot ,d1 ,d012)) `(bot ,d1 ,d002)) 208 | -------------------------------------------------------------------------------- /hw1.md: -------------------------------------------------------------------------------- 1 | 2 | * Read chapters 4 and 5 of Schmidt's book on Denotational Semantics. 3 | 4 | * Read chapter 1 of my notes, concerning Binary Arithmetic. 5 | 6 | * Do exercises 1, 2, 3, and 4 and submit your answers in LaTeX. 7 | -------------------------------------------------------------------------------- /hw2.md: -------------------------------------------------------------------------------- 1 | * Read chapter 6 of Schmidt's book. 2 | 3 | * Read chapter 2 of my notes concerning IMP. 4 | 5 | * Do exercises 5, 6, and 7 in my notes. 6 | 7 | * Do exercises 2(a), 3, 8 in chapter 6 of Schmidt's book. 8 | -------------------------------------------------------------------------------- /hw3.md: -------------------------------------------------------------------------------- 1 | - Read [Chapter 2](GunterCh2.pdf) of Gunter's textbook. 2 | - From Chapter 2 of Gunter 3 | - exercises 2.3 and 2.5 (on pages 46 and 47) 4 | - exercise 2.10 (on page 60) 5 | 6 | -------------------------------------------------------------------------------- /hw4.md: -------------------------------------------------------------------------------- 1 | - Read: [Revisiting Elementary Denotational Semantics](https://arxiv.org/abs/1707.03762), Siek 2017. 2 | - Fill in the proof of Lemma 5 (Reverse substitution preserves meaning). 3 | - Read: sections [2.1](Lambda2_1.pdf), [5.3](Lambda5_3.pdf), and [5.4](Lambda5_4.pdf) of 4 | The Lambda Calculus: its Syntax and Semantics, Barendregt 1984. 5 | - Do exercise 5.8.7 (i) (page 128) of Barendregt 1984, which states: 6 | Compute [|M|]^{D_A} for M = I, K, S, \Omega. Which of these sets is empty? 7 | -------------------------------------------------------------------------------- /hw5.md: -------------------------------------------------------------------------------- 1 | - Read sections 1, 2, and 4 of [Data Types as Lattices](https://www.dropbox.com/s/ikfyrwkizooah3q/data_types_as_lattices.pdf?dl=1) Update: I obtained a better typeset version from Scott which is [here](./ScottDTL1976.pdf). 2 | - Look up the definitions of 3 | * topological space, 4 | * open set, 5 | * a basis for a topological space, 6 | * and continuous functions between topological spaces. 7 | Give an instance of the above notions for the real number line. 8 | - Prove that P(ω) is a topological space (as defined via open sets), 9 | using the basis given by Scott on page 584. 10 | - Prove that a function is continuous (page 584) 11 | iff it is continuous in the topological sense, that is, 12 | if inverse images of open sets are open sets. 13 | - Restate the proof of Theorem 2.2 in your own words. 14 | (The proof is in the Appendix, page 642.) 15 | - Prove that (1), (2), and (3) on page 604 are retracts. 16 | - Given the definition of int in equation (7) on page 606, prove that 17 | int(\bot) = \bot 18 | int(n) = n (n is an integer) 19 | int(\top) = \top 20 | - Work out the semantics of (λx.x+1)(2) using the semantics defined 21 | on page 613. Show your work. 22 | -------------------------------------------------------------------------------- /hw6.md: -------------------------------------------------------------------------------- 1 | - Read [Intersection Types and Lambda Models](https://doi.org/10.1016/j.tcs.2006.01.004) 2 | - Prove associativity of intersection with respect to the type 3 | preorder using the axioms in Fig. 1. 4 | - Define an isomorphism (a function and its inverse) between Engeler's 5 | domain: 6 | D = ℤ + ℘f(D) × D 7 | and intersection types (taking ℂ to be {Ω} ∪ ℤ), using the rules (→-∩~), 8 | (η~), and (Ω-η). Define an ordering relation on Engeler's domain and 9 | show that this ordering is the inverse of subtyping, as in 10 | Proposition 3 of [Revisiting Elementary Denotational Semantics](https://arxiv.org/abs/1707.03762). 11 | - Use results from the paper [Intersection Types and Lambda Models](https://doi.org/10.1016/j.tcs.2006.01.004) to show that the filter model 12 | for the intersetions type system En corresponding to Engeler's domain. 13 | -------------------------------------------------------------------------------- /hw7.md: -------------------------------------------------------------------------------- 1 | - Read Nate Foster's [lecture notes](http://www.cs.cornell.edu/courses/cs6110/2011sp/lectures/lecture24.pdf) on the D∞ model of the λ-calculus. 2 | - I believe there is an error in the definition of down(f). 3 | Instead of d_0 = f(\bot) it should be d_0 = \bot. 4 | - Compute the meaning of (λx.x), (λx.λy.y), (λx.λy.x), and ((λx.x) (λx.x)), 5 | but only giving the first three elements of the infinite tuple. 6 | Instead of using Nate's definitions of up and down, I recommend using 7 | Scott's definitions which can be found in my notes 8 | (where they are named apply and abstr). 9 | 10 | -------------------------------------------------------------------------------- /hw8.md: -------------------------------------------------------------------------------- 1 | - Read [An introduction to the category-theoretic solution of recursive domain equations](https://pure.tue.nl/ws/files/2401150/8930814.pdf) 2 | - TBD 3 | -------------------------------------------------------------------------------- /scribbles.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | B629 Topics in Programming Languages 4 | Indiana University 5 | Spring 2018 6 | 7 | Denotational semantics via domains, graphs, and types. 8 | 9 | Description 10 | ----------- 11 | 12 | In this course we shall study the denotational semantics of 13 | programming languages, including the classic lattic-theoretic models 14 | as well as elementary models based on functions-as-graphs and 15 | intersection types. The course assignments will include readings from 16 | selected chapters and papers from the literature, presentations, 17 | written homework, and some programming. 18 | 19 | Readings 20 | ----------- 21 | 22 | Denotational semantics: a methodology for language development, 23 | David Schmidt, 1986. (pdf available online) 24 | Ch. 4 Binary arithmetic and a calculator 25 | Ch. 5 Imperative Languages 26 | Ch. 6 domain theory (for loops and recursive functions) 27 | Ch. 7 lambda calculus 28 | Ch. 9 continuations 29 | Ch. 11 inverse limit construction 30 | 31 | The denotational semantics of programming languages, 32 | Tennent, CACM 1976. 33 | LOOP language: natural numbers, loops, input/output, continuations 34 | AEXP 35 | GEDANKEN 36 | 37 | ?? Denotational Semantics. P. Mosses, 1989. 38 | 39 | ?? Semantics domains. Gunter and Scott, 1989. 40 | 41 | ?? Semantics of Programming Languages: Structures and Techniques 42 | Gunter, 1992. 43 | 44 | ?? Denotational Semantics: The Scott-Strachey Approach to PL Theory. 45 | Joseph Stoy, 1977. 46 | 47 | ?? A Theory of Programming Language Semantics, Milne and Strachey. 48 | 49 | ?? Domains and Lambda Calculi, Amadio and Curien, 1998. 50 | 51 | Outline of a Mathematical Theory of Computation, Dana Scott 1970 52 | D∞ 53 | 54 | Data Types as Lattices, Dana Scott 1976 55 | Pω 56 | 57 | ?? Notes on a lattice-theoretical approach to the theory of computation 58 | John Reynolds, 1972. 59 | 60 | The Lambda Calculus: its Syntax and Semantics. Barendregt 1984. 61 | Def. of λ-model? 62 | 63 | ?? What is a Model of the Lambda Calculus? 64 | Albert Meyer, Inf. and Control, 1982. 65 | 66 | ?? The category-theoretic solution of recursive domain equations 67 | Smyth and Plotkin, Siam Journal on Computing, 1982. 68 | 69 | Set-theoretical and other elementary models of the λ-calculus, 70 | Plotkin 1993. 71 | 72 | Algebras and combinators, Engeler, 1981. 73 | 74 | Functional characterization of some semantic equalities 75 | inside λ-calculus, Coppo, Dezani-Ciancaglini, Salle 1979. 76 | 77 | Functional Characters of Solvable Terms 78 | Coppo, Dezani-Ciancaglini, Venneri, Math. Logic Quart. 1981. 79 | 80 | A filter lambda model and the completeness of type assignment, 81 | Barendregt, Coppo, Dezani-Ciancaglini, 1983. 82 | (BCD) 83 | 84 | ?? Extended Type Structures and Filter Lambda Models, 85 | Coppo, Dezani-Ciancaglini, Honsell, Longo, 1984. 86 | 87 | Intersection Types and Lambda Models 88 | Alessi, Barbanera, Dezani-Ciancaglini, TCS 2006. 89 | 90 | Recursive Domain Equations of Filter Models, 91 | Alessi, Severi, SOFSEM 2008. 92 | 93 | Revisiting Elementary Denotational Semantics, 94 | Siek, draft 2017. 95 | 96 | Lambda Calculus with Types, Barendregt, Dekkers, Statman, 2013. 97 | 98 | Notions of computation and monads, Moggi, 1991. 99 | 100 | ?? An Abstract View of Programming Languages, Moggi, 1989. 101 | (Monads, Category Theory) 102 | 103 | Something about PCF and full abstraction 104 | 105 | ??A fully abstract semantics for concurrent graph reduction. 106 | Alan Jeffrey 1993. 107 | 108 | Full abstraction in the lazy lambda calculus, 109 | Abramsky and Ong, Inf. and Comp., 1993. 110 | 111 | Observable sequentiality and full abstraction, 112 | Cartwright and Felleisen, POPL 1992. 113 | 114 | Towards Compatible and Interderivable Semantic Specifications for the 115 | Scheme Programming Language, Part I: Denotational Semantics, Natural 116 | Semantics, and Abstract Machines 117 | Olivier Danvy, 2009. 118 | 119 | Languages to consider 120 | --------------------- 121 | 122 | Binary numerals and arithmetic (Schmidt) 123 | Regular expressions 124 | IMP (or While) 125 | λ-calculus (Full, CBN, Lazy, CBV) 126 | Scheme 127 | PCF 128 | SPCF 129 | 130 | loops 131 | input/output 132 | recursive functions 133 | errors 134 | exceptions 135 | continuations 136 | recursive types 137 | 138 | 139 | Notes 140 | ----- 141 | 142 | domain theory in logical form 143 | ω-algebraic complete lattices 144 | types are compact elements of Plotkin's λ-structures 145 | Stone duality 146 | Topology via Logic 147 | 148 | 149 | 150 | * The Lambda Calculus: its Syntax and Semantics. Barendregt 1984. 151 | Chapter 5 152 | retract 153 | cartesian closed category? 154 | 155 | λ-algebra: satisfy equations of the λ-calculus, 156 | form an equational class axiomatized by kxy=x, sxyz=xz(yz), 157 | and five combinatory axioms of Curry 158 | λ-model: satisfy equations of the λ-calculus and also 159 | weak extensionality: ∀x(M=N) ⇒ λx.M = λx.N 160 | 161 | 5.4 Models in Cartesian Closed Categories 162 | 163 | "we will describe the models D_A introduced by Engeler [1981] 164 | as a simplification of the graph model Pω introduced in §18.1." 165 | 166 | Let A be an arbitrary set. 167 | B = A + P_f(B) × B 168 | D_A = P(B) 169 | 170 | For x,y ∈ D_A, f ∈ [D_A → D_A] 171 | x ⋅ y = { b | ∃β. β ⊆ y and (β,b) ∈ x } 172 | λG x. f(x) = { (β,b) | β ∈ P_f(B) and b ∈ f(β) } 173 | 174 | 5.4.6 Theorem D_A is a reflexive cpo by definining 175 | F(x)(y) = x ⋅ y 176 | G(f) = λG x. f(x). 177 | Therefore D_A is a λ-model. 178 | 179 | See exercises 5.77, 18.5.29, 18.4.31 for more information about D_A. 180 | 181 | Chapter 18 182 | 183 | e(n) = {k_0,...,k_m-1} such that n = sum 2^{k_i} 184 | 185 | [x]ρ = ρ(x) 186 | [M N]ρ = {m | ∃n. e(n) ⊆ [N]ρ and (n,m) ∈ [M]ρ } 187 | [λx.M]ρ = { (n,m) | m ∈ [M]ρ(x:=e(n)) } 188 | 189 | So yes, Pω is just an encoding of D_A into natural numbers! 190 | 191 | 192 | * Koymans [1982] history of lambda models 193 | 194 | 195 | topology for P(N) 196 | 197 | Def. A basis (basic set) is the upward closed set of set(n), for a given n. 198 | That is, { S | set(n) ⊆ S } 199 | 200 | Def. An open subset is a union of basic sets. 201 | 202 | The finite sets, set(n), are dense in that every S ∈ P(N) 203 | is the "limit" (lub) of its finite subsets 204 | S = { set(n) | set(n) ⊆ S } 205 | 206 | -------------------------------------------------------------------------------- /topology.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{amsthm} 3 | \usepackage{amsmath} 4 | \usepackage{amssymb} 5 | \usepackage{stmaryrd} 6 | \usepackage{hyperref} 7 | \usepackage{xypic} 8 | 9 | \newtheorem{theorem}{Theorem}%[section] 10 | \newtheorem{lemma}[theorem]{Lemma} 11 | \newtheorem{proposition}[theorem]{Proposition} 12 | \newtheorem{corollary}{Corollary} 13 | \newtheorem{definition}{Definition}%[section] 14 | \newtheorem{conjecture}{Conjecture}%[section] 15 | \newtheorem{example}{Example}%[section] 16 | \newtheorem{remark}{Remark} 17 | 18 | \newcommand{\Reals}[0]{\mathbb{R}} 19 | \newcommand{\Rats}[0]{\mathbb{Q}} 20 | 21 | \title{Notes on Topology} 22 | 23 | \author{Jeremy G. Siek} 24 | 25 | \begin{document} 26 | \maketitle 27 | 28 | Questions: 29 | \begin{itemize} 30 | \item What is the relationship between $\epsilon$-$\delta$ continuity 31 | (i.e. limit-based continuity) on reals and continuity for complete 32 | partial orders? 33 | \item How does the slogan: ``only finite input is needed to produce 34 | finite output'' apply to continuous functions on the reals? 35 | \item How does this relate to the topology on $\mathcal{P}(\mathbb{N})$? 36 | \end{itemize} 37 | 38 | 39 | From Wikipedia: 40 | \begin{quote} 41 | ``For example, in order theory, an order-preserving function $f: X \to 42 | Y$ between particular types of partially ordered sets $X$ and $Y$ is 43 | continuous if for each directed subset A of X, we have $\bigsqcup 44 | f(A) = f(\bigsqcup A)$. Here $\bigsqcup$ is the least-upper bound 45 | with respect to the orderings in $X$ and $Y$, respectively. This 46 | notion of continuity is the same as topological continuity when the 47 | partially ordered sets are given the Scott topology.'' 48 | \end{quote} 49 | 50 | From Davey and Priestley: 51 | \begin{quote} 52 | ``In analysis, a function is continuous if it preserves limits. 53 | In a context in which a computation is modelled as the join (= limit) 54 | of a directed set, it is natural to consider a map as being continuous if it is compatible with 55 | the formation of directed joins. Formally, we say $f : P \to Q$ is continuous if, 56 | for every directed set $D$ in $P$, the subset $f(Q)$ of $Q$ is directed and 57 | \[ 58 | f\left(\sqcup D\right) = \bigsqcup \{ f(x) \mid x \in D \} 59 | \] 60 | ... every continous map is order preserving. Where the order represents 'is less defined than' 61 | or 'is a worse approximation then', an order-preserving map $f$ is one in which the 62 | better the input $x$, the better the output $f(x)$. 63 | \end{quote} 64 | 65 | \section{Topology on $\Reals$} 66 | 67 | We consider topological notions in the familiar setting of the real 68 | numbers $\Reals$. 69 | 70 | \begin{definition}[Open Interval] 71 | $\mathcal{I}_r(x) = (x-r,x+r)$ 72 | \end{definition} 73 | 74 | \begin{definition}[Accumulation Point] 75 | A point $x \in \Reals$ is an accumulation point of $A \subseteq 76 | \Reals$ if for every $\delta > 0$, there exists $z \in 77 | \mathcal{I}_\delta(x) \cap A$ such that $z \neq x$. 78 | \end{definition} 79 | 80 | 81 | \begin{definition}[Limit of Function] 82 | Suppose $f : A \to \Reals$ and $A \subseteq \Reals$. 83 | Suppose $c \in \Reals$ is an accumulation point of $A$. 84 | Then 85 | \[ 86 | \lim_{x\to c} f(x) = \ell 87 | \] 88 | if for every $\epsilon > 0$ there exists a $\delta > 0$ 89 | such that 90 | \[ 91 | x \in \mathcal{I}_\delta(c) \implies f(x) \in \mathcal{I}_\epsilon(\ell) 92 | \] 93 | \end{definition} 94 | 95 | \begin{definition}[Continuous] 96 | A function $f : A \to \Reals$, with $A \subseteq \Reals$, 97 | is continuous at $c \in A$ if $f$ preserves the limit at $c$: 98 | \[ 99 | \lim_{x\to c} f(x) = f(c) 100 | \] 101 | or equivalently, expanding the definition of limit, for every 102 | $\epsilon > 0$, there exists $\delta > 0$ such that 103 | \[ 104 | |x - c| < \delta \land x \in A \implies |f(x) - f(c)| < \epsilon 105 | \] 106 | or in terms of open intervals, 107 | \[ 108 | x \in \mathcal{I}_\delta(c) \land x \in A \implies f(x) \in \mathcal{I}_\epsilon(f(c)). 109 | \] 110 | 111 | A function $f$ is continuous on a set $B \subseteq A$ if it is 112 | continuous on every element in B. 113 | \end{definition} 114 | 115 | \begin{example} 116 | $f(x) = \sqrt x$ is continuous at all $c > 0$. 117 | For $0 \leq x$, we calculate 118 | \begin{equation}\label{eq:sqrt-cont-1} 119 | |f(x) - f(c)| = |\sqrt x - \sqrt c| 120 | = \left| \frac{x - c}{\sqrt x + \sqrt c} \right| 121 | \leq \frac{1}{\sqrt c} |x - c| 122 | \end{equation} 123 | Choose $\delta = \epsilon \sqrt c$. Assume $|x - c| < \epsilon \sqrt c$ 124 | and $x \in A$. We need to show that $|\sqrt x - \sqrt c| < \epsilon$. 125 | From the assumption we have $\frac{1}{\sqrt c}|x - c| < \epsilon$, 126 | and then by calculation \eqref{eq:sqrt-cont-1} we conclude. 127 | \end{example} 128 | 129 | \begin{example} 130 | \[ 131 | \mathrm{sign}(x) = 132 | \begin{cases} 133 | 1 & \text{if } x > 0 \\ 134 | 0 & \text{if } x = 0 \\ 135 | -1 & \text{if } x < 0 136 | \end{cases} 137 | \] 138 | $\mathrm{sign}$ is not continuous at $0$. Consider $\epsilon = \frac{1}{2}$. 139 | We have $|f(x)| = 1$ for any $x \neq 0$, no matter how close $x$ is to 140 | $0$. And obviously, $|f(x)| = 1 \not < \frac{1}{2}$. 141 | \end{example} 142 | 143 | 144 | \begin{definition}[Neighborhood] 145 | A set $U \subseteq \Reals$ is a neighborhood of $x \in \Reals$ 146 | if there is a $\delta > 0$ such that $\mathcal{I}_\delta(x) \subseteq U$. 147 | (Munkres instead defines a neighborhood of $x$ to be 148 | an open set containing $x$.) 149 | \end{definition} 150 | 151 | 152 | \begin{definition}[N-Continuous] 153 | A function $f : A \to \Reals$, with $A \subseteq \Reals$, 154 | is n-continuous at $c \in A$ if for every neighborhood 155 | $V$ of $f(c)$ there exists a neighborhood $U$ of $c$ 156 | such that 157 | \[ 158 | x \in A \cap U \implies f(x) \in V 159 | \] 160 | \end{definition} 161 | 162 | \begin{proposition} 163 | Continuous and n-continuous are equivalent. 164 | \end{proposition} 165 | \begin{proof} 166 | Intuitively, the reason that they are the same is that in the 167 | definition of continuity, we talk of all the $x$'s that are within 168 | a certain distance of $c$, which means we're talking about an open 169 | interval around $c$, and a neighborhood of $c$ is guaranteed to 170 | include such a open interval around $c$. (And similarly for an open 171 | interval around $f(c)$.) 172 | \begin{enumerate} 173 | \item (continuous $\implies$ n-continuous) 174 | Suppose $f$ is continuous at $c$. 175 | Let $V$ be a neighborhood of $f(c)$. 176 | By the definition of neighborhood there exists a $\epsilon > 0$ such that 177 | \begin{equation} \label{eq:ball-V-1} 178 | \mathcal{I}_\epsilon(f(c)) \subseteq V 179 | \end{equation} 180 | Because $f : A \to \Reals$ is continuous at $c$, 181 | there exists $\delta > 0$ such that 182 | \begin{equation} \label{eq:ed-cont-1} 183 | |x - c| < \delta \land x \in A \implies |f(x) - f(c)| < \epsilon 184 | \end{equation} 185 | Choose $U=\mathcal{I}_\delta(c)$. We need to show 186 | \[ 187 | x \in A \cap U \implies f(x) \in V 188 | \] 189 | We assume $x \in A \cap U$. Then by \eqref{eq:ed-cont-1} we have 190 | $|f(x) - f(c)| < \epsilon$. So $f(x) \in \mathcal{I}_\epsilon(f(c))$ 191 | and then $f(x) \in V$ by \eqref{eq:ball-V-1}. 192 | Therefore $f$ is n-continuous. 193 | 194 | \item (n-continuous $\implies$ continuous) Suppose $f$ is 195 | n-continouous at $c$ and $\epsilon > 0$. Note that 196 | $\mathcal{I}_\epsilon(f(c))$ is a neighborhood of $f(c)$. Then because $f$ 197 | n-continuous there is a neighborhood $U$ of $c$ such that 198 | \begin{equation}\label{eq:xU-fx-Be} 199 | x \in A \cap U \implies f(x) \in \mathcal{I}_\epsilon(f(c)) 200 | \end{equation} 201 | Because $U$ is a neighborhood of $c$, there is a $\delta > 0$ 202 | such that $\mathcal{I}_\delta(c) \subseteq U$. We need to show that 203 | \[ 204 | |x - c| < \delta \land x \in A \implies |f(x) - f(c)| < \epsilon 205 | \] 206 | Assume $|x - c| < \delta$ and $x \in A$. 207 | We have $x \in U$, then by \eqref{eq:xU-fx-Be} obtain 208 | $f(x) \in \mathcal{I}_\epsilon(f(c))$. From this we conclude that 209 | $|f(x) - f(c)| < \epsilon$. Therefore $f$ is continuous. 210 | 211 | \end{enumerate} 212 | \end{proof} 213 | 214 | 215 | \begin{definition}[Open Set] 216 | A set $A$ is open in $\Reals$ if for every $x \in A$ there exists 217 | $\delta > 0$ such that $\mathcal{I}_\delta(x) \subseteq A$. 218 | \end{definition} 219 | 220 | \begin{definition}[O-Continuous] 221 | A function $f : A \to \Reals$ is o-continuous if for each 222 | open set $V \subseteq \Reals$, $f^{-1}(V)$ is an open subset of $A$. 223 | \end{definition} 224 | 225 | \begin{proposition} 226 | Continuous and o-continuous are equivalent. 227 | \end{proposition} 228 | \begin{proof}\ 229 | \begin{enumerate} 230 | \item (continuous $\implies$ o-continuous) 231 | Let $V \subseteq \Reals$ be an open set. 232 | We need to show that $f^{-1}(V)$ is an open set. 233 | Let $c$ be an arbitrary member of $f^{-1}(V)$. We need 234 | to show that there exists an open interval around $c$ 235 | that is contained by $f^{-1}(V)$. 236 | % 237 | We have $f(c) \in V$. Then because $V$ is open, there exists 238 | $\epsilon > 0$ such that 239 | \begin{equation}\label{eq:i-fc-v} 240 | \mathcal{I}_\epsilon(f(c)) \subseteq V 241 | \end{equation} 242 | Then by the 243 | continuity of $f$, there is a $\delta > 0$ such that 244 | \begin{equation}\label{eq:fx-iefc} 245 | x \in \mathcal{I}_\delta(c) \implies f(x) \in \mathcal{I}_\epsilon(f(c)) 246 | \end{equation} 247 | Now that we have an appropriate $\delta$, we need to show 248 | \[ 249 | \mathcal{I}_\delta(c) \subseteq f^{-1}(V) = \{ x \mid f(x) \in V \} 250 | \] 251 | Let $x$ be an arbitrary point in $\mathcal{I}_\delta(c)$. So by 252 | \eqref{eq:fx-iefc} we have $f(x) \in \mathcal{I}_\epsilon(f(c))$. Then by 253 | \eqref{eq:i-fc-v} we have $f(x) \in V$, therefore $x \in f^{-1}(V)$. 254 | 255 | 256 | \item (o-continuous $\implies$ continuous) Let $\epsilon > 0$. Observe 257 | that $V=\mathcal{I}_\epsilon(f(c))$ is an open set. Then because $f$ is 258 | o-continuous, $f^{-1}(V)$ is an open set. We know $c \in 259 | f^{-1}(V)$, so there exists a $\delta > 0$ such that 260 | \begin{equation}\label{eq:id-fv} 261 | \mathcal{I}_\delta(c) \subseteq f^{-1}(V) 262 | \end{equation} 263 | We need to show that 264 | \[ 265 | x \in \mathcal{I}_\delta(c) \implies f(x) \in V 266 | \] 267 | We assume $x \in \mathcal{I}_\delta(c)$, so also $x \in f^{-1}(V)$ 268 | by \eqref{eq:id-fv} and therefore $f(x) \in V$. 269 | 270 | \end{enumerate} 271 | \end{proof} 272 | 273 | 274 | 275 | 276 | 277 | \begin{definition}[S-Continuous] 278 | Suppose $f : A \to \Reals$ and $A \subseteq \Reals$. 279 | Let $(x_n)_{n \in \mathbb{N}}$ be a sequence in $A$. 280 | If $(x_n)$ converges to $c$, then $(f(x_n))$ converges to $f(c)$. 281 | \[ 282 | \lim_{n\to\infty} x_n = c \implies 283 | \lim_{n\to\infty} f(x_n) = f(c) 284 | \] 285 | \end{definition} 286 | 287 | 288 | \paragraph{Rational (Finite) Approximations of Reals} 289 | 290 | Next we talk about using rational intervals to approximate real 291 | numbers. For $p,q \in \Rats$ with $p \leq q$, the pair $\langle p,q \rangle$ 292 | represents the closed interval from $p$ to $q$. Alternatively, one can 293 | consider an interval centered at $r$ with error bound $e$, but then we 294 | just have $p = r-e$ and $q = r+e$. We form a partial order 295 | $\mathcal{R}$ containing both the real numbers and the rational 296 | intervals. 297 | \[ 298 | \mathcal{R} = \Reals \cup \{ \langle p,q \rangle \mid p,q \in \Rats \} 299 | \] 300 | Each rational interval can be viewed as a finite approximation for any 301 | real number $x$ within the interval. 302 | \[ 303 | \langle p,q \rangle \sqsubseteq x \qquad \text{iff } p \leq x \leq q 304 | \] 305 | An interval $\langle p_1,q_1 \rangle$ is a worse approximation than interval 306 | $\langle p_2,q_2 \rangle$ if the first interval contains the second, i.e. 307 | \[ 308 | \langle p_1,q_1 \rangle \sqsubseteq \langle p_2,q_2 \rangle 309 | \qquad 310 | \text{iff } 311 | p_1 \leq p_2 312 | \text{ and } 313 | q_2 \leq q_1 314 | \] 315 | \[ 316 | \xymatrix@=15pt{ 317 | \underset{p_1}{\bullet} \ar@{-}[rrr] & & & 318 | \underset{p_2}{\bullet} \ar@{-}[rr] & & 319 | \underset{q_2}{\bullet} \ar@{-}[r] & 320 | \underset{q_1}{\bullet} 321 | } 322 | \] 323 | The interval $\langle q,q \rangle$ is just as good an approximation of the rational 324 | number $q$ as $q$, so we have 325 | \[ 326 | q \sqsubseteq \langle q,q \rangle 327 | \] 328 | And of course, every real $x \in \Reals$ is an equally good 329 | approximation to itself. 330 | \[ 331 | x \sqsubseteq x 332 | \] 333 | We write $a \sqsubset b$ if $a \sqsubseteq b$ and $a \neq b$. 334 | 335 | 336 | The join $\sqcup$ is induced by the $\sqsubseteq$ ordering, so $a 337 | \sqcup b$ is the least upper bound of $\{a,b\}$. Similarly, the meet 338 | $a \sqcap b$ is greatest lower bound of $\{a,b\}$. For example, the 339 | join $\sqcup$ of two intervals collects their common information, that 340 | is, it is the intersection of the two intervals. 341 | \[ 342 | \langle p_1,q_1 \rangle \sqcup \langle p_2,q_2 \rangle = \langle \max(p_1, p_2), \min(q_1, q_2) \rangle 343 | \] 344 | Given a subset $S \subseteq \mathcal{R}$, the least upper bound of $S$ 345 | is written $\bigsqcup S$. Some sets of rational intervals do not have 346 | a least upper bound because they have no intersection, such as $\{ 347 | \langle 0,\frac{1}{3} \rangle, \langle \frac{2}{3},1 \rangle \}$. A 348 | real number can be identified by the least upper bound of an infinite 349 | set of rational intervals. If we have an infinite sequence of 350 | intervals that are progressively better approximations 351 | \[ 352 | a_1 \sqsubset a_2 \sqsubset a_3 \sqsubset \cdots 353 | \] 354 | then the Nested Intervals Theorem says the sequence will have a real 355 | number as its least upper bound 356 | \[ 357 | \bigsqcup \{ a_1,a_2,a_3,\ldots \} \in \Reals 358 | \] 359 | 360 | 361 | Need to review what is a real number. 362 | \begin{itemize} 363 | \item Dedekind: a real number is a pair $\langle L, R \rangle$ 364 | where $L$ and $R$ are sets of rational numbers that partition 365 | $\Rats$ and that for every $p \in L, q \in R$ we have $p < q$. 366 | \end{itemize} 367 | 368 | %% The meet $\sqcap$ of two intervals is the interval that contains both 369 | %% of them. (Or should we add collections of intervals to $\mathcal{R}$ 370 | %% as in Vickers?) 371 | %% \[ 372 | %% \langle p_1,q_1 \rangle \sqcap \langle p_2,q_2 \rangle = \langle \min(p_1, p_2), \max(q_1, q_2) \rangle 373 | %% \] 374 | %% Given a subset $S \subseteq \mathcal{R}$, the greatest lower bound of 375 | %% $S$ is written $\bigsqcap S$. 376 | 377 | 378 | Now let us consider functions on real numbers, and how we might 379 | approximate them on rationals. Suppose $f \in A \to \Reals$ and $x \in 380 | A \subseteq \Reals$. We wish we could have the exact result $f(x)$ but 381 | will be satisfied if we are given a rational interval $\langle p', q' 382 | \rangle$ that contains $f(x)$ and that is small enough, i.e., $|p' - 383 | q'| < \epsilon$ for some choice of $\epsilon$. If $f$ is continuous, 384 | then we know there is a $\delta$ such that 385 | \[ 386 | \forall y.\; |y-x| < \delta \implies |f(y) - f(x)| < \epsilon 387 | \] 388 | If we can find a rational number $p$ that is close enough to $x$, that 389 | is, $|p-x| < \delta$, then we'll know that $f(p)$ is close enough to 390 | $f(x)$, that is $|f(p) - f(x)| < \epsilon$. 391 | 392 | Is there a sequence of rational intervals for every real number? If 393 | so, then we can march through the sequence $\langle p_1,q_1 \rangle, 394 | \langle p_2,q_2 \rangle, \ldots$ until we get to an interval $\langle 395 | p_i,q_i \rangle$ that is small enough ($|p_i - q_i| < \delta$) and 396 | choose the middle $m=\frac{q_i - p_i}{2}$. So we have $|m - x| < 397 | \delta$ and therefore $|f(m) - f(x)| < \epsilon$, as desired. 398 | 399 | 400 | 401 | 402 | 403 | %% Now let us consider the relationship between rational intervals and 404 | %% continuous functions on the reals. Suppose $f : A \to \Reals$ with $A 405 | %% \subseteq \Reals$. 406 | 407 | 408 | 409 | Hmm, how to relate the above to the following. 410 | 411 | We lift $f$ to a function $f^\dagger : A' \to \mathcal{R}$ with $A' 412 | \subseteq \mathcal{R}$ as follows. 413 | \begin{align*} 414 | f^\dagger(a) = 415 | \begin{cases} 416 | f(x) & \text{if } a=x \in \Reals \\ 417 | \langle p',q' \rangle & \text{if } a = \langle p,q \rangle \text{ and } 418 | \forall x, p \leq x \leq q \implies p' \leq f(x) \leq q' 419 | \end{cases} 420 | \end{align*} 421 | 422 | \begin{theorem} 423 | If $f : A \to \Reals$ is continuous and $S \subseteq \mathcal{R}$ 424 | with some conditions on $S$, 425 | then 426 | \[ 427 | \bigsqcup \{ f^\dagger(a) \mid a \in S \} = f^\dagger\left(\bigsqcup S\right) 428 | \] 429 | \end{theorem} 430 | \begin{proof} 431 | UNDER CONSTRUCTION 432 | \end{proof} 433 | 434 | 435 | 436 | \section{Topology on $\mathcal{P}(\mathbb{N})$} 437 | 438 | 439 | 440 | \section{Scott Topology} 441 | 442 | \begin{definition} 443 | A set $S \subseteq P$ of a poset $P$ is Scott-open if it is upward 444 | closed and if all directed sets $D$ with lub in $S$ have non-empty 445 | intersection with $S$. 446 | 447 | A partial order $P$ and all of its Scott-open subsets forms a 448 | topological space, the Scott-topology. 449 | \end{definition} 450 | 451 | \section{Miscelaneous} 452 | 453 | In a $T_0$ space on $X$ (aka. Kolmogorov space), for every pair of 454 | points in $X$, at least one of the points is in a neighborhood that 455 | does not contain the other point. (Wikipedia) 456 | 457 | 458 | \end{document} 459 | -------------------------------------------------------------------------------- /tufte-common.def: -------------------------------------------------------------------------------- 1 | %% 2 | %% This file contains the code that is common to the Tufte-LaTeX document classes. 3 | %% 4 | 5 | \ProvidesFile{tufte-common.def}[2015/06/21 v3.5.2 Common code for the Tufte-LaTeX styles] 6 | 7 | %% 8 | % The `xkeyval' package simplifies the user interface for the document class options 9 | \RequirePackage{xkeyval} 10 | 11 | %% 12 | % We use the `xifthen' package to handle our package option switches 13 | \RequirePackage{xifthen} 14 | 15 | %% 16 | % Define some shortcut macros for error/warning/info logging. 17 | \RequirePackage{hardwrap} 18 | \GenerateClassLogMacros[@tufte]{\@tufte@pkgname} 19 | \newcommand{\@tufte@debug@info}[1]{\ifthenelse{\boolean{@tufte@debug}}{\@tufte@info{#1}}{}} 20 | \newcommand{\@tufte@debug@info@noline}[1]{\ifthenelse{\boolean{@tufte@debug}}{\@tufte@info@noline{#1}}{}} 21 | 22 | %% 23 | % `debug' option -- provides more information in the .log file for use in 24 | % troubleshooting problems 25 | \newboolean{@tufte@debug} 26 | \DeclareOptionX[tufte]{debug}{\setboolean{@tufte@debug}{true}} 27 | 28 | %% 29 | % `nofonts' option -- doesn't load any fonts 30 | % `fonts' option -- tries to load fonts 31 | \newboolean{@tufte@loadfonts}\setboolean{@tufte@loadfonts}{true} 32 | \DeclareOptionX[tufte]{fonts}{\setboolean{@tufte@loadfonts}{true}} 33 | \DeclareOptionX[tufte]{nofonts}{\setboolean{@tufte@loadfonts}{false}} 34 | 35 | %% 36 | % `nols' option -- doesn't configure letterspacing 37 | % `ls' option -- configures letterspacing 38 | \newboolean{@tufte@letterspace}\setboolean{@tufte@letterspace}{true} 39 | \DeclareOptionX[tufte]{ls}{\setboolean{@tufte@letterspace}{true}} 40 | \DeclareOptionX[tufte]{nols}{\setboolean{@tufte@letterspace}{false}} 41 | 42 | %% 43 | % `nobib' option -- doesn't load natbib or adjust the \cite command 44 | \newboolean{@tufte@loadnatbib}\setboolean{@tufte@loadnatbib}{true} 45 | \DeclareOptionX[tufte]{nobib}{\setboolean{@tufte@loadnatbib}{false}} 46 | 47 | %% 48 | % `titlepage' option -- creates a full title page with \maketitle 49 | 50 | \newboolean{@tufte@titlepage} 51 | \DeclareOptionX[tufte]{titlepage}{\setboolean{@tufte@titlepage}{true}} 52 | \DeclareOptionX[tufte]{notitlepage}{\setboolean{@tufte@titlepage}{false}} 53 | 54 | %% 55 | % `a4paper' option 56 | 57 | \newboolean{@tufte@afourpaper} 58 | \DeclareOptionX[tufte]{a4paper}{\setboolean{@tufte@afourpaper}{true}} 59 | 60 | %% 61 | % `b5paper' option 62 | 63 | \newboolean{@tufte@bfivepaper} 64 | \DeclareOptionX[tufte]{b5paper}{\setboolean{@tufte@bfivepaper}{true}} 65 | 66 | %% 67 | % `sfsidenotes' option -- typesets sidenotes in sans serif typeface 68 | 69 | \newboolean{@tufte@sfsidenotes} 70 | \DeclareOptionX[tufte]{sfsidenotes}{\setboolean{@tufte@sfsidenotes}{true}} 71 | 72 | %% 73 | % `symmetric' option -- puts marginpar space to the outside edge of the page 74 | % Note: this option forces the twoside option (see the .cls files) 75 | 76 | \newboolean{@tufte@symmetric} 77 | \DeclareOptionX[tufte]{symmetric}{ 78 | \setboolean{@tufte@symmetric}{true} 79 | \@tufte@info@noline{The `symmetric' option implies `twoside'} 80 | \ExecuteOptionsX[tufte]{twoside} 81 | } 82 | 83 | %% 84 | % `twoside' option -- alternates running heads 85 | 86 | \newboolean{@tufte@twoside} 87 | \DeclareOptionX[tufte]{twoside}{% 88 | \setboolean{@tufte@twoside}{true} 89 | \@tufte@info@noline{Passing the `twoside' option to the `\@tufte@class' class} 90 | \PassOptionsToClass{twoside}{\@tufte@class} 91 | } 92 | 93 | %% 94 | % `notoc' option -- suppresses the Tufte-style table of contents 95 | 96 | \newboolean{@tufte@toc} 97 | \setboolean{@tufte@toc}{true} 98 | \DeclareOptionX[tufte]{notoc}{\setboolean{@tufte@toc}{false}} 99 | \DeclareOptionX[tufte]{toc}{\setboolean{@tufte@toc}{true}} 100 | 101 | %% 102 | % `justified' option -- uses fully justified text (flush left and flush 103 | % right) instead of ragged right. 104 | 105 | \newboolean{@tufte@justified} 106 | \DeclareOptionX[tufte]{justified}{\setboolean{@tufte@justified}{true}} 107 | 108 | %% 109 | % `bidi' option -- loads the bidi package for bi-directional text 110 | 111 | \newboolean{@tufte@loadbidi} 112 | \DeclareOptionX[tufte]{bidi}{\setboolean{@tufte@loadbidi}{true}} 113 | \DeclareOptionX[tufte]{nobidi}{\setboolean{@tufte@loadbidi}{false}} 114 | 115 | %% 116 | % `nohyper' option -- suppresses loading of the hyperref package 117 | 118 | \newboolean{@tufte@loadhyper} 119 | \setboolean{@tufte@loadhyper}{true} 120 | \DeclareOptionX[tufte]{hyper}{\setboolean{@tufte@loadhyper}{true}} 121 | \DeclareOptionX[tufte]{nohyper}{\setboolean{@tufte@loadhyper}{false}} 122 | 123 | %% 124 | % `sidenote', `marginnote', `caption', `citation', `marginals' options 125 | % Each allows one of {justified,raggedleft,raggedright,raggedouter,auto}. 126 | 127 | \newcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect} 128 | \define@choicekey*+[tufte]{common}{sidenote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% 129 | \ifcase\@tufte@kvnum\relax 130 | \renewcommand*{\@tufte@sidenote@justification}{\justifying}% justified 131 | \or 132 | \renewcommand*{\@tufte@sidenote@justification}{\RaggedLeft}% ragged left 133 | \or 134 | \renewcommand*{\@tufte@sidenote@justification}{\RaggedRight}% ragged right 135 | \or 136 | \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages) 137 | \or 138 | \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 139 | \fi 140 | }{% 141 | \@tufte@warning@noline{Invalid option `#1' for sidenote key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto} 142 | \renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 143 | } 144 | 145 | \newcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect} 146 | \define@choicekey*+[tufte]{common}{marginnote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% 147 | \ifcase\@tufte@kvnum\relax 148 | \renewcommand*{\@tufte@marginnote@justification}{\justifying}% justified 149 | \or 150 | \renewcommand*{\@tufte@marginnote@justification}{\RaggedLeft}% ragged left 151 | \or 152 | \renewcommand*{\@tufte@marginnote@justification}{\RaggedRight}% ragged right 153 | \or 154 | \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages) 155 | \or 156 | \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 157 | \fi 158 | }{% 159 | \@tufte@warning@noline{Invalid option `#1' for marginnote key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto} 160 | \renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 161 | } 162 | 163 | \newcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect} 164 | \define@choicekey*+[tufte]{common}{caption}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% 165 | \ifcase\@tufte@kvnum\relax 166 | \renewcommand*{\@tufte@caption@justification}{\justifying}% justified 167 | \or 168 | \renewcommand*{\@tufte@caption@justification}{\RaggedLeft}% ragged left 169 | \or 170 | \renewcommand*{\@tufte@caption@justification}{\RaggedRight}% ragged right 171 | \or 172 | \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@caption@outer}% ragged outer (flush right on verso pages, flush left on recto pages) 173 | \or 174 | \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 175 | \fi 176 | }{% 177 | \@tufte@warning@noline{Invalid option `#1' for caption key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto} 178 | \renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 179 | } 180 | 181 | \newcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect} 182 | \define@choicekey*+[tufte]{common}{citation}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% 183 | \ifcase\@tufte@kvnum\relax 184 | \renewcommand*{\@tufte@citation@justification}{\justifying}% justified 185 | \or 186 | \renewcommand*{\@tufte@citation@justification}{\RaggedLeft}% ragged left 187 | \or 188 | \renewcommand*{\@tufte@citation@justification}{\RaggedRight}% ragged right 189 | \or 190 | \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages) 191 | \or 192 | \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 193 | \fi 194 | }{% 195 | \@tufte@warning@noline{Invalid option `#1' for citation key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto} 196 | \renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options 197 | } 198 | 199 | % The ``marginals'' key simultaneously sets the same justification for all marginal material 200 | \define@choicekey*+[tufte]{common}{marginals}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{% 201 | \ifcase\@tufte@kvnum\relax 202 | \ExecuteOptionsX[tufte]{citation=justified,sidenote=justified,caption=justified,marginnote=justified}% justified 203 | \or 204 | \ExecuteOptionsX[tufte]{citation=raggedleft,sidenote=raggedleft,caption=raggedleft,marginnote=raggedleft}% ragged left 205 | \or 206 | \ExecuteOptionsX[tufte]{citation=raggedright,sidenote=raggedright,caption=raggedright,marginnote=raggedright}% ragged right 207 | \or 208 | \ExecuteOptionsX[tufte]{citation=raggedouter,sidenote=raggedouter,caption=raggedouter,marginnote=raggedouter}% ragged outer (flush right on verso pages, flush left on recto pages) 209 | \or 210 | \ExecuteOptionsX[tufte]{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options 211 | \fi 212 | }{% 213 | \@tufte@warning@noline{Invalid option `#1' for marginals key. Must be one of: justified, raggedleft, raggedright, raggedouter, auto} 214 | \ExecuteOptionsX[tufte]{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options 215 | } 216 | 217 | 218 | %% 219 | % Unsupported options 220 | 221 | \newcommand{\@tufte@unsupported@option}[1]{\@tufte@warning@noline{Option `#1' is not supported -- ignoring option}\OptionNotUsed} 222 | 223 | \DeclareOptionX[tufte]{10pt}{\@tufte@unsupported@option{\CurrentOption}} 224 | \DeclareOptionX[tufte]{11pt}{\@tufte@unsupported@option{\CurrentOption}} 225 | \DeclareOptionX[tufte]{12pt}{\@tufte@unsupported@option{\CurrentOption}} 226 | \DeclareOptionX[tufte]{a5paper}{\@tufte@unsupported@option{\CurrentOption}} 227 | \DeclareOptionX[tufte]{executivepaper}{\@tufte@unsupported@option{\CurrentOption}} 228 | \DeclareOptionX[tufte]{legalpaper}{\@tufte@unsupported@option{\CurrentOption}} 229 | \DeclareOptionX[tufte]{landscape}{\@tufte@unsupported@option{\CurrentOption}} 230 | \DeclareOptionX[tufte]{onecolumn}{\@tufte@unsupported@option{\CurrentOption}} 231 | \DeclareOptionX[tufte]{twocolumn}{\@tufte@unsupported@option{\CurrentOption}} 232 | 233 | %% 234 | % Default `book' and `handout' options 235 | 236 | \ifthenelse{\equal{\@tufte@pkgname}{tufte-book}} 237 | {\ExecuteOptionsX[tufte]{titlepage}} 238 | {\ExecuteOptionsX[tufte]{notitlepage}} 239 | 240 | 241 | \DeclareOptionX*{% 242 | \@tufte@info@noline{Passing \CurrentOption\space to the `\@tufte@class' class.}% 243 | \PassOptionsToClass{\CurrentOption}{\@tufte@class}% 244 | } 245 | \ProcessOptionsX*[tufte]\relax 246 | 247 | %% 248 | % Load the appropriate base class 249 | \@tufte@info@noline{Loading the base class `\@tufte@class'} 250 | \LoadClass{\@tufte@class} 251 | 252 | %% 253 | % Detect whether we're in two-side mode or not. (Used to set up running 254 | % heads later.) 255 | 256 | \ifthenelse{\boolean{@twoside}} 257 | {\setboolean{@tufte@twoside}{true}} 258 | {} 259 | 260 | 261 | 262 | %% 263 | % Detect if we're using pdfLaTeX 264 | 265 | \newboolean{@tufte@pdf} 266 | \IfFileExists{ifpdf.sty}{% 267 | \RequirePackage{ifpdf} 268 | \ifthenelse{\boolean{pdf}} 269 | {\setboolean{@tufte@pdf}{true}} 270 | {\setboolean{@tufte@pdf}{false}} 271 | }{% assume we're not using pdfTex? 272 | \setboolean{@tufte@pdf}{false} 273 | } 274 | 275 | %% 276 | % Detect if we're using XeLaTeX 277 | 278 | \newboolean{@tufte@xetex} 279 | \IfFileExists{ifxetex.sty}{% 280 | \RequirePackage{ifxetex} 281 | \ifthenelse{\boolean{xetex}} 282 | {\setboolean{@tufte@xetex}{true}} 283 | {\setboolean{@tufte@xetex}{false}} 284 | }{% not using xelatex 285 | \setboolean{@tufte@xetex}{false} 286 | } 287 | 288 | \ifthenelse{\boolean{@tufte@xetex}}{% 289 | \RequirePackage{xltxtra}% xltxtra loads xunicode and fontspec; must be loaded before bidi 290 | }{} 291 | 292 | %% 293 | % Detect if we're using LuaTeX 294 | 295 | \newboolean{@tufte@luatex} 296 | \IfFileExists{ifluatex.sty}{% 297 | \RequirePackage{ifluatex} 298 | \ifthenelse{\boolean{luatex}} 299 | {\setboolean{@tufte@luatex}{true}} 300 | {\setboolean{@tufte@luatex}{false}} 301 | }{% not using luatex 302 | \setboolean{@tufte@luatex}{false} 303 | } 304 | 305 | \ifthenelse{\boolean{@tufte@luatex}}{% 306 | \RequirePackage{fontspec} 307 | \RequirePackage[osf,sc]{mathpazo} 308 | \setmainfont[Renderer=Basic, Numbers=OldStyle, Scale = 1.0]{TeX Gyre Pagella} 309 | \setsansfont[Renderer=Basic, Scale=0.90]{TeX Gyre Heros} 310 | \setmonofont[Renderer=Basic]{TeX Gyre Cursor} 311 | }{} 312 | 313 | %% 314 | % Globally sets the length 315 | 316 | \newcommand*{\gsetlength}[2]{% 317 | \setlength{#1}{#2}% 318 | \global#1=#1\relax% 319 | } 320 | 321 | %% 322 | % Globally sets a boolean 323 | 324 | \newcommand*{\gsetboolean}[2]{% based on code from ifthen pkg 325 | \lowercase{\def\@tempa{#2}}% 326 | \@ifundefined{@tempswa\@tempa}% 327 | {\PackageError{ifthen}{You can only set a boolean to `true' or `false'}\@ehc}% 328 | {\@ifundefined{#1\@tempa}% 329 | {\PackageError{ifthen}{Boolean #1 undefined}\@ehc}% 330 | {\global\csname#1\@tempa\endcsname}% 331 | }% 332 | } 333 | 334 | %% 335 | % The titlesec and titletoc packages are used to change the style of the 336 | % section headings. These packages should be loaded before the hyperref 337 | % package. 338 | 339 | \RequirePackage{titlesec,titletoc} 340 | 341 | %%% 342 | %% Loads the hyperref package and sets some default options. 343 | 344 | \newcommand{\TufteLoadHyperref}{% 345 | \ifthenelse{\boolean{@tufte@xetex}} 346 | {\RequirePackage[unicode,hyperfootnotes=false,xetex]{hyperref}} 347 | {\RequirePackage[unicode,hyperfootnotes=false]{hyperref}} 348 | \hypersetup{% 349 | pdfborder = {0 0 0}, 350 | bookmarksdepth = section, 351 | citecolor = DarkGreen, 352 | linkcolor = DarkBlue, 353 | urlcolor = DarkGreen, 354 | }% 355 | } 356 | 357 | %%% 358 | %% Load the `hyperref' package. 359 | 360 | \ifthenelse{\boolean{@tufte@loadhyper}}{% 361 | \TufteLoadHyperref% 362 | }{% hyperfootnotes override our modifications to the \footnote* and \@footnote* commands. 363 | \PassOptionsToPackage{hyperfootnotes=false}{hyperref} 364 | } 365 | 366 | %% 367 | % Set the font sizes and baselines to match Tufte's books 368 | \renewcommand\normalsize{% 369 | \@setfontsize\normalsize\@xpt{14}% 370 | \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@ 371 | \abovedisplayshortskip \z@ \@plus3\p@ 372 | \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@ 373 | \belowdisplayskip \abovedisplayskip 374 | \let\@listi\@listI} 375 | \normalbaselineskip=14pt 376 | \normalsize 377 | \renewcommand\small{% 378 | \@setfontsize\small\@ixpt{12}% 379 | \abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@ 380 | \abovedisplayshortskip \z@ \@plus2\p@ 381 | \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@ 382 | \def\@listi{\leftmargin\leftmargini 383 | \topsep 4\p@ \@plus2\p@ \@minus2\p@ 384 | \parsep 2\p@ \@plus\p@ \@minus\p@ 385 | \itemsep \parsep}% 386 | \belowdisplayskip \abovedisplayskip 387 | } 388 | \renewcommand\footnotesize{% 389 | \@setfontsize\footnotesize\@viiipt{10}% 390 | \abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@ 391 | \abovedisplayshortskip \z@ \@plus\p@ 392 | \belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@ 393 | \def\@listi{\leftmargin\leftmargini 394 | \topsep 3\p@ \@plus\p@ \@minus\p@ 395 | \parsep 2\p@ \@plus\p@ \@minus\p@ 396 | \itemsep \parsep}% 397 | \belowdisplayskip \abovedisplayskip 398 | } 399 | \renewcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt} 400 | \renewcommand\tiny{\@setfontsize\tiny\@vpt\@vipt} 401 | \renewcommand\large{\@setfontsize\large\@xipt{15}} 402 | \renewcommand\Large{\@setfontsize\Large\@xiipt{16}} 403 | \renewcommand\LARGE{\@setfontsize\LARGE\@xivpt{18}} 404 | \renewcommand\huge{\@setfontsize\huge\@xxpt{30}} 405 | \renewcommand\Huge{\@setfontsize\Huge{24}{36}} 406 | 407 | \setlength\leftmargini {1pc} 408 | \setlength\leftmarginii {1pc} 409 | \setlength\leftmarginiii {1pc} 410 | \setlength\leftmarginiv {1pc} 411 | \setlength\leftmarginv {1pc} 412 | \setlength\leftmarginvi {1pc} 413 | \setlength\labelsep {.5pc} 414 | \setlength\labelwidth {\leftmargini} 415 | \addtolength\labelwidth{-\labelsep} 416 | 417 | %% 418 | % \RaggedRight allows hyphenation 419 | 420 | \setlength{\parindent}{1.0pc}% 421 | \setlength{\parskip}{0pt}% 422 | \RequirePackage{ragged2e} 423 | \setlength{\RaggedRightRightskip}{\z@ plus 0.08\hsize} 424 | 425 | % Paragraph indentation and separation for normal text 426 | \newcommand{\@tufte@reset@par}{% 427 | \setlength{\RaggedRightParindent}{1.0pc}% 428 | \setlength{\JustifyingParindent}{1.0pc}% 429 | \setlength{\parindent}{1pc}% 430 | \setlength{\parskip}{0pt}% 431 | } 432 | \@tufte@reset@par 433 | 434 | % Paragraph indentation and separation for marginal text 435 | \newcommand{\@tufte@margin@par}{% 436 | \setlength{\RaggedRightParindent}{0.5pc}% 437 | \setlength{\JustifyingParindent}{0.5pc}% 438 | \setlength{\parindent}{0.5pc}% 439 | \setlength{\parskip}{0pt}% 440 | } 441 | 442 | 443 | %% 444 | % Set page layout geometry 445 | 446 | \RequirePackage[letterpaper,left=1in,top=1in,headsep=2\baselineskip,textwidth=26pc,marginparsep=2pc,marginparwidth=12pc,textheight=44\baselineskip,headheight=\baselineskip]{geometry} 447 | 448 | \ifthenelse{\boolean{@tufte@afourpaper}} 449 | {\geometry{a4paper,left=24.8mm,top=27.4mm,headsep=2\baselineskip,textwidth=107mm,marginparsep=8.2mm,marginparwidth=49.4mm,textheight=49\baselineskip,headheight=\baselineskip}} 450 | {} 451 | 452 | \ifthenelse{\boolean{@tufte@bfivepaper}} 453 | {\geometry{paperwidth=176mm,paperheight=250mm,left=14.66mm,top=13.88mm,textwidth=102.66mm,marginparsep=7.33mm,marginparwidth=36.66mm,textheight=38\baselineskip,includehead}} 454 | {} 455 | 456 | \ifthenelse{\boolean{@tufte@symmetric}} 457 | {} 458 | {\geometry{asymmetric}}% forces internal LaTeX `twoside' 459 | 460 | 461 | %% 462 | % Separation marginpars by a line's worth of space. 463 | 464 | \setlength\marginparpush{10pt} 465 | 466 | %% 467 | % Font for margin items 468 | 469 | \ifthenelse{\boolean{@tufte@sfsidenotes}} 470 | {\newcommand{\@tufte@marginfont}{\normalfont\footnotesize\sffamily}} 471 | {\newcommand{\@tufte@marginfont}{\normalfont\footnotesize}} 472 | 473 | \newcommand*{\@tufte@sidenote@font}{\@tufte@marginfont} 474 | \newcommand*{\@tufte@caption@font}{\@tufte@marginfont} 475 | \newcommand*{\@tufte@marginnote@font}{\@tufte@marginfont} 476 | \newcommand*{\@tufte@citation@font}{\@tufte@marginfont} 477 | 478 | \newcommand*{\setsidenotefont}[1]{\renewcommand*{\@tufte@sidenote@font}{#1}} 479 | \newcommand*{\setcaptionfont}[1]{\renewcommand*{\@tufte@caption@font}{#1}} 480 | \newcommand*{\setmarginnotefont}[1]{\renewcommand*{\@tufte@marginnote@font}{#1}} 481 | \newcommand*{\setcitationfont}[1]{\renewcommand*{\@tufte@citation@font}{#1}} 482 | 483 | %% 484 | % Set the justification baesed on the `justified' class option 485 | 486 | \newcommand{\@tufte@justification}{% 487 | \ifthenelse{\boolean{@tufte@justified}}% 488 | {\justifying}% 489 | {\RaggedRight}% 490 | } 491 | 492 | %% 493 | % Turn off section numbering 494 | 495 | %\setcounter{secnumdepth}{-1} 496 | 497 | %% 498 | % Tighten up space between displays (e.g., a figure or table) and make symmetric 499 | 500 | \setlength\abovedisplayskip{6pt plus 2pt minus 4pt} 501 | \setlength\belowdisplayskip{6pt plus 2pt minus 4pt} 502 | 503 | %% 504 | % To implement full-width display environments 505 | 506 | \newboolean{@tufte@changepage} 507 | \IfFileExists{changepage.sty}{% 508 | \@tufte@debug@info@noline{Found changepage.sty} 509 | \RequirePackage[strict]{changepage} 510 | \setboolean{@tufte@changepage}{true} 511 | }{% 512 | \@tufte@debug@info@noline{Found chngpage.sty} 513 | \RequirePackage[strict]{chngpage} 514 | \setboolean{@tufte@changepage}{false} 515 | } 516 | 517 | % Write our own aliases for the \checkoddpage and \ifoddpage or \ifcpoddpage commands 518 | \newboolean{@tufte@odd@page} 519 | \setboolean{@tufte@odd@page}{true} 520 | \newcommand*{\@tufte@checkoddpage}{% 521 | \checkoddpage% 522 | \ifthenelse{\boolean{@tufte@changepage}}{% 523 | \ifoddpage% 524 | \setboolean{@tufte@odd@page}{true}% 525 | \else% 526 | \setboolean{@tufte@odd@page}{false}% 527 | \fi% 528 | }{% 529 | \ifcpoddpage% 530 | \setboolean{@tufte@odd@page}{true}% 531 | \else% 532 | \setboolean{@tufte@odd@page}{false}% 533 | \fi% 534 | }% 535 | } 536 | 537 | %% 538 | % Compute lengths used for full-width displays 539 | 540 | \newlength{\@tufte@overhang}% used by the fullwidth environment and the running heads 541 | \newlength{\@tufte@fullwidth} 542 | \newlength{\@tufte@caption@fill} 543 | 544 | \newcommand{\TufteRecalculate}{% 545 | \setlength{\@tufte@overhang}{\marginparwidth} 546 | \addtolength{\@tufte@overhang}{\marginparsep} 547 | 548 | \setlength{\@tufte@fullwidth}{\textwidth} 549 | \addtolength{\@tufte@fullwidth}{\marginparsep} 550 | \addtolength{\@tufte@fullwidth}{\marginparwidth} 551 | 552 | \setlength{\@tufte@caption@fill}{\textwidth} 553 | \addtolength{\@tufte@caption@fill}{\marginparsep} 554 | } 555 | 556 | \AtBeginDocument{\TufteRecalculate} 557 | 558 | %% 559 | % Modified \title, \author, and \date commands. These store the 560 | % (footnote-less) values in \plaintitle, \plainauthor, and \thedate, respectively. 561 | 562 | \newcommand{\plaintitle}{}% plain-text-only title 563 | \newcommand{\plainauthor}{}% plain-text-only author 564 | \newcommand{\plainpublisher}{}% plain-text-only publisher 565 | 566 | \newcommand{\thanklesstitle}{}% full title text minus \thanks{} 567 | \newcommand{\thanklessauthor}{}% full author text minus \thanks{} 568 | \newcommand{\thanklesspublisher}{}% full publisher minus \thanks{} 569 | 570 | \newcommand{\@publisher}{}% full publisher with \thanks{} 571 | \newcommand{\thedate}{\today} 572 | 573 | % TODO Fix it so that \thanks is not spaced out (with `soul') and can be 574 | % used in \maketitle when the `sfsidenotes' option is provided. 575 | \renewcommand{\thanks}[1]{\NoCaseChange{\footnote{#1}}} 576 | 577 | \renewcommand{\title}[2][]{% 578 | \gdef\@title{#2}% 579 | \begingroup% 580 | % TODO store contents of \thanks command 581 | \renewcommand{\thanks}[1]{}% swallow \thanks contents 582 | \protected@xdef\thanklesstitle{#2}% 583 | \endgroup% 584 | \ifthenelse{\isempty{#1}}% 585 | {\renewcommand{\plaintitle}{\thanklesstitle}}% use thankless title 586 | {\renewcommand{\plaintitle}{#1}}% use provided plain-text title 587 | \ifthenelse{\isundefined{\hypersetup}}% 588 | {}% hyperref is not loaded; do nothing 589 | {\hypersetup{pdftitle={\plaintitle}}}% set the PDF metadata title 590 | } 591 | 592 | \let\@author\@empty% suppress default latex.ltx ``no author'' warning 593 | \renewcommand{\author}[2][]{% 594 | \ifthenelse{\isempty{#2}}{}{\gdef\@author{#2}}% 595 | \begingroup% 596 | % TODO store contents of \thanks command 597 | \renewcommand{\thanks}[1]{}% swallow \thanks contents 598 | \protected@xdef\thanklessauthor{#2}% 599 | \endgroup% 600 | \ifthenelse{\isempty{#1}}% 601 | {\renewcommand{\plainauthor}{\thanklessauthor}}% use thankless author 602 | {\renewcommand{\plainauthor}{#1}}% use provided plain-text author 603 | \ifthenelse{\isundefined{\hypersetup}}% 604 | {}% hyperref is not loaded; do nothing 605 | {\hypersetup{pdfauthor={\plainauthor}}}% set the PDF metadata author 606 | } 607 | 608 | \renewcommand{\date}[1]{% 609 | \gdef\@date{#1}% 610 | \begingroup% 611 | % TODO store contents of \thanks command 612 | \renewcommand{\thanks}[1]{}% swallow \thanks contents 613 | \protected@xdef\thedate{#1}% 614 | \endgroup% 615 | } 616 | 617 | %% 618 | % Provides a \publisher command to set the publisher 619 | 620 | \newcommand{\publisher}[2][]{% 621 | \gdef\@publisher{#2}% 622 | \begingroup% 623 | \renewcommand{\thanks}[1]{}% swallow \thanks contents 624 | \protected@xdef\thanklesspublisher{#2}% 625 | \endgroup% 626 | \ifthenelse{\isempty{#1}} 627 | {\renewcommand{\plainpublisher}{\thanklesspublisher}}% use thankless publisher 628 | {\renewcommand{\plainpublisher}{#1}}% use provided plain-text publisher 629 | } 630 | 631 | % TODO: Test \hypersetup{pdfauthor,pdftitle} with DVI and XeTeX 632 | 633 | %% 634 | % Require paralist package for tighter lists 635 | 636 | \RequirePackage{paralist} 637 | 638 | % Add rightmargin to compactenum 639 | 640 | \def\@compactenum@{% 641 | \expandafter\list\csname label\@enumctr\endcsname{% 642 | \usecounter{\@enumctr}% 643 | \rightmargin=2em% added this 644 | \parsep\plparsep 645 | \itemsep\plitemsep 646 | \topsep\pltopsep 647 | \partopsep\plpartopsep 648 | \def\makelabel##1{\hss\llap{##1}}}} 649 | 650 | %% 651 | % Improved letterspacing of small caps and all-caps text. 652 | % 653 | % First, try to use the `microtype' package, if it's available. 654 | % Failing that, try to use the `soul' package, if it's available. 655 | % Failing that, well, I give up. 656 | 657 | \DeclareTextFontCommand{\textsmallcaps}{\scshape} 658 | 659 | \RequirePackage{textcase} % provides \MakeTextUppercase and \MakeTextLowercase 660 | \def\allcapsspacing{\@tufte@warning{Proper spacing of ALL-CAPS letters has not been set up.}} 661 | \def\smallcapsspacing{\@tufte@warning{Proper spacing of small-caps letters has not been set up.}} 662 | \newcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{#1}}} 663 | \newcommand{\smallcaps}[1]{\smallcapsspacing{\MakeTextLowercase{#1}}} 664 | 665 | % If we're using pdfLaTeX v1.40+, use the letterspace package. 666 | % If we're using pdfLaTex < v1.40, use the soul package. 667 | % If we're using XeLaTeX, use XeLaTeX letterspacing options. 668 | % Otherwise fall back on the soul package. 669 | 670 | \ifthenelse{\boolean{@tufte@pdf}} 671 | {\@tufte@debug@info@noline{ifpdf = true}} 672 | {\@tufte@debug@info@noline{ifpdf = false}} 673 | 674 | \ifthenelse{\boolean{@tufte@xetex}} 675 | {\@tufte@debug@info@noline{ifxetex = true}} 676 | {\@tufte@debug@info@noline{ifxetex = false}} 677 | 678 | % Check pdfLaTeX version 679 | \def\@tufte@pdftexversion{0} 680 | \ifx\normalpdftexversion\@undefined \else 681 | \let\pdftexversion \normalpdftexversion 682 | \let\pdftexrevision\normalpdftexrevision 683 | \let\pdfoutput \normalpdfoutput 684 | \fi 685 | \ifx\pdftexversion\@undefined \else 686 | \ifx\pdftexversion\relax \else 687 | \def\@tufte@pdftexversion{6} 688 | \ifnum\pdftexversion < 140 689 | \def\@tufte@pdftexversion{5} 690 | \fi 691 | \fi 692 | \fi 693 | 694 | \newboolean{@tufte@letterspace@pkg@prereqs} 695 | \setboolean{@tufte@letterspace@pkg@prereqs}{true} 696 | \ifnum\@tufte@pdftexversion<6 697 | \setboolean{@tufte@letterspace@pkg@prereqs}{false} 698 | \fi 699 | 700 | 701 | \newcommand{\@tufte@letterspacing@soul}{% 702 | \RequirePackage{soul}% 703 | \sodef\allcapsspacing{}{0.15em}{0.65em}{0.6em}% 704 | \sodef\smallcapsspacing{}{0.075em}{0.5em}{0.6em}% 705 | \sodef\sotextsc{\scshape}{0.075em}{0.5em}{0.6em}% 706 | \renewcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{##1}}}% 707 | \renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{##1}}}% 708 | \renewcommand{\textsc}[1]{\sotextsc{##1}}% 709 | } 710 | 711 | \newcommand{\@tufte@letterspacing@letterspace}{% 712 | \@tufte@debug@info@noline{Modern version of pdfTeX detected. Using `letterspace' package}% 713 | \RequirePackage{letterspace}% 714 | % Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+ 715 | \renewcommand{\allcapsspacing}[1]{\textls[200]{##1}}% 716 | \renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}}% 717 | \renewcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{##1}}}% 718 | \renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{##1}}}% 719 | \renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{##1}}}% 720 | } 721 | 722 | \ifthenelse{\boolean{@tufte@letterspace}}{% 723 | \ifthenelse{\boolean{@tufte@pdf}\AND\boolean{@tufte@letterspace@pkg@prereqs}\AND\NOT\boolean{@tufte@xetex}}{% 724 | % load letterspace pkg 725 | \IfFileExists{letterspace.sty}{% 726 | \@tufte@letterspacing@letterspace 727 | }{}% 728 | }{}% 729 | % load soul pkg 730 | \@ifpackageloaded{letterspace}{}{% 731 | \IfFileExists{soul.sty}{% 732 | \@tufte@letterspacing@soul 733 | }{% 734 | \@tufte@warning@noline{Couldn't locate `soul' package}% 735 | }% soul not installed... giving up. 736 | }% 737 | }{} 738 | 739 | %\ifthenelse{\boolean{@tufte@letterspace}}{% 740 | %\ifthenelse{\boolean{pdf}}{% 741 | %\ifthenelse{\NOT\boolean{@tufte@letterspace@pkg@prereqs}}{% 742 | %% pdfLaTeX version is too old or not using pdfLaTeX 743 | %\ifthenelse{\boolean{@tufte@xetex}}{% 744 | %% TODO use xetex letterspacing 745 | %\@tufte@debug@info@noline{XeTeX detected. Reverting to `soul' package for letterspacing}% 746 | %\@tufte@loadsoul% 747 | %}{% 748 | %% use `soul' package for letterspacing 749 | %\@tufte@debug@info@noline{Old version of pdfTeX detected. Reverting to `soul' package for letterspacing}% 750 | %\@tufte@loadsoul% 751 | %} 752 | %}{% 753 | %\IfFileExists{letterspace.sty}{% 754 | %\@tufte@debug@info@noline{Modern version of pdfTeX detected. Using `letterspace' package} 755 | %\RequirePackage{letterspace} 756 | %% Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+ 757 | %\renewcommand{\allcapsspacing}[1]{\textls[200]{##1}} 758 | %\renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}} 759 | %\renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}} 760 | %\renewcommand{\smallcaps}[1]{\smallcapsspacing{\MakeTextLowercase{##1}}} 761 | %\renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{##1}}} 762 | %}{% microtype failed, check for soul 763 | %\@tufte@debug@info@noline{Modern version of pdfTeX detected, but `letterspace' package not installed. Reverting to `soul' package for letterspacing} 764 | %\@tufte@loadsoul 765 | %}% 766 | %}% 767 | %}{% 768 | %\@tufte@debug@info@noline{Plain LaTeX detected. Using `soul' package for letterspacing} 769 | %\@tufte@loadsoul 770 | %} 771 | %}{% 772 | %% we're not to load letterspacing, so do nothing 773 | %} 774 | 775 | 776 | %% 777 | % An environment for paragraph-style section 778 | 779 | \providecommand\newthought[1]{% 780 | \tuftebreak 781 | \noindent\textsc{#1}% 782 | } 783 | 784 | %% 785 | % Redefine the display environments (quote, quotation, etc.) 786 | 787 | \renewenvironment{verse} 788 | {\let\\\@centercr 789 | \list{}{\itemsep \z@ 790 | \itemindent -1pc% 791 | \listparindent\itemindent 792 | \rightmargin \leftmargin 793 | \advance\leftmargin 1pc}% 794 | \small% 795 | \item\relax} 796 | {\endlist} 797 | \renewenvironment{quotation} 798 | {\list{}{\listparindent 1pc% 799 | \itemindent \listparindent 800 | \rightmargin \leftmargin 801 | \parsep \z@ \@plus\p@}% 802 | \small% 803 | \item\relax\noindent\ignorespaces} 804 | {\endlist} 805 | \renewenvironment{quote} 806 | {\list{}{\rightmargin\leftmargin}% 807 | \small% 808 | \item\relax} 809 | {\endlist} 810 | 811 | %% 812 | % Italicize description run-in headings (instead of the default bold) 813 | 814 | \renewcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\em #1} 815 | 816 | 817 | %% 818 | % Used for doublespacing, and other linespacing 819 | 820 | \RequirePackage{setspace} 821 | 822 | %% 823 | % Color 824 | \RequirePackage[dvipsnames,svgnames]{xcolor}% load before bidi 825 | 826 | %% 827 | % Load the bidi package if instructed to do so. This package must be loaded 828 | % prior to our redefining the \footnote and \cite commands. 829 | 830 | \ifthenelse{\boolean{@tufte@loadbidi}}{% 831 | \AtBeginDocument{% 832 | \RequirePackage{bidi} 833 | \@tufte@pkghook@post@bidi% 834 | }% 835 | }{} 836 | 837 | 838 | %% 839 | % A function that removes leading and trailling spaces from the supplied macro. 840 | % Based on code written by Michael Downes (See ``Around the Bend'', #15.) 841 | % Executing \@tufte@trim@spaces\xyzzy will result in the contents of \xyzzy 842 | % being trimmed of leading and trailing white space. 843 | 844 | \catcode`\Q=3 845 | \def\@tufte@trim@spaces#1{% 846 | % Use grouping to emulate a multi-token afterassignment queue 847 | \begingroup% 848 | % Put `\toks 0 {' into the afterassignment queue 849 | \aftergroup\toks\aftergroup0\aftergroup{% 850 | % Apply \trimb to the replacement text of #1, adding a leading 851 | % \noexpand to prevent brace stripping and to serve another purpose 852 | % later. 853 | \expandafter\@tufte@trim@b\expandafter\noexpand#1Q Q}% 854 | % Transfer the trimmed text back into #1. 855 | \edef#1{\the\toks0}% 856 | } 857 | 858 | % \trimb removes a trailing space if present, then calls \@tufte@trim@c to 859 | % clean up any leftover bizarre Qs, and trim a leading space. In 860 | % order for \trimc to work properly we need to put back a Q first. 861 | \def\@tufte@trim@b#1 Q{\@tufte@trim@c#1Q} 862 | 863 | % Execute \vfuzz assignment to remove leading space; the \noexpand 864 | % will now prevent unwanted expansion of a macro or other expandable 865 | % token at the beginning of the trimmed text. The \endgroup will feed 866 | % in the \aftergroup tokens after the \vfuzz assignment is completed. 867 | \def\@tufte@trim@c#1Q#2{\afterassignment\endgroup \vfuzz\the\vfuzz#1} 868 | \catcode`\Q=11 869 | 870 | %% 871 | % Citations should go in the margin as sidenotes 872 | 873 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 874 | \RequirePackage{natbib}% 875 | \RequirePackage{bibentry}% allows bibitems to be typeset outside thebibliography environment 876 | % Redefine the \BR@b@bibitem command to fix a bug with bibentry+chicago style 877 | \renewcommand\BR@b@bibitem[2][]{% 878 | \ifthenelse{\isempty{#1}}% 879 | {\BR@bibitem{#2}}% 880 | {\BR@bibitem[#1]{#2}}% 881 | \BR@c@bibitem{#2}% 882 | }% 883 | \nobibliography*% pre-loads the bibliography keys 884 | \providecommand{\doi}[1]{\textsc{doi:} #1}% pre-defining this so it may be used before the \bibliography command it issued 885 | }{} 886 | 887 | %% 888 | % Normal \cite behavior 889 | \newcounter{@tufte@num@bibkeys}% 890 | \newcommand{\@tufte@normal@cite}[2][0pt]{% 891 | % Snag the last bibentry in the list for later comparison 892 | \let\@temp@last@bibkey\@empty% 893 | \@for\@temp@bibkey:=#2\do{\let\@temp@last@bibkey\@temp@bibkey}% 894 | \sidenote[][#1]{% 895 | % Loop through all the bibentries, separating them with semicolons and spaces 896 | \normalsize\normalfont\@tufte@citation@font% 897 | \setcounter{@tufte@num@bibkeys}{0}% 898 | \@for\@temp@bibkeyx:=#2\do{% 899 | \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}% 900 | {\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }% 901 | \@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey 902 | \bibentry{\@temp@bibkeyx}}% 903 | {\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey 904 | \bibentry{\@temp@bibkeyx};\ }% 905 | \stepcounter{@tufte@num@bibkeys}% 906 | }% 907 | }% 908 | } 909 | 910 | 911 | %% 912 | % Macros for holding the list of cite keys until after the \sidenote 913 | 914 | \gdef\@tufte@citations{}% list of cite keys 915 | \newcommand\@tufte@add@citation[1]{\relax% adds a new bibkey to the list of cite keys 916 | \ifx\@tufte@citations\@empty\else 917 | \g@addto@macro\@tufte@citations{,}% separate by commas 918 | \fi 919 | \g@addto@macro\@tufte@citations{#1} 920 | } 921 | 922 | \newcommand{\@tufte@print@citations}[1][0pt]{% puts the citations in a margin note 923 | % Snag the last bibentry in the list for later comparison 924 | \let\@temp@last@bibkey\@empty% 925 | \@for\@temp@bibkey:=\@tufte@citations\do{\let\@temp@last@bibkey\@temp@bibkey}% 926 | \marginpar{% 927 | \hbox{}\vspace*{#1}% 928 | \@tufte@citation@font% 929 | \@tufte@citation@justification% 930 | \@tufte@margin@par% use parindent and parskip settings for marginal text 931 | \vspace*{-1\baselineskip}% 932 | % Loop through all the bibentries, separating them with semicolons and spaces 933 | \setcounter{@tufte@num@bibkeys}{0}% 934 | \@for\@temp@bibkeyx:=\@tufte@citations\do{% 935 | \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}% 936 | {\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }% 937 | \@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey 938 | \bibentry{\@temp@bibkeyx}}% 939 | {\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey 940 | \bibentry{\@temp@bibkeyx};\ }% 941 | \stepcounter{@tufte@num@bibkeys}% 942 | }% 943 | }% 944 | } 945 | 946 | %% 947 | % \cite behavior when executed within a sidenote 948 | 949 | \newcommand{\@tufte@sidenote@citations}{}% contains list of \cites in sidenote 950 | \newcommand{\@tufte@infootnote@cite}[1]{% 951 | \@tufte@add@citation{#1} 952 | } 953 | 954 | %% 955 | % Set the default \cite style. This is set and reset by the \sidenote command. 956 | 957 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 958 | \let\cite\@tufte@normal@cite 959 | }{} 960 | 961 | %% 962 | % Transform existing \footnotes into \sidenotes 963 | % Sidenote: ``Where God meant footnotes to go.'' ---Tufte 964 | 965 | \RequirePackage{optparams}% for our new sidenote commands -- provides multiple optional arguments for commands 966 | 967 | \providecommand{\footnotelayout}{\@tufte@sidenote@font\@tufte@sidenote@justification} 968 | \renewcommand{\footnotelayout}{\@tufte@sidenote@font\@tufte@sidenote@justification} 969 | 970 | % Override footmisc's definition to set the sidenote marks (numbers) inside the 971 | % sidenote's text block. 972 | \long\def\@makefntext#1{\@textsuperscript{\@tufte@sidenote@font\tiny\@thefnmark}\,\footnotelayout#1} 973 | 974 | % Set the in-text footnote mark in the same typeface as the body text itself. 975 | \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\footnotesize\@thefnmark}}} 976 | 977 | \providecommand*{\multiplefootnotemarker}{3sp} 978 | \providecommand*{\multfootsep}{,} 979 | 980 | \renewcommand{\@footnotemark}{% 981 | \leavevmode% 982 | \ifhmode% 983 | \edef\@x@sf{\the\spacefactor}% 984 | \@tufte@check@multiple@sidenotes% 985 | \nobreak% 986 | \fi% 987 | \@makefnmark% 988 | \ifhmode\spacefactor\@x@sf\fi% 989 | \relax% 990 | } 991 | 992 | \newcommand{\@tufte@check@multiple@sidenotes}{% 993 | \ifdim\lastkern=\multiplefootnotemarker\relax% 994 | \edef\@x@sf{\the\spacefactor}% 995 | \unkern% 996 | \textsuperscript{\multfootsep}% 997 | \spacefactor\@x@sf\relax% 998 | \fi 999 | } 1000 | 1001 | \renewcommand\@footnotetext[2][0pt]{% 1002 | \marginpar{% 1003 | \hbox{}\vspace*{#1}% 1004 | \def\baselinestretch {\setspace@singlespace}% 1005 | \reset@font\footnotesize% 1006 | \@tufte@margin@par% use parindent and parskip settings for marginal text 1007 | \vspace*{-1\baselineskip}\noindent% 1008 | \protected@edef\@currentlabel{% 1009 | \csname p@footnote\endcsname\@thefnmark% 1010 | }% 1011 | \color@begingroup% 1012 | \@makefntext{% 1013 | \ignorespaces#2% 1014 | }% 1015 | \color@endgroup% 1016 | }% 1017 | }% 1018 | 1019 | % Ensure this is run after the bidi package has been loaded 1020 | \def\@tufte@pkghook@post@bidi{}% 1021 | \g@addto@macro{\@tufte@pkghook@post@bidi}{% 1022 | \renewcommand\@footnotetext[2][0pt]{% 1023 | \marginpar{% 1024 | \hbox{}\vspace*{#1}% 1025 | \def\baselinestretch {\setspace@singlespace}% 1026 | \if@rl@footnote\@rltrue\else\@rlfalse\fi% 1027 | \reset@font\footnotesize% 1028 | \@tufte@margin@par% use parindent and parskip settings for marginal text 1029 | \vspace*{-1\baselineskip}\noindent% 1030 | \protected@edef\@currentlabel{% 1031 | \csname p@footnote\endcsname\@thefnmark% 1032 | }% 1033 | \color@begingroup% 1034 | \@makefntext{% 1035 | \ignorespaces#2% 1036 | }% 1037 | \color@endgroup% 1038 | }% 1039 | }% 1040 | }% 1041 | 1042 | % 1043 | % Define \sidenote command. Can handle \cite. 1044 | 1045 | \newlength{\@tufte@sidenote@vertical@offset} 1046 | \setlength{\@tufte@sidenote@vertical@offset}{0pt} 1047 | 1048 | % #1 = footnote num, #2 = vertical offset, #3 = footnote text 1049 | \long\def\@tufte@sidenote[#1][#2]#3{% 1050 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 1051 | \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command 1052 | }{}% 1053 | \gdef\@tufte@citations{}% clear out any old citations 1054 | \ifthenelse{\NOT\isempty{#2}}{% 1055 | \gsetlength{\@tufte@sidenote@vertical@offset}{#2}% 1056 | }{% 1057 | \gsetlength{\@tufte@sidenote@vertical@offset}{0pt}% 1058 | }% 1059 | \ifthenelse{\isempty{#1}}{% 1060 | % no specific footnote number provided 1061 | \stepcounter\@mpfn% 1062 | \protected@xdef\@thefnmark{\thempfn}% 1063 | \@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}% 1064 | }{% 1065 | % specific footnote number provided 1066 | \begingroup% 1067 | \csname c@\@mpfn\endcsname #1\relax% 1068 | \unrestored@protected@xdef\@thefnmark{\thempfn}% 1069 | \endgroup% 1070 | \@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}% 1071 | }% 1072 | \@tufte@print@citations% print any citations 1073 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 1074 | \let\cite\@tufte@normal@cite% go back to using normal in-text \cite command 1075 | }{}% 1076 | \unskip\ignorespaces% remove extra white space 1077 | \kern-\multiplefootnotemarker% remove \kern left behind by sidenote 1078 | \kern\multiplefootnotemarker\relax% add new \kern here to replace the one we yanked 1079 | } 1080 | 1081 | \newcommand{\sidenote}{\optparams{\@tufte@sidenote}{[][0pt]}} 1082 | \renewcommand{\footnote}{\optparams{\@tufte@sidenote}{[][0pt]}} 1083 | 1084 | %% 1085 | % Sidenote without the footnote mark 1086 | 1087 | \newcommand\marginnote[2][0pt]{% 1088 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 1089 | \let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command 1090 | }{}% 1091 | \gdef\@tufte@citations{}% clear out any old citations 1092 | \marginpar{\hbox{}\vspace*{#1}\@tufte@marginnote@font\@tufte@marginnote@justification\@tufte@margin@par\vspace*{-1\baselineskip}\noindent #2}% 1093 | \@tufte@print@citations% print any citations 1094 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 1095 | \let\cite\@tufte@normal@cite% go back to using normal in-text \cite command 1096 | }{}% 1097 | } 1098 | 1099 | 1100 | %% 1101 | % The placeins package provides the \FloatBarrier command. This forces 1102 | % LaTeX to place all of the floats before proceeding. We'll use this to 1103 | % keep the float (figure and table) numbers in sequence. 1104 | \RequirePackage{placeins} 1105 | 1106 | %% 1107 | % Margin float environment 1108 | 1109 | \newsavebox{\@tufte@margin@floatbox} 1110 | \newenvironment{@tufte@margin@float}[2][-1.2ex]% 1111 | {\FloatBarrier% process all floats before this point so the figure/table numbers stay in order. 1112 | \begin{lrbox}{\@tufte@margin@floatbox}% 1113 | \begin{minipage}{\marginparwidth}% 1114 | \@tufte@caption@font% 1115 | \def\@captype{#2}% 1116 | \hbox{}\vspace*{#1}% 1117 | \@tufte@caption@justification% 1118 | \@tufte@margin@par% 1119 | \noindent% 1120 | } 1121 | {\end{minipage}% 1122 | \end{lrbox}% 1123 | \marginpar{\usebox{\@tufte@margin@floatbox}}% 1124 | } 1125 | 1126 | 1127 | %% 1128 | % Margin figure environment 1129 | 1130 | \newenvironment{marginfigure}[1][-1.2ex]% 1131 | {\begin{@tufte@margin@float}[#1]{figure}} 1132 | {\end{@tufte@margin@float}} 1133 | 1134 | 1135 | %% 1136 | % Margin table environment 1137 | 1138 | \newenvironment{margintable}[1][-1.2ex]% 1139 | {\begin{@tufte@margin@float}[#1]{table}} 1140 | {\end{@tufte@margin@float}} 1141 | 1142 | 1143 | %% 1144 | % Auto-detects the proper text alignment based on the various class options 1145 | 1146 | \newcommand*{\@tufte@justification@autodetect}{% 1147 | \ifthenelse{\boolean{@tufte@justified}}% 1148 | {\justifying}% 1149 | {\RaggedRight}% 1150 | } 1151 | 1152 | %% 1153 | % Forces the outer edge of the caption to be set ragged. 1154 | % Therefore, on verso pages it's ragged left, and on recto pages it's ragged right. 1155 | 1156 | \newcommand*{\@tufte@justification@caption@outer}{% 1157 | \ifthenelse{\boolean{@tufte@float@recto}}% 1158 | {\RaggedRight}% 1159 | {\RaggedLeft}% 1160 | } 1161 | 1162 | \newcommand*{\@tufte@justification@outer}{% 1163 | \@tufte@checkoddpage% 1164 | \ifthenelse{\boolean{@tufte@odd@page}}% 1165 | {\RaggedRight}% 1166 | {\RaggedLeft}% 1167 | } 1168 | 1169 | 1170 | 1171 | %% 1172 | % A collection of macros to be used with the new Tufte-style float environments. 1173 | % \setfloatalignment forces the caption placement to be treated as top, bottom, etc. 1174 | % \forcerectofloat forces the float to be treated as if it were appearing on a recto page. 1175 | % \forceversofloat does the same, but for verso pages. 1176 | 1177 | \newcommand{\@tufte@float@debug@info}{}% contains debug info generated as the float is processed 1178 | \newcommand{\@tufte@float@debug}[1]{% adds debug info to the queue for output 1179 | \ifthenelse{\equal{\@tufte@float@debug@info}{}}% 1180 | {\def\@tufte@float@debug@info{#1}}% 1181 | {\g@addto@macro\@tufte@float@debug@info{\MessageBreak#1}}% 1182 | } 1183 | 1184 | \newcommand{\floatalignment}{x}% holds the current float alignment (t, b, h, p) 1185 | \newcommand{\setfloatalignment}[1]{\global\def\floatalignment{#1}\@tufte@float@debug{Forcing position: [#1]}}% manually sets the float alignment 1186 | \newboolean{@tufte@float@recto} 1187 | \newcommand{\forcerectofloat}{\gsetboolean{@tufte@float@recto}{true}\@tufte@float@debug{Forcing page: [recto]}} 1188 | \newcommand{\forceversofloat}{\gsetboolean{@tufte@float@recto}{false}\@tufte@float@debug{Forcing page: [verso]}} 1189 | 1190 | % Boxes to temporarily store our float and caption 1191 | \newsavebox{\@tufte@figure@box} 1192 | \newsavebox{\@tufte@caption@box} 1193 | 1194 | % Save original LaTeX float environment 1195 | \let\@tufte@orig@float\@float 1196 | \let\@tufte@orig@endfloat\end@float 1197 | 1198 | % New length for tweaking float captions 1199 | \newlength{\@tufte@caption@vertical@offset} 1200 | \setlength{\@tufte@caption@vertical@offset}{0pt} 1201 | 1202 | % Store the caption and label contents 1203 | \newcommand{\@tufte@stored@shortcaption}{} 1204 | \newcommand{\@tufte@stored@caption}{} 1205 | \newcommand{\@tufte@stored@label}{} 1206 | 1207 | \long\def\@tufte@caption[#1][#2]#3{% 1208 | \ifthenelse{\isempty{#1}}% 1209 | {\gdef\@tufte@stored@shortcaption{#3}}% 1210 | {\gdef\@tufte@stored@shortcaption{#1}}% 1211 | \gsetlength{\@tufte@caption@vertical@offset}{-#2}% we want a positive offset to lower captions 1212 | \gdef\@tufte@stored@caption{#3}% 1213 | } 1214 | 1215 | \newcommand{\@tufte@label}[1]{% 1216 | \gdef\@tufte@stored@label{#1}% 1217 | } 1218 | 1219 | \newcommand{\@tufte@fps}{} 1220 | 1221 | \newboolean{@tufte@float@star} 1222 | \newlength{\@tufte@float@contents@width} 1223 | 1224 | %% 1225 | % Define a float environment to place the captions in the margin space 1226 | 1227 | \newenvironment{@tufte@float}[3][htbp]% 1228 | {% begin @tufte@float 1229 | % Should this float be full-width or just text-width? 1230 | \ifthenelse{\equal{#3}{star}}% 1231 | {\gsetboolean{@tufte@float@star}{true}}% 1232 | {\gsetboolean{@tufte@float@star}{false}}% 1233 | % Check page side (recto/verso) and store detected value -- can be overriden in environment contents 1234 | \@tufte@checkoddpage% 1235 | \ifthenelse{\boolean{@tufte@odd@page}}% 1236 | {\gsetboolean{@tufte@float@recto}{true}\@tufte@float@debug{Detected page: [recto/odd]}}% 1237 | {\gsetboolean{@tufte@float@recto}{false}\@tufte@float@debug{Detected page: [verso/even]}}% 1238 | % If the float placement specifier is 'b' and only 'b', then bottom-align the mini-pages, otherwise top-align them. 1239 | \renewcommand{\@tufte@fps}{#1}% 1240 | \@tufte@float@debug{Allowed positions: [#1]}% 1241 | \ifthenelse{\equal{#1}{b}\OR\equal{#1}{B}}% 1242 | {\renewcommand{\floatalignment}{b}\@tufte@float@debug{Presumed position: [bottom]}}% 1243 | {\renewcommand{\floatalignment}{t}\@tufte@float@debug{Presumed position: [top]}}% 1244 | % Capture the contents of the \caption and \label commands to use later 1245 | \global\let\@tufte@orig@caption\caption% 1246 | \global\let\@tufte@orig@label\label% 1247 | \renewcommand{\caption}{\optparams{\@tufte@caption}{[][0pt]}}% 1248 | \renewcommand{\label}[1]{\@tufte@label{##1}}% 1249 | % Handle subfigure package compatibility 1250 | \ifthenelse{\boolean{@tufte@packages@subfigure}}{% 1251 | % don't move the label while inside a \subfigure or \subtable command 1252 | \global\let\label\@tufte@orig@label% 1253 | }{}% subfigure package is not loaded 1254 | \@tufte@orig@float{#2}[#1]% 1255 | \ifthenelse{\boolean{@tufte@float@star}}% 1256 | {\setlength{\@tufte@float@contents@width}{\@tufte@fullwidth}}% 1257 | {\setlength{\@tufte@float@contents@width}{\textwidth}}% 1258 | \begin{lrbox}{\@tufte@figure@box}% 1259 | \begin{minipage}[\floatalignment]{\@tufte@float@contents@width}\hbox{}% 1260 | }{% end @tufte@float 1261 | \par\hbox{}\vspace{-\baselineskip}\ifthenelse{\prevdepth>0}{\vspace{-\prevdepth}}{}% align baselines of boxes 1262 | \end{minipage}% 1263 | \end{lrbox}% 1264 | % build the caption box 1265 | \begin{lrbox}{\@tufte@caption@box}% 1266 | \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}% 1267 | \ifthenelse{\NOT\equal{\@tufte@stored@caption}{}}{\@tufte@orig@caption[\@tufte@stored@shortcaption]{\@tufte@stored@caption}}{}% 1268 | \ifthenelse{\NOT\equal{\@tufte@stored@label}{}}{\@tufte@orig@label{\@tufte@stored@label}}{}% 1269 | \par\vspace{-\prevdepth}%% TODO: DOUBLE-CHECK FOR SAFETY 1270 | \end{minipage}% 1271 | \end{lrbox}% 1272 | % now typeset the stored boxes 1273 | \begin{fullwidth}% 1274 | \begin{minipage}[\floatalignment]{\linewidth}% 1275 | \ifthenelse{\boolean{@tufte@float@star}}% 1276 | {\@tufte@float@fullwidth[\@tufte@caption@vertical@offset]{\@tufte@figure@box}{\@tufte@caption@box}}% 1277 | {\@tufte@float@textwidth[\@tufte@caption@vertical@offset]{\@tufte@figure@box}{\@tufte@caption@box}}% 1278 | \end{minipage}% 1279 | \end{fullwidth}% 1280 | \@tufte@orig@endfloat% end original LaTeX float environment 1281 | % output debug info 1282 | \ifthenelse{\boolean{@tufte@debug}}{% 1283 | \typeout{^^J^^J----------- Tufte-LaTeX float information ----------}% 1284 | \ifthenelse{\equal{\@tufte@stored@label}{}}% 1285 | {\typeout{Warning: Float unlabeled!}}% 1286 | {\typeout{Float label: [\@tufte@stored@label]}}% 1287 | \typeout{Page number: [\thepage]}% 1288 | \def\MessageBreak{^^J}% 1289 | \typeout{\@tufte@float@debug@info}% 1290 | \ifthenelse{\boolean{@tufte@symmetric}}% 1291 | {\typeout{Symmetric: [true]}}% 1292 | {\typeout{Symmetric: [false]}}% 1293 | \typeout{----------------------------------------------------^^J^^J}% 1294 | }{}% 1295 | % reset commands and temp boxes and captions 1296 | \gdef\@tufte@float@debug@info{}% 1297 | \let\caption\@tufte@orig@caption% 1298 | \let\label\@tufte@orig@label% 1299 | \begin{lrbox}{\@tufte@figure@box}\hbox{}\end{lrbox}% 1300 | \begin{lrbox}{\@tufte@caption@box}\hbox{}\end{lrbox}% 1301 | \gdef\@tufte@stored@shortcaption{}% 1302 | \gdef\@tufte@stored@caption{}% 1303 | \gdef\@tufte@stored@label{}% 1304 | \gsetlength{\@tufte@caption@vertical@offset}{0pt}% reset caption offset 1305 | } 1306 | 1307 | \newcommand{\@tufte@float@textwidth}[3][0pt]{% 1308 | \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}{% 1309 | % asymmetric or page is odd, so caption is on the right 1310 | \hbox{% 1311 | \usebox{#2}% 1312 | \hspace{\marginparsep}% 1313 | \smash{\raisebox{#1}{\usebox{#3}}}% 1314 | }% 1315 | \@tufte@float@debug{Caption position: [right]}% 1316 | }{% symmetric pages and page is even, so caption is on the left 1317 | \hbox{% 1318 | \smash{\raisebox{#1}{\usebox{#3}}}% 1319 | \hspace{\marginparsep}% 1320 | \usebox{#2}% 1321 | }% 1322 | \@tufte@float@debug{Caption position: [left]}% 1323 | }% 1324 | } 1325 | 1326 | \newcommand{\@tufte@float@fullwidth}[3][0pt]{% 1327 | \ifthenelse{\equal{\floatalignment}{b}}% 1328 | {% place caption above figure 1329 | \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}% 1330 | {\hfill\smash{\raisebox{#1}{\usebox{#3}}}\par\usebox{#2}\@tufte@float@debug{Caption position: [above right]}}% caption on the right 1331 | {\smash{\raisebox{#1}{\usebox{#3}}}\hfill\par\usebox{#2}\@tufte@float@debug{Caption position: [above left]}}% caption on the left 1332 | }{% place caption below figure 1333 | \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}% 1334 | {\usebox{#2}\par\hfill\smash{\raisebox{#1}{\usebox{#3}}}\@tufte@float@debug{Caption position: [below right]}}% caption on the right 1335 | {\usebox{#2}\par\smash{\raisebox{#1}{\usebox{#3}}}\hfill\@tufte@float@debug{Caption position: [below left]}}% caption on the left 1336 | }% 1337 | } 1338 | 1339 | 1340 | %% 1341 | % Redefine the figure environment to place the captions in the margin space 1342 | 1343 | \renewenvironment{figure}[1][htbp]% 1344 | {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{figure}{}} 1345 | {\end{@tufte@float}} 1346 | 1347 | 1348 | %% 1349 | % Redefine the table environment to place the captions in the margin space 1350 | 1351 | \renewenvironment{table}[1][htbp] 1352 | {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{table}{}} 1353 | {\end{@tufte@float}} 1354 | 1355 | 1356 | %% 1357 | % Full-width figure 1358 | 1359 | \renewenvironment{figure*}[1][htbp]% 1360 | {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{figure}{star}} 1361 | {\end{@tufte@float}} 1362 | 1363 | 1364 | %% 1365 | % Full-width table 1366 | 1367 | \renewenvironment{table*}[1][htbp]% 1368 | {\ifvmode\else\unskip\fi\begin{@tufte@float}[#1]{table}{star}} 1369 | {\end{@tufte@float}} 1370 | 1371 | 1372 | %% 1373 | % Full-page-width area 1374 | 1375 | \newenvironment{fullwidth} 1376 | {\ifthenelse{\boolean{@tufte@symmetric}}% 1377 | {\ifthenelse{\boolean{@tufte@changepage}}{\begin{adjustwidth*}{}{-\@tufte@overhang}}{\begin{adjustwidth}[]{}{-\@tufte@overhang}}}% 1378 | {\begin{adjustwidth}{}{-\@tufte@overhang}}% 1379 | }% 1380 | {\ifthenelse{\boolean{@tufte@symmetric}}% 1381 | {\ifthenelse{\boolean{@tufte@changepage}}{\end{adjustwidth*}}{\end{adjustwidth}}}% 1382 | {\end{adjustwidth}}% 1383 | } 1384 | 1385 | %% 1386 | % Format the captions in a style similar to the sidenotes 1387 | 1388 | \long\def\@caption#1[#2]#3{% 1389 | \par% 1390 | \addcontentsline{\csname ext@#1\endcsname}{#1}% 1391 | {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}% 1392 | \begingroup% 1393 | \@parboxrestore% 1394 | \if@minipage% 1395 | \@setminipage% 1396 | \fi% 1397 | \@tufte@caption@font\@tufte@caption@justification% 1398 | \noindent\csname fnum@#1\endcsname: \ignorespaces#3\par% 1399 | %\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par 1400 | \endgroup} 1401 | 1402 | %% 1403 | % If we're NOT using XeLaTeX and the `nofonts' class option was NOT provided, 1404 | % we should load the Palatino, Helvetica, and Bera Mono fonts (if they are 1405 | % installed.) 1406 | 1407 | \ifthenelse{\boolean{@tufte@loadfonts}\AND\NOT\boolean{@tufte@xetex}\AND\NOT\boolean{@tufte@luatex}}{% 1408 | \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{} 1409 | \IfFileExists{helvet.sty}{\RequirePackage[scaled=0.90]{helvet}}{} 1410 | \IfFileExists{beramono.sty}{\RequirePackage[scaled=0.85]{beramono}}{} 1411 | \RequirePackage[T1]{fontenc} 1412 | \RequirePackage{textcomp} 1413 | }{} 1414 | 1415 | 1416 | %% 1417 | % Turns newlines into spaces. Based on code from the `titlesec' package. 1418 | 1419 | \DeclareRobustCommand{\@tufte@newlinetospace}{% 1420 | \@ifstar{\@tufte@newlinetospace@i}{\@tufte@newlinetospace@i}% 1421 | } 1422 | 1423 | \def\@tufte@newlinetospace@i{% 1424 | \ifdim\lastskip>\z@\else\space\fi 1425 | \ignorespaces% 1426 | } 1427 | 1428 | \DeclareRobustCommand{\newlinetospace}[1]{% 1429 | \let\@tufte@orig@cr\\% save the original meaning of \\ 1430 | \def\\{\@tufte@newlinetospace}% turn \\ and \\* into \space 1431 | \let\newline\\% turn \newline into \space 1432 | #1% 1433 | \let\\\@tufte@orig@cr% revert to original meaning of \\ 1434 | } 1435 | 1436 | 1437 | %% 1438 | % Sets up the running heads and folios. 1439 | 1440 | \RequirePackage{fancyhdr} 1441 | 1442 | % Set the default page style to 'fancy' 1443 | \pagestyle{fancy} 1444 | 1445 | % Set the header/footer width to be the body text block plus the margin 1446 | % note area. 1447 | \AtBeginDocument{% 1448 | \ifthenelse{\boolean{@tufte@symmetric}} 1449 | {\fancyhfoffset[LE,RO]{\@tufte@overhang}} 1450 | {\fancyhfoffset[RE,RO]{\@tufte@overhang}} 1451 | } 1452 | 1453 | % The running heads/feet don't have rules 1454 | \renewcommand{\headrulewidth}{0pt} 1455 | \renewcommand{\footrulewidth}{0pt} 1456 | 1457 | % The 'fancy' page style is the default style for all pages. 1458 | \fancyhf{} % clear header and footer fields 1459 | \ifthenelse{\boolean{@tufte@twoside}} 1460 | {\fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\plainauthor}}}% 1461 | \fancyhead[RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}} 1462 | {\fancyhead[RE,RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}} 1463 | 1464 | 1465 | % The `plain' page style is used on chapter opening pages. 1466 | % In Tufte's /Beautiful Evidence/ he never puts page numbers at the 1467 | % bottom of pages -- the folios are unexpressed. 1468 | \fancypagestyle{plain}{ 1469 | \fancyhf{} % clear header and footer fields 1470 | % Uncomment the following five lines of code if you want the opening page 1471 | % of the chapter to express the folio in the lower outside corner. 1472 | %\ifthenelse{\boolean{@tufte@twoside}} 1473 | % {\fancyfoot[LE,RO]{\thepage}} 1474 | % {\fancyfoot[RE,RO]{\thepage}} 1475 | } 1476 | 1477 | % The `empty' page style suppresses all headers and footers. 1478 | % It's used on title pages and `intentionally blank' pages. 1479 | \fancypagestyle{empty}{ 1480 | \fancyhf{} % clear header and footer fields 1481 | } 1482 | 1483 | 1484 | %% 1485 | % Set raggedright and paragraph indentation for document 1486 | 1487 | \AtBeginDocument{\@tufte@justification} 1488 | 1489 | 1490 | %% 1491 | % Prints the list of class options and their states. 1492 | 1493 | \newcommand{\typeoutbool}[2]{% 1494 | \ifthenelse{\boolean{#2}} 1495 | {\typeout{\space\space#1: true}} 1496 | {\typeout{\space\space#1: false}} 1497 | } 1498 | 1499 | \newcommand{\typeoutstr}[2]{% 1500 | \typeout{\space\space#1: #2} 1501 | } 1502 | 1503 | \newcommand{\PrintTufteSettings}{% 1504 | \typeout{-------------------- Tufte-LaTeX settings ----------} 1505 | \typeout{Class: \@tufte@pkgname} 1506 | \typeout{} 1507 | \typeout{Class options:} 1508 | \typeoutbool{a4paper}{@tufte@afourpaper} 1509 | \typeoutbool{b5paper}{@tufte@bfivepaper} 1510 | \typeoutbool{load fonts}{@tufte@loadfonts} 1511 | \typeoutbool{fully-justified}{@tufte@justified} 1512 | \typeoutbool{letterspacing}{@tufte@letterspace} 1513 | \typeoutbool{sans-serif sidenotes}{@tufte@sfsidenotes} 1514 | \typeoutbool{symmetric margins}{@tufte@symmetric} 1515 | \typeoutbool{titlepage}{@tufte@titlepage} 1516 | \typeoutbool{twoside}{@tufte@twoside} 1517 | \typeoutbool{debug}{@tufte@debug} 1518 | \typeout{} 1519 | \typeout{Internal variables:} 1520 | \typeoutbool{[twoside]}{@twoside} 1521 | \typeoutbool{pdflatex}{@tufte@pdf} 1522 | \typeoutbool{xelatex}{@tufte@xetex} 1523 | \typeout{----------------------------------------------------} 1524 | } 1525 | 1526 | %% 1527 | % Amount of space to skip before \newthought or after title block 1528 | 1529 | \newskip\tufteskipamount 1530 | \tufteskipamount=1.0\baselineskip plus 0.5ex minus 0.2ex 1531 | 1532 | \newcommand{\tuftebreak}{\par\ifdim\lastskip<\tufteskipamount 1533 | \removelastskip\penalty-100\tufteskip\fi} 1534 | 1535 | \newcommand{\tufteskip}{\vspace\tufteskipamount} 1536 | 1537 | 1538 | %% 1539 | % Produces a full title page 1540 | 1541 | \newcommand{\maketitlepage}[0]{% 1542 | \cleardoublepage% 1543 | {% 1544 | \sffamily% 1545 | \begin{fullwidth}% 1546 | \fontsize{18}{20}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklessauthor}}% 1547 | \vspace{11.5pc}% 1548 | \fontsize{36}{40}\selectfont\par\noindent\textcolor{darkgray}{\allcaps{\thanklesstitle}}% 1549 | \vfill% 1550 | \fontsize{14}{16}\selectfont\par\noindent\allcaps{\thanklesspublisher}% 1551 | \end{fullwidth}% 1552 | } 1553 | \thispagestyle{empty}% 1554 | \clearpage% 1555 | } 1556 | 1557 | %% 1558 | % Title block 1559 | 1560 | \renewcommand{\maketitle}{% 1561 | \newpage 1562 | \global\@topnum\z@% prevent floats from being placed at the top of the page 1563 | \begingroup 1564 | \setlength{\parindent}{0pt}% 1565 | \setlength{\parskip}{4pt}% 1566 | \let\@@title\@empty 1567 | \let\@@author\@empty 1568 | \let\@@date\@empty 1569 | \ifthenelse{\boolean{@tufte@sfsidenotes}}{% 1570 | \gdef\@@title{\sffamily\LARGE\allcaps{\@title}\par}% 1571 | \gdef\@@author{\sffamily\Large\allcaps{\@author}\par}% 1572 | \gdef\@@date{\sffamily\Large\allcaps{\@date}\par}% 1573 | }{% 1574 | \gdef\@@title{\LARGE\itshape\@title\par}% 1575 | \gdef\@@author{\Large\itshape\@author\par}% 1576 | \gdef\@@date{\Large\itshape\@date\par}% 1577 | }% 1578 | \@@title 1579 | \@@author 1580 | \@@date 1581 | \endgroup 1582 | \thispagestyle{plain}% suppress the running head 1583 | \tuftebreak% add some space before the text begins 1584 | \@afterindentfalse\@afterheading% suppress indentation of the next paragraph 1585 | } 1586 | 1587 | 1588 | %% 1589 | % Title page (if the `titlepage' option was passed to the tufte-handout 1590 | % class.) 1591 | 1592 | \ifthenelse{\boolean{@tufte@titlepage}} 1593 | {\renewcommand{\maketitle}{\maketitlepage}} 1594 | {} 1595 | 1596 | %% 1597 | % When \cleardoublepage is called, produce a blank (empty) page -- i.e., 1598 | % without headers and footers 1599 | \def\cleardoublepage{\clearpage\if@twoside\ifodd\c@page\else 1600 | \hbox{} 1601 | %\vspace*{\fill} 1602 | %\begin{center} 1603 | % This page intentionally contains only this sentence. 1604 | %\end{center} 1605 | %\vspace{\fill} 1606 | \thispagestyle{empty} 1607 | \newpage 1608 | \if@twocolumn\hbox{}\newpage\fi\fi\fi} 1609 | 1610 | %% 1611 | % Make Tuftian-style section headings and TOC formatting 1612 | 1613 | \titleformat{\chapter}% 1614 | [display]% shape 1615 | {\relax\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text 1616 | {\itshape\huge\thechapter}% label 1617 | {0pt}% horizontal separation between label and title body 1618 | {\huge\rmfamily\itshape}% before the title body 1619 | [\ifthenelse{\NOT\boolean{@tufte@symmetric}}{\end{fullwidth}}{}]% after the title body 1620 | 1621 | \titleformat{\section}% 1622 | [hang]% shape 1623 | {\normalfont\Large\itshape}% format applied to label+text 1624 | {\thesection}% label 1625 | {1em}% horizontal separation between label and title body 1626 | {}% before the title body 1627 | []% after the title body 1628 | 1629 | \titleformat{\subsection}% 1630 | [hang]% shape 1631 | {\normalfont\large\itshape}% format applied to label+text 1632 | {\thesubsection}% label 1633 | {1em}% horizontal separation between label and title body 1634 | {}% before the title body 1635 | []% after the title body 1636 | 1637 | \titleformat{\paragraph}% 1638 | [runin]% shape 1639 | {\normalfont\itshape}% format applied to label+text 1640 | {\theparagraph}% label 1641 | {1em}% horizontal separation between label and title body 1642 | {}% before the title body 1643 | []% after the title body 1644 | 1645 | \titlespacing*{\chapter}{0pt}{50pt}{40pt} 1646 | \titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex} 1647 | \titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus.2ex} 1648 | 1649 | % Subsubsection and following section headings shouldn't be used. 1650 | % See Bringhurst's _The Elements of Typography_, section 4.2.2. 1651 | \renewcommand\subsubsection{% 1652 | \@tufte@error{\string\subsubsection is undefined by this class. 1653 | See Robert Bringhurst's _The Elements of 1654 | Typographic Style_, section 4.2.2. 1655 | \string\subsubsection was used} 1656 | {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as 1657 | many levels of headings as you need, no more and no fewer. Also see the many 1658 | related threads on Ask E.T. at http://www.edwardtufte.com/.} 1659 | } 1660 | 1661 | \renewcommand\subparagraph{% 1662 | \@tufte@error{\string\subparagraph is undefined by this class.% 1663 | See Robert Bringhurst's _The Elements of 1664 | Typographic Style_, section 4.2.2. 1665 | \string\subparagraph was used} 1666 | {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as 1667 | many levels of headings as you need, no more and no fewer. Also see the many 1668 | related threads on Ask E.T. at http://www.edwardtufte.com/.} 1669 | } 1670 | 1671 | 1672 | % Formatting for main TOC (printed in front matter) 1673 | % {section} [left] {above} {before w/label} {before w/o label} {filler + page} [after] 1674 | \ifthenelse{\boolean{@tufte@toc}}{% 1675 | \titlecontents{part}% FIXME 1676 | [0em] % distance from left margin 1677 | {\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry) 1678 | {\contentslabel{2em}} % before w/label (label = ``II'') 1679 | {} % before w/o label 1680 | {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) 1681 | [\end{fullwidth}] % after 1682 | \titlecontents{chapter}% 1683 | [0em] % distance from left margin 1684 | {\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry) 1685 | {\hspace*{0em}\contentslabel{2em}} % before w/label (label = ``2'') 1686 | {\hspace*{0em}} % before w/o label 1687 | {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) 1688 | [\end{fullwidth}] % after 1689 | \titlecontents{section}% FIXME 1690 | [0em] % distance from left margin 1691 | {\vspace{0\baselineskip}\begin{fullwidth}\Large\rmfamily\itshape} % above (global formatting of entry) 1692 | {\hspace*{2em}\contentslabel{2em}} % before w/label (label = ``2.6'') 1693 | {\hspace*{2em}} % before w/o label 1694 | {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) 1695 | [\end{fullwidth}] % after 1696 | \titlecontents{subsection}% FIXME 1697 | [0em] % distance from left margin 1698 | {\vspace{0\baselineskip}\begin{fullwidth}\large\rmfamily\itshape} % above (global formatting of entry) 1699 | {\hspace*{4em}\contentslabel{4em}} % before w/label (label = ``2.6.1'') 1700 | {\hspace*{4em}} % before w/o label 1701 | {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) 1702 | [\end{fullwidth}] % after 1703 | \titlecontents{paragraph}% FIXME 1704 | [0em] % distance from left margin 1705 | {\vspace{0\baselineskip}\begin{fullwidth}\normalsize\rmfamily\itshape} % above (global formatting of entry) 1706 | {\hspace*{6em}\contentslabel{2em}} % before w/label (label = ``2.6.0.0.1'') 1707 | {\hspace*{6em}} % before w/o label 1708 | {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) 1709 | [\end{fullwidth}] % after 1710 | }{} 1711 | 1712 | %% 1713 | % Format lists of figures/tables 1714 | 1715 | \renewcommand\listoffigures{% 1716 | \ifthenelse{\equal{\@tufte@class}{book}}% 1717 | {\chapter*{\listfigurename}}% 1718 | {\section*{\listfigurename}}% 1719 | % \begin{fullwidth}% 1720 | \@starttoc{lof}% 1721 | % \end{fullwidth}% 1722 | } 1723 | 1724 | \renewcommand\listoftables{% 1725 | \ifthenelse{\equal{\@tufte@class}{book}}% 1726 | {\chapter*{\listtablename}}% 1727 | {\section*{\listtablename}}% 1728 | % \begin{fullwidth}% 1729 | \@starttoc{lot}% 1730 | % \end{fullwidth}% 1731 | } 1732 | 1733 | \newcommand{\@tufte@lof@line}[2]{% 1734 | % #1 is the figure/table number and its caption text 1735 | % #2 is the page number on which the figure/table appears 1736 | \leftskip 0.0em 1737 | \rightskip 0em 1738 | \parfillskip 0em plus 1fil 1739 | \parindent 0.0em 1740 | \@afterindenttrue 1741 | \interlinepenalty\@M 1742 | \leavevmode 1743 | \@tempdima 2.0em 1744 | \advance\leftskip\@tempdima 1745 | \null\nobreak\hskip -\leftskip 1746 | {#1}\nobreak\qquad\nobreak#2% 1747 | \par% 1748 | } 1749 | 1750 | \renewcommand*\l@figure{\@tufte@lof@line} 1751 | \let\l@table\l@figure 1752 | 1753 | 1754 | %% 1755 | % A handy command to disable hyphenation for short bits of text. 1756 | % Borrowed from Peter Wilson's `hyphenat' package. 1757 | 1758 | \AtBeginDocument{% 1759 | \@ifpackageloaded{hyphenat}{}{% 1760 | \newlanguage\langwohyphens% define a language without hyphenation rules 1761 | \providecommand{\nohyphens}[1]{{\language\langwohyphens #1}}% used for short bits of text 1762 | \providecommand{\nohyphenation}{\language\langwohyphens}% can be used inside environments for longer text 1763 | }% 1764 | } 1765 | 1766 | %% 1767 | % Redefine \bibsection to not mark the running heads. 1768 | % (Code modified from natbib.sty.) 1769 | 1770 | \ifthenelse{\boolean{@tufte@loadnatbib}}{% 1771 | \@ifundefined{chapter}{% 1772 | \renewcommand\bibsection{\section*{\refname}}% 1773 | }{% 1774 | \@ifundefined{NAT@sectionbib}{% 1775 | \renewcommand\bibsection{\chapter{\bibname}}% 1776 | }{% 1777 | \renewcommand\bibsection{\section*{\bibname}}% 1778 | }% 1779 | }% 1780 | } 1781 | 1782 | %% 1783 | % An index environment to mimic Tufte's indexes 1784 | 1785 | \RequirePackage{multicol} 1786 | \renewenvironment{theindex}{% 1787 | \ifthenelse{\equal{\@tufte@class}{book}}% 1788 | {\chapter{\indexname}}% 1789 | {\section*{\indexname}}% 1790 | \begin{fullwidth}% 1791 | \small% 1792 | \parskip0pt% 1793 | \parindent0pt% 1794 | \let\item\@idxitem% 1795 | \begin{multicols}{3}% 1796 | }{% 1797 | \end{multicols}% 1798 | \end{fullwidth}% 1799 | } 1800 | \renewcommand\@idxitem{\par\hangindent 2em} 1801 | \renewcommand\subitem{\par\hangindent 3em\hspace*{1em}} 1802 | \renewcommand\subsubitem{\par\hangindent 4em\hspace*{2em}} 1803 | \renewcommand\indexspace{\par\addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}\relax}% 1804 | \newcommand{\lettergroup}[1]{}% swallow the letter heading in the index 1805 | 1806 | 1807 | %% 1808 | % A couple commands to incresae the number of floats you can use at a time. 1809 | 1810 | \def\morefloats{% provides a total of 52 floats 1811 | \ifthenelse{\isundefined{\bx@S}}{% 1812 | \@tufte@debug@info@noline{Adding 34 more float slots.} 1813 | \newinsert\bx@S 1814 | \newinsert\bx@T 1815 | \newinsert\bx@U 1816 | \newinsert\bx@V 1817 | \newinsert\bx@W 1818 | \newinsert\bx@X 1819 | \newinsert\bx@Y 1820 | \newinsert\bx@Z 1821 | \newinsert\bx@a 1822 | \newinsert\bx@b 1823 | \newinsert\bx@c 1824 | \newinsert\bx@d 1825 | \newinsert\bx@e 1826 | \newinsert\bx@f 1827 | \newinsert\bx@g 1828 | \newinsert\bx@h 1829 | \newinsert\bx@i 1830 | \newinsert\bx@j 1831 | \newinsert\bx@k 1832 | \newinsert\bx@l 1833 | \newinsert\bx@m 1834 | \newinsert\bx@n 1835 | \newinsert\bx@o 1836 | \newinsert\bx@p 1837 | \newinsert\bx@q 1838 | \newinsert\bx@r 1839 | \newinsert\bx@s 1840 | \newinsert\bx@t 1841 | \newinsert\bx@u 1842 | \newinsert\bx@v 1843 | \newinsert\bx@w 1844 | \newinsert\bx@x 1845 | \newinsert\bx@y 1846 | \newinsert\bx@z 1847 | \gdef\@freelist{\@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E 1848 | \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J 1849 | \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N 1850 | \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R 1851 | \@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V 1852 | \@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z 1853 | \@elt\bx@a\@elt\bx@b\@elt\bx@c\@elt\bx@d\@elt\bx@e 1854 | \@elt\bx@f\@elt\bx@g\@elt\bx@h\@elt\bx@i\@elt\bx@j 1855 | \@elt\bx@k\@elt\bx@l\@elt\bx@m\@elt\bx@n 1856 | \@elt\bx@o\@elt\bx@p\@elt\bx@q\@elt\bx@r 1857 | \@elt\bx@s\@elt\bx@t\@elt\bx@u\@elt\bx@v 1858 | \@elt\bx@w\@elt\bx@x\@elt\bx@y\@elt\bx@z}% 1859 | }{% we've already added another 34 floats, so we'll add 26 more, but that's it! 1860 | \ifthenelse{\isundefined{\bx@AA}}{% 1861 | \@tufte@debug@info@noline{Adding 26 more float slots.} 1862 | \newinsert\bx@AA 1863 | \newinsert\bx@BB 1864 | \newinsert\bx@CC 1865 | \newinsert\bx@DD 1866 | \newinsert\bx@EE 1867 | \newinsert\bx@FF 1868 | \newinsert\bx@GG 1869 | \newinsert\bx@HH 1870 | \newinsert\bx@II 1871 | \newinsert\bx@JJ 1872 | \newinsert\bx@KK 1873 | \newinsert\bx@LL 1874 | \newinsert\bx@MM 1875 | \newinsert\bx@NN 1876 | \newinsert\bx@OO 1877 | \newinsert\bx@PP 1878 | \newinsert\bx@QQ 1879 | \newinsert\bx@RR 1880 | \newinsert\bx@SS 1881 | \newinsert\bx@TT 1882 | \newinsert\bx@UU 1883 | \newinsert\bx@VV 1884 | \newinsert\bx@WW 1885 | \newinsert\bx@XX 1886 | \newinsert\bx@YY 1887 | \newinsert\bx@ZZ 1888 | \gdef\@freelist{\@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E 1889 | \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J 1890 | \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N 1891 | \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R 1892 | \@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V 1893 | \@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z 1894 | \@elt\bx@a\@elt\bx@b\@elt\bx@c\@elt\bx@d\@elt\bx@e 1895 | \@elt\bx@f\@elt\bx@g\@elt\bx@h\@elt\bx@i\@elt\bx@j 1896 | \@elt\bx@k\@elt\bx@l\@elt\bx@m\@elt\bx@n 1897 | \@elt\bx@o\@elt\bx@p\@elt\bx@q\@elt\bx@r 1898 | \@elt\bx@s\@elt\bx@t\@elt\bx@u\@elt\bx@v 1899 | \@elt\bx@w\@elt\bx@x\@elt\bx@y\@elt\bx@z 1900 | \@elt\bx@AA\@elt\bx@BB\@elt\bx@CC\@elt\bx@DD\@elt\bx@EE 1901 | \@elt\bx@FF\@elt\bx@GG\@elt\bx@HH\@elt\bx@II\@elt\bx@JJ 1902 | \@elt\bx@KK\@elt\bx@LL\@elt\bx@MM\@elt\bx@NN 1903 | \@elt\bx@OO\@elt\bx@PP\@elt\bx@QQ\@elt\bx@RR 1904 | \@elt\bx@SS\@elt\bx@TT\@elt\bx@UU\@elt\bx@VV 1905 | \@elt\bx@WW\@elt\bx@XX\@elt\bx@YY\@elt\bx@ZZ}% 1906 | }{% 1907 | \@tufte@error{You may only call \string\morefloats\space twice. See the Tufte-LaTeX documentation for other workarounds} 1908 | {There are already 78 float slots allocated. Try using \string\FloatBarrier\space or \string\clearpage\space to place some floats before creating more.} 1909 | }% 1910 | }% 1911 | } 1912 | 1913 | 1914 | %% 1915 | % Detect if the subfigure package has been loaded 1916 | 1917 | \newboolean{@tufte@packages@subfigure} 1918 | \setboolean{@tufte@packages@subfigure}{false} 1919 | \AtBeginDocument{% 1920 | \@ifpackageloaded{subfigure} 1921 | {\gsetboolean{@tufte@packages@subfigure}{true}} 1922 | {\gsetboolean{@tufte@packages@subfigure}{false}}% 1923 | } 1924 | 1925 | 1926 | %% 1927 | % Detect of the float package has been loaded 1928 | 1929 | \AtBeginDocument{% 1930 | \@ifpackageloaded{float}{% 1931 | % Save the redefined float environment (instead of the LaTeX float environment) 1932 | \let\@tufte@orig@float\@float 1933 | \let\@tufte@orig@endfloat\end@float 1934 | 1935 | % Define Tuftian float styles (with the caption in the margin) 1936 | \newcommand{\floatc@tufteplain}[2]{% 1937 | \begin{lrbox}{\@tufte@caption@box}% 1938 | \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}% 1939 | \@tufte@caption@font{\@fs@cfont #1:} #2\par% 1940 | \end{minipage}% 1941 | \end{lrbox}% 1942 | \smash{\hspace{\@tufte@caption@fill}\usebox{\@tufte@caption@box}}% 1943 | } 1944 | \newcommand{\fs@tufteplain}{% 1945 | \def\@fs@cfont{\@tufte@caption@font}% 1946 | \let\@fs@capt\floatc@tufteplain% 1947 | \def\@fs@pre{}% 1948 | \def\@fs@post{}% 1949 | \def\@fs@mid{}% 1950 | \let\@fs@iftopcapt\iftrue% 1951 | } 1952 | \let\fs@tufteplaintop=\fs@tufteplain 1953 | \let\floatc@tufteplaintop=\floatc@tufteplain 1954 | \newcommand\floatc@tufteruled[2]{% 1955 | {\@fs@cfont #1} #2\par% 1956 | } 1957 | \newcommand\fs@tufteruled{% 1958 | \def\@fs@cfont{\@tufte@caption@font}% 1959 | \let\@fs@capt\floatc@tufteplain% 1960 | \def\@fs@pre{\hrule height.8pt depth0pt width\textwidth \kern2pt}% 1961 | \def\@fs@post{\kern2pt\hrule width\textwidth\relax}% 1962 | \def\@fs@mid{}% 1963 | \let\@fs@iftopcapt\iftrue% 1964 | } 1965 | \newcommand\fs@tufteboxed{% 1966 | \def\@fs@cfont{}% 1967 | \let\@fs@capt\floatc@tufteplain% 1968 | \def\@fs@pre{% 1969 | \setbox\@currbox\vbox{\hbadness10000 1970 | \moveleft3.4pt\vbox{\advance\hsize by6.8pt 1971 | \hrule \hbox to\hsize{\vrule\kern3pt 1972 | \vbox{\kern3pt\box\@currbox\kern3pt}\kern3pt\vrule}\hrule}} 1973 | }% 1974 | \def\@fs@mid{\kern2pt}% 1975 | \def\@fs@post{}% 1976 | \let\@fs@iftopcapt\iftrue% 1977 | } 1978 | }{% 1979 | % Nothing to do 1980 | } 1981 | } 1982 | 1983 | \AtBeginDocument{% 1984 | \@ifpackageloaded{algorithm}{% 1985 | % Set the float style to the Tuftian version 1986 | \ifthenelse{\equal{\ALG@floatstyle}{plain}\OR\equal{\ALG@floatstyle}{ruled}\OR\equal{\ALG@floatstyle}{boxed}}{% 1987 | \@tufte@info@noline{Switching algorithm float style from \ALG@floatstyle\space to tufte\ALG@floatstyle}% 1988 | \floatstyle{tufte\ALG@floatstyle}% 1989 | \restylefloat{algorithm}% 1990 | }{}% 1991 | }{% 1992 | % Nothing to do 1993 | } 1994 | } 1995 | 1996 | 1997 | %% 1998 | % For compatibility with the subfig package, we'll set captions=false so that 1999 | % it doesn't load the caption package (which modifies our own caption 2000 | % formatting). 2001 | 2002 | \PassOptionsToPackage{caption=false}{subfig} 2003 | 2004 | 2005 | %% 2006 | % If debugging is enabled, print the Tufte-LaTeX options and the list of 2007 | % files. 2008 | 2009 | \ifthenelse{\boolean{@tufte@debug}} 2010 | {\PrintTufteSettings\listfiles} 2011 | {} 2012 | 2013 | 2014 | %% 2015 | % If there is a `tufte-common-local.tex' file, load it up. 2016 | 2017 | \IfFileExists{tufte-common-local.tex} 2018 | {\input{tufte-common-local.tex}% 2019 | \@tufte@info@noline{Loading tufte-common-local.tex}} 2020 | {} 2021 | 2022 | 2023 | %% 2024 | % End of file 2025 | \endinput 2026 | 2027 | -------------------------------------------------------------------------------- /tufte-handout.cls: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e}[1994/06/01] 2 | 3 | \ProvidesClass{tufte-handout}[2015/06/21 v3.5.2 Tufte-handout class] 4 | 5 | %% 6 | % Declare we're tufte-handout 7 | \newcommand{\@tufte@class}{article}% the base LaTeX class (defaults to the article/handout style) 8 | \newcommand{\@tufte@pkgname}{tufte-handout}% the name of the package (defaults to tufte-handout) 9 | 10 | %% 11 | % Load the common style elements 12 | \input{tufte-common.def} 13 | 14 | 15 | %% 16 | % Set up any handout-specific stuff now 17 | 18 | %% 19 | % Abstract 20 | 21 | % TODO The abstract should be printed on its own page of the `titlepage' 22 | % option was specified. 23 | \renewenvironment{abstract} 24 | {\begin{quotation}\if@tufte@sfsidenotes\begin{sffamily}\fi} 25 | {\if@tufte@sfsidenotes\end{sffamily}\fi\end{quotation}} 26 | 27 | 28 | %% 29 | % If there is a `tufte-handout-local.tex' file, load it. 30 | 31 | \IfFileExists{tufte-handout-local.tex}{% 32 | \input{tufte-handout-local}% 33 | \@tufte@info@noline{Loading tufte-handout-local.tex}% 34 | }{} 35 | 36 | 37 | %% 38 | % End of file 39 | \endinput 40 | --------------------------------------------------------------------------------