Getting all Symbols
Hi all, I've posted this question to comp.text.tex, and they've suggested to take a look at LuaTeX. So I forwarded the message to the User mailing list, but probably this one is more appropriate. If not, excuse me! I'm trying to find *at runtime* all the symbols allowed in a latex environment. So, given a tex file, I'd like to access - the complete predefined commands/symbols/definitions; - the complete list of commands/symbols/definitions defined in packages. So, the predefined language list would include \LaTeX, \def, \newcommand, ~, \usepackage, and so on. I've been informed that this is a naive view, since there are lots of other commands such as \@ and similars, and a simple match with a \ would be unrealistic (e.g., anything beginning with a \ is a command). When including a package, for example graphicx, I expect to find a way to have \includegraphics and its siblings. Again, packages may mess up a little bit. The best would be having commands along with their options, but I don't know if this is possible. One thing I'd like to avoid: creating my own parser. Why on earth should I create a parser when latex knows more than me (or everyone else) what symbols and commands it knows? The suggestions from the newsgroup is that *maybe* LuaTeX gives a way to access all TeX's macro hash table. If so, I'd be really happy. Thanks & Cheers!
On 11-6-2012 15:10, Sensei wrote:
Hi all,
I've posted this question to comp.text.tex, and they've suggested to take a look at LuaTeX. So I forwarded the message to the User mailing list, but probably this one is more appropriate. If not, excuse me!
I'm trying to find *at runtime* all the symbols allowed in a latex environment. So, given a tex file, I'd like to access - the complete predefined commands/symbols/definitions; - the complete list of commands/symbols/definitions defined in packages.
So, the predefined language list would include \LaTeX, \def, \newcommand, ~, \usepackage, and so on. I've been informed that this is a naive view, since there are lots of other commands such as \@ and similars, and a simple match with a \ would be unrealistic (e.g., anything beginning with a \ is a command).
When including a package, for example graphicx, I expect to find a way to have \includegraphics and its siblings. Again, packages may mess up a little bit.
The best would be having commands along with their options, but I don't know if this is possible.
One thing I'd like to avoid: creating my own parser. Why on earth should I create a parser when latex knows more than me (or everyone else) what symbols and commands it knows?
The suggestions from the newsgroup is that *maybe* LuaTeX gives a way to access all TeX's macro hash table. If so, I'd be really happy.
a matter of reading the manual .. (or using context) ... local list = { } for name, _ in pairs(tex.hashtokens()) do if string.find(name,"^[a-zA-Z]+$") then list[#list+1] = name end end table.sort(list) print(table.serialize(list)) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Sensei