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.
-
Install
num2wordsfrom Python. -
Load the
shellescpackage in LaTeX. -
Run the program, e.g.
pdflatexwith the--shell-escapeflag. Example:pdflatex --shell-escape [other flags] "main".tex. Without it, LaTeX is not granted access to shell. -
Write something like this in the preamble:
\newcommand{\nWords}[1]{\ShellEscape{num2words #1 -l is > #1.aux} \input{#1.aux}}. This produces a filenWords.auxin the main directory, you can delete it when delete all the aux files. I know there are other ways I left to your skills. -
Use it like this
\nWords{n}in the document.