From 5ef1d0f461742779e06d395eeb2300f1a9172fe8 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 12 Jan 2023 10:30:53 -0800 Subject: [PATCH] Moved tex packages into this repo --- Advanced/Cryptography/main.tex | 4 +- Advanced/Error-Correcting Codes/main.tex | 4 +- Advanced/Euler's Number/main.tex | 4 +- Advanced/Graph Algorithms/main.tex | 4 +- Advanced/Lambda Calculus/main.tex | 5 +- Advanced/Pidgeonhole Problems/main.tex | 4 +- .../An Introduction to Graph Theory/main.tex | 7 +- Intermediate/Combinatorics/main.tex | 4 +- Intermediate/Instant Insanity/main.tex | 4 +- Intermediate/Newton's Laws/main.tex | 6 +- Intermediate/Probability/main.tex | 4 +- Intermediate/Slide Rules/main.tex | 4 +- Intermediate/Slide Rules/sliderule.sty | 534 ++++++++++++++++++ Intermediate/Vectors 1/main.tex | 4 +- Intermediate/Vectors 2/main.tex | 4 +- Misc/Moscow Puzzles/main.tex | 4 +- Misc/Warm-Ups/electician.tex | 4 +- Misc/Warm-Ups/raid.tex | 4 +- README.md | 30 +- resources/ormc_handout.cls | 441 +++++++++++++++ 20 files changed, 1022 insertions(+), 57 deletions(-) create mode 100755 Intermediate/Slide Rules/sliderule.sty create mode 100644 resources/ormc_handout.cls diff --git a/Advanced/Cryptography/main.tex b/Advanced/Cryptography/main.tex index 6f3652c..8e9f7d6 100755 --- a/Advanced/Cryptography/main.tex +++ b/Advanced/Cryptography/main.tex @@ -1,11 +1,9 @@ -% https://git.betalupi.com/Mark/latex % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 \documentclass[ solutions, singlenumbering -]{ormc_handout} +]{../../resources/ormc_handout} \usepackage{amsmath} \usepackage{amssymb} diff --git a/Advanced/Error-Correcting Codes/main.tex b/Advanced/Error-Correcting Codes/main.tex index 8960bf5..ad0e8c7 100755 --- a/Advanced/Error-Correcting Codes/main.tex +++ b/Advanced/Error-Correcting Codes/main.tex @@ -1,10 +1,8 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 \documentclass[ solutions -]{ormc_handout} +]{../../resources/ormc_handout} \usepackage{tikz} diff --git a/Advanced/Euler's Number/main.tex b/Advanced/Euler's Number/main.tex index bdc0266..e42de35 100755 --- a/Advanced/Euler's Number/main.tex +++ b/Advanced/Euler's Number/main.tex @@ -1,11 +1,9 @@ -% https://git.betalupi.com/Mark/latex % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 \documentclass[ singlenumbering, nosolutions -]{ormc_handout} +]{../../resources/ormc_handout} \usepackage{amsmath} \usepackage{amssymb} diff --git a/Advanced/Graph Algorithms/main.tex b/Advanced/Graph Algorithms/main.tex index bdf9a5b..bd47eb0 100755 --- a/Advanced/Graph Algorithms/main.tex +++ b/Advanced/Graph Algorithms/main.tex @@ -1,10 +1,8 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 \documentclass[ solutions -]{ormc_handout} +]{../../resources/ormc_handout} \input{tikxset} diff --git a/Advanced/Lambda Calculus/main.tex b/Advanced/Lambda Calculus/main.tex index 7346b39..5f5ed22 100755 --- a/Advanced/Lambda Calculus/main.tex +++ b/Advanced/Lambda Calculus/main.tex @@ -1,12 +1,9 @@ -% https://git.betalupi.com/Mark/latex % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 - \documentclass[ solutions, singlenumbering -]{ormc_handout} +]{../../resources/ormc_handout} \usepackage{url} \usepackage{mathtools} % for \coloneqq diff --git a/Advanced/Pidgeonhole Problems/main.tex b/Advanced/Pidgeonhole Problems/main.tex index 2d2eef6..0a2edfe 100755 --- a/Advanced/Pidgeonhole Problems/main.tex +++ b/Advanced/Pidgeonhole Problems/main.tex @@ -1,10 +1,8 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 \documentclass[ solutions -]{ormc_handout} +]{../../resources/ormc_handout} \usepackage{amsmath} \usepackage{amssymb} diff --git a/Intermediate/An Introduction to Graph Theory/main.tex b/Intermediate/An Introduction to Graph Theory/main.tex index 4bb689f..2926de6 100755 --- a/Intermediate/An Introduction to Graph Theory/main.tex +++ b/Intermediate/An Introduction to Graph Theory/main.tex @@ -1,11 +1,8 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.0.6 \documentclass[ - solutions, - simplefooter -]{ormc_handout} + solutions +]{../../resources/ormc_handout} \usepackage{tkz-graph} diff --git a/Intermediate/Combinatorics/main.tex b/Intermediate/Combinatorics/main.tex index 41df0fd..06ba540 100755 --- a/Intermediate/Combinatorics/main.tex +++ b/Intermediate/Combinatorics/main.tex @@ -1,8 +1,6 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 -\documentclass[solutions]{ormc_handout} +\documentclass[solutions]{../../resources/ormc_handout} \newcommand{\nck}[2] { \ensuremath{ diff --git a/Intermediate/Instant Insanity/main.tex b/Intermediate/Instant Insanity/main.tex index 716d0db..d74a262 100755 --- a/Intermediate/Instant Insanity/main.tex +++ b/Intermediate/Instant Insanity/main.tex @@ -1,10 +1,8 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 \documentclass[ solutions -]{ormc_handout} +]{../../resources/ormc_handout} \usepackage{tkz-graph} diff --git a/Intermediate/Newton's Laws/main.tex b/Intermediate/Newton's Laws/main.tex index 0d8c59f..18de8a0 100755 --- a/Intermediate/Newton's Laws/main.tex +++ b/Intermediate/Newton's Laws/main.tex @@ -1,8 +1,8 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.0.6 -\documentclass[solutions, simplefooter]{ormc_handout} +\documentclass[ + solutions +]{../../resources/ormc_handout} \begin{document} diff --git a/Intermediate/Probability/main.tex b/Intermediate/Probability/main.tex index b0702c8..91e594c 100755 --- a/Intermediate/Probability/main.tex +++ b/Intermediate/Probability/main.tex @@ -1,8 +1,6 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 -\documentclass[solutions]{ormc_handout} +\documentclass[solutions]{../../resources/ormc_handout} % Quick P() macro. diff --git a/Intermediate/Slide Rules/main.tex b/Intermediate/Slide Rules/main.tex index 60a1016..8838305 100755 --- a/Intermediate/Slide Rules/main.tex +++ b/Intermediate/Slide Rules/main.tex @@ -1,10 +1,8 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 \documentclass[ solutions -]{ormc_handout} +]{../../resources/ormc_handout} \usepackage{pdfpages} \usepackage{sliderule} diff --git a/Intermediate/Slide Rules/sliderule.sty b/Intermediate/Slide Rules/sliderule.sty new file mode 100755 index 0000000..13e3995 --- /dev/null +++ b/Intermediate/Slide Rules/sliderule.sty @@ -0,0 +1,534 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{sliderule}[2022/08/22 Slide rule tools] + +\RequirePackage{tikz} +\RequirePackage{ifthen} + + +% Scale functions: +% See https://sliderulemuseum.com/SR_Scales.htm +% +% l: length of the rule +% n: the number on the rule +% +% A/B: (l/2) * log(n) +% C/D: l / log(n) +% CI: abs(l * log(10 / n) - l) +% K: (l/3) * log(n) +% +% L: n * l +% T: l * log(10 * tan(n)) +% S: l * log(10 * sin(n)) + +\def\sliderulewidth{10} + +\def\abscalefn(#1){(\sliderulewidth/2) * log10(#1)} +\def\cdscalefn(#1){(\sliderulewidth * log10(#1))} +\def\ciscalefn(#1){(\sliderulewidth - \cdscalefn(#1))} +\def\kscalefn(#1){(\sliderulewidth/3) * log10(#1)} +\def\lscalefn(#1){(\sliderulewidth * #1)} +\def\tscalefn(#1){(\sliderulewidth * log10(10 * tan(#1)))} +\def\sscalefn(#1){(\sliderulewidth * log10(10 * sin(#1)))} + + +% Arguments: +% Label +% x of start +% y of start +\newcommand{\linearscale}[3]{ + \draw[black] ({#1}, #2) -- ({#1 + \sliderulewidth}, #2); + \draw[black] ({#1}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.9); + \draw[black] ({#1}, #2 + 0.9) -- ({#1}, #2 + 0.7); + \draw[black] ({#1 + \sliderulewidth}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.7); + + \draw ({#1 - 0.1}, #2 + 0.5) node[left] {#3}; + + % Numbers and marks + \foreach \i in {0,..., 10}{ + \draw[black] + ({#1 + (\sliderulewidth / 10) * \i}, #2) -- + ({#1 + (\sliderulewidth / 10) * \i}, #2 + 0.3) + node[above] {\i}; + } + + % Submarks + \foreach \n in {0, ..., 9} { + \foreach \i in {1,..., 9} { + \ifthenelse{\i=5}{ + \draw[black] + ({#1 + (\sliderulewidth / 10) * (\n + \i / 10)}, #2) -- + ({#1 + (\sliderulewidth / 10) * (\n + \i / 10)}, #2 + 0.2); + } { + \draw[black] + ({#1 + (\sliderulewidth / 10) * (\n + \i / 10)}, #2) -- + ({#1 + (\sliderulewidth / 10) * (\n + \i / 10)}, #2 + 0.1); + } + } + } +} + + +% Arguments: +% Label +% x of start +% y of start +\newcommand{\abscale}[3]{ + \draw[black] ({#1}, #2) -- ({#1 + \sliderulewidth}, #2); + \draw[black] ({#1}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.9); + \draw[black] ({#1}, #2 + 0.9) -- ({#1}, #2 + 0.7); + \draw[black] ({#1 + \sliderulewidth}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.7); + + + \draw ({#1 - 0.1}, #2 + 0.5) node[left] {#3}; + + % Numbers and marks 1 - 9 + \foreach \i in {1,..., 9}{ + \draw[black] + ({#1 + \abscalefn(\i)}, #2) -- + ({#1 + \abscalefn(\i)}, #2 + 0.3) + node[above] {\i}; + } + % Numbers and marks 10 - 100 + \foreach \i in {1,..., 10}{ + \draw[black] + ({#1 + \abscalefn(10 * \i)}, #2) -- + ({#1 + \abscalefn(10 * \i)}, #2 + 0.3) + node[above] {\ifthenelse{\i=10}{1}{\i}}; + } + + % Submarks 1 - 9 + \foreach \n in {1, ..., 9} { + \ifthenelse{\n<5}{ + \foreach \i in {1,..., 9} + } { + \foreach \i in {2,4,6,8} + } + { + \ifthenelse{\i=5}{ + \draw[black] + ({#1 + \abscalefn(\n + \i / 10)}, #2) -- + ({#1 + \abscalefn(\n + \i / 10)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \abscalefn(\n + \i / 10)}, #2) -- + ({#1 + \abscalefn(\n + \i / 10)}, #2 + 0.1); + } + } + } + + % Submarks 10 - 100 + \foreach \n in {10,20,...,90} { + \ifthenelse{\n<50}{ + \foreach \i in {1,..., 9} + } { + \foreach \i in {2,4,6,8} + } + { + \ifthenelse{\i=5}{ + \draw[black] + ({#1 + \abscalefn(\n + \i)}, #2) -- + ({#1 + \abscalefn(\n + \i)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \abscalefn(\n + \i)}, #2) -- + ({#1 + \abscalefn(\n + \i)}, #2 + 0.1); + } + } + } +} + +\newcommand{\cdscale}[3]{ + \draw[black] ({#1}, #2) -- ({#1 + \sliderulewidth}, #2); + \draw[black] ({#1}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.9); + \draw[black] ({#1}, #2 + 0.9) -- ({#1}, #2 + 0.7); + \draw[black] ({#1 + \sliderulewidth}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.7); + + + \draw ({#1 - 0.1}, #2 + 0.5) node[left] {#3}; + + % Numbers and marks 1 - 10 + \foreach \i in {1,..., 10}{ + \draw[black] + ({#1 + \cdscalefn(\i)}, #2) -- + ({#1 + \cdscalefn(\i)}, #2 + 0.3) + node[above] {\ifthenelse{\i=10}{1}{\i}}; + } + + % Submarks 1 - 9 + \foreach \n in {1, ..., 9} { + \ifthenelse{\n<3}{ + \foreach \i in {5,10,...,95} + } { + \foreach \i in {10,20,...,90} + } + { + \ifthenelse{\i=50}{ + \draw[black] + ({#1 + \cdscalefn(\n + \i / 100)}, #2) -- + ({#1 + \cdscalefn(\n + \i / 100)}, #2 + 0.2); + \ifthenelse{\n=1}{ + \draw + ({#1 + \cdscalefn(\n + \i / 100)}, #2 + 0.2) + node [above] {1.5}; + }{} + } { + \ifthenelse{ + \i=10 \OR \i=20 \OR \i=30 \OR \i=40 \OR + \i=60 \OR \i=70 \OR \i=80 \OR \i=90 + }{ + \draw[black] + ({#1 + \cdscalefn(\n + \i / 100)}, #2) -- + ({#1 + \cdscalefn(\n + \i / 100)}, #2 + 0.15); + } { + \draw[black] + ({#1 + \cdscalefn(\n + \i / 100)}, #2) -- + ({#1 + \cdscalefn(\n + \i / 100)}, #2 + 0.1); + } + } + } + } +} + +\newcommand{\ciscale}[3]{ + \draw[black] ({#1}, #2) -- ({#1 + \sliderulewidth}, #2); + \draw[black] ({#1}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.9); + \draw[black] ({#1}, #2 + 0.9) -- ({#1}, #2 + 0.7); + \draw[black] ({#1 + \sliderulewidth}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.7); + + + \draw ({#1 - 0.1}, #2 + 0.5) node[left] {#3}; + + % Numbers and marks + \foreach \i in {1,...,10}{ + \draw[black] + ({#1 + \ciscalefn(\i)}, #2) -- + ({#1 + \ciscalefn(\i)}, #2 + 0.3) + node[above] {\ifthenelse{\i=10}{1}{\ifthenelse{\i=0}{0}{.\i}}}; + } + + % Submarks 1 - 9 + \foreach \n in {1, ..., 9} { + \ifthenelse{\n<3}{ + \foreach \i in {5,10,...,95} + } { + \foreach \i in {10,20,...,90} + } + { + \ifthenelse{\i=50}{ + \draw[black] + ({#1 + \ciscalefn(\n + \i / 100)}, #2) -- + ({#1 + \ciscalefn(\n + \i / 100)}, #2 + 0.2); + \ifthenelse{\n=1}{ + \draw + ({#1 + \ciscalefn(\n + \i / 100)}, #2 + 0.2) + node [above] {1.5}; + }{} + } { + \ifthenelse{ + \i=10 \OR \i=20 \OR \i=30 \OR \i=40 \OR + \i=60 \OR \i=70 \OR \i=80 \OR \i=90 + }{ + \draw[black] + ({#1 + \ciscalefn(\n + \i / 100)}, #2) -- + ({#1 + \ciscalefn(\n + \i / 100)}, #2 + 0.15); + } { + \draw[black] + ({#1 + \ciscalefn(\n + \i / 100)}, #2) -- + ({#1 + \ciscalefn(\n + \i / 100)}, #2 + 0.1); + } + } + } + } +} + +\newcommand{\kscale}[3]{ + \draw[black] ({#1}, #2) -- ({#1 + \sliderulewidth}, #2); + \draw[black] ({#1}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.9); + \draw[black] ({#1}, #2 + 0.9) -- ({#1}, #2 + 0.7); + \draw[black] ({#1 + \sliderulewidth}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.7); + + + \draw ({#1 - 0.1}, #2 + 0.5) node[left] {#3}; + + % Numbers and marks 1 - 9 + \foreach \i in {1,...,9}{ + \draw[black] + ({#1 + \kscalefn(\i)}, #2) -- + ({#1 + \kscalefn(\i)}, #2 + 0.3) + node[above] {\i}; + } + % Numbers and marks 10 - 90 + \foreach \i in {1,..., 9}{ + \draw[black] + ({#1 + \kscalefn(10 * \i)}, #2) -- + ({#1 + \kscalefn(10 * \i)}, #2 + 0.3) + node[above] {\ifthenelse{\i=10}{1}{\i}}; + } + % Numbers and marks 100 - 1000 + \foreach \i in {1,..., 10}{ + \draw[black] + ({#1 + \kscalefn(100 * \i)}, #2) -- + ({#1 + \kscalefn(100 * \i)}, #2 + 0.3) + node[above] {\ifthenelse{\i=10}{1}{\i}}; + } + + % Submarks 1 - 9 + \foreach \n in {1, ..., 9} { + \ifthenelse{\n<4}{ + \foreach \i in {1,..., 9} + } { + \foreach \i in {2,4,6,8} + } + { + \ifthenelse{\i=5}{ + \draw[black] + ({#1 + \kscalefn(\n + \i / 10)}, #2) -- + ({#1 + \kscalefn(\n + \i / 10)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \kscalefn(\n + \i / 10)}, #2) -- + ({#1 + \kscalefn(\n + \i / 10)}, #2 + 0.1); + } + } + } + + % Submarks 10 - 90 + \foreach \n in {10,20,...,90} { + \ifthenelse{\n<40}{ + \foreach \i in {1,..., 9} + } { + \foreach \i in {2,4,6,8} + } + { + \ifthenelse{\i=5}{ + \draw[black] + ({#1 + \kscalefn(\n + \i)}, #2) -- + ({#1 + \kscalefn(\n + \i)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \kscalefn(\n + \i)}, #2) -- + ({#1 + \kscalefn(\n + \i)}, #2 + 0.1); + } + } + } + + % Submarks 100 - 1000 + \foreach \n in {100,200,...,900} { + \ifthenelse{\n<400}{ + \foreach \i in {10,20,...,90} + } { + \foreach \i in {20,40,60,80} + } + { + \ifthenelse{\i=50}{ + \draw[black] + ({#1 + \kscalefn(\n + \i)}, #2) -- + ({#1 + \kscalefn(\n + \i)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \kscalefn(\n + \i)}, #2) -- + ({#1 + \kscalefn(\n + \i)}, #2 + 0.1); + } + } + } +} + +\newcommand{\lscale}[3]{ + \draw[black] ({#1}, #2) -- ({#1 + \sliderulewidth}, #2); + \draw[black] ({#1}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.9); + \draw[black] ({#1}, #2 + 0.9) -- ({#1}, #2 + 0.7); + \draw[black] ({#1 + \sliderulewidth}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.7); + + + \draw ({#1 - 0.1}, #2 + 0.5) node[left] {#3}; + + % Numbers and marks + \foreach \i in {0,..., 10}{ + \draw[black] + ({#1 + \lscalefn(\i / 10)}, #2) -- + ({#1 + \lscalefn(\i / 10)}, #2 + 0.3) + node[above] {\ifthenelse{\i=10}{1}{\ifthenelse{\i=0}{0}{.\i}}}; + } + + % Submarks + \foreach \n in {0, ..., 9} { + \foreach \i in {1,...,19} { + \ifthenelse{\i=10}{ + \draw[black] + ({#1 + \lscalefn((\n + (\i / 20))/10)}, #2) -- + ({#1 + \lscalefn((\n + (\i / 20))/10)}, #2 + 0.2); + } { + \ifthenelse{ + \i=1 \OR \i=3 \OR \i=5 \OR \i=7 \OR + \i=9 \OR \i=11 \OR \i=13 \OR \i=15 \OR + \i=17 \OR \i=19 + }{ + \draw[black] + ({#1 + \lscalefn((\n + (\i / 20))/10)}, #2) -- + ({#1 + \lscalefn((\n + (\i / 20))/10)}, #2 + 0.1); + } { + \draw[black] + ({#1 + \lscalefn((\n + (\i / 20))/10)}, #2) -- + ({#1 + \lscalefn((\n + (\i / 20))/10)}, #2 + 0.15); + } + } + } + } +} + +\newcommand{\tscale}[3]{ + \draw[black] ({#1}, #2) -- ({#1 + \sliderulewidth}, #2); + \draw[black] ({#1}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.9); + \draw[black] ({#1}, #2 + 0.9) -- ({#1}, #2 + 0.7); + \draw[black] ({#1 + \sliderulewidth}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.7); + + % First line + \draw[black] ({#1}, #2) -- ({#1}, #2 + 0.2); + + + \draw ({#1 - 0.1}, #2 + 0.5) node[left] {#3}; + + % Numbers and marks 6 - 10 + \foreach \i in {6,...,9,10,15,...,45}{ + \draw[black] + ({#1 + \tscalefn(\i)}, #2) -- + ({#1 + \tscalefn(\i)}, #2 + 0.3) + node[above] {\i}; + } + + % Submarks 6 - 10 + \foreach \n in {6, ..., 9} { + \foreach \i in {1,...,9}{ + \ifthenelse{\i=5}{ + \draw[black] + ({#1 + \tscalefn(\n + \i / 10)}, #2) -- + ({#1 + \tscalefn(\n + \i / 10)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \tscalefn(\n + \i / 10)}, #2) -- + ({#1 + \tscalefn(\n + \i / 10)}, #2 + 0.1); + } + } + } + + % Submarks 15 - 45 + \foreach \n in {10, 15, ..., 40} { + \foreach \i in {1,...,24}{ + \ifthenelse{ + \i=5 \OR \i=10 \OR \i=15 \OR \i=20 + } { + \draw[black] + ({#1 + \tscalefn(\n + \i / 5)}, #2) -- + ({#1 + \tscalefn(\n + \i / 5)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \tscalefn(\n + \i / 5)}, #2) -- + ({#1 + \tscalefn(\n + \i / 5)}, #2 + 0.1); + } + } + } +} + +\newcommand{\sscale}[3]{ + \draw[black] ({#1}, #2) -- ({#1 + \sliderulewidth}, #2); + \draw[black] ({#1}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.9); + \draw[black] ({#1}, #2 + 0.9) -- ({#1}, #2 + 0.7); + \draw[black] ({#1 + \sliderulewidth}, #2 + 0.9) -- ({#1 + \sliderulewidth}, #2 + 0.7); + + % First line + \draw[black] ({#1}, #2) -- ({#1}, #2 + 0.2); + + + \draw ({#1 - 0.1}, #2 + 0.5) node[left] {#3}; + + % Numbers and marks + \foreach \i in {6,...,9,10,15,...,30,40,50,...,60,90}{ + \draw[black] + ({#1 + \sscalefn(\i)}, #2) -- + ({#1 + \sscalefn(\i)}, #2 + 0.3) + node[above] {\i}; + } + + % Submarks 6 - 10 + \foreach \n in {6, ..., 9} { + \foreach \i in {1,...,9}{ + \ifthenelse{\i=5}{ + \draw[black] + ({#1 + \sscalefn(\n + \i / 10)}, #2) -- + ({#1 + \sscalefn(\n + \i / 10)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \sscalefn(\n + \i / 10)}, #2) -- + ({#1 + \sscalefn(\n + \i / 10)}, #2 + 0.1); + } + } + } + + % Submarks 15 - 30 + \foreach \n in {10, 15, ..., 25} { + \foreach \i in {1,...,24}{ + \ifthenelse{ + \i=5 \OR \i=10 \OR \i=15 \OR \i=20 + } { + \draw[black] + ({#1 + \sscalefn(\n + \i / 5)}, #2) -- + ({#1 + \sscalefn(\n + \i / 5)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \sscalefn(\n + \i / 5)}, #2) -- + ({#1 + \sscalefn(\n + \i / 5)}, #2 + 0.1); + } + } + } + + % Submarks 30 + \foreach \n in {30} { + \foreach \i in {1,...,19}{ + \ifthenelse{ + \i=2 \OR \i=4 \OR \i=6 \OR \i=8 \OR + \i=10 \OR \i=12 \OR \i=14 \OR \i=16 \OR + \i=18 + } { + \draw[black] + ({#1 + \sscalefn(\n + \i / 2)}, #2) -- + ({#1 + \sscalefn(\n + \i / 2)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \sscalefn(\n + \i / 2)}, #2) -- + ({#1 + \sscalefn(\n + \i / 2)}, #2 + 0.1); + } + } + } + + % Submarks 40 - 50 + \foreach \n in {40, 50} { + \foreach \i in {1,...,9}{ + \ifthenelse{ + \i=5 \OR \i=10 \OR \i=15 \OR \i=20 + } { + \draw[black] + ({#1 + \sscalefn(\n + \i)}, #2) -- + ({#1 + \sscalefn(\n + \i)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \sscalefn(\n + \i)}, #2) -- + ({#1 + \sscalefn(\n + \i)}, #2 + 0.1); + } + } + } + + % Submarks 60 + \foreach \i in {1,...,10}{ + \ifthenelse{ + \i=5 \OR \i=10 + } { + \draw[black] + ({#1 + \sscalefn(60 + \i * 2)}, #2) -- + ({#1 + \sscalefn(60 + \i * 2)}, #2 + 0.2); + } { + \draw[black] + ({#1 + \sscalefn(60 + \i * 2)}, #2) -- + ({#1 + \sscalefn(60 + \i * 2)}, #2 + 0.1); + } + } +} diff --git a/Intermediate/Vectors 1/main.tex b/Intermediate/Vectors 1/main.tex index 9da6e22..0e0eb70 100755 --- a/Intermediate/Vectors 1/main.tex +++ b/Intermediate/Vectors 1/main.tex @@ -1,8 +1,6 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.0.4 -\documentclass[solutions]{ormc_handout} +\documentclass[solutions]{../../resources/ormc_handout} \usepackage{adjustbox} \begin{document} diff --git a/Intermediate/Vectors 2/main.tex b/Intermediate/Vectors 2/main.tex index f71a28c..be80758 100755 --- a/Intermediate/Vectors 2/main.tex +++ b/Intermediate/Vectors 2/main.tex @@ -1,8 +1,6 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.0.6 -\documentclass[solutions]{ormc_handout} +\documentclass[solutions]{../../resources/ormc_handout} \begin{document} diff --git a/Misc/Moscow Puzzles/main.tex b/Misc/Moscow Puzzles/main.tex index 9587847..1e9911a 100755 --- a/Misc/Moscow Puzzles/main.tex +++ b/Misc/Moscow Puzzles/main.tex @@ -1,10 +1,8 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 \documentclass[ solutions -]{ormc_handout} +]{../../resources/ormc_handout} \usepackage{subfiles} \usepackage{graphicx} diff --git a/Misc/Warm-Ups/electician.tex b/Misc/Warm-Ups/electician.tex index b2dcb8a..2728546 100755 --- a/Misc/Warm-Ups/electician.tex +++ b/Misc/Warm-Ups/electician.tex @@ -1,12 +1,10 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 \documentclass[ nosolutions, singlenumbering, nopagenumber -]{ormc_handout} +]{../../resources/ormc_handout} % We put nodes in a separate layer, so we can % slightly overlap with paths for a perfect fit diff --git a/Misc/Warm-Ups/raid.tex b/Misc/Warm-Ups/raid.tex index c884f59..28187ab 100755 --- a/Misc/Warm-Ups/raid.tex +++ b/Misc/Warm-Ups/raid.tex @@ -1,12 +1,10 @@ -% https://git.betalupi.com/Mark/latex-packages % use [nosolutions] flag to hide solutions. % use [solutions] flag to show solutions. -% Last built with version 1.1.0 \documentclass[ nosolutions, singlenumbering, nopagenumber -]{ormc_handout} +]{../../resources/ormc_handout} \usepackage{tikz} diff --git a/README.md b/README.md index c6ba54e..1c6b9d6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # ORMC Handouts -This repository contains all the handouts I've written for the [ORMC](https://circles.math.ucla.edu/circles/). Most of them are built using [these](https://git.betalupi.com/Mark/latex) packages. - +This repository contains all the handouts I've written for the [ORMC](https://circles.math.ucla.edu/circles/). If you are not affiliated with the ORMC, ask for permission before using these. @@ -11,4 +10,29 @@ Handouts are sorted by the class they're for: - [`./Intermediate`](./Intermediate/): Grades 5 - 9 - [`./Advanced`](./Advanced): Grades 9 - 12 -These grade levels are estimates. \ No newline at end of file +Grade levels are estimates. + +## Usage + +Most handouts use a custom document class. If you move any files out of this repository, you'll need to change a few things for the handout to compile: + 1. Download [`./resources/ormc_handout.cls`](./resources/ormc_handout.cls). + 2. Put it in the same directory as the handout. + 3. Fix the include path at the top of the handout. + + Usually, you'll need to replace + + ```latex + \documentclass[ + solutions + ]{../../resources/ormc_handout} + ``` + + with + + ```latex + \documentclass[ + solutions + ]{ormc_handout} + ``` + +**Warning:** As of now, `ormc_handout.cls` does not work with hyperref. \ No newline at end of file diff --git a/resources/ormc_handout.cls b/resources/ormc_handout.cls new file mode 100644 index 0000000..d630a79 --- /dev/null +++ b/resources/ormc_handout.cls @@ -0,0 +1,441 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{ormc_handout}[2022/05/07 1.1.0 ORMC Handout] + + +% Boolean that determines solution behavior. +% If false, solutions and instructor notes are hidden. +\newif{\ifsolutions} +\solutionstrue + +% Boolean that determines object numbering +% If true, the same counter is used for all objects. +\newif{\ifsinglenumbering} +\singlenumberingfalse + +% Boolean. If true, don't number pages. +\newif{\ifnopagenumber} +\nopagenumberfalse + +% Declare and parse arguments +\DeclareOption{solutions}{\solutionstrue} +\DeclareOption{nosolutions}{\solutionsfalse} +\DeclareOption{singlenumbering}{\singlenumberingtrue} +\DeclareOption{nopagenumber}{\nopagenumbertrue} +\DeclareOption*{\ClassWarning{ormc_handout}{\CurrentOption ignored}} +\ProcessOptions\relax + +% Based on article class +\LoadClass{article} +\makeatletter % Allow commands with @ (\makeatother is at end of this file) + +\newcommand\sbullet[1][.5]{\mathbin{\vcenter{\hbox{\scalebox{#1}{$\bullet$}}}}} + +\renewcommand{\labelitemi}{$\sbullet$} +\renewcommand{\labelitemii}{$\cdot$} + + +% Hack for command-line arguments. +% To force a build with solutions, run +% latexmk +% -synctex=1 +% -interaction=nonstopmode +% -file-line-error +% -outdir=%OUTDIR% +% -xelatex +% -jobname=%DOCFILE%.sol +% -pdfxelatex="xelatex %O \"\\def\\argYesSolutions{1}\\input{%S}\"" +% %DOC% +% +% Or, make a new file with the contents +% \def\argYesSolutions{1}\input{} +% and build that with latex. +\ifdefined\argYesSolutions + \solutionstrue +\else + \ifdefined\argNoSolutions + \solutionsfalse + \fi +\fi + + + + +%%% PACKAGES %%% + + +% Set up page geometry. +% MUST BE DONE FIRST! +\RequirePackage{geometry} +\geometry{ + paper = letterpaper, + top = 25mm, + bottom = 30mm, + left = 30mm, + right = 30mm, + headheight = 75mm, + footskip = 15mm, + headsep = 75mm, +} + +\RequirePackage{enumitem} % list customization +\RequirePackage{xparse} % Provides powerful macros via \NewDocumentCommand +\RequirePackage{xcolor} % For colored text +\RequirePackage{tcolorbox} % For solution boxes +\RequirePackage{tikz} % Used by \boxlinehack +\RequirePackage{comment} % Used to hide solutions +\RequirePackage{fancyhdr} % Header/Footer customization +\RequirePackage{adjustbox} % Used for title + +\RequirePackage[ + left = ``, + right = '', + leftsub = `, + rightsub = ' +]{dirtytalk} + +% Not used by this class, but likely to be used in documents +\RequirePackage{amsmath} +\RequirePackage{amssymb} +\RequirePackage{multicol} +\RequirePackage{subfiles} + + + + + +%%% CONFIG %%% + + +% No paragraph indentation, no list item spacing, +% raggedright layout (hyphenation is excessive). +\setlength{\parindent}{0mm} +\setlist{noitemsep, topsep=0mm} +\raggedright + +% Use symbols instead of numbers for footnotes +\renewcommand*{\thefootnote}{\arabic{footnote}} + +% One space after a period. +\frenchspacing + + +% Fancyhdr setup +\pagestyle{fancy} +\fancyhf{} +\renewcommand{\headrulewidth}{0mm} + +\ifnopagenumber +\else + \fancyfoot[C]{\thepage} +\fi + + + + +%%% COMMANDS %%% + + +% Make a heading. +% Arguments: +% +% First: Top-left text +% Second: Top-right text +% Both are optional, but should only be provided TOGETHER. +% +% Third: Title +% Forth: author +\RenewDocumentCommand{\maketitle}{ d<> d<> m m } { + \begin{adjustbox}{minipage=0.7\textwidth, margin=0pt \smallskipamount,center} + \begin{center} + + \IfNoValueF{#1}{\textsc{#1}} \hfill \IfNoValueF{#2}{\textsc{#2}} \\ + \rule{\linewidth}{0.2mm}\\ + + \huge + #3 \\ + \normalsize + \vspace{1ex} + #4 + \rule{\linewidth}{0.2mm} \\ + + % Instructor's handout warning + \ifsolutions + \begin{tcolorbox}[ + colback=white, + colframe=red + ] + \begin{center} + \large + \textcolor{red}{ + \textbf{Instructor's Handout} + } \\ + \normalsize + \end{center} + + \vspace{1ex} + + \textcolor{red}{This file contains solutions and notes.} + + \textcolor{red}{Compile with the ``nosolutions'' flag before distributing.} + \end{tcolorbox} + \fi + + \end{center} + \end{adjustbox} +} + + +% Helper command that creates a label with custom text. +% First arg: label name +% Second arg: custom text +\newcommand{\customlabel}[2]{% + \protected@write \@auxout {}{ + \string \newlabel {#1}{{#2}{}} + } +} + + +% Commands for problems, theorems, and definitions +% +% Each of these take two arguments. For example: +% +% \problem{} makes an unnamed problem +% \problem{Division} makes a named problem +% \problem{} +% makes a problem and a label "problem:gcd" +% that gives text "Problem X" when referenced. + +\newcounter{section_counter} +\newcounter{problempartcounter} + +\ifsinglenumbering + \newcounter{object_counter} + + \def\problemcounter{object_counter} + \def\theoremcounter{object_counter} + \def\definitioncounter{object_counter} + \def\examplecounter{object_counter} + \def\propositioncounter{object_counter} +\else + \newcounter{problem_counter} + \newcounter{theorem_counter} + \newcounter{definition_counter} + \newcounter{example_counter} + \newcounter{proposition_counter} + + \def\problemcounter{problem_counter} + \def\theoremcounter{theorem_counter} + \def\definitioncounter{definition_counter} + \def\examplecounter{example_counter} + \def\propositioncounter{proposition_counter} +\fi + + +% Generic object command. +% First arg: counter name (mandatory) +% Second arg: object type (optional) +% Third arg: object title (mandatory, can be empty) +% +% If the second argument is ommited, the counter is hidden +% and only the object title is shown. For example: +% \@object{counter}[Problem]{Example Problem} -> Problem 1: Example Problem +% \@object{counter}{Example Problem} -> Example Problem +% +% Only used internally (See following definitions) +\NewDocumentCommand{\@object}{ m d[] m}{ + \stepcounter{#1} + \vspace{3mm} + \IfNoValueTF{#2} { + {\bf\normalsize #3} + } { + {\bf\normalsize #2 \arabic{#1}:\IfNoValueF{#3}{ #3}} + } +} + +% Generic object. +% Does the same thing as \problem, \theorem, etc, but with no counter. +\NewDocumentCommand{\generic}{ m d<> }{ + \vspace{3mm} + {\bf\normalsize #1} \\* + + \IfNoValueF{#2}{ + \customlabel{#2}{#1} + } +} + +% If not starred, text is "Part X: " +% If starred, text is "<title>" +\RenewDocumentCommand{\section}{ s m d<> }{ + \stepcounter{section_counter} + \vspace{8mm} + \IfBooleanTF{#1}{ + {\bf\Large \hfill #2 \hfill} + \IfNoValueF{#3}{\customlabel{#3}#2} \\* + } { + {\bf\Large \hfill Part \arabic{section_counter}\IfNoValueF{#2}{: #2} \hfill} + \IfNoValueF{#3}{\customlabel{#3}Part \arabic{section_counter}} \\* + } + \vspace{2mm} +} + + +\RenewDocumentCommand{\paragraph}{}{ + \hspace{1cm} +} + +\NewDocumentCommand{\problem}{ m d<> }{ + \setcounter{problempartcounter}{0} + + \@object{\problemcounter}[Problem]{#1} + \IfNoValueF{#2}{ + \customlabel{#2}{Problem \arabic{\problemcounter}} + \customlabel{NUM:#2}{\arabic{\problemcounter}} + } \\* +} + +\NewDocumentCommand{\problempart}{ m d<> }{ + \@object{problempartcounter}[Part]{#1} + \IfNoValueF{#2}{ + \customlabel + {#2} + {Problem \arabic{\problemcounter}\alph{problempartcounter}} + \customlabel{NUM:#2}{\arabic{\problemcounter}\alph{problempartcounter}} + } \\* +} + +\NewDocumentCommand{\definition}{ m d<> }{ + \@object{\definitioncounter}[Definition]{#1} + \IfNoValueF{#2}{ + \customlabel{#2}{Definition \arabic{\definitioncounter}} + \customlabel{NUM:#2}{\arabic{\definitioncounter}} + } \\* +} + +\NewDocumentCommand{\theorem}{ m d<> }{ + \@object{\theoremcounter}[Theorem]{#1} + \IfNoValueF{#2}{ + \customlabel{#2}{Theorem \arabic{\theoremcounter}} + \customlabel{NUM:#2}{\arabic{\theoremcounter}} + } \\* +} + +\NewDocumentCommand{\proposition}{ m d<> }{ + \@object{\propositioncounter}[Proposition]{#1} + \IfNoValueF{#2}{ + \customlabel{#2}{Proposition \arabic{\propositioncounter}} + \customlabel{NUM:#2}{\arabic{\propositioncounter}} + } \\* +} + +\NewDocumentCommand{\example}{ m d<> }{ + \@object{\examplecounter}[Example]{#1} + \IfNoValueF{#2}{ + \customlabel{#2}{Example \arabic{\examplecounter}} + \customlabel{NUM:#2}{\arabic{\examplecounter}} + } \\* +} + + +% Solution environment. +% examplesolution environment is always shown (useful for example problems) +% solution environments do the same thing, but are hidden when the [nosolutions] flag is passed. +\newenvironment{examplesolution} { + \begin{tcolorbox}[ + colback=white, + colframe=gray!75!black, + title={\textbf{Example Solution}} + ] +}{ + \end{tcolorbox} +} + +\def\ORMCbgcolor{white} + +% \if isn't parsed inside of LaTeX environents, +% so we have to use the comment package. +\newenvironment{@shown_solution} { + \def\ORMCbgcolor{red!5!white} + \begin{tcolorbox}[ + colback=red!5!white, + colframe=red!75!black, + title={\textbf{Solution}} + ] + \raggedright +}{ + \end{tcolorbox} +} + +\newenvironment{@shown_note} { + \def\ORMCbgcolor{cyan!5!white} + \begin{tcolorbox}[ + colback=cyan!5!white, + colframe=cyan!75!black, + title={\textbf{Note for Instructors}} + ] + \raggedright +}{ + \end{tcolorbox} +} + +% tcolorbox only give us two sections. +% This macro makes a macro \linehack that draws +% lines across a tcolorbox. +% +% Inside every environment that needs a +% \linehack macro, put \@makelinehack{color}. +\newcommand{\@makelinehack}[1]{ + \newcommand{\linehack}{ + \begin{tikzpicture} + \path[use as bounding box] + (0, 0) + -- + (\linewidth, 0); + + \draw[ + color=#1, + dashed, + dash phase=1mm + ] + ( + 0 - \kvtcb@leftlower-\kvtcb@boxsep, + 0 + ) -- ( + \linewidth + \kvtcb@rightlower + \kvtcb@boxsep, + 0 + ); + \end{tikzpicture} \\ + } +} + +\ifsolutions + \newenvironment{solution}{ + \@makelinehack{red!75!black} + \begin{@shown_solution} + } { + \end{@shown_solution} + } + \newenvironment{instructornote}{ + \@makelinehack{cyan!75!black} + \begin{@shown_note} + } { + \end{@shown_note} + } +\else + \excludecomment{solution} + \excludecomment{instructornote} +\fi + + +\NewDocumentCommand{\note}{ d<> m }{ + \IfNoValueTF{#1} { + \textcolor{gray}{#2} \\ + } { + \textcolor{gray}{\textit{#1:} #2} \\ + } +} + +\NewDocumentCommand{\hint}{ m }{ + \note<Hint>{#1} +} + +\makeatother