[texworks] Manual: 5.2 Special comment strings - % !TeX jobname = "Some Other Name"
Reinhard Kotucha
reinhard.kotucha at web.de
Sun Jul 14 02:10:55 CEST 2019
Hi Paul,
nowadays these magic lines are only understood by text editors. Long
time ago there had been magic lines which were understood by the TeX
engine in order to load the appropriate format file. But nowadays
this doesn't work anymore because we have more than one
engine.
On 2019-07-13 at 20:27:03 +1200, Paul A Norman wrote:
> Its useful for example when you are using this package
>
> \usepackage[1-9,18-24,131-136,401, 429-431]{pagesel}
There is a much better solution. Add the following lines to the
preamble of your main document:
\ifdefined\myselection
\usepackage[\myselection]{pagesel}
\fi
Now create a second document, for instance "selection-1.tex":
\newcommand\myselection{1-9,18-24,131-136,401, 429-431}
\renewcommand{\jobname}{mainfile}
\input{mainfile}
Replace "mainfile" with the actual name of your document.
The line
\renewcommand{\jobname}{mainfile}
needs some explanation. It doesn't change the name of the output file
because it has already been determined from the command line and
cannot be changed later.
However, LaTeX is using \jobname in order to assemble names of
auxiliary files (for instance \jobname.aux). Thus, the line above
allows "selection-1.tex" to steal auxiliary files created by
"mainfile.tex".
The advantages of this approach are:
* Add a few lines to the main document and never touch it again in
order to select other page ranges.
* You can create as many "selection-*.tex" files as you want
without the need to edit one and the same file again and again.
* Auxiliary files are stolen from the master document and don't
have to be created again.
* No need to change the internal behavior of TeX engines.
Regards,
Reinhard
--
------------------------------------------------------------------
Reinhard Kotucha Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover mailto:reinhard.kotucha at web.de
------------------------------------------------------------------
More information about the texworks
mailing list