MikTeX and TeXLive are not TeX packages but distributions. Both implement basically the same compilers. Both take the packages (the files you include with \usepackage
) from CTAN. These are independent from the distributions. However, some (newer) packages might be not (yet) included in one distribution. But there should not be any difference for "normal day-to-day use".
What is different between these two distributions is how they allow you to update packages, i.e. which user interface they give you in addition to the normal (La)TeX compilers. MikTeX for example allows the automatic installation of missing packages on-the-fly. AFAIK it is also more optimized towards Windows users. TeXLive is provided for other OSs as well and is therefor less Windows specific. You might want to use MikTeX on Windows because of that. TeXMaker should work fine with both.
When you write
\newcommand{\iterate}[2]{
\directlua{
for i=1,#1,1 do
tex.print(\\compare{i}{#2})
end
}
}
The Lua process sees
for i=1,#1,1 do
tex.print(<the result of \compare>)
end
What you need to do is something like that:
\newcommand\iterate[2]{%
\luaexec{
for i=1,#1 do
tex.print(string.format("\\compare{\%d}{#2}",i))
end
}
}
\iterate{3}{2}
(luaexec is from the luacode package) This prints "\compare{1}{2}
\compare{2}{2}
\compare{3}{2}
" into TeX's input string and that gets evaluated. This works because \\
generates a backslash and it is separate from the word "compare". It's a hack and I don't recommend that. Please see How to do a 'printline' in LuaTeX for more info.
This is an experiment on "reevaluating":
For example: if you write
\documentclass[a4paper]{article}
\usepackage{luacode}
\begin{document}
\begin{luacode*}
tex.sprint("%hello")
\end{luacode*}
\end{document}
TeX will see %hello
and interprets it as a comment and thus no output file will be generated.
When you write this instead (see the -2 as the first argument to tex.print())
\documentclass[a4paper]{article}
\usepackage{luacode}
\begin{document}
\begin{luacode*}
tex.sprint(-2,"%hello")
\end{luacode*}
\end{document}
tex sees %hello, but the % has a "safe" category code. If the first argument to tex.print is a number, it will be taken as a catcode table. What I want to show: TeX reads the result of the \directlua{}
call.
Best Answer
You do not have to install Lua separately in order to run
luatex
. If you have installed TeX Live (the usual install is the full install) you will have it on your machine. If you want to double-check usetexlua --version
in the command line of your operating system.