Skip to content

Instantly share code, notes, and snippets.

@alexboche
Created February 14, 2019 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexboche/cdb5a1ac33091e4a4d0898a1d7085a5d to your computer and use it in GitHub Desktop.
Save alexboche/cdb5a1ac33091e4a4d0898a1d7085a5d to your computer and use it in GitHub Desktop.
natural numerical fraction command
# Here's a new command for writing numerical fractions more naturally. Not the most elegant but gets the job done.
"<number> <denominator>": R(Text("\\frac %(number)d") + Key("down")
+ Text("%(denominator)s") + Key("right")),
"[one] <denominator_single>": R(Text("\\frac 1") + Key("down")
+ Text("%(denominator_single)s") + Key("right")),
IntegerRefST("number", 2, 100),
Choice("denominator", {
"halves": "2",
"thirds": "3",
"fourths": "4",
"fifths": "5",
"sixths": "6",
"sevenths": "7",
"eighths": "8",
"ninths": "9",
"tenths": "10",
"elevenths": "11",
"twelfths": "12",
"thirteenths": "13",
"fourteenths": "14",
"fifteenths": "15",
"sixteenths": "16",
"seventeens": "17",
"eighteenths": "18",
"nineteenths": "19",
"twentieths": "20",
}),
Choice("denominator_single", {
"half": "2",
"third": "3",
"fourth": "4",
"fifth": "5",
"sixth": "6",
"seventh": "7",
"eighth": "8",
"ninth": "9",
"tenth": "10",
"eleventh": "11",
"twelfth": "12",
"thirteenth": "13",
"fourteenth": "14",
"fifteenth": "15",
"sixteenth": "16",
"seventeen": "17",
"eighteenth": "18",
"nineteenth": "19",
"twentieth": "20",
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment