目前下载到的是 Tex live 2015版。
第一步选择国内的CTAN(Comprehensive TeX Archive Network)站点。
如果全部安装,需要4322MB空间。由于从网上下载大批安装包,预计安装过程比较漫长。
这里选择 basic scheme(plain and latex) ,只需要磁盘空间244MB。
推荐选择 custom selection of collections。然后选择四个组件: Essential programs and files;LaTex fundamental packages;chinese;windows-only support programs。需要456MB空间。
Portable Setup选择了“是”。安装目录可以修改到其他驱动器,这里选择安装到D盘。其他选项基本不用修改,例如缺省纸张是A4,等等。
安装完成之后,到系统设置-高级选项-环境变量里面,把Path环境变量加上tex live的二进制程序目录。这里是 D:\texlive\bin\win32;
安装之后进行简单测试。
由于本机安装了python环境,直接 pip install pylatex。然后找了一个源码进行测试。
#!/usr/bin/python
"""
This example shows basic document generation functionality.
.. :copyright: (c) 2014 by Jelte Fennema.
:license: MIT, see License for more details.
"""
# begin-doc-include
from pylatex import Document, Section, Subsection, Command
from pylatex.utils import italic, NoEscape
def fill_document(doc):
"""Add a section, a subsection and some text to the document.
:param doc: the document
:type doc: :class:`pylatex.document.Document` instance
"""
with doc.create(Section('A section')):
doc.append('Some regular text and some ')
doc.append(italic('italic text. '))
with doc.create(Subsection('A subsection')):
doc.append('Also some crazy characters: ${}')
if __name__ == '__main__':
# Basic document
doc = Document('basic')
fill_document(doc)
doc.generate_pdf()
doc.generate_tex()
# Document with `\maketitle` command activated
doc = Document()
doc.preamble.append(Command('title', 'Awesome Title'))
doc.preamble.append(Command('author', 'Anonymous author'))
doc.preamble.append(Command('date', NoEscape(r'\today')))
doc.append(NoEscape(r'\maketitle'))
fill_document(doc)
doc.generate_pdf('basic_maketitle', clean=False)
# Add stuff to the document
with doc.create(Section('A second section')):
doc.append('Some text.')
doc.generate_pdf('basic_maketitle2')
tex = doc.dumps() # The document as string in LaTeX syntax
保存为testlatex.py
> python testlatex.py
如果没问题,将生成basic.pdf。如果出错,需要根据出错信息进行处理。可能遇到下面的两个错误。
! Font T1/cmr/m/n/10=ecrm1000 at 10.0pt not loadable: Metric (TFM) file not found.
! LaTeX Error: File `lmodern.sty' not found.
错误是缺少相应的包导致。
更新包的过程很简单,TeX Live提供了图形化程序 TeX Live manager。
打开管理器,刷新软件源,分别搜索ec和lm,安装下面的两个包。
ec computer modern fonts in T1 and TS1 encodings
lm latin modern fonts in outline formats
完毕之后重新运行测试代码,如果无误将不会报错。检查输出文件basic.pdf是否已在当前目录创建,打开basic.pdf看内容是否符合预期。