The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Power of L A T EX: Typing Mathematics Easily Anders O. F . - - PowerPoint PPT Presentation
The Power of L A T EX: Typing Mathematics Easily Anders O. F . - - PowerPoint PPT Presentation
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion The Power of L A T EX: Typing Mathematics Easily Anders O. F . Hendrickson Concordia College Moorhead, MN Math/CS
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Outline
1
The Problem
2
The Solution: T EX
3
Pros and Cons
4
Writing as Programming
5
Peculiarities of T EX programming
6
Conclusion
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Question
Question: You want to type some math for a printed paper or journal or book. How hard could that be?
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print a novel? Answer: ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz .,:;?!’"$%&()*-/0123456789 About 78 or so.
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print a novel? Answer: ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz .,:;?!’"$%&()*-/0123456789 About 78 or so.
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print mathematics? Answer: All of the above, and
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print mathematics? Answer: All of the above, and
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print mathematics? Answer: All of the above, and αβγδεζηθικλµνoξπρστυϕχψω
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print mathematics? Answer: All of the above, and αβγδεζηθικλµνoξπρστυϕχψω Γ∆ΘΛΞΠΣΥΦΨΩ
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print mathematics? Answer: All of the above, and αβγδεζηθικλµνoξπρστυϕχψω Γ∆ΘΛΞΠΣΥΦΨΩ ∞∂ℵ∀∃∅
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print mathematics? Answer: All of the above, and αβγδεζηθικλµνoξπρστυϕχψω Γ∆ΘΛΞΠΣΥΦΨΩ ∞∂ℵ∀∃∅ NZQRCHOFK . . .
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print mathematics? Answer: All of the above, and αβγδεζηθικλµνoξπρστυϕχψω Γ∆ΘΛΞΠΣΥΦΨΩ ∞∂ℵ∀∃∅ NZQRCHOFK . . . <≤>≥⊂⊃⊆⊇∈=≡∼ ==≡∼ = ⊳ ⊳[]{}⌊⌋
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print mathematics? Answer: All of the above, and αβγδεζηθικλµνoξπρστυϕχψω Γ∆ΘΛΞΠΣΥΦΨΩ ∞∂ℵ∀∃∅ NZQRCHOFK . . . <≤>≥⊂⊃⊆⊇∈=≡∼ ==≡∼ = ⊳ ⊳[]{}⌊⌋ + − × ÷ ± ∓ ⊕ ⊖ ⊗ ⊙ ∧ ∨ ∩∪
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print mathematics? Answer: All of the above, and αβγδεζηθικλµνoξπρστυϕχψω Γ∆ΘΛΞΠΣΥΦΨΩ ∞∂ℵ∀∃∅ NZQRCHOFK . . . <≤>≥⊂⊃⊆⊇∈=≡∼ ==≡∼ = ⊳ ⊳[]{}⌊⌋ + − × ÷ ± ∓ ⊕ ⊖ ⊗ ⊙ ∧ ∨ ∩∪ →⇒⇔֒ →։
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols
Question: How many symbols does it take to print mathematics? Answer: All of the above, and αβγδεζηθικλµνoξπρστυϕχψω Γ∆ΘΛΞΠΣΥΦΨΩ ∞∂ℵ∀∃∅ NZQRCHOFK . . . <≤>≥⊂⊃⊆⊇∈=≡∼ ==≡∼ = ⊳ ⊳[]{}⌊⌋ + − × ÷ ± ∓ ⊕ ⊖ ⊗ ⊙ ∧ ∨ ∩∪ →⇒⇔֒ →։ . . .
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Arrangement
When printing a novel, all the letters go one right after the
- ther in nice even rows.
When printing mathematics, . . .
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Arrangement
When printing a novel, all the letters go one right after the
- ther in nice even rows.
When printing mathematics, . . .
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Arrangement
When printing a novel, all the letters go one right after the
- ther in nice even rows.
When printing mathematics, . . .
3
- x2 + 7x − 5
log5 x +
∞
- i=1
aixi +
51 times
- y · y · y · y · · · y
+ 5 3
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols that stretch and shrink
We want √ b2 − 4ac, not √ b2 − 4ac And ( sin x cos x )2 looks funny too; we want sin x cos x 2 The fraction line in n(n − 1)(n − 2) · · · 3 · 2 · 1 k(k − 1) · · · 3 · 2 · 1 must stretch. We want x5, not x5, and
3
√ 17, not 3 √ 17. And what about xik vs. xik ?
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols that stretch and shrink
We want √ b2 − 4ac, not √ b2 − 4ac And ( sin x cos x )2 looks funny too; we want sin x cos x 2 The fraction line in n(n − 1)(n − 2) · · · 3 · 2 · 1 k(k − 1) · · · 3 · 2 · 1 must stretch. We want x5, not x5, and
3
√ 17, not 3 √ 17. And what about xik vs. xik ?
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols that stretch and shrink
We want √ b2 − 4ac, not √ b2 − 4ac And ( sin x cos x )2 looks funny too; we want sin x cos x 2 The fraction line in n(n − 1)(n − 2) · · · 3 · 2 · 1 k(k − 1) · · · 3 · 2 · 1 must stretch. We want x5, not x5, and
3
√ 17, not 3 √ 17. And what about xik vs. xik ?
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols that stretch and shrink
We want √ b2 − 4ac, not √ b2 − 4ac And ( sin x cos x )2 looks funny too; we want sin x cos x 2 The fraction line in n(n − 1)(n − 2) · · · 3 · 2 · 1 k(k − 1) · · · 3 · 2 · 1 must stretch. We want x5, not x5, and
3
√ 17, not 3 √ 17. And what about xik vs. xik ?
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Symbols that stretch and shrink
We want √ b2 − 4ac, not √ b2 − 4ac And ( sin x cos x )2 looks funny too; we want sin x cos x 2 The fraction line in n(n − 1)(n − 2) · · · 3 · 2 · 1 k(k − 1) · · · 3 · 2 · 1 must stretch. We want x5, not x5, and
3
√ 17, not 3 √ 17. And what about xik vs. xik ?
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Spacing
Contrast 3−5 with 3 − 5. But in a negation, −7 looks better than − 7. And compare
- cos xdx
- cos x dx
- cos x dx
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Spacing
Contrast 3−5 with 3 − 5. But in a negation, −7 looks better than − 7. And compare
- cos xdx
- cos x dx
- cos x dx
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Problem: Spacing
Contrast 3−5 with 3 − 5. But in a negation, −7 looks better than − 7. And compare
- cos xdx
- cos x dx
- cos x dx
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Some Solutions
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Some Solutions
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Some Solutions
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Some Solutions
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Some Solutions
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Some Solutions
There’s always. . . Microsoft Word. . .
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The Solution: T EX
In 1977, Donald Knuth of Stanford was publishing the 2nd edition of The Art of Computer Programming The publisher’s work disappointed him, so he vowed to write a better computer typesetting system. The result was T EX, written in 1978, improved in 1982, and finally frozen in 1989. In the early 1980’s, Leslie Lamport wrote L
A
T EX, a document preparation system based on T EX.
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
How it works
source file (.tex) L
A
T EX viewable file (.dvi or .pdf)
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
So let’s try it!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Disadvantages:
1
Learning curve steep, oddly shaped. . .
2
Two-step process, not “WYSIWYG”. . .
3
The further you get from simple typesetting, the harder it is to program. . .
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Disadvantages:
1
Learning curve steep, oddly shaped. . . but there is help!
2
Two-step process, not “WYSIWYG”. . .
3
The further you get from simple typesetting, the harder it is to program. . .
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Disadvantages:
1
Learning curve steep, oddly shaped. . . but there is help!
2
Two-step process, not “WYSIWYG”. . . but there are editors!
3
The further you get from simple typesetting, the harder it is to program. . .
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Disadvantages:
1
Learning curve steep, oddly shaped. . . but there is help!
2
Two-step process, not “WYSIWYG”. . . but there are editors!
3
The further you get from simple typesetting, the harder it is to program. . . but there are packages!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Advantages:
1
Mathematics is easy to type!
2
Small file sizes—no hidden bloat.
3
Complete control over source code
4
Universality
5
In-text invisible comments
6
Whitespace allows visible document structure.
7
Completely programmable (more on this later)
8
Packages
9
And best of all. . . it’s free!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Advantages:
1
Mathematics is easy to type!
2
Small file sizes—no hidden bloat.
3
Complete control over source code
4
Universality
5
In-text invisible comments
6
Whitespace allows visible document structure.
7
Completely programmable (more on this later)
8
Packages
9
And best of all. . . it’s free!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Advantages:
1
Mathematics is easy to type!
2
Small file sizes—no hidden bloat.
3
Complete control over source code
4
Universality
5
In-text invisible comments
6
Whitespace allows visible document structure.
7
Completely programmable (more on this later)
8
Packages
9
And best of all. . . it’s free!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Advantages:
1
Mathematics is easy to type!
2
Small file sizes—no hidden bloat.
3
Complete control over source code
4
Universality
5
In-text invisible comments
6
Whitespace allows visible document structure.
7
Completely programmable (more on this later)
8
Packages
9
And best of all. . . it’s free!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Universality
L
A
T EX files are used by academics across the world. are easily exchanged because they’re small. compile exactly the same on all computer systems. can be archived indefinitely, because the language is “frozen.”
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Advantages:
1
Mathematics is easy to type!
2
Small file sizes—no hidden bloat.
3
Complete control over source code
4
Universality
5
In-text invisible comments
6
Whitespace allows visible document structure.
7
Completely programmable (more on this later)
8
Packages
9
And best of all. . . it’s free!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Advantages:
1
Mathematics is easy to type!
2
Small file sizes—no hidden bloat.
3
Complete control over source code
4
Universality
5
In-text invisible comments
6
Whitespace allows visible document structure.
7
Completely programmable (more on this later)
8
Packages
9
And best of all. . . it’s free!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Advantages:
1
Mathematics is easy to type!
2
Small file sizes—no hidden bloat.
3
Complete control over source code
4
Universality
5
In-text invisible comments
6
Whitespace allows visible document structure.
7
Completely programmable (more on this later)
8
Packages
9
And best of all. . . it’s free!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Advantages:
1
Mathematics is easy to type!
2
Small file sizes—no hidden bloat.
3
Complete control over source code
4
Universality
5
In-text invisible comments
6
Whitespace allows visible document structure.
7
Completely programmable (more on this later)
8
Packages
9
And best of all. . . it’s free!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Advantages:
1
Mathematics is easy to type!
2
Small file sizes—no hidden bloat.
3
Complete control over source code
4
Universality
5
In-text invisible comments
6
Whitespace allows visible document structure.
7
Completely programmable (more on this later)
8
Packages
9
And best of all. . . it’s free!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Packages
Developers have written packages and extensions for L
AT
EX
- to. . .
provide multilingual support for languages from Arabic to Chinese automatically generate indices and bibliographies include every mathematical symbol you can imagine handle columns, tables, floating figures, etc. handle graphics and animation Make books, slideshows, newsletters Run database operations like mail merges much, much more.
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Advantages:
1
Mathematics is easy to type!
2
Small file sizes—no hidden bloat.
3
Complete control over source code
4
Universality
5
In-text invisible comments
6
Whitespace allows visible document structure.
7
Completely programmable (more on this later)
8
Packages
9
And best of all. . . it’s free!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Pros and Cons of T EX
Advantages:
1
Mathematics is easy to type!
2
Small file sizes—no hidden bloat.
3
Complete control over source code
4
Universality
5
In-text invisible comments
6
Whitespace allows visible document structure.
7
Completely programmable (more on this later)
8
Packages
9
And best of all. . . it’s free!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Freedom!
Free speech vs. Free beer
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Freedom!
Free speech vs. Free beer frei kostenlos
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Freedom!
Free speech vs. Free beer frei kostenlos You can read the source, $0.00 improve it, and redistribute it.
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Freedom!
Free speech vs. Free beer frei kostenlos You can read the source, $0.00 improve it, and redistribute it. T EX and L
AT
EX are both!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Writing as programming
T EX is a completely programmable language. The key concept: defining macros Examples: \today, \thm, \Z You can even redefine T EX’s original commands, such as \phi and \par You can choose commands that make sense to you!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Writing as programming
T EX is a completely programmable language. The key concept: defining macros Examples: \today, \thm, \Z You can even redefine T EX’s original commands, such as \phi and \par You can choose commands that make sense to you!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Writing as programming
T EX is a completely programmable language. The key concept: defining macros Examples: \today, \thm, \Z You can even redefine T EX’s original commands, such as \phi and \par You can choose commands that make sense to you!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Writing as programming
T EX is a completely programmable language. The key concept: defining macros Examples: \today, \thm, \Z You can even redefine T EX’s original commands, such as \phi and \par You can choose commands that make sense to you!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Writing as programming
T EX is a completely programmable language. The key concept: defining macros Examples: \today, \thm, \Z You can even redefine T EX’s original commands, such as \phi and \par You can choose commands that make sense to you!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Document structure: the idea of L
AT
EX
T EX is about putting ink on the paper; L
AT
EX focuses on your document’s structure Example: section headings \noindent{\Large\bf The Next Section}\par You could encapsulate this in a \newsection command. Then, if you ever changed your mind and wanted it bigger, you could just change \Large to \LARGE in one place to affect all the sections. You separated the logical markup from the typographical markup. This logical markup is exactly what L
AT
EX does, and much more!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Document structure: the idea of L
AT
EX
T EX is about putting ink on the paper; L
AT
EX focuses on your document’s structure Example: section headings \noindent{\Large\bf The Next Section}\par You could encapsulate this in a \newsection command. Then, if you ever changed your mind and wanted it bigger, you could just change \Large to \LARGE in one place to affect all the sections. You separated the logical markup from the typographical markup. This logical markup is exactly what L
AT
EX does, and much more!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Document structure: the idea of L
AT
EX
T EX is about putting ink on the paper; L
AT
EX focuses on your document’s structure Example: section headings \noindent{\Large\bf The Next Section}\par You could encapsulate this in a \newsection command. Then, if you ever changed your mind and wanted it bigger, you could just change \Large to \LARGE in one place to affect all the sections. You separated the logical markup from the typographical markup. This logical markup is exactly what L
AT
EX does, and much more!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Document structure: the idea of L
AT
EX
T EX is about putting ink on the paper; L
AT
EX focuses on your document’s structure Example: section headings \noindent{\Large\bf The Next Section}\par You could encapsulate this in a \newsection command. Then, if you ever changed your mind and wanted it bigger, you could just change \Large to \LARGE in one place to affect all the sections. You separated the logical markup from the typographical markup. This logical markup is exactly what L
AT
EX does, and much more!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Document structure: the idea of L
AT
EX
T EX is about putting ink on the paper; L
AT
EX focuses on your document’s structure Example: section headings \noindent{\Large\bf The Next Section}\par You could encapsulate this in a \newsection command. Then, if you ever changed your mind and wanted it bigger, you could just change \Large to \LARGE in one place to affect all the sections. You separated the logical markup from the typographical markup. This logical markup is exactly what L
AT
EX does, and much more!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Document structure: the idea of L
AT
EX
T EX is about putting ink on the paper; L
AT
EX focuses on your document’s structure Example: section headings \noindent{\Large\bf The Next Section}\par You could encapsulate this in a \newsection command. Then, if you ever changed your mind and wanted it bigger, you could just change \Large to \LARGE in one place to affect all the sections. You separated the logical markup from the typographical markup. This logical markup is exactly what L
AT
EX does, and much more!
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
More on L
A
T EX
L
A
T EX’s document structuring features include Automatic numbering of chapters, sections, theorems, lists, etc. Automatic cross-referencing BIBT EX: automatic bibliographies \makeindex: automatic indices
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
The flexibility of structured documents
If we use logical markup in an article and submit it to a journal, the publisher can automatically adjust the article to the journal’s style \defnstyle vs. \emph \renewcommand{\labelenumi}{G\theenumi.} Practice exams with and without solutions
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Macro expansion programming
The primary mechanism of T EX is macro expansion, but there’s a little more: \if. . . \else. . . \fi conditionals registers for saving integers, lengths, and boxes
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Example: A Loop
Let’s say we want a loop to print 1 2 3 . Our syntax will be \loop \fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4 \repeat Here is how our \loop macro is defined: \def\loop#1\repeat{\def\body{#1}\iterate} \def\iterate{\body \let\next=\iterate \else \let\next=\relax \fi \next}
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: T EX sees
\loop \fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4 \repeat
State of the Machine: \body is undefined \next is undefined \MyCount is 1
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: T EX sees
\def\body{\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4} \iterate
State of the Machine: \body is undefined \next is undefined \MyCount is 1
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: T EX sees
\iterate
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is undefined \MyCount is 1
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: T EX sees
\body \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is undefined \MyCount is 1
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: T EX sees
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4 \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is undefined \MyCount is 1
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 T EX sees
\advance\MyCount by 1 \ifnum\MyCount<4 \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is undefined \MyCount is 1
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 T EX sees
\ifnum\MyCount<4 \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is undefined \MyCount is 2
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 T EX sees
\let\next=\iterate \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is undefined \MyCount is 2
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 T EX sees
\next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 2
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 T EX sees
\iterate
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 2
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 T EX sees
\body \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 2
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 T EX sees
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4 \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 2
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 T EX sees
\advance\MyCount by 1 \ifnum\MyCount<4 \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 2
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 T EX sees
\ifnum\MyCount<4 \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 3
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 T EX sees
\let\next=\iterate \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 3
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 T EX sees
\next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 3
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 T EX sees
\iterate
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 3
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 T EX sees
\body \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 3
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 T EX sees
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4 \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 3
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 3 T EX sees
\advance\MyCount by 1 \ifnum\MyCount<4 \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 3
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 3 T EX sees
\ifnum\MyCount<4 \let\next=\iterate \else \let\next=\relax \fi \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 4
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 3 T EX sees
\let\next=\relax \next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\iterate
\MyCount is 4
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 3 T EX sees
\next
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\relax
\MyCount is 4
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 3 T EX sees
\relax
State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\relax
\MyCount is 4
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Our loop in action
Output: 1 2 3 T EX sees State of the Machine: \body is
\fbox{\the\MyCount} \advance\MyCount by 1 \ifnum\MyCount<4
\next is
\relax
\MyCount is 4
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion
Let’s close by looking at some examples.
The Problem The Solution: T EX Pros and Cons Writing as Programming Peculiarities of T EX programming Conclusion