Quantcast
Channel: Active questions tagged convert - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 74

Converting letters to numbers (e.g., A=0, B=1, et cetera)

$
0
0

I recently asked the opposite question, and got some really awesome answers, but just realized I'm uncertain of a counterpart for converting letters to numbers.

Here's the code I'm using to convert numbers to letters:

\newcommand\makeAlph[1]{%\ifcase #1 a\or b\or c\or d\or e\or f\or g\or h\ori\or j\or k\or l\or m\or n\or o\or p\or q\or r\ors\or t\or u\or v\or w\or x\or y\or z\fi}

Because it appears that \ifcase expects a number, I'm unsure how to tweak this code to accept a letter and convert to numbers instead; it could be because it can't, in its current form, and there's another solution. I've looked at various packages but can't quite find the solution, but I feel that I'm again overlooking something subtle, but simple.

Basically, I'd like to work on a 36-character alphabet (a-z0-9), where a=0, b=1...8=34, 9=35. Ideally, there'd be some command like this, \makeNum{}, like \makeAlph{} in the example above.

Thankful for any guidance on this one, as with the other! Happy to provide any more detail as well as dive into any resources that I might have missed. Cheers!


Viewing all articles
Browse latest Browse all 74

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>