Quantcast
Channel: Using Luatex to draw a geometric sequence - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 2

Using Luatex to draw a geometric sequence

$
0
0

I would like to recreate the following geometric sequence, sans colours and fonts:

enter image description here

Writing a sequencer in Lua was straightforward enough:

\begin{luacode}local sequence = {}function geo_seq (a, r, n)   for i = 1, n do   x = a * r^(i-1)   sequence[#sequence+1] = x   end   return xend\end{luacode}

This creates a table with {1, 2, 4, 8, 16}My plan was then to use this as a list to pass to the tikz draw function:

\newcommand\printseqq[3]{\directlua{print_seq(#1,#2,#3)}}\begin{tikzpicture}[scale = 0.4] \draw[latex-latex] (0,0) -- (21,0); \foreach \x in {0,...,21} \draw[shift={(\x,0)},color=black] (0pt,0pt) -- (0pt,-2pt) node[below] % \foreach \x in \printseqq{1}{2}{5} % \draw[->, bend left] (0,0) to (\x,0);  {$\x$};\end{tikzpicture}

Where print_seq is something like:

function print_seq (a, r, n)  geo_seq(a, r, n)  tex.print("")  for index, value in ipairs(sequence) do  tex.print(math.floor(value)..[[, ]])  tex.print("")  endend

But I can't seem to pass the table or use the tex.print function in a way that lets me specify the nodes for tikz to use.

This is what I have so far with the arrow drawing attempt commented as above:enter image description here


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images