5

This function was working in the production system and I'm not aware of changing anything (MikTeX did some package updates which may have had an effect).

A very much stripped down MWE is

\documentclass{article}

\directlua{
    function underscore(s)                                      
        s = tostring(s+2080)      
        tex.print(s)                                           
    end                                                    
}

\DeclareRobustCommand{\Binl}[1]{\directlua{underscore([[#1]])}}% 

\begin{document}

Use M\Binl{1} or M\Binl{2}

\end{document}  

I used to get M_1 and M_2 with proper subscripts, but now the correct unicode characters U+2081 and U+2082 are being generated but have acquired a trailing ".0" as can be seen in the output. N.B. I've omitted prepending "\char\"" to s before passing the string back.

Output :

Use M2081.0 or M2082.0
7

That's due to the change from lua 5.2 to lua 5.3.

You can force the number to be an integer e.g. with math.floor:

\documentclass{article}

\directlua{
    function underscore(s)
        s = tostring(math.floor(s+2080))
        tex.print(s)
    end
}

\DeclareRobustCommand{\Binl}[1]{\directlua{underscore([[#1]])}}%

\begin{document}

Use M\Binl{1} or M\Binl{2}

\end{document}  

enter image description here

  • Thanks @Ulrike Fischer. That fixed it. – DLyons Jun 4 '19 at 18:33
3
s = tostring(math.floor(s+2080))      
  • Thanks Red-Cloud. Millisecs behind Ulrike. – DLyons Jun 4 '19 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.