关于\include命令的两个问题

2021-01-28 22:17发布

## 编译环境 操作系统 * [x] Windows 7/8/10 * [ ] macOS * [ ] Linux `若需勾选,请把[ ]改成[x]` Tex发行版 * [x] TexLive `2...

## 编译环境 操作系统 * [x] Windows 7/8/10 * [ ] macOS * [ ] Linux `若需勾选,请把[ ]改成[x]` Tex发行版 * [x] TexLive `2020` * [ ] MikTeX `版本号` * [ ] CTeX `若需勾选,请把[ ]改成[x]` ## 我的问题 总的来说,就是两个问题: 1. 为什么`\include`命令不能加后缀?根据[lshort-zh-cn](http://mirrors.ctan.org/info/lshort/chinese/lshort-zh-cn.pdf)中所给的例子: ![](https://wenda.latexstudio.net/data/attach/210128/4n5acY3H.png) 该命令应当是使用文件的路径,而对于tex文件是可以省去的,但在我这里出现的问题是,添加后缀后文件编译出现问题,而不使用后缀的话能够正常编译。 2. 为什么`\include`之后那个LastPage的label会失效呢? 我猜测可能的原因是`\include`命令是相当于这个: ``` \clearpage \input{} \clearpage ``` 然后刚好那个label贴在`\clearpage`上面,就没了,所以又有个衍生的问题,为啥label贴在`\clearpage`上面会没了呢? 求各位大佬解答,十分感谢! ## 事发流程 > 下面是详细的经过 我在一个全英文路径下,创建了两个文件,分别是: ``` %test.tex \documentclass{article} \begin{document} This is a \LaTeX \ file. The LastPage is Page \pageref{LastPage} \input{anotherfile.tex} %\include{anotherfile.tex} \label{LastPage} \end{document} ``` ``` %anotherfile.tex This is anotherfile. ``` 补充一下文件结构,是这样的: ![](https://wenda.latexstudio.net/data/attach/210128/xadtj85v.png) 用pdflatex编译两次后,我得到了满意的结果: ![](https://wenda.latexstudio.net/data/attach/210128/8abpl8cH.png) 但是,当我把第一个文件改成这样的时候: ``` %test.tex \documentclass{article} \begin{document} This is a \LaTeX \ file. The LastPage is Page \pageref{LastPage} %\input{anotherfile.tex} \include{anotherfile.tex} \label{LastPage} \end{document} ``` 编译两次,输出没了第二个文件的内容,同时LastPage变成无定义的了。 ![](https://wenda.latexstudio.net/data/attach/210128/9kfIx6nO.png) 然后,我再修改一下: ``` %test.tex \documentclass{article} \begin{document} This is a \LaTeX \ file. The LastPage is Page \pageref{LastPage} %\input{anotherfile.tex} \include{anotherfile} \label{LastPage} \end{document} ``` 多了一页,放上了第二个文件的内容,但是LastPage依然无定义: ![](https://wenda.latexstudio.net/data/attach/210128/3oktt91N.png)