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

From the start of the game what is the longest possible series of consecutive white moves where white can do those moves no matter what black does?

Idioms: Should it be " the internet is a seemingly infinite well of information" or "the internet is a seemingly infinite wealth of information"

Other than a swing wing, what types of variable geometry have flown?

What is the spanish equivalent of "the boys are sitting"?

Can a character with a low Intelligence score take the Ritual Caster feat and choose the Wizard class?

Is it okay to paraphrase other authors' literature reviews?

The seven story archetypes. Are they truly all of them?

What is "ass door"?

How to repair basic cable/wire issue for household appliances

Impact of throwing away fruit waste on a peak > 3200 m above a glacier

Is the apartment I want to rent a scam?

Are symplectomorphisms of Weil–Petersson symplectic form induced from surface diffeomorphisms?

Why is chess failing to attract big name sponsors?

Travelling from Venice to Budapest, making a stop in Croatia

ExactlyOne extension method

Short story about a group of sci-fi writers sitting around discussing their profession

Monty Hall Problem with a Fallible Monty

What Is the Meaning of "you has the wind of me"?

What kind of world would drive brains to evolve high-throughput sensory?

What happens when two cards both modify what I'm allowed to do?

What's the explanation for this joke about a three-legged dog that walks into a bar?

What would be the side effects on the life of a person becoming indestructible?

Why must API keys be kept private?

Short story where a flexible reality hardens to an unchanging one



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;








3















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
    8 hours ago












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

    – egreg
    8 hours ago

















3















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
    8 hours ago












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

    – egreg
    8 hours ago













3












3








3








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 8 hours ago









user61681user61681

4162 silver badges11 bronze badges




4162 silver badges11 bronze badges












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

    – user61681
    8 hours ago












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

    – egreg
    8 hours ago

















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

    – user61681
    8 hours ago












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

    – egreg
    8 hours ago
















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

– user61681
8 hours ago






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

– user61681
8 hours ago














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

– egreg
8 hours ago





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

– egreg
8 hours ago










2 Answers
2






active

oldest

votes


















5














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
    8 hours ago


















2














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









    5














    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
      8 hours ago















    5














    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
      8 hours ago













    5












    5








    5







    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 8 hours ago









    MarijnMarijn

    11k1 gold badge6 silver badges40 bronze badges




    11k1 gold badge6 silver badges40 bronze badges







    • 1





      Thanks for fast and correct explanation.

      – user61681
      8 hours ago












    • 1





      Thanks for fast and correct explanation.

      – user61681
      8 hours ago







    1




    1





    Thanks for fast and correct explanation.

    – user61681
    8 hours ago





    Thanks for fast and correct explanation.

    – user61681
    8 hours ago













    2














    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



























      2














      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

























        2












        2








        2







        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 6 hours ago









        David CarlisleDavid Carlisle

        516k44 gold badges1172 silver badges1941 bronze badges




        516k44 gold badges1172 silver badges1941 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

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480