[texhax] Fwd: A few questions

Uwe Lueck uwe.lueck at web.de
Mon May 9 00:18:21 CEST 2011

"Steve Revilak" <steve at srevilak.net> answered 08.05.2011 16:29:39
to "Seyed Naser Hoseini" <nhoseini at uk.ac.ir>:
>> 1) Suppose I have a file, named xyz.abc. In my latex source file A.tex, with
>> the help of some macro, I would like to get the file name xyz.abc. For
>> example, I like to read the contents of the file xyz.abc. Obviously if the
>> name xyz.abc was fixed this wouldn't be neccessary. So I am changing the
>> file name xyz.abc and I want A.tex to do the job without me having to change
>> anything in A.tex.
>> 2) In the source file A.tex, I would like to delete a file named, say B.tex,
>> that is in the same or different directory.
>> 3) In the source file A.tex, I would like to run a file named, say B.pdf,
>> that is in the same or different directory.
>> 4) Can I pass the values of some variables from one source file to another,
>> via some arguments?
> In (3), I don't understand what you mean by "I would like to run a
> file named, say B.pdf". But, I can offer a suggestion for (1), and (4).
> Here are the contents of A.tex
> ------------------------------------------------------------------
> \documentclass{article}
> \begin{document}
> This is the main document
> Below are the contents of \myotherfile.
> \input{\myotherfile}
> \end{document}
> ------------------------------------------------------------------
> Here are the contents of xyz.abc:
> ------------------------------------------------------------------
> This is the secondary file.
> \LaTeX{} opened it as \myotherfile.
> ------------------------------------------------------------------
> And here is a command line that runs latex on A.tex, giving xyz.abc as
> the definition for \myotherfile.
> pdflatex '\newcommand{\myotherfile}{xyz.abc}\input{A.tex}'
> I believe this was the basic goal of (1). xyz.abc has access to the
> definition for \myotherfile, so this is also an example of (4).

As to (1) and (4), Steve suggests (I understand) to use the
command line for passing parameters.
Just as another idea that I have used is
providing job parameters in a separate .tex file, say,
jobdefs.tex that is input by that A.tex.
So you do not change A.tex to adjust job-dependent settings,
you just adjust jobdefs.tex. I.e., A.tex is something like
(like Steve, always assuming LaTeX)


For (1), "xyz.abc" is generalized to \thisjob which is defined in
jobdefs.tex as


or so ...

Actually, for the case where you have a fixed little set of "target files" like xyz.abc,
in jobdefs.tex you could have something like

    %  {xyz1.abc}
    %  {xyz3.abc}

I.e., jobdefs.tex contains a list of ("embraced") target files,
one each line, and all but one are "commented out".
My editor makes choosing the only effective line easy.

For (4), I don't know of a standard for passing "arguments",
rather you can pass "parameters":  In order to  pass a  parameter
from Y.tex to Z.tex, Z.tex may contain


somewhere, and Y.tex has


somewhere ...

(2) and (3) require \write18, a function of pdfTeX which is enabled
by a command line option

you may study the UK FAQ




or MiKTeX/TeX Live documentation for this feature.

Hope this helps

    -- Uwe.

More information about the texhax mailing list