General ⇒ Latex as a programming language
Latex as a programming language
Essentially, I'm trying to make a command like:
\name[last]{person}
which would output the person's last/first name which I define after the fact, and has to work for different people. A switch case statement:
Switch{name}
{
Case name1:
Case name2:
}
Would be very helpful. Array access might be less helpful (unless it has auto-hashing), but I could always define a simple hash algorithm, and I'd have some other uses for arrays anyway. (For example, spamming short answers to problems with ANS[counter].)
Right now, I implement \name by numerous annoying \ifthenelse statements (because, after all, that's the same thing as a switch), but it's very annoying to read even. I appreciate any hints.
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Re: Latex as a programming language
Re: Latex as a programming language
Score: 78/90
Score: 66/100
...
Everytime. I'd like to be able to stick something like [78,90 ; 66, 100 , ... ] in an array and just do
\score
\score
...
Re: Latex as a programming language
-
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
Re: Latex as a programming language
Re: Latex as a programming language
Latex as a programming language
Re: Latex as a programming language
Still missing the switch *hint hint* <3
Latex as a programming language
Hi again,gmedina wrote:Another option (for array data structures) could be the arrayjob package.
arrayjob is almost passable. The only problem is that \checkarrayname seems to create a tab every time (and it's necessary, as it's the only way to actually access the array data to compare and stuff aside from actually printing it out).
For example, if an array is called Names, then
a\checkNames(2,3)b
gives out something like:
Code: Select all
a b
Latex as a programming language
Code: Select all
\documentclass{article}
\usepackage{arrayjob}
\begin{document}
\newarray\Names
\readarray{Names}{Abel&Borel&Cantor&Dedekind&Eisenstein&Fermat&Galois&Hilbert}
\dataheight=4
a\checkNames(2,3)b
\cachedata
\end{document}