TeXworkswhat's the meaning of % !TEX?

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

what's the meaning of % !TEX?

Post by yaozhao »

% !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 2024:

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

what's the meaning of % !TEX?

Post by Stefan Kottwitz »

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?

Post by yaozhao »

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: 4182
Joined: Thu Nov 01, 2012 4:08 pm

what's the meaning of % !TEX?

Post by Johannes_B »

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: 10266
Joined: Mon Mar 10, 2008 9:44 pm

what's the meaning of % !TEX?

Post by Stefan Kottwitz »

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

Code: Select all

\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
Post Reply