// Copied from https://github.com/typst/templates
//
// MIT No Attribution
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify,
// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// unequivocal-ams/template/main.typ

// Sizes used across the template.
#let script-size = 7.97224pt
#let footnote-size = 8.50012pt
#let small-size = 9.24994pt
#let normal-size = 10.00002pt
#let large-size = 11.74988pt

// Workaround for the lack of an `std` scope.
#let std-bibliography = bibliography

// This function gets your whole document as its `body` and formats
// it as an article in the style of the American Mathematical Society.
#let ams-article(
  // The article's title.
  title: <beginfold id='1'>[</beginfold id='1'>Paper title<endfold id='1'>]</endfold id='1'>,

  // An array of authors. For each author you can specify a name,
  // department, organization, location, and email. Everything but
  // but the name is optional.
  authors: <beginfold id='2'>(</beginfold id='2'><endfold id='2'>)</endfold id='2'>,

  // Your article's abstract. Can be omitted if you don't have one.
  abstract: none,

  // The article's paper size. Also affects the margins.
  paper-size: "us-letter",

  // The result of a call to the `bibliography` function or `none`.
  bibliography: none,

  // The document's content.
  body,
) = <beginfold id='3'>{</beginfold id='3'>
  // Formats the author's names in a list with commas and a
  // final "and".
  let names = authors.map(author => author.name<endfold id='2'>)</endfold id='2'>
  let author-string = if authors.len(<endfold id='2'>)</endfold id='2'> == 2 <beginfold id='3'>{</beginfold id='3'>
    names.join(" and "<endfold id='2'>)</endfold id='2'>
  <endfold id='3'>}</endfold id='3'> else <beginfold id='3'>{</beginfold id='3'>
    names.join(", ", last: ", and "<endfold id='2'>)</endfold id='2'>
  <endfold id='3'>}</endfold id='3'>

  // Set document metadata.
  set document(title: title, author: names<endfold id='2'>)</endfold id='2'>

  // Set the body font. AMS uses the LaTeX font.
  set text(size: normal-size, font: "New Computer Modern"<endfold id='2'>)</endfold id='2'>

  // Configure the page.
  set page(
    paper: paper-size,
    // The margins depend on the paper size.
    margin: if paper-size != "a4" <beginfold id='3'>{</beginfold id='3'>
      <beginfold id='2'>(</beginfold id='2'>
        top: <beginfold id='2'>(</beginfold id='2'>116pt / 279mm<endfold id='2'>)</endfold id='2'> * 100%,
        left: <beginfold id='2'>(</beginfold id='2'>126pt / 216mm<endfold id='2'>)</endfold id='2'> * 100%,
        right: <beginfold id='2'>(</beginfold id='2'>128pt / 216mm<endfold id='2'>)</endfold id='2'> * 100%,
        bottom: <beginfold id='2'>(</beginfold id='2'>94pt / 279mm<endfold id='2'>)</endfold id='2'> * 100%,
      <endfold id='2'>)</endfold id='2'>
    <endfold id='3'>}</endfold id='3'> else <beginfold id='3'>{</beginfold id='3'>
      <beginfold id='2'>(</beginfold id='2'>
        top: 117pt,
        left: 118pt,
        right: 119pt,
        bottom: 96pt,
      <endfold id='2'>)</endfold id='2'>
    <endfold id='3'>}</endfold id='3'>,

    // The page header should show the page number and list of
    // authors, except on the first page. The page number is on
    // the left for even pages and on the right for odd pages.
    header-ascent: 14pt,
    header: locate(loc => <beginfold id='3'>{</beginfold id='3'>
      let i = counter(page<endfold id='2'>)</endfold id='2'>.at(loc<endfold id='2'>)</endfold id='2'>.first(<endfold id='2'>)</endfold id='2'>
      if i == 1 <beginfold id='3'>{</beginfold id='3'> return <endfold id='3'>}</endfold id='3'>
      set text(size: script-size<endfold id='2'>)</endfold id='2'>
      grid(
        columns: <beginfold id='2'>(</beginfold id='2'>6em, 1fr, 6em<endfold id='2'>)</endfold id='2'>,
        if calc.even(i<endfold id='2'>)</endfold id='2'> <beginfold id='1'>[</beginfold id='1'>#i<endfold id='1'>]</endfold id='1'>,
        align(center, upper(
          if calc.odd(i<endfold id='2'>)</endfold id='2'> <beginfold id='3'>{</beginfold id='3'> title <endfold id='3'>}</endfold id='3'> else <beginfold id='3'>{</beginfold id='3'> author-string <endfold id='3'>}</endfold id='3'>
        <endfold id='2'>)</endfold id='2'><endfold id='2'>)</endfold id='2'>,
        if calc.odd(i<endfold id='2'>)</endfold id='2'> <beginfold id='3'>{</beginfold id='3'> align(right<endfold id='2'>)</endfold id='2'><beginfold id='1'>[</beginfold id='1'>#i<endfold id='1'>]</endfold id='1'> <endfold id='3'>}</endfold id='3'>
      <endfold id='2'>)</endfold id='2'>
    <endfold id='3'>}</endfold id='3'><endfold id='2'>)</endfold id='2'>,

    // On the first page, the footer should contain the page number.
    footer-descent: 12pt,
    footer: locate(loc => <beginfold id='3'>{</beginfold id='3'>
      let i = counter(page<endfold id='2'>)</endfold id='2'>.at(loc<endfold id='2'>)</endfold id='2'>.first(<endfold id='2'>)</endfold id='2'>
      if i == 1 <beginfold id='3'>{</beginfold id='3'>
        align(center, text(size: script-size, <beginfold id='1'>[</beginfold id='1'>#i<endfold id='1'>]</endfold id='1'><endfold id='2'>)</endfold id='2'><endfold id='2'>)</endfold id='2'>
      <endfold id='3'>}</endfold id='3'>
    <endfold id='3'>}</endfold id='3'><endfold id='2'>)</endfold id='2'>
  <endfold id='2'>)</endfold id='2'>

  // Configure headings.
  set heading(numbering: "1."<endfold id='2'>)</endfold id='2'>
  show heading: it => <beginfold id='3'>{</beginfold id='3'>
    // Create the heading numbering.
    let number = if it.numbering != none <beginfold id='3'>{</beginfold id='3'>
      counter(heading<endfold id='2'>)</endfold id='2'>.display(it.numbering<endfold id='2'>)</endfold id='2'>
      h(7pt, weak: true<endfold id='2'>)</endfold id='2'>
    <endfold id='3'>}</endfold id='3'>

    // Level 1 headings are centered and smallcaps.
    // The other ones are run-in.
    set text(size: normal-size, weight: 400<endfold id='2'>)</endfold id='2'>
    if it.level == 1 <beginfold id='3'>{</beginfold id='3'>
      set align(center<endfold id='2'>)</endfold id='2'>
      set text(size: normal-size<endfold id='2'>)</endfold id='2'>
      smallcaps<beginfold id='1'>[</beginfold id='1'>
        #v(15pt, weak: true<endfold id='2'>)</endfold id='2'>
        #number
        #it.body
        #v(normal-size, weak: true<endfold id='2'>)</endfold id='2'>
      <endfold id='1'>]</endfold id='1'>
      counter(figure.where(kind: "theorem"<endfold id='2'>)</endfold id='2'><endfold id='2'>)</endfold id='2'>.update(0<endfold id='2'>)</endfold id='2'>
    <endfold id='3'>}</endfold id='3'> else <beginfold id='3'>{</beginfold id='3'>
      v(11pt, weak: true<endfold id='2'>)</endfold id='2'>
      number
      let styled = if it.level == 2 <beginfold id='3'>{</beginfold id='3'> strong <endfold id='3'>}</endfold id='3'> else <beginfold id='3'>{</beginfold id='3'> emph <endfold id='3'>}</endfold id='3'>
      styled(it.body + <beginfold id='1'>[</beginfold id='1'>. <endfold id='1'>]</endfold id='1'><endfold id='2'>)</endfold id='2'>
      h(7pt, weak: true<endfold id='2'>)</endfold id='2'>
    <endfold id='3'>}</endfold id='3'>
  <endfold id='3'>}</endfold id='3'>

  // Configure lists and links.
  set list(indent: 24pt, body-indent: 5pt<endfold id='2'>)</endfold id='2'>
  set enum(indent: 24pt, body-indent: 5pt<endfold id='2'>)</endfold id='2'>
  show link: set text(font: "New Computer Modern Mono"<endfold id='2'>)</endfold id='2'>

  // Configure equations.
  show math.equation: set block(below: 8pt, above: 9pt<endfold id='2'>)</endfold id='2'>
  show math.equation: set text(weight: 400<endfold id='2'>)</endfold id='2'>

  // Configure citation and bibliography styles.
  set std-bibliography(style: "springer-mathphys", title: <beginfold id='1'>[</beginfold id='1'>References<endfold id='1'>]</endfold id='1'><endfold id='2'>)</endfold id='2'>

  show figure: it => <beginfold id='3'>{</beginfold id='3'>
    show: pad.with(x: 23pt<endfold id='2'>)</endfold id='2'>
    set align(center<endfold id='2'>)</endfold id='2'>

    v(12.5pt, weak: true<endfold id='2'>)</endfold id='2'>

    // Display the figure's body.
    it.body

    // Display the figure's caption.
    if it.has("caption"<endfold id='2'>)</endfold id='2'> <beginfold id='3'>{</beginfold id='3'>
      // Gap defaults to 17pt.
      v(if it.has("gap"<endfold id='2'>)</endfold id='2'> <beginfold id='3'>{</beginfold id='3'> it.gap <endfold id='3'>}</endfold id='3'> else <beginfold id='3'>{</beginfold id='3'> 17pt <endfold id='3'>}</endfold id='3'>, weak: true<endfold id='2'>)</endfold id='2'>
      smallcaps(it.supplement<endfold id='2'>)</endfold id='2'>
      if it.numbering != none <beginfold id='3'>{</beginfold id='3'>
        <beginfold id='1'>[</beginfold id='1'> <endfold id='1'>]</endfold id='1'>
        it.counter.display(it.numbering<endfold id='2'>)</endfold id='2'>
      <endfold id='3'>}</endfold id='3'>
      <beginfold id='1'>[</beginfold id='1'>. <endfold id='1'>]</endfold id='1'>
      it.caption.body
    <endfold id='3'>}</endfold id='3'>

    v(15pt, weak: true<endfold id='2'>)</endfold id='2'>
  <endfold id='3'>}</endfold id='3'>

  // Theorems.
  show figure.where(kind: "theorem"<endfold id='2'>)</endfold id='2'>: it => block(above: 11.5pt, below: 11.5pt, <beginfold id='3'>{</beginfold id='3'>
    strong(<beginfold id='3'>{</beginfold id='3'>
      it.supplement
      if it.numbering != none <beginfold id='3'>{</beginfold id='3'>
        <beginfold id='1'>[</beginfold id='1'> <endfold id='1'>]</endfold id='1'>
        counter(heading<endfold id='2'>)</endfold id='2'>.display(<endfold id='2'>)</endfold id='2'>
        it.counter.display(it.numbering<endfold id='2'>)</endfold id='2'>
      <endfold id='3'>}</endfold id='3'>
      <beginfold id='1'>[</beginfold id='1'>.<endfold id='1'>]</endfold id='1'>
    <endfold id='3'>}</endfold id='3'><endfold id='2'>)</endfold id='2'>
    emph(it.body<endfold id='2'>)</endfold id='2'>
  <endfold id='3'>}</endfold id='3'><endfold id='2'>)</endfold id='2'>

  // Display the title and authors.
  v(35pt, weak: true<endfold id='2'>)</endfold id='2'>
  align(center, upper(<beginfold id='3'>{</beginfold id='3'>
    text(size: large-size, weight: 700, title<endfold id='2'>)</endfold id='2'>
    v(25pt, weak: true<endfold id='2'>)</endfold id='2'>
    text(size: footnote-size, author-string<endfold id='2'>)</endfold id='2'>
  <endfold id='3'>}</endfold id='3'><endfold id='2'>)</endfold id='2'><endfold id='2'>)</endfold id='2'>

  // Configure paragraph properties.
  set par(first-line-indent: 1.2em, justify: true, leading: 0.58em<endfold id='2'>)</endfold id='2'>
  show par: set block(spacing: 0.58em<endfold id='2'>)</endfold id='2'>

  // Display the abstract
  if abstract != none <beginfold id='3'>{</beginfold id='3'>
    v(20pt, weak: true<endfold id='2'>)</endfold id='2'>
    set text(script-size<endfold id='2'>)</endfold id='2'>
    show: pad.with(x: 35pt<endfold id='2'>)</endfold id='2'>
    smallcaps<beginfold id='1'>[</beginfold id='1'>Abstract. <endfold id='1'>]</endfold id='1'>
    abstract
  <endfold id='3'>}</endfold id='3'>

  // Display the article's contents.
  v(29pt, weak: true<endfold id='2'>)</endfold id='2'>
  body

  // Display the bibliography, if any is given.
  if bibliography != none <beginfold id='3'>{</beginfold id='3'>
    show std-bibliography: set text(footnote-size<endfold id='2'>)</endfold id='2'>
    show std-bibliography: pad.with(x: 0.5pt<endfold id='2'>)</endfold id='2'>
    bibliography
  <endfold id='3'>}</endfold id='3'>

  // The thing ends with details about the authors.
  show: pad.with(x: 11.5pt<endfold id='2'>)</endfold id='2'>
  set par(first-line-indent: 0pt<endfold id='2'>)</endfold id='2'>
  set text(script-size<endfold id='2'>)</endfold id='2'>

  for author in authors <beginfold id='3'>{</beginfold id='3'>
    let keys = <beginfold id='2'>(</beginfold id='2'>"department", "organization", "location"<endfold id='2'>)</endfold id='2'>

    let dept-str = keys
      .filter(key => key in author<endfold id='2'>)</endfold id='2'>
      .map(key => author.at(key<endfold id='2'>)</endfold id='2'><endfold id='2'>)</endfold id='2'>
      .join(", "<endfold id='2'>)</endfold id='2'>

    smallcaps(dept-str<endfold id='2'>)</endfold id='2'>
    linebreak(<endfold id='2'>)</endfold id='2'>

    if "email" in author <beginfold id='1'>[</beginfold id='1'>
      _Email address:_ #link("mailto:" + author.email<endfold id='2'>)</endfold id='2'> \
    <endfold id='1'>]</endfold id='1'>

    if "url" in author <beginfold id='1'>[</beginfold id='1'>
      _URL:_ #link(author.url<endfold id='2'>)</endfold id='2'>
    <endfold id='1'>]</endfold id='1'>

    v(12pt, weak: true<endfold id='2'>)</endfold id='2'>
  <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

// The ASM template also provides a theorem function.
#let theorem(body, numbered: true) = figure(
  body,
  kind: "theorem",
  supplement: <beginfold id='1'>[</beginfold id='1'>Theorem<endfold id='1'>]</endfold id='1'>,
  numbering: if numbered <beginfold id='3'>{</beginfold id='3'> "1" <endfold id='3'>}</endfold id='3'>,
<endfold id='2'>)</endfold id='2'>

// And a function for a proof.
#let proof(body) = block(spacing: 11.5pt, <beginfold id='3'>{</beginfold id='3'>
  emph<beginfold id='1'>[</beginfold id='1'>Proof.<endfold id='1'>]</endfold id='1'>
  <beginfold id='1'>[</beginfold id='1'> <endfold id='1'>]</endfold id='1'> + body
  h(1fr<endfold id='2'>)</endfold id='2'>
  box(scale(160%, origin: bottom + right, sym.square.stroked<endfold id='2'>)</endfold id='2'><endfold id='2'>)</endfold id='2'>
<endfold id='3'>}</endfold id='3'><endfold id='2'>)</endfold id='2'>

// unequivocal-ams/lib.typ

#import "@preview/unequivocal-ams:0.1.0": ams-article, theorem, proof

#show: ams-article.with(
  title: <beginfold id='1'>[</beginfold id='1'>Mathematical Theorems<endfold id='1'>]</endfold id='1'>,
  authors: <beginfold id='2'>(</beginfold id='2'>
    <beginfold id='2'>(</beginfold id='2'>
      name: "Ralph Howard",
      department: <beginfold id='1'>[</beginfold id='1'>Department of Mathematics<endfold id='1'>]</endfold id='1'>,
      organization: <beginfold id='1'>[</beginfold id='1'>University of South Carolina<endfold id='1'>]</endfold id='1'>,
      location: <beginfold id='1'>[</beginfold id='1'>Columbia, SC 29208<endfold id='1'>]</endfold id='1'>,
      email: "howard@math.sc.edu",
      url: "www.math.sc.edu/~howard"
    <endfold id='2'>)</endfold id='2'>,
  <endfold id='2'>)</endfold id='2'>,
  abstract: lorem(100<endfold id='2'>)</endfold id='2'>,
  bibliography: bibliography("refs.bib"<endfold id='2'>)</endfold id='2'>,
<endfold id='2'>)</endfold id='2'>

Call me Ishmael. Some years ago --- never mind how long precisely ---
having little or no money in my purse, and nothing particular to
interest me on shore, I thought I would sail about a little and see
the watery part of the world. It is a way I have of driving off the
spleen, and regulating the circulation.  Whenever I find myself
growing grim about the mouth; whenever it is a damp, drizzly November
in my soul; whenever I find myself involuntarily pausing before coffin
warehouses, and bringing up the rear of every funeral I meet; and
especially whenever my hypos get such an upper hand of me, that it
requires a strong moral principle to prevent me from deliberately
stepping into the street, and methodically knocking people's hats off
--- then, I account it high time to get to sea as soon as I can. This
is my substitute for pistol and ball. With a philosophical flourish
Cato throws himself upon his sword; I quietly take to the ship. There
is nothing surprising in this. If they but knew it, almost all men in
their degree, some time or other, cherish very nearly the same
feelings towards the ocean with me. @netwok2020

There now is your insular city of the Manhattoes, belted round by
wharves as Indian isles by coral reefs - commerce surrounds it with
her surf. Right and left, the streets take you waterward. Its extreme
down-town is the battery, where that noble mole is washed by waves,
and cooled by breezes, which a few hours previous were out of sight of
land. Look at the crowds of water-gazers there.

Anyone caught using formulas such as <beginfold id='4'>$</beginfold id='4'>sqrt(x+y)=sqrt(x)+sqrt(y)<endfold id='4'>$</endfold id='4'>
or <beginfold id='4'>$</beginfold id='4'>1/(x+y) = 1/x + 1/y<endfold id='4'>$</endfold id='4'> will fail.

The binomial theorem is
<beginfold id='4'>$</beginfold id='4'> (x+y)^n=sum_(k=0)^n binom(n, k) x^k y^(n-k). <endfold id='4'>$</endfold id='4'>

A favorite sum of most mathematicians is
<beginfold id='4'>$</beginfold id='4'> sum_(n=1)^oo 1/n^2 = pi^2 / 6. <endfold id='4'>$</endfold id='4'>

Likewise a popular integral is
<beginfold id='4'>$</beginfold id='4'> integral_(-oo)^oo e^(-x^2) dif x = sqrt(pi) <endfold id='4'>$</endfold id='4'>

#theorem<beginfold id='1'>[</beginfold id='1'>
  The square of any real number is non-negative.
<endfold id='1'>]</endfold id='1'>

#proof<beginfold id='1'>[</beginfold id='1'>
  Any real number <beginfold id='4'>$</beginfold id='4'>x<endfold id='4'>$</endfold id='4'> satisfies <beginfold id='4'>$</beginfold id='4'>x > 0<endfold id='4'>$</endfold id='4'>, <beginfold id='4'>$</beginfold id='4'>x = 0<endfold id='4'>$</endfold id='4'>, or <beginfold id='4'>$</beginfold id='4'>x < 0<endfold id='4'>$</endfold id='4'>. If <beginfold id='4'>$</beginfold id='4'>x = 0<endfold id='4'>$</endfold id='4'>,
  then <beginfold id='4'>$</beginfold id='4'>x^2 = 0 >= 0<endfold id='4'>$</endfold id='4'>. If <beginfold id='4'>$</beginfold id='4'>x > 0<endfold id='4'>$</endfold id='4'> then as a positive time a positive is
  positive we have <beginfold id='4'>$</beginfold id='4'>x^2 = x x > 0<endfold id='4'>$</endfold id='4'>. If <beginfold id='4'>$</beginfold id='4'>x < 0<endfold id='4'>$</endfold id='4'> then <beginfold id='4'>$</beginfold id='4'>−x > 0<endfold id='4'>$</endfold id='4'> and so by
  what we have just done <beginfold id='4'>$</beginfold id='4'>x^2 = (−x)^2 > 0<endfold id='4'>$</endfold id='4'>. So in all cases <beginfold id='4'>$</beginfold id='4'>x^2 ≥ 0<endfold id='4'>$</endfold id='4'>.
<endfold id='1'>]</endfold id='1'>

= Introduction
This is a new section.
You can use tables like @solids.

#figure(
  table(
    columns: <beginfold id='2'>(</beginfold id='2'>1fr, auto, auto<endfold id='2'>)</endfold id='2'>,
    inset: 5pt,
    align: horizon,
    <beginfold id='1'>[</beginfold id='1'><endfold id='1'>]</endfold id='1'>, <beginfold id='1'>[</beginfold id='1'>*Area*<endfold id='1'>]</endfold id='1'>, <beginfold id='1'>[</beginfold id='1'>*Parameters*<endfold id='1'>]</endfold id='1'>,
    <beginfold id='1'>[</beginfold id='1'>*Cylinder*<endfold id='1'>]</endfold id='1'>,
    <beginfold id='4'>$</beginfold id='4'> pi h (D^2 - d^2) / 4 <endfold id='4'>$</endfold id='4'>,
    <beginfold id='1'>[</beginfold id='1'><beginfold id='4'>$</beginfold id='4'>h<endfold id='4'>$</endfold id='4'>: height \
     <beginfold id='4'>$</beginfold id='4'>D<endfold id='4'>$</endfold id='4'>: outer radius \
     <beginfold id='4'>$</beginfold id='4'>d<endfold id='4'>$</endfold id='4'>: inner radius<endfold id='1'>]</endfold id='1'>,
    <beginfold id='1'>[</beginfold id='1'>*Tetrahedron*<endfold id='1'>]</endfold id='1'>,
    <beginfold id='4'>$</beginfold id='4'> sqrt(2) / 12 a^3 <endfold id='4'>$</endfold id='4'>,
    <beginfold id='1'>[</beginfold id='1'><beginfold id='4'>$</beginfold id='4'>a<endfold id='4'>$</endfold id='4'>: edge length<endfold id='1'>]</endfold id='1'>
  <endfold id='2'>)</endfold id='2'>,
  caption: "Solids",
<endfold id='2'>)</endfold id='2'> <solids>

== Things that need to be done
Prove theorems.

= Background
#lorem(40<endfold id='2'>)</endfold id='2'>
