LaTeX forum ⇒ TeXworkswhat's the meaning of % !TEX?

Information and discussion about TeXworks, an integrated LaTeX environment for several platforms
yaozhao
Posts: 57
Joined: Sat Oct 27, 2018 10:38 pm

what's the meaning of % !TEX?

Postby yaozhao » Sat Oct 27, 2018 10:45 pm

% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode


These are the first two lines of "template article.tex". I know they are comments. Can someone explain them?

Many thanks in advance!

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net
LaTeX Beginner's Guide LaTeX Cookbook
User avatar
Stefan Kottwitz
Site Admin
Posts: 9880
Joined: Mon Mar 10, 2008 9:44 pm

what's the meaning of % !TEX?

Postby Stefan Kottwitz » Sat Oct 27, 2018 10:54 pm

Hi yaozhao,

welcome to the forum!

That's "meta data" compiler information. It's no TeX and no LaTeX instruction. From LaTeX's point of view, it's just a comment, since it starts with %. There are LaTeX editors that support compiler information in documents, provided within comments, such as here.

Here, it's information for the TeXshop editor (TS) on Mac PCs or Macbooks. The first line means, that the pdfLaTeX compiler shall be used, and the second lines determines that utf8 unicode should be used, for the TeX compiler.

Other editors (and compilers) would ignore those lines. And it's pretty default anyway.

Sometimes a template author wants to define the way the template is used/compiled, as here. Like preventing accidental use of XeLaTeX or LuaLaTeX or a non-standard encoding. These two lines say something like "use default common settings".

Stefan
LaTeX.org admin

yaozhao
Posts: 57
Joined: Sat Oct 27, 2018 10:38 pm

what's the meaning of % !TEX?

Postby yaozhao » Sun Oct 28, 2018 2:55 am

Hi Stefan,

Thank you for your reply. In the template article, I notice that some comments starting from %, while other comments starting from %%%.

Can you explain the difference?

User avatar
Johannes_B
Site Moderator
Posts: 4183
Joined: Thu Nov 01, 2012 4:08 pm

what's the meaning of % !TEX?

Postby Johannes_B » Sun Oct 28, 2018 3:07 am

There is no difference. One percent sign starts a comment.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9880
Joined: Mon Mar 10, 2008 9:44 pm

what's the meaning of % !TEX?

Postby Stefan Kottwitz » Sun Oct 28, 2018 12:48 pm

Johannes is right! Just by the way, some people use more %%%%% signs just to mark comments better visible or to highlight information in the code or "borders", such as


\frontmatter
some code
some text
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%     here the front matter ends     % 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mainmatter
\section{One}


After a single % that starts a comment, it doesn't matter. And some LaTeX editors highlight comments in a different way.

Stefan
LaTeX.org admin


Return to “TeXworks”

Who is online

Users browsing this forum: No registered users and 1 guest