Bug in Lualatex: not printing characters from calculationLuaLaTeX pass characters without “ ” to luaProblem printing LaTeX from lua in lualatexSymbol not found error when using Lua C .so module with LuaLaTeXnon-printing characters in the OpenType layout of LuaLaTeXLuaLaTeX output from tex.print not interpretedcsquotes conflicts with quotation marks in Lua codeHow shall I launch from lualatex a lua program contained in a lua variable?Load fields from JSON file using LuaLatexHow to use lua code from external file in lualatex?Lualatex function producing trailing characters

Subtle ways to render a planet uninhabitable

Who's behind community AMIs on Amazon EC2?

What is Albrecht Dürer's Perspective Machine drawing style?

Does proof-of-work contribute directly to prevent double-spending?

Why wasn't interlaced CRT scanning done back and forth?

Does WSL2 runs Linux in a virtual machine or alongside windows Kernel?

How to transform a function from f[#1] to f[x]

HackerRank Implement Queue using two stacks Solution

On the expression "sun-down"

Why does Shift-right says it is bound to right?

Is there a word that describes people who are extraverted and/or energetic, but uneducated, unintelligent and/or uncreative?

How long should I wait to plug in my refrigerator after unplugging it?

Difference between "jail" and "prison" in German

Lower bound for the number of lattice points on high dimensional spheres

Why adjustbox needs a tweak of raise=-0.3ex with enumitem?

Being told my "network" isn't PCI compliant. I don't even have a server! Do I have to comply?

What license to choose for my PhD thesis?

Phase portrait of a system of differential equations

What is the reason behind water not falling from a bucket at the top of loop?

Why isn't the new LEGO CV joint available on Bricklink or Brickowl?

Want to manipulate and visualize differential equation of a falling object

Can an unintentional murderer leave Ir Miklat for Shalosh Regalim?

What is it exactly about flying a Flyboard across the English channel that made Zapata's thighs burn?

Basic CPA walkthrough



Bug in Lualatex: not printing characters from calculation


LuaLaTeX pass characters without “ ” to luaProblem printing LaTeX from lua in lualatexSymbol not found error when using Lua C .so module with LuaLaTeXnon-printing characters in the OpenType layout of LuaLaTeXLuaLaTeX output from tex.print not interpretedcsquotes conflicts with quotation marks in Lua codeHow shall I launch from lualatex a lua program contained in a lua variable?Load fields from JSON file using LuaLatexHow to use lua code from external file in lualatex?Lualatex function producing trailing characters






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I have the following code



documentclassarticle
usepackageluacode
begindocument
beginluacode*
local matrix = require "matrix"
local complex = require "complex"
function cmatrix(n)
return matrix(n):replace(complex)
end
function det(m)
tex.sprint(matrix.det(cmatrix(m)))
end
endluacode*
newcommandmatrixdet[1]directluadet(#1)
matrixdet1,2,3,4,5,6,"7+8i",8,10
enddocument


Here I am using matrix.lua and complex.lua from the following links.



https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua



https://github.com/davidm/lua-matrix/blob/master/lua/complex.lua



The expected answer is -3-24i. However it gives the answer -3-24. The character i is not printed. This works well in lua itself. But it seems to be a bug in lualatex. How can it be over come? Any help will be appreciated.










share|improve this question
























  • copy matrix.lua and complex.lua from the given links to the working folder. Then compile with lualatex.

    – user61681
    Jul 24 at 14:26












  • Rather than a bug in LuaTeX, I'd suspect a bug in complex.lua first.

    – egreg
    Jul 24 at 14:27

















4















I have the following code



documentclassarticle
usepackageluacode
begindocument
beginluacode*
local matrix = require "matrix"
local complex = require "complex"
function cmatrix(n)
return matrix(n):replace(complex)
end
function det(m)
tex.sprint(matrix.det(cmatrix(m)))
end
endluacode*
newcommandmatrixdet[1]directluadet(#1)
matrixdet1,2,3,4,5,6,"7+8i",8,10
enddocument


Here I am using matrix.lua and complex.lua from the following links.



https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua



https://github.com/davidm/lua-matrix/blob/master/lua/complex.lua



The expected answer is -3-24i. However it gives the answer -3-24. The character i is not printed. This works well in lua itself. But it seems to be a bug in lualatex. How can it be over come? Any help will be appreciated.










share|improve this question
























  • copy matrix.lua and complex.lua from the given links to the working folder. Then compile with lualatex.

    – user61681
    Jul 24 at 14:26












  • Rather than a bug in LuaTeX, I'd suspect a bug in complex.lua first.

    – egreg
    Jul 24 at 14:27













4












4








4








I have the following code



documentclassarticle
usepackageluacode
begindocument
beginluacode*
local matrix = require "matrix"
local complex = require "complex"
function cmatrix(n)
return matrix(n):replace(complex)
end
function det(m)
tex.sprint(matrix.det(cmatrix(m)))
end
endluacode*
newcommandmatrixdet[1]directluadet(#1)
matrixdet1,2,3,4,5,6,"7+8i",8,10
enddocument


Here I am using matrix.lua and complex.lua from the following links.



https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua



https://github.com/davidm/lua-matrix/blob/master/lua/complex.lua



The expected answer is -3-24i. However it gives the answer -3-24. The character i is not printed. This works well in lua itself. But it seems to be a bug in lualatex. How can it be over come? Any help will be appreciated.










share|improve this question














I have the following code



documentclassarticle
usepackageluacode
begindocument
beginluacode*
local matrix = require "matrix"
local complex = require "complex"
function cmatrix(n)
return matrix(n):replace(complex)
end
function det(m)
tex.sprint(matrix.det(cmatrix(m)))
end
endluacode*
newcommandmatrixdet[1]directluadet(#1)
matrixdet1,2,3,4,5,6,"7+8i",8,10
enddocument


Here I am using matrix.lua and complex.lua from the following links.



https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua



https://github.com/davidm/lua-matrix/blob/master/lua/complex.lua



The expected answer is -3-24i. However it gives the answer -3-24. The character i is not printed. This works well in lua itself. But it seems to be a bug in lualatex. How can it be over come? Any help will be appreciated.







luatex matrices lua luacode directlua






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 24 at 14:14









user61681user61681

5092 silver badges12 bronze badges




5092 silver badges12 bronze badges















  • copy matrix.lua and complex.lua from the given links to the working folder. Then compile with lualatex.

    – user61681
    Jul 24 at 14:26












  • Rather than a bug in LuaTeX, I'd suspect a bug in complex.lua first.

    – egreg
    Jul 24 at 14:27

















  • copy matrix.lua and complex.lua from the given links to the working folder. Then compile with lualatex.

    – user61681
    Jul 24 at 14:26












  • Rather than a bug in LuaTeX, I'd suspect a bug in complex.lua first.

    – egreg
    Jul 24 at 14:27
















copy matrix.lua and complex.lua from the given links to the working folder. Then compile with lualatex.

– user61681
Jul 24 at 14:26






copy matrix.lua and complex.lua from the given links to the working folder. Then compile with lualatex.

– user61681
Jul 24 at 14:26














Rather than a bug in LuaTeX, I'd suspect a bug in complex.lua first.

– egreg
Jul 24 at 14:27





Rather than a bug in LuaTeX, I'd suspect a bug in complex.lua first.

– egreg
Jul 24 at 14:27










2 Answers
2






active

oldest

votes


















6














There seems to be an issue in how tex.sprint interprets complex numbers. As a solution, you can convert it to a string before printing:



documentclassarticle
usepackageluacode
begindocument
beginluacode*
local matrix = require "matrix"
local complex = require "complex"
function cmatrix(n)
return matrix(n):replace(complex)
end
function det(m)
tex.sprint(tostring(matrix.det(cmatrix(m))))
end
endluacode*
newcommandmatrixdet[1]directluadet(#1)
matrixdet1,2,3,4,5,6,"7+8i",8,10
enddocument





share|improve this answer




















  • 1





    Thanks for fast and correct explanation.

    – user61681
    Jul 24 at 14:30


















6














Unlike the Lua print function, which implicitly applies tostringto its argument, tex.sprint is defined to print each entry of a table separately if its argument is a table. The complex number is a two item table with the real and imaginary part with a custom tostring function that adds the i.



So print(matrix.det(cmatrix(m))) invokes tostring and prints -3-24i but tex.sprint applies the normal numeric tostring to each element of the table separately so prints -3 then -24. If you explicitly apply tostring before calling tex.sprint then the function specified for the complex number table will be used, resulting in "-3-24i" again.






share|improve this answer



























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "85"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f501273%2fbug-in-lualatex-not-printing-characters-from-calculation%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    6














    There seems to be an issue in how tex.sprint interprets complex numbers. As a solution, you can convert it to a string before printing:



    documentclassarticle
    usepackageluacode
    begindocument
    beginluacode*
    local matrix = require "matrix"
    local complex = require "complex"
    function cmatrix(n)
    return matrix(n):replace(complex)
    end
    function det(m)
    tex.sprint(tostring(matrix.det(cmatrix(m))))
    end
    endluacode*
    newcommandmatrixdet[1]directluadet(#1)
    matrixdet1,2,3,4,5,6,"7+8i",8,10
    enddocument





    share|improve this answer




















    • 1





      Thanks for fast and correct explanation.

      – user61681
      Jul 24 at 14:30















    6














    There seems to be an issue in how tex.sprint interprets complex numbers. As a solution, you can convert it to a string before printing:



    documentclassarticle
    usepackageluacode
    begindocument
    beginluacode*
    local matrix = require "matrix"
    local complex = require "complex"
    function cmatrix(n)
    return matrix(n):replace(complex)
    end
    function det(m)
    tex.sprint(tostring(matrix.det(cmatrix(m))))
    end
    endluacode*
    newcommandmatrixdet[1]directluadet(#1)
    matrixdet1,2,3,4,5,6,"7+8i",8,10
    enddocument





    share|improve this answer




















    • 1





      Thanks for fast and correct explanation.

      – user61681
      Jul 24 at 14:30













    6












    6








    6







    There seems to be an issue in how tex.sprint interprets complex numbers. As a solution, you can convert it to a string before printing:



    documentclassarticle
    usepackageluacode
    begindocument
    beginluacode*
    local matrix = require "matrix"
    local complex = require "complex"
    function cmatrix(n)
    return matrix(n):replace(complex)
    end
    function det(m)
    tex.sprint(tostring(matrix.det(cmatrix(m))))
    end
    endluacode*
    newcommandmatrixdet[1]directluadet(#1)
    matrixdet1,2,3,4,5,6,"7+8i",8,10
    enddocument





    share|improve this answer













    There seems to be an issue in how tex.sprint interprets complex numbers. As a solution, you can convert it to a string before printing:



    documentclassarticle
    usepackageluacode
    begindocument
    beginluacode*
    local matrix = require "matrix"
    local complex = require "complex"
    function cmatrix(n)
    return matrix(n):replace(complex)
    end
    function det(m)
    tex.sprint(tostring(matrix.det(cmatrix(m))))
    end
    endluacode*
    newcommandmatrixdet[1]directluadet(#1)
    matrixdet1,2,3,4,5,6,"7+8i",8,10
    enddocument






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jul 24 at 14:28









    MarijnMarijn

    11.2k1 gold badge6 silver badges40 bronze badges




    11.2k1 gold badge6 silver badges40 bronze badges










    • 1





      Thanks for fast and correct explanation.

      – user61681
      Jul 24 at 14:30












    • 1





      Thanks for fast and correct explanation.

      – user61681
      Jul 24 at 14:30







    1




    1





    Thanks for fast and correct explanation.

    – user61681
    Jul 24 at 14:30





    Thanks for fast and correct explanation.

    – user61681
    Jul 24 at 14:30













    6














    Unlike the Lua print function, which implicitly applies tostringto its argument, tex.sprint is defined to print each entry of a table separately if its argument is a table. The complex number is a two item table with the real and imaginary part with a custom tostring function that adds the i.



    So print(matrix.det(cmatrix(m))) invokes tostring and prints -3-24i but tex.sprint applies the normal numeric tostring to each element of the table separately so prints -3 then -24. If you explicitly apply tostring before calling tex.sprint then the function specified for the complex number table will be used, resulting in "-3-24i" again.






    share|improve this answer





























      6














      Unlike the Lua print function, which implicitly applies tostringto its argument, tex.sprint is defined to print each entry of a table separately if its argument is a table. The complex number is a two item table with the real and imaginary part with a custom tostring function that adds the i.



      So print(matrix.det(cmatrix(m))) invokes tostring and prints -3-24i but tex.sprint applies the normal numeric tostring to each element of the table separately so prints -3 then -24. If you explicitly apply tostring before calling tex.sprint then the function specified for the complex number table will be used, resulting in "-3-24i" again.






      share|improve this answer



























        6












        6








        6







        Unlike the Lua print function, which implicitly applies tostringto its argument, tex.sprint is defined to print each entry of a table separately if its argument is a table. The complex number is a two item table with the real and imaginary part with a custom tostring function that adds the i.



        So print(matrix.det(cmatrix(m))) invokes tostring and prints -3-24i but tex.sprint applies the normal numeric tostring to each element of the table separately so prints -3 then -24. If you explicitly apply tostring before calling tex.sprint then the function specified for the complex number table will be used, resulting in "-3-24i" again.






        share|improve this answer













        Unlike the Lua print function, which implicitly applies tostringto its argument, tex.sprint is defined to print each entry of a table separately if its argument is a table. The complex number is a two item table with the real and imaginary part with a custom tostring function that adds the i.



        So print(matrix.det(cmatrix(m))) invokes tostring and prints -3-24i but tex.sprint applies the normal numeric tostring to each element of the table separately so prints -3 then -24. If you explicitly apply tostring before calling tex.sprint then the function specified for the complex number table will be used, resulting in "-3-24i" again.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 24 at 16:30









        David CarlisleDavid Carlisle

        518k44 gold badges1173 silver badges1943 bronze badges




        518k44 gold badges1173 silver badges1943 bronze badges






























            draft saved

            draft discarded
















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f501273%2fbug-in-lualatex-not-printing-characters-from-calculation%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

            Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?