Is it possible to develop functions for LaTeX? [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this questionOkay, I'm a real LaTeX noob. But I will have to use it. And a friend who knows it (as a student who writes his diploma with it) said, there is a Listings package to put source code into a document. Well, after I saw that listings 开发者_StackOverflow中文版package, I realized that's not really what I want. So I'm curious if it's possible to develop something like that listings package. I have no idea what sort of thing such a "package" actually is. Right now I'd bet it's some kind of program.
So: How could I write a module or package (or whatever the LaTeX folks call that) to extend LaTeX with custom functionality? What programming language must I use there? And are there any helpful tutorials online?
Look at The latex class and package authors guide. Also look at this rather similar SO question, in particular, the implementation of texments gives you another avenue for implementing things.
LaTeX is a program suite developed in the language known as TeX :)
For simple things you can define your own environments and commands. See how to use \newcommand
and \newenvironment
. Look at some examples here. It is easy.
Putting your commands and environments in a separate package is the next step.
Programming TeX (engine which LaTeX is based upon) is more complicated. The TeXbook [1], [2] is your friend.
You can look into the source code of the listings
package if you're interested in its workings but beware. Writing LaTeX packages yourself isn't easy.
An example of a re-writing of Listings is mcode which I found here. If you browse the .sty file you will have a good idea. However, if as a total beginner you are supposed to develop an entire package it can be due to the fact that you don't know how to use existing stuff. For example, with listings you have a lot of options and it can fit a lot of different languages. If you prefer to use pseudo-code, you can have a look at the "algorithm" package.
精彩评论