提问于:
浏览数:
4161
**魔法注释是指什么呢?和普通注释区别在哪里呢?具体怎么使用呢?**
[LaTeX 源文件的命名、组织与管理](https://wenda.latexstudio.net/article-5039.html "LaTeX 源文件的命名、组织与管理") 写到:
**在多文件结构的子文件中,可以使用魔法注释指定主文件,从而实现打开子文件也能编译的目的,如:**
```tex
% 其它内容 ...
% 魔法注释,指定主控文件为上一级文件夹中的“main.tex”文件
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../main.tex"
%%% End:
```
**显然,如果主控文件采用 “main.tex” 命名,在各类子文件中用魔法注释指定主控文件及路径,则可以构造一个万能的 LaTeX 撰写文件结构框架。以后,每创建一个新的项目,只需要将该框架拷贝一下就可以了。**
完全看不懂。。。。
2 回答
2
截取 texworks 说明书给你看。
### Special comment strings
Special comments, at the very beginning of the files, can be used to manage two other aspects of the compilation.
By default, TEXworks uses the “utf-8” encoding for loading and saving files, but some files could be saved in another encoding. Common ones are “latin1”, which is the dominant encoding on Windows when using western languages, and “Apple Roman” which is dominant on Mac OS.
To set a different encoding for a specific file one can put the following at the beginning of that file:
```tex
% !TeX program = <the>
```
for example:
```tex
% !TeX program = xelatex
```
Pay attention to this last instruction. You have to use the name of the programme here which should be used for the whole project, as the first encountered programme when starting typesetting is used (which is the one from the sub-document you are in). TEXworks will use that programme, even if another name appears in the main document!
When opening a document which contains a `% !TeX program` line, the specified programme will become the one to use and its name will appear in the drop down menu in the toolbar; you can, however, override this by selecting a different one from the drop down list, if you want.
In addition, you can set the spell checking language by a similar comment line:
```tex
% !TeX spellcheck = <language>
```
The language codes available on your system are listed in parentheses in Edit →Spelling next to the human-readable name of the language.
当然了,不同编辑器的名称不一样,功能和写法也各不相同。
-
非常感谢! – lerh 2019-10-08 10:28 回复
4
这个目的是在打开多文件工程中的某个子文件时,也能够直接对子文件进行编译。在编译这个子文件时,可以通过这一魔法注释找到main.tex主控文件(前题是`%%% TeX-master: "../main.tex"`中的路径要写对)。
找到主控文件main.tex后,就可以通过主控文件实现载入文档类,引入需要的宏包等操作,就像你打开了main.tex进行编译一样。
建议使用main.tex命名,主要是含义明确,当然,你写成demo.tex也没什么问题。
你的回答
请登录后回答
你的回答将会帮助更多人,请务必认真回答问题。