pkra / laml

a lame joke about LaTeX and HTML
https://pkra.github.io/laml/
2 stars 1 forks source link

counter module #50

Open pkra opened 6 years ago

pkra commented 6 years ago

Counters. We need them.

@scoskey what requirements do you see?

scoskey commented 6 years ago

First let me record the amsthm way. Then we should think about whether this is good.

There are chapter, section, and subsection counters. There are also counters for theorem-like environments. Whenever you declare a theorem-like environment, you have an initial choice from 3 options: 1) The environment has no counter and goes unnumbered and un-ref-able 2) The environment joins forces with an existing counter. 3) The environment gets its own new counter.

If you choose (3), you have a choice from 2 options: A) The counter is numbered alone continuously through the document B) The counter is numbered "within" another counter, resets when that one increments, and is printed parent.child.

Extra items: 1) One can also choose the "style" of the environment. The options are Theorem, Definition, and Remark. These three style names are stupid and arbitrary. Theorem style has italic contents. Definition style looks "normal". Remark style has italicized name but not content. We should just leave this to CSS. 2) One should also be able to control how the counter is printed by default (as a number or letter). This isn't standard in amsthm but presumably easy to implement.

scoskey commented 6 years ago

The amsthm way described above is kind of weird in that it conflates counter names and environment names (by choosing option 3). Maybe it makes more sense for the user to be able to declare named counters, and then specify which environments use which counters.

The default should probably be a "statement" counter which is numbered within a "section" counter, and that's it.

Here is a sample (but would be simpler given we'd have defaults).

---
counters:
  - section
    - appearance: roman
  - statement:
    - numberwithin: section
    - appearance: arabic
  - exercise
    - appearance: arabic
statements:
  - theorem:
    - counter: statement
  - definition:
    - counter: statement
  - exercise:
    - counter: exercise
  - question [no counter]
---
pkra commented 6 years ago

Thanks, Sam!

pkra commented 6 years ago

Extending statements to read the fulll configuration (so you get access to the counters property which is separate from the statements options that are passed now), then do something like

  var elem=document.createElement('style');
  elem.styleSheet.cssText=css;
  document.getElementsByTagName('head')[0].appendChild(elem);