Defining new commands from LuaTeX
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
Latex provides several commands relating to creating new commands such as newcommand
. If I want to define new commands from a Lua script one way is use tex.print
to write this directly into the document.
It this really the best way though? The whole point of LuaTeX is to avoid programming with Tex macros, yet this approaches involves doing exactly that. How can I directly access, edit and create commands directly from Lua?
script.lua
tex.print("\newcommand\helloHello world")
document.tex
documentclassarticle
begindocument
directlua require("script")
hello
enddocument
luatex
add a comment |Â
up vote
6
down vote
favorite
Latex provides several commands relating to creating new commands such as newcommand
. If I want to define new commands from a Lua script one way is use tex.print
to write this directly into the document.
It this really the best way though? The whole point of LuaTeX is to avoid programming with Tex macros, yet this approaches involves doing exactly that. How can I directly access, edit and create commands directly from Lua?
script.lua
tex.print("\newcommand\helloHello world")
document.tex
documentclassarticle
begindocument
directlua require("script")
hello
enddocument
luatex
LuaTeX is about combining Lua and TeX: if you look at ConTeXt, it is still a macro system using Lua _where it adds functionality
â Joseph Wrightâ¦
6 mins ago
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
Latex provides several commands relating to creating new commands such as newcommand
. If I want to define new commands from a Lua script one way is use tex.print
to write this directly into the document.
It this really the best way though? The whole point of LuaTeX is to avoid programming with Tex macros, yet this approaches involves doing exactly that. How can I directly access, edit and create commands directly from Lua?
script.lua
tex.print("\newcommand\helloHello world")
document.tex
documentclassarticle
begindocument
directlua require("script")
hello
enddocument
luatex
Latex provides several commands relating to creating new commands such as newcommand
. If I want to define new commands from a Lua script one way is use tex.print
to write this directly into the document.
It this really the best way though? The whole point of LuaTeX is to avoid programming with Tex macros, yet this approaches involves doing exactly that. How can I directly access, edit and create commands directly from Lua?
script.lua
tex.print("\newcommand\helloHello world")
document.tex
documentclassarticle
begindocument
directlua require("script")
hello
enddocument
luatex
luatex
edited 8 mins ago
Mico
263k30355730
263k30355730
asked 1 hour ago
raiksey
364
364
LuaTeX is about combining Lua and TeX: if you look at ConTeXt, it is still a macro system using Lua _where it adds functionality
â Joseph Wrightâ¦
6 mins ago
add a comment |Â
LuaTeX is about combining Lua and TeX: if you look at ConTeXt, it is still a macro system using Lua _where it adds functionality
â Joseph Wrightâ¦
6 mins ago
LuaTeX is about combining Lua and TeX: if you look at ConTeXt, it is still a macro system using Lua _where it adds functionality
â Joseph Wrightâ¦
6 mins ago
LuaTeX is about combining Lua and TeX: if you look at ConTeXt, it is still a macro system using Lua _where it adds functionality
â Joseph Wrightâ¦
6 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
9
down vote
accepted
documentclassarticle
begindocument
directluatoken.set_macro("hello","goodbye")
hello
enddocument
Accepted, thank you. Do you know of any good packages/classes on CTAN I could look at that are implemented in Lua and do this sort of thing? (To try to understand the common patterns a bit better. I'm looking at building a document class)
â raiksey
1 hour ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
9
down vote
accepted
documentclassarticle
begindocument
directluatoken.set_macro("hello","goodbye")
hello
enddocument
Accepted, thank you. Do you know of any good packages/classes on CTAN I could look at that are implemented in Lua and do this sort of thing? (To try to understand the common patterns a bit better. I'm looking at building a document class)
â raiksey
1 hour ago
add a comment |Â
up vote
9
down vote
accepted
documentclassarticle
begindocument
directluatoken.set_macro("hello","goodbye")
hello
enddocument
Accepted, thank you. Do you know of any good packages/classes on CTAN I could look at that are implemented in Lua and do this sort of thing? (To try to understand the common patterns a bit better. I'm looking at building a document class)
â raiksey
1 hour ago
add a comment |Â
up vote
9
down vote
accepted
up vote
9
down vote
accepted
documentclassarticle
begindocument
directluatoken.set_macro("hello","goodbye")
hello
enddocument
documentclassarticle
begindocument
directluatoken.set_macro("hello","goodbye")
hello
enddocument
answered 1 hour ago
David Carlisle
467k3810941817
467k3810941817
Accepted, thank you. Do you know of any good packages/classes on CTAN I could look at that are implemented in Lua and do this sort of thing? (To try to understand the common patterns a bit better. I'm looking at building a document class)
â raiksey
1 hour ago
add a comment |Â
Accepted, thank you. Do you know of any good packages/classes on CTAN I could look at that are implemented in Lua and do this sort of thing? (To try to understand the common patterns a bit better. I'm looking at building a document class)
â raiksey
1 hour ago
Accepted, thank you. Do you know of any good packages/classes on CTAN I could look at that are implemented in Lua and do this sort of thing? (To try to understand the common patterns a bit better. I'm looking at building a document class)
â raiksey
1 hour ago
Accepted, thank you. Do you know of any good packages/classes on CTAN I could look at that are implemented in Lua and do this sort of thing? (To try to understand the common patterns a bit better. I'm looking at building a document class)
â raiksey
1 hour ago
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f450891%2fdefining-new-commands-from-luatex%23new-answer', 'question_page');
);
Post as a guest
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
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
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
LuaTeX is about combining Lua and TeX: if you look at ConTeXt, it is still a macro system using Lua _where it adds functionality
â Joseph Wrightâ¦
6 mins ago