Latex之文件拆分及独立编译

Latex之文件拆分及独立编译


发布日期: 1970-01-01 更新日期: 2015-01-27 编辑:giser 浏览次数: 4624

标签:

摘要: 最近使用Latex编写长文档,对于文件的组织有些困扰,找了一些资料。 如果LaTeX文档比较大,可以考虑拆分为几个部分。比如编辑一本书的时候可以将各章独立为 chap1.tex,chap2.tex,chap3.tex,然后在主文件main.tex中包含进来: ...

最近使用Latex编写长文档,对于文件的组织有些困扰,找了一些资料。 如果LaTeX文档比较大,可以考虑拆分为几个部分。比如编辑一本书的时候可以将各章独立为 chap1.tex,chap2.tex,chap3.tex,然后在主文件main.tex中包含进来:

documentclass{book}
    begin{document}
    title{A LaTeX Book}
    author{cohomo@blogbus}
    date{}maketitle
    input{chap1}
    input{chap2}
    input{chap3}
    end{document}

上面的input命令可以改为include,区别在于,input可以放在导言区和正文区,包含的内容不另起一页;而include只能放在正文区,包含的内容另起一页。另外CJK中还有CJKinput和CJKinclude命令。还有个问题就是,如何使得各章既可以被包含在另一个文件中也可以独立编译呢?方法是将main.tex和chap1.tex作如下修改:

 % main.tex
    documentclass{book}
    defallfiles{}
    begin{document}
    title{A LaTeX Book}
    author{cohomo@blogbus}
    date{}maketitle
    input{chap1}
    input{chap2}
    input{chap3}
    end{document}
    % chap1.tex
    ifx allfiles undefined
    documentclass{article}
    begin{document}
    title{Something in Title}
    author{cohomo@blogbus}
    date{}maketitle
    else
    chapter{Chap1's Title}
    fi
    section{First Section}
    section{Second Section}
    ifx allfiles undefined
    end{document}
    fi

这样编写长文档就很方便和灵活了。

关注公众号
获取免费资源

随机推荐


Copyright © Since 2014. 开源地理空间基金会中文分会 吉ICP备05002032号

Powered by TorCMS

OSGeo 中国中心 邮件列表

问题讨论 : 要订阅或者退订列表,请点击 订阅

发言 : 请写信给: osgeo-china@lists.osgeo.org