Re: Il disegno programmato nell’Arte di scrivere con LaTeX

#72807
admin
Amministratore del forum
    Up
    0
    Down
    ::


    Su invito di @OldClaudio, riporto un codice per LuaLaTeX. Attenzione: non è farina del mio sacco perché mi sono basato su un codice di @azoun su TeX StackExchange: LuaLaTeX:PGFplots can’t read data passed by Lua.

    `% !TEX program = LuaLaTeX

    \documentclass{standalone}

    \usepackage{pgfplots}
    \usepackage{luacode}

    \begin{luacode*}

    function Liss(val,t)
    return math.sin(val*t)
    end

    function stampa_pgf(a,b)

    tex.sprint(“\\addplot[mark=, red, smooth] coordinates{“)

    — 2pi_greco/500=0.0125663
    for i=0,2*math.pi,0.0125663 do
    x=Liss(a,i)
    y=Liss(b,i)
    tex.sprint(“(“..x..”,”..y..”)”)
    end

    tex.sprint(“};”)
    end

    \end{luacode*}

    \newcommand\myaddplot[2]{\directlua{stampa_pgf(#1,#2)}}

    \begin{document}
    \begin{tikzpicture}
    \begin{axis}
    \myaddplot{7}{2}
    \end{axis}
    \end{tikzpicture}
    \end{document}

    %%% Local Variables:
    %%% mode: latex
    %%% TeX-engine: luatex
    %%% TeX-master: t
    %%% End:`
    Ciao
    Orlando

    Go to top