[texhax] Fwd: A few questions
Uwe Lueck
uwe.lueck at web.de
Mon May 9 16:30:14 CEST 2011
More on (3) (running a file) and (2) (deleting a file)
(while somebody having experience with these matters
better should have answered):
Ad (3): With LaTeX and the `hyperref' package, \href{run:...} seems to launch a binary or so.
I wonder what this has to do with \write18. I tried in vain to find documentation
about this on the web. Indeed I learnt about \href{run:...} only by the earlier posting
http://tug.org/pipermail/texhax/2010-September/015701.html
(... which, however, seems not to be helpful, just a collection of jokes.)
An example of (3) seems to be the bashful package (ctan.org/pkg/bashful)
which enables launching bash scripts, so studying this package may help.
Actually, such a script may contain rm commands, so this way you could
delete files, as desired according to (2).
The reason for asking (2) may also have been "tidying up after a TeX run".
The lintex package (ctan.org/pkg/lintex) is a tool doing this.
Caveat: I have never tried these things.
Hope it helps though -- Uwe.
-----Ursprüngliche Nachricht-----
Von: "Uwe Lueck" <uwe.lueck at web.de>
Gesendet: 09.05.2011 00:18:21
An: "Steve Revilak" <steve at srevilak.net>, "Seyed Naser Hoseini" <nhoseini at uk.ac.ir>
Betreff: Re: [texhax] Fwd: A few questions
>"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)
>
> \documentclass...
> ...
> \input{jobdefs}
> \begin{document}
> \input{\thisjob}
> \end{document}
>
>For (1), "xyz.abc" is generalized to \thisjob which is defined in
>jobdefs.tex as
>
> \newcommand{\thisjob}{xyz.abc}
>
>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
>
> \newcommand{\thisjob}
> % {xyz1.abc}
> {xyz2.abc}
> % {xyz3.abc}
> ...
> \endinput
>
>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
>
> \paramy
>
>somewhere, and Y.tex has
>
> \newcommand{\paramy}{...}
>
>somewhere ...
>
>(2) and (3) require \write18, a function of pdfTeX which is enabled
>by a command line option
>
> --shell-escape
>
>you may study the UK FAQ
>
> http://www.tex.ac.uk/cgi-bin/texfaq2html?label=spawnprog
>
>or
>
> http://www.texdev.net/tag/write18/
>
>or MiKTeX/TeX Live documentation for this feature.
>
>Hope this helps
>
> -- Uwe.
>
>_______________________________________________
>TeX FAQ: http://www.tex.ac.uk/faq
>Mailing list archives: http://tug.org/pipermail/texhax/
>More links: http://tug.org/begin.html
>
>Automated subscription management: http://tug.org/mailman/listinfo/texhax
>Human mailing list managers: postmaster at tug.org
More information about the texhax
mailing list