How to register callbacks in lualatexLuapath broke after upgrading miktexWhy does it take LuaLaTeX so long to...

Would the melodic leap of the opening phrase of Mozart's K545 be considered dissonant?

How do you say “my friend is throwing a party, do you wanna come?” in german

Split a number into equal parts given the number of parts

Four buttons on a table

Plagiarism of code by other PhD student

Is there a math equivalent to the conditional ternary operator?

Did Amazon pay $0 in taxes last year?

How does insurance birth control work?

When to use mean vs median

How to use math.log10 function on whole pandas dataframe

Wardrobe above a wall with fuse boxes

School performs periodic password audits. Is my password compromised?

In which way proportional valves are controlled solely by current?

How do I deal with being envious of my own players?

PTIJ: What’s wrong with eating meat and couscous?

How to kill a localhost:8080

Reason why dimensional travelling would be restricted

What is the difference between 主菜 and 主食?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

GPL code private and stolen

Is there a limit on the maximum number of future jobs queued in an org?

Why won't the strings command stop?

Why do phishing e-mails use faked e-mail addresses instead of the real one?

If nine coins are tossed, what is the probability that the number of heads is even?



How to register callbacks in lualatex


Luapath broke after upgrading miktexWhy does it take LuaLaTeX so long to load fonts and can I speed it up?Lualatex, Pdflatex fail with externalizeLualatex capacity exceeded with Gb's of free RAMError when compiling with lualatex file “ltluatex.tex”Missing number error when using the scrbook document class LuaLaTeXWhile compiling expl3-code.tex takes more time than the othersIncluded lilypond files being processed by lualatex can't contain % symbol commentsHow to use lua code from external file in lualatex?Install cryst font on macOS 10.14 for pdflatex and lualatex













2















Help me please,how i can register callbacks in lualatex. For example it need to me catch,when the page of my document started or ended and print number of this page*2. I found in luatex documentation only how to catch,when the end of the page,but it not works for me. Here is my code:



documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f()
tex.print("page "..thepage*2)
end
id,error=callback.register("finish_pdfpage",f)
tex.sprint(error," ",id)
end{luacode}
begin{document}
test
newpage
new test
end{document}


But when i compile this document in lualatex,i get errors:



C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:109:
Module luatexbase Error: Attempt to use callback.register() directly
(luatexbase) on input line 14

stack traceback:
[C]: in function 'error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:109: in function 'modu
le_error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:116: in function 'luat
exbase_error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:320: in function 'regi
ster'
[directlua]:4: in main chunk.
luacode@dbg@exec ...code@maybe@printdbg {#1} #1 }

l.14 end{luacode}
?


Also help me please,how i can catch event,when new page started,to print,for example,number of this page*2 or simple number of this page. Thank everybody for help.










share|improve this question









New contributor




Aleksandr Kozlovskiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • the ltluatex code used by latex (based on an earlier luatexbase package) implements an allocation scheme for callbacks so different packages can access the callbacks without over-writing each other, but to make that work the primitive callback registration has to be hidden.

    – David Carlisle
    yesterday






  • 1





    you can use texdoc ltluatex to see the documentation latex lua interface. You register a callback with luatexbase.add_to_callback as shown in Ulrike's answer.

    – David Carlisle
    yesterday











  • I tryed use texdoc ltluatex,but it give me some useful information about callbacks,but not so mutch about the tex functions and attributes of tex tables such as: tex.attribute tex.count tex.dimen tex.skip tex.toks etc,. It seems,that i must guess al this attributes. 😁

    – Aleksandr Kozlovskiy
    7 hours ago
















2















Help me please,how i can register callbacks in lualatex. For example it need to me catch,when the page of my document started or ended and print number of this page*2. I found in luatex documentation only how to catch,when the end of the page,but it not works for me. Here is my code:



documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f()
tex.print("page "..thepage*2)
end
id,error=callback.register("finish_pdfpage",f)
tex.sprint(error," ",id)
end{luacode}
begin{document}
test
newpage
new test
end{document}


But when i compile this document in lualatex,i get errors:



C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:109:
Module luatexbase Error: Attempt to use callback.register() directly
(luatexbase) on input line 14

stack traceback:
[C]: in function 'error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:109: in function 'modu
le_error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:116: in function 'luat
exbase_error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:320: in function 'regi
ster'
[directlua]:4: in main chunk.
luacode@dbg@exec ...code@maybe@printdbg {#1} #1 }

l.14 end{luacode}
?


Also help me please,how i can catch event,when new page started,to print,for example,number of this page*2 or simple number of this page. Thank everybody for help.










share|improve this question









New contributor




Aleksandr Kozlovskiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • the ltluatex code used by latex (based on an earlier luatexbase package) implements an allocation scheme for callbacks so different packages can access the callbacks without over-writing each other, but to make that work the primitive callback registration has to be hidden.

    – David Carlisle
    yesterday






  • 1





    you can use texdoc ltluatex to see the documentation latex lua interface. You register a callback with luatexbase.add_to_callback as shown in Ulrike's answer.

    – David Carlisle
    yesterday











  • I tryed use texdoc ltluatex,but it give me some useful information about callbacks,but not so mutch about the tex functions and attributes of tex tables such as: tex.attribute tex.count tex.dimen tex.skip tex.toks etc,. It seems,that i must guess al this attributes. 😁

    – Aleksandr Kozlovskiy
    7 hours ago














2












2








2








Help me please,how i can register callbacks in lualatex. For example it need to me catch,when the page of my document started or ended and print number of this page*2. I found in luatex documentation only how to catch,when the end of the page,but it not works for me. Here is my code:



documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f()
tex.print("page "..thepage*2)
end
id,error=callback.register("finish_pdfpage",f)
tex.sprint(error," ",id)
end{luacode}
begin{document}
test
newpage
new test
end{document}


But when i compile this document in lualatex,i get errors:



C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:109:
Module luatexbase Error: Attempt to use callback.register() directly
(luatexbase) on input line 14

stack traceback:
[C]: in function 'error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:109: in function 'modu
le_error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:116: in function 'luat
exbase_error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:320: in function 'regi
ster'
[directlua]:4: in main chunk.
luacode@dbg@exec ...code@maybe@printdbg {#1} #1 }

l.14 end{luacode}
?


Also help me please,how i can catch event,when new page started,to print,for example,number of this page*2 or simple number of this page. Thank everybody for help.










share|improve this question









New contributor




Aleksandr Kozlovskiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












Help me please,how i can register callbacks in lualatex. For example it need to me catch,when the page of my document started or ended and print number of this page*2. I found in luatex documentation only how to catch,when the end of the page,but it not works for me. Here is my code:



documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f()
tex.print("page "..thepage*2)
end
id,error=callback.register("finish_pdfpage",f)
tex.sprint(error," ",id)
end{luacode}
begin{document}
test
newpage
new test
end{document}


But when i compile this document in lualatex,i get errors:



C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:109:
Module luatexbase Error: Attempt to use callback.register() directly
(luatexbase) on input line 14

stack traceback:
[C]: in function 'error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:109: in function 'modu
le_error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:116: in function 'luat
exbase_error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:320: in function 'regi
ster'
[directlua]:4: in main chunk.
luacode@dbg@exec ...code@maybe@printdbg {#1} #1 }

l.14 end{luacode}
?


Also help me please,how i can catch event,when new page started,to print,for example,number of this page*2 or simple number of this page. Thank everybody for help.







luatex






share|improve this question









New contributor




Aleksandr Kozlovskiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Aleksandr Kozlovskiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









Phelype Oleinik

23.8k54587




23.8k54587






New contributor




Aleksandr Kozlovskiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









Aleksandr KozlovskiyAleksandr Kozlovskiy

211




211




New contributor




Aleksandr Kozlovskiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Aleksandr Kozlovskiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Aleksandr Kozlovskiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • the ltluatex code used by latex (based on an earlier luatexbase package) implements an allocation scheme for callbacks so different packages can access the callbacks without over-writing each other, but to make that work the primitive callback registration has to be hidden.

    – David Carlisle
    yesterday






  • 1





    you can use texdoc ltluatex to see the documentation latex lua interface. You register a callback with luatexbase.add_to_callback as shown in Ulrike's answer.

    – David Carlisle
    yesterday











  • I tryed use texdoc ltluatex,but it give me some useful information about callbacks,but not so mutch about the tex functions and attributes of tex tables such as: tex.attribute tex.count tex.dimen tex.skip tex.toks etc,. It seems,that i must guess al this attributes. 😁

    – Aleksandr Kozlovskiy
    7 hours ago



















  • the ltluatex code used by latex (based on an earlier luatexbase package) implements an allocation scheme for callbacks so different packages can access the callbacks without over-writing each other, but to make that work the primitive callback registration has to be hidden.

    – David Carlisle
    yesterday






  • 1





    you can use texdoc ltluatex to see the documentation latex lua interface. You register a callback with luatexbase.add_to_callback as shown in Ulrike's answer.

    – David Carlisle
    yesterday











  • I tryed use texdoc ltluatex,but it give me some useful information about callbacks,but not so mutch about the tex functions and attributes of tex tables such as: tex.attribute tex.count tex.dimen tex.skip tex.toks etc,. It seems,that i must guess al this attributes. 😁

    – Aleksandr Kozlovskiy
    7 hours ago

















the ltluatex code used by latex (based on an earlier luatexbase package) implements an allocation scheme for callbacks so different packages can access the callbacks without over-writing each other, but to make that work the primitive callback registration has to be hidden.

– David Carlisle
yesterday





the ltluatex code used by latex (based on an earlier luatexbase package) implements an allocation scheme for callbacks so different packages can access the callbacks without over-writing each other, but to make that work the primitive callback registration has to be hidden.

– David Carlisle
yesterday




1




1





you can use texdoc ltluatex to see the documentation latex lua interface. You register a callback with luatexbase.add_to_callback as shown in Ulrike's answer.

– David Carlisle
yesterday





you can use texdoc ltluatex to see the documentation latex lua interface. You register a callback with luatexbase.add_to_callback as shown in Ulrike's answer.

– David Carlisle
yesterday













I tryed use texdoc ltluatex,but it give me some useful information about callbacks,but not so mutch about the tex functions and attributes of tex tables such as: tex.attribute tex.count tex.dimen tex.skip tex.toks etc,. It seems,that i must guess al this attributes. 😁

– Aleksandr Kozlovskiy
7 hours ago





I tryed use texdoc ltluatex,but it give me some useful information about callbacks,but not so mutch about the tex functions and attributes of tex tables such as: tex.attribute tex.count tex.dimen tex.skip tex.toks etc,. It seems,that i must guess al this attributes. 😁

– Aleksandr Kozlovskiy
7 hours ago










1 Answer
1






active

oldest

votes


















4














You need to use luatexbase.add_to_callback. But you shouldn't try to print something in finish_pdfpage. Here an example that writes to the log:



documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f()
texio.write_nl("HELLO: page "..tex.count["c@page"]*2)
end
id,error=luatexbase.add_to_callback("finish_pdfpage",f,"finish")
end{luacode}
begin{document}
test
newpage
new test
end{document}





share|improve this answer
























  • Ok,now it print number of page,but it seems for me,that it print at the second page. How i can catch end of the page and print information about it and how i can catch a start of new page and print information about it and,if it possible,how i can get content only for this pages? It also not understandeble for ne,how i can get the name of callback,which call my function,because in future i want to use one function with several callbacks. Thanks very mutch everybody for the help.

    – Aleksandr Kozlovskiy
    6 hours ago











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
});


}
});






Aleksandr Kozlovskiy is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477901%2fhow-to-register-callbacks-in-lualatex%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














You need to use luatexbase.add_to_callback. But you shouldn't try to print something in finish_pdfpage. Here an example that writes to the log:



documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f()
texio.write_nl("HELLO: page "..tex.count["c@page"]*2)
end
id,error=luatexbase.add_to_callback("finish_pdfpage",f,"finish")
end{luacode}
begin{document}
test
newpage
new test
end{document}





share|improve this answer
























  • Ok,now it print number of page,but it seems for me,that it print at the second page. How i can catch end of the page and print information about it and how i can catch a start of new page and print information about it and,if it possible,how i can get content only for this pages? It also not understandeble for ne,how i can get the name of callback,which call my function,because in future i want to use one function with several callbacks. Thanks very mutch everybody for the help.

    – Aleksandr Kozlovskiy
    6 hours ago
















4














You need to use luatexbase.add_to_callback. But you shouldn't try to print something in finish_pdfpage. Here an example that writes to the log:



documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f()
texio.write_nl("HELLO: page "..tex.count["c@page"]*2)
end
id,error=luatexbase.add_to_callback("finish_pdfpage",f,"finish")
end{luacode}
begin{document}
test
newpage
new test
end{document}





share|improve this answer
























  • Ok,now it print number of page,but it seems for me,that it print at the second page. How i can catch end of the page and print information about it and how i can catch a start of new page and print information about it and,if it possible,how i can get content only for this pages? It also not understandeble for ne,how i can get the name of callback,which call my function,because in future i want to use one function with several callbacks. Thanks very mutch everybody for the help.

    – Aleksandr Kozlovskiy
    6 hours ago














4












4








4







You need to use luatexbase.add_to_callback. But you shouldn't try to print something in finish_pdfpage. Here an example that writes to the log:



documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f()
texio.write_nl("HELLO: page "..tex.count["c@page"]*2)
end
id,error=luatexbase.add_to_callback("finish_pdfpage",f,"finish")
end{luacode}
begin{document}
test
newpage
new test
end{document}





share|improve this answer













You need to use luatexbase.add_to_callback. But you shouldn't try to print something in finish_pdfpage. Here an example that writes to the log:



documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f()
texio.write_nl("HELLO: page "..tex.count["c@page"]*2)
end
id,error=luatexbase.add_to_callback("finish_pdfpage",f,"finish")
end{luacode}
begin{document}
test
newpage
new test
end{document}






share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









Ulrike FischerUlrike Fischer

194k8302688




194k8302688













  • Ok,now it print number of page,but it seems for me,that it print at the second page. How i can catch end of the page and print information about it and how i can catch a start of new page and print information about it and,if it possible,how i can get content only for this pages? It also not understandeble for ne,how i can get the name of callback,which call my function,because in future i want to use one function with several callbacks. Thanks very mutch everybody for the help.

    – Aleksandr Kozlovskiy
    6 hours ago



















  • Ok,now it print number of page,but it seems for me,that it print at the second page. How i can catch end of the page and print information about it and how i can catch a start of new page and print information about it and,if it possible,how i can get content only for this pages? It also not understandeble for ne,how i can get the name of callback,which call my function,because in future i want to use one function with several callbacks. Thanks very mutch everybody for the help.

    – Aleksandr Kozlovskiy
    6 hours ago

















Ok,now it print number of page,but it seems for me,that it print at the second page. How i can catch end of the page and print information about it and how i can catch a start of new page and print information about it and,if it possible,how i can get content only for this pages? It also not understandeble for ne,how i can get the name of callback,which call my function,because in future i want to use one function with several callbacks. Thanks very mutch everybody for the help.

– Aleksandr Kozlovskiy
6 hours ago





Ok,now it print number of page,but it seems for me,that it print at the second page. How i can catch end of the page and print information about it and how i can catch a start of new page and print information about it and,if it possible,how i can get content only for this pages? It also not understandeble for ne,how i can get the name of callback,which call my function,because in future i want to use one function with several callbacks. Thanks very mutch everybody for the help.

– Aleksandr Kozlovskiy
6 hours ago










Aleksandr Kozlovskiy is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Aleksandr Kozlovskiy is a new contributor. Be nice, and check out our Code of Conduct.













Aleksandr Kozlovskiy is a new contributor. Be nice, and check out our Code of Conduct.












Aleksandr Kozlovskiy is a new contributor. Be nice, and check out our Code of Conduct.
















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%2f477901%2fhow-to-register-callbacks-in-lualatex%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

Installing LyX: “No textclass is found.”LyX installation error- text class not found- 'Reconfigure' or...

(1602) Indiana Índice Designación y nombre Características orbitales Véase...

Universidad Autónoma de Occidente Índice Historia Campus Facultades Programas Académicos Medios de...