zoukankan      html  css  js  c++  java
  • 大型文档源文件拆分编辑编译\include{filename}

    大型文档,如果把所有的文字都录入在同一个.tex文件中,那个文件的体积是不可估量的,文件的结构式混乱不堪的,文字的定位也是令人头疼的。幸亏latex提供了结构化的处理命令---include。
    命令\include{filename}(filename不包含后缀名.tex)能够把那个文件filename的内容编译时插入到当前位置。

    要点:

    • 在主文档(例如 main.tex)中书写导言区,包含哪些宏包,对整个文档的风格、字体、行距、引用进行定义。
    • 在主文档的正文区使用命令 \include{filename}来包含子文档。
    • 在子文档里直接以\chapter{} 、\section{}开头,不需要导言区、标题、作者等信息了。
    • 可以再任何一个文件中引用其他文件的标签。
    请看下面的实例:
    • main.tex
    1. % !TeX:pdflatex,pdfTeXify
    2. % 测试大型文档拆分多个源文件进行编译。
    3. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    4. %% main.tex
    5. %% 只在 main.tex 当中建立导言区,并include子文件
    6. %% 子文件不需要导言区、begin{document},只需
    7. %% \chapter{}、\section{}等等。
    8. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    9. \documentclass[UTF8]{ctexbook}
    10. \usepackage{graphicx}
    11. \usepackage[CJKbookmarks=true,colorlinks,linkcolor=black,anchorcolor=blue,citecolor=green]{hyperref}
    12. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    13. %%%%%%%%%% Text body %%%%%%%%%%
    14. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    15. \begin{document}
    16. \youyuan
    17. \sffamily
    18. \title{源文件拆分编译}
    19. \author{Lin\TeX9527}
    20. \date{2014--09--04}
    21. \maketitle
    22. \tableofcontents
    23. \include{file1}
    24. \include{file2}
    25. \end{document}

    • file1.tex
    1. \chapter{水果}
    2. \section{葡萄}
    3. 葡萄,紫黑紫黑的,甜,真甜。
    4. \section{西瓜}
    5. 西瓜,圆又圆。
    6. \section{狗狗和西瓜}
    7. 见第\pageref{fig:dog}页的图\ref{fig:dog}。

    • file2.tex
    1. \chapter{动物}
    2. \section{人}
    3. 人,人心隔肚皮。
    4. \section{狗}
    5. 狗是人类的好朋友。
    6. \begin{figure}[htbp]
    7. \centering
    8. % Requires \usepackage{graphicx}
    9. \includegraphics[scale=0.5]{dog}\\
    10. \caption{两只很萌的哈士奇}\label{fig:dog}
    11. \end{figure}

    这时整个工程的结构文件:


    可以再任何一个源文件中点击编译按钮。






  • 相关阅读:
    Latex 双栏模式下表格太长怎么办?
    HTTP状态码大全
    You can't specify target table 'Person' for update in FROM clause
    mysql实战笔记
    「2020年中总结」这半年我又做了哪些副业?
    Mysql导入数据报错SQL Error(1153)
    PS制作电子签名
    Windows Server 2012 R2安装mssql
    Windows Server 2012 R2安装.net3.5
    Linux常用命令
  • 原文地址:https://www.cnblogs.com/LinTeX9527/p/3994804.html
Copyright © 2011-2022 走看看