[texhax] Running tex from a command line

Reinhard Kotucha reinhard.kotucha at web.de
Mon Sep 4 03:30:09 CEST 2017


On 2017-09-03 at 16:55:39 -0300, Jim Diamond wrote:

 > On Sun, Sep  3, 2017 at 15:08 (-0400), Michael Barr wrote:
 > 
 > 
 > > I have not run tex other than from a command line ever.  When I
 > > install texlive from CTAN (although I just got a disk from tug, it
 > > is useless as my computers don't have readers) it adds it to the
 > > path.  I can certainly say on the command line latex filename, but I
 > > actually have three tiny batch files.  Each one looks to see if a
 > > filename is supplied.  If it is, it sets a variable dfile = filename
 > > (no filetype).  If not, it uses dfile.  The other batch files load
 > > my editor and load the pdf reader (I use Sumatra.pdf), all using (or
 > > setting) the dfile.  This is under Windows (although it goes back to
 > > my DOS days) and cannot be implemented under any version of Linux I
 > > have ever tried since there is no way to set the dfile that doesn't
 > > go away when the batch file terminates.
 > 
 > If, in Linux (or Unix) you "source" a shell script instead of
 > executing it, variables it sets will be preserved.

Why not simply type the commands with all arguments and then fetch
them from the command history?  With <cursor-up> you can fetch any
command entered earlier and even alter it before you press the
<return> key.

The batch file approach looks convenient at a first glance but it's
not very flexible.  And on multitasking systems you start the editor
when you get up and shut it down when you go to bed.  Hence a batch
file which starts an editor isn't helpful nowadays anymore.  But of
course, it was quite helpful under MS-DOG.

Given that the editor is running all the time, a session would
look like this:

   pdflatex myfile.tex
   sumatra myfile.pdf
   <cursor-up><cursor-up><return>  %% run pdflatex again
   <cursor-up><cursor-up><return>  %% run sumatra again
   <cursor-up><cursor-up><return>  %% run pdflatex again
   <cursor-up><cursor-up><return>  %% run sumatra again
   <cursor-up><cursor-up><return>  %% run pdflatex again
   <cursor-up><cursor-up><return>  %% run sumatra again
   <cursor-up><cursor-up><return>  %% run pdflatex again
   <cursor-up><cursor-up><return>  %% run sumatra again
   
It's even more convenient than typing the name of the batch file again
and again.

On Unix, sourcing scripts is not the best approach because all
variables set within the script pollute the environment.  It's better
to put a file into each project directory containing the name of the
project.

   echo "myproject" > project.name

The scripts can then deduce the basename of the (La)TeX master file
like this:

   dfile=$(cat ./project.name)

Then $dfile expands to "myproject".  (not tested)

There is nothing, absolutely nothing, you can do under Windows which
you can't do on Unix.  Unix is always more convenient and powerful
than Windows.    

Michael, are you using Windows because your batch files don't work on
Unix?  Tell me what you need and I'll provide a much better
environment for Unix.

Regards,
  Reinhard

-- 
------------------------------------------------------------------
Reinhard Kotucha                            Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                    mailto:reinhard.kotucha at web.de
------------------------------------------------------------------


More information about the texhax mailing list