Tex与PDF

由Knuth Donald开发的tex.web会生成DVI文件,DVI也是Knuth自己实现的(虽然概念是其他人提出的)一种文件格式,目标是与设备无关。

通过dvips程序可以将DVI格式转化成PostScript格式,而PostScript格式是Adobe公司起家的产品,也是PDF格式的前身,甚至PDF现在的绘画机制与PostScript也相差无几。

可以使用ps2pdf将PostScript文件转化成PDF格式文件。

 

Tex的机制基本上就可以这样描述。

因为Tex的产生比较早,当时PostScript还只是个雏形,因此tex没有直接输出PostScript文件格式也是情理之中,不过Knuth还真是有远见,选择了一种与PDF的Portable类似的思想,生成DVI格式。然后,接下来的事其实也理所当然,PostScript以至PDF成了行业的标准,Tex就在不断地向PDF靠拢,直到最后出现了pdftex

The main difference between TeX and pdfTeX is that whereas TeX outputs DVIfiles, pdfTeX can output PDF files directly.

 

Pdftex能够直接将tex程序输出成PDF格式。

 

那么事情发展到这个地步已经很完美了,但是问题出在tex脚本语言本身,它太自限了,很难扩展或者与其他语言兼容,因此出现了LuaTex

The main objective of the project is to provide a version of TeX where all internals are accessible from Lua.

Lua是一门很容易嵌入到其他语言中的语言,那么它应该可以成为tex与其他语言结合的桥梁。

LuaTex之间的结合方式参考:Programming in LuaTeX

There are two main ways to execute Lua code in a ConTeXt document: The command \ctxlua, and the environment \startluacode...\stopluacode. Both are wrappers around the LuaTeX primitive\directlua, which you should never need to use. In general, you will define a function inside a\startluacode block, and then define a TeX command that calls the function using \ctxlua, especially because \ctxlua has a few idiosyncracies.

 

Most commands that you would type with a backslash in plain ConTeXt, you can access from Lua withcontext.command. Unadorned strings end up in TeX as arguments in curly braces; Lua tables end up in TeX as paramater blocks in square brackets. 

不过看起来,Lua只是被嵌入到了tex中去,毕竟Lua只有一个比较小的核心,也基本上无法自己独立生存。

所以LuaTex只是tex自身的一个提升,而并不是向外界的开放接口。

posted @ 2014-08-20 10:49  Daniel King  阅读(351)  评论(0编辑  收藏  举报