Error during using callback start_page_number in lualatex
I updated miktex and all packages and now i have an error,when i try use callback start_page_number in my document. The error appeared even in very small document,for example in this document:
documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
tex.print("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
end{document}
When i compile it,i get errors:
{C:/Users/ksash/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] (./lua3.aux
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing = inserted for ifnum.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
__bool_p_0:
l.3 select@language {russian}
Help me please fix this errors (i use russian language,because i want to use it in documents,which contains cyrillic chars). Help me please fix this errors. Thanks everybody for the help.
luatex
add a comment |
I updated miktex and all packages and now i have an error,when i try use callback start_page_number in my document. The error appeared even in very small document,for example in this document:
documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
tex.print("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
end{document}
When i compile it,i get errors:
{C:/Users/ksash/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] (./lua3.aux
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing = inserted for ifnum.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
__bool_p_0:
l.3 select@language {russian}
Help me please fix this errors (i use russian language,because i want to use it in documents,which contains cyrillic chars). Help me please fix this errors. Thanks everybody for the help.
luatex
add a comment |
I updated miktex and all packages and now i have an error,when i try use callback start_page_number in my document. The error appeared even in very small document,for example in this document:
documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
tex.print("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
end{document}
When i compile it,i get errors:
{C:/Users/ksash/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] (./lua3.aux
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing = inserted for ifnum.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
__bool_p_0:
l.3 select@language {russian}
Help me please fix this errors (i use russian language,because i want to use it in documents,which contains cyrillic chars). Help me please fix this errors. Thanks everybody for the help.
luatex
I updated miktex and all packages and now i have an error,when i try use callback start_page_number in my document. The error appeared even in very small document,for example in this document:
documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage[babelshorthands=true]{russian}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
tex.print("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
end{document}
When i compile it,i get errors:
{C:/Users/ksash/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] (./lua3.aux
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing = inserted for ifnum.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
p
l.3 select@language {russian}
?
! Missing number, treated as zero.
<to be read again>
__bool_p_0:
l.3 select@language {russian}
Help me please fix this errors (i use russian language,because i want to use it in documents,which contains cyrillic chars). Help me please fix this errors. Thanks everybody for the help.
luatex
luatex
edited 5 hours ago
Ulrike Fischer
195k8302688
195k8302688
asked 5 hours ago
Aleksandr KozlovskiyAleksandr Kozlovskiy
361
361
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
start_page_number
"replaces the code that prints the [ and the page number at the begin of shipout.". This code sends information to the terminal and the log. It doesn't make much sense to replace it by code that tries to write something in the document. With texio.write_nl
e.g. it works fine:
documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage{russian}
usepackage{fontspec}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
texio.write_nl("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
end{document}
add a comment |
You are trying to use tex.print
in a callback. That will almost never work in the way you expect.
To show the issue in this particular case, compile the following modification of your document:
documentclass{article}
usepackage{luacode}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
tex.print("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
clearpage
Xdirectlua{tex.print''}X
end{document}
On the second page, this will print
What happened? After clearpage
LuaTeX finished up the first page and called your callback. This added something to the Lua TeX output buffer and returned.
Now the next time directlua
tries to print something, it will be added to the same buffer which will be sent to TeX after the evaluation of directlua
.
So the text printed with tex.print
during a callback is printed during a random following directlua
use. In you example, polyglossia tries to use LuaTeX to access some number and was confused about page 1
being returned instead.
This demonstrates: Never use tex.print
in a callback. The actual behaviour might also change with any update, to quote the manual: (referring to the whole tex.*print
family of functions)
The result of using these functions from inside callbacks is undefined at the moment.
Now you could add tokens into the TeX input stream from a callback using the token.put_next
interface, but this is very likely not what you are trying to do: It would insert the tokens at a basically random position because the callback is called when shipout
is done, so they would probably end up in the code of the output routine. This routine does not expect random code insertions, so it will either result in another error or add the tokens to the main vertical list. In the last case, the page number would end up in some "random" location after the actual page it refers to because of the asynchronous nature of the TeX output routine.
So how to fix it depends on what you are trying to archive:
If you want to print something to the console, see Ulrike Fischer's answer.
If you want to print a page number in your TeX document or some other information in the page footer, see for example this question. LuaTeX callbacks operate on a much lower level.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478937%2ferror-during-using-callback-start-page-number-in-lualatex%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
start_page_number
"replaces the code that prints the [ and the page number at the begin of shipout.". This code sends information to the terminal and the log. It doesn't make much sense to replace it by code that tries to write something in the document. With texio.write_nl
e.g. it works fine:
documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage{russian}
usepackage{fontspec}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
texio.write_nl("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
end{document}
add a comment |
start_page_number
"replaces the code that prints the [ and the page number at the begin of shipout.". This code sends information to the terminal and the log. It doesn't make much sense to replace it by code that tries to write something in the document. With texio.write_nl
e.g. it works fine:
documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage{russian}
usepackage{fontspec}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
texio.write_nl("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
end{document}
add a comment |
start_page_number
"replaces the code that prints the [ and the page number at the begin of shipout.". This code sends information to the terminal and the log. It doesn't make much sense to replace it by code that tries to write something in the document. With texio.write_nl
e.g. it works fine:
documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage{russian}
usepackage{fontspec}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
texio.write_nl("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
end{document}
start_page_number
"replaces the code that prints the [ and the page number at the begin of shipout.". This code sends information to the terminal and the log. It doesn't make much sense to replace it by code that tries to write something in the document. With texio.write_nl
e.g. it works fine:
documentclass{article}
usepackage{luacode}
usepackage{polyglossia}
setmainlanguage{russian}
usepackage{fontspec}
setmainfont{Times New Roman}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
texio.write_nl("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
end{document}
answered 5 hours ago
Ulrike FischerUlrike Fischer
195k8302688
195k8302688
add a comment |
add a comment |
You are trying to use tex.print
in a callback. That will almost never work in the way you expect.
To show the issue in this particular case, compile the following modification of your document:
documentclass{article}
usepackage{luacode}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
tex.print("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
clearpage
Xdirectlua{tex.print''}X
end{document}
On the second page, this will print
What happened? After clearpage
LuaTeX finished up the first page and called your callback. This added something to the Lua TeX output buffer and returned.
Now the next time directlua
tries to print something, it will be added to the same buffer which will be sent to TeX after the evaluation of directlua
.
So the text printed with tex.print
during a callback is printed during a random following directlua
use. In you example, polyglossia tries to use LuaTeX to access some number and was confused about page 1
being returned instead.
This demonstrates: Never use tex.print
in a callback. The actual behaviour might also change with any update, to quote the manual: (referring to the whole tex.*print
family of functions)
The result of using these functions from inside callbacks is undefined at the moment.
Now you could add tokens into the TeX input stream from a callback using the token.put_next
interface, but this is very likely not what you are trying to do: It would insert the tokens at a basically random position because the callback is called when shipout
is done, so they would probably end up in the code of the output routine. This routine does not expect random code insertions, so it will either result in another error or add the tokens to the main vertical list. In the last case, the page number would end up in some "random" location after the actual page it refers to because of the asynchronous nature of the TeX output routine.
So how to fix it depends on what you are trying to archive:
If you want to print something to the console, see Ulrike Fischer's answer.
If you want to print a page number in your TeX document or some other information in the page footer, see for example this question. LuaTeX callbacks operate on a much lower level.
add a comment |
You are trying to use tex.print
in a callback. That will almost never work in the way you expect.
To show the issue in this particular case, compile the following modification of your document:
documentclass{article}
usepackage{luacode}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
tex.print("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
clearpage
Xdirectlua{tex.print''}X
end{document}
On the second page, this will print
What happened? After clearpage
LuaTeX finished up the first page and called your callback. This added something to the Lua TeX output buffer and returned.
Now the next time directlua
tries to print something, it will be added to the same buffer which will be sent to TeX after the evaluation of directlua
.
So the text printed with tex.print
during a callback is printed during a random following directlua
use. In you example, polyglossia tries to use LuaTeX to access some number and was confused about page 1
being returned instead.
This demonstrates: Never use tex.print
in a callback. The actual behaviour might also change with any update, to quote the manual: (referring to the whole tex.*print
family of functions)
The result of using these functions from inside callbacks is undefined at the moment.
Now you could add tokens into the TeX input stream from a callback using the token.put_next
interface, but this is very likely not what you are trying to do: It would insert the tokens at a basically random position because the callback is called when shipout
is done, so they would probably end up in the code of the output routine. This routine does not expect random code insertions, so it will either result in another error or add the tokens to the main vertical list. In the last case, the page number would end up in some "random" location after the actual page it refers to because of the asynchronous nature of the TeX output routine.
So how to fix it depends on what you are trying to archive:
If you want to print something to the console, see Ulrike Fischer's answer.
If you want to print a page number in your TeX document or some other information in the page footer, see for example this question. LuaTeX callbacks operate on a much lower level.
add a comment |
You are trying to use tex.print
in a callback. That will almost never work in the way you expect.
To show the issue in this particular case, compile the following modification of your document:
documentclass{article}
usepackage{luacode}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
tex.print("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
clearpage
Xdirectlua{tex.print''}X
end{document}
On the second page, this will print
What happened? After clearpage
LuaTeX finished up the first page and called your callback. This added something to the Lua TeX output buffer and returned.
Now the next time directlua
tries to print something, it will be added to the same buffer which will be sent to TeX after the evaluation of directlua
.
So the text printed with tex.print
during a callback is printed during a random following directlua
use. In you example, polyglossia tries to use LuaTeX to access some number and was confused about page 1
being returned instead.
This demonstrates: Never use tex.print
in a callback. The actual behaviour might also change with any update, to quote the manual: (referring to the whole tex.*print
family of functions)
The result of using these functions from inside callbacks is undefined at the moment.
Now you could add tokens into the TeX input stream from a callback using the token.put_next
interface, but this is very likely not what you are trying to do: It would insert the tokens at a basically random position because the callback is called when shipout
is done, so they would probably end up in the code of the output routine. This routine does not expect random code insertions, so it will either result in another error or add the tokens to the main vertical list. In the last case, the page number would end up in some "random" location after the actual page it refers to because of the asynchronous nature of the TeX output routine.
So how to fix it depends on what you are trying to archive:
If you want to print something to the console, see Ulrike Fischer's answer.
If you want to print a page number in your TeX document or some other information in the page footer, see for example this question. LuaTeX callbacks operate on a much lower level.
You are trying to use tex.print
in a callback. That will almost never work in the way you expect.
To show the issue in this particular case, compile the following modification of your document:
documentclass{article}
usepackage{luacode}
pagestyle{empty}
thispagestyle{empty}
begin{luacode}
function f0()
tex.print("page "..tex.count["c@page"])
end
luatexbase.add_to_callback("start_page_number",f0,"start")
end{luacode}
begin{document}
test
clearpage
Xdirectlua{tex.print''}X
end{document}
On the second page, this will print
What happened? After clearpage
LuaTeX finished up the first page and called your callback. This added something to the Lua TeX output buffer and returned.
Now the next time directlua
tries to print something, it will be added to the same buffer which will be sent to TeX after the evaluation of directlua
.
So the text printed with tex.print
during a callback is printed during a random following directlua
use. In you example, polyglossia tries to use LuaTeX to access some number and was confused about page 1
being returned instead.
This demonstrates: Never use tex.print
in a callback. The actual behaviour might also change with any update, to quote the manual: (referring to the whole tex.*print
family of functions)
The result of using these functions from inside callbacks is undefined at the moment.
Now you could add tokens into the TeX input stream from a callback using the token.put_next
interface, but this is very likely not what you are trying to do: It would insert the tokens at a basically random position because the callback is called when shipout
is done, so they would probably end up in the code of the output routine. This routine does not expect random code insertions, so it will either result in another error or add the tokens to the main vertical list. In the last case, the page number would end up in some "random" location after the actual page it refers to because of the asynchronous nature of the TeX output routine.
So how to fix it depends on what you are trying to archive:
If you want to print something to the console, see Ulrike Fischer's answer.
If you want to print a page number in your TeX document or some other information in the page footer, see for example this question. LuaTeX callbacks operate on a much lower level.
edited 5 hours ago
answered 5 hours ago
Marcel KrügerMarcel Krüger
12.6k11636
12.6k11636
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478937%2ferror-during-using-callback-start-page-number-in-lualatex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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