tags:

views:

258

answers:

4

I don't know much about latex itself. All I need is list of available commands. All standard commands and that come from "usepackage" declarations.

I'm currently focused on MiKTeX, so if MiKTeX do provide, it is of course great, otherwise I do get the idea of parsing some .sty or .def files. But I don't understand the syntax behind those files. What should I look for in those files, if parsing is the only solution?

A: 

latex is a macro package, and macro systems (some hygenienic ones excepted) are notoriously difficult to parse.

The fact that there is no decent latex to html converter after all these years proves that.

But anyway, the existing ones could give you an example how to proceed, search for latex2html (in Perl), tex2ht and hevea

Marco van de Voort
i think i couldnt make it clear, i am not going to convert latex to anything, nor i will not parse latex documents. When i was mentioning about parsing, it was parsing of package descriptions to get commands that package provides.
Serkan Kasapbaşı
Perhaps the difficulty of latex-to-html is more a matter of expressiveness that of hard-to-parseness. Latex simply offers more control, so not all latex constructs *can* be mapped to html, ad the Turing complete nature of latex means you can never cover all the bases.
dmckee
A: 

Seems to me, you could use something like a "cheat sheet". There is one here, but there's bound to be more of them lying around.

ldigas
cheat sheets are definitely a start, but since latex's capacity can be enhanced by packages, i need to find a generic solution which covers packages too.
Serkan Kasapbaşı
Yes, that is a little hard. Now, don't take me wrong, I'm no expert at this, so I may be talking off the top of my head, but latex does seem to have a lot (A LOT !!) of packages, and covering them all seems a little too ambitious ... unrealistic even, really. So I'd suggest you try to cover the most used ones. That being said, by my guess 20 packages cover maybe 80% of what people use.
ldigas
I've read your question, yes ... but still, if I may ask, without being to inquisitive, what is it that you are try to accomplish ?
ldigas
what i'm trying to do is, provide a list in order to use in intellisense of a latex editor.So this will be a small portion of a latex editor. Now, this make sense right :)I agree with u about all packages will be irrelevant. That is why i will get the package names from latex document (from \usepackages) , then list those commands, not every package exist in the system or internet.
Serkan Kasapbaşı
Yes, that could work (in my last comment I misunderstood something). Well, good luck.
ldigas
+3  A: 

Parsing TeX code is by no means the only way to get a list of all control sequences. Other possibilities include:

  • cause TeX to dump its data structures after loading the relevant package, then parse the dump file; when you run the latex command, what really happens is that the tex binary loads the latex.fmt dump file, which was generated by having the same binary parse all the built-in code of LaTeX and dumping its data structures;

  • modify the source code of TeX to output something every time a control sequence gets defined;

  • run TeX in a scriptable debugger, insert a breakpoint where the sequence is inserted to the hash table, and have a script output the name of the sequence.

None of these is likely to be a particularly easy solution, but probably easier than writing a TeX-equivalent parser yourself. To get started, look at TeX: The Program, and your TeX system's source code.

If your goal is to provide "intellisense" in an editor, a mere list of command sequences is not going to be much help: when the user types \ref{, you should offer a list of labels defined in the document (bonus points if typing Chapter~\ref{ results in a list of chapter labels, not all labels); for \settowidth{, a list of length commands; for \begin{, a list of environments; etc.

You could see what AUCTeX (an Emacs mode) does; it has a limited, regexp-based parser that handles the common case, and a bunch of package-specific libraries that extend the functionality.

Jouni K. Seppänen
A: 

It's not clear from your question if you want a list for use in a program, or just documentation for yourself?

In the latter case, recent TeX distributions include the command texdoc which will locate and open the documentation for whatever you ask it, e.g texdoc hyperref. It has aliases defined for convenience: texdoc koma will find and open the koma-script manual even though the actual file is named scrguien.pdf.

Damien Pollet