Skip to content

Instantly share code, notes, and snippets.

@FriendsAtDawn
Last active October 7, 2023 01:08
Show Gist options
  • Save FriendsAtDawn/7e4593eb2c8f1d191f6db2850ee1af91 to your computer and use it in GitHub Desktop.
Save FriendsAtDawn/7e4593eb2c8f1d191f6db2850ee1af91 to your computer and use it in GitHub Desktop.
Numbers to spelling-words

I have previously attempted this with Lua, but was unsuccessful. I barely know how to do scripts. This is not one, it's just a little trick for newbies.

  1. Install num2words from Python.

  2. Load the shellesc package in LaTeX.

  3. Run the program, e.g. pdflatex with the --shell-escape flag. Example: pdflatex --shell-escape [other flags] "main".tex. Without it, LaTeX is not granted access to shell.

  4. Write something like this in the preamble:\newcommand{\nWords}[1]{\ShellEscape{num2words #1 -l is > #1.aux} \input{#1.aux}}. This produces a file nWords.aux in the main directory, you can delete it when delete all the aux files. I know there are other ways I left to your skills.

  5. Use it like this \nWords{n} in the document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment