Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

Set pdflatex output filename from within document

3.854 Aufrufe
Direkt zur ersten ungelesenen Nachricht

jiho

ungelesen,
06.10.2009, 17:45:5806.10.09
an
Hello,

I have an article (foo.tex) within which an if condition allows to
switch between a "press" version and a "web" version. I would like to
set the output name within the document e.g.
\ifpress
# load packages specific to press version
# set output to foo-press.pdf
\else
# load packages specific to web version
# set output to foo-web.pdf
\fi
I know I could do it with
pdflatex --jobname=foo-press foo.tex
but I usually run the compilation from within my editor, not from the
command line. I tried
\ifpress
\def\jobname{foo-press}
\else
\def\jobname{foo-web}
\fi
but, while this produces foo-press.aux, etc. I still end up with
foo.pdf and not foo-press.pdf.

Is it even possible to do what I want?

Thanks in advance,
JiHO
---
http://maururu.net

Joseph Wright

ungelesen,
07.10.2009, 02:07:0907.10.09
an

I'm afraid I think the answer is "no" (this question comes up
occasionally). The output name itself is not really alterable from
within TeX. When you redefine \jobname, that affects what happens if
\jobname is used somewhere else, but TeX uses the internal "thing" that
\jobname normally points at, and not the *current* meaning of \jobname.
--
Joseph Wright

jiho

ungelesen,
07.10.2009, 04:50:1807.10.09
an
On Oct 7, 8:07 am, Joseph Wright <joseph.wri...@morningstar2.co.uk>
wrote:

> I'm afraid I think the answer is "no" (this question comes up
> occasionally).  The output name itself is not really alterable from
> within TeX. When you redefine \jobname, that affects what happens if
> \jobname is used somewhere else, but TeX uses the internal "thing" that
> \jobname normally points at, and not the *current* meaning of \jobname.

OK too bad then. I googled around quite a bit for an answer before
posting here. I guess I used the wrong keywords since I did not came
up with something.

Thanks,

JiHO
---
http://maururu.net

zugzwang

ungelesen,
07.10.2009, 05:19:4407.10.09
an
On Oct 6, 11:07 pm, Joseph Wright <joseph.wri...@morningstar2.co.uk>
wrote:

I can give you a conceptual approach, but I suspect that implementing
it may not be painless. You want to conditionally compile the
document from within your editor (rather than from a command line).
Apparently, the output name itself is not really alterable from within
TeX. Therefore, you need to _transfer_ setting the condition to an
_external_ file that is accessible by _both_ your tex document _and_
your "internal" compile process.

I have no experience doing any of this, so my suggestion below is very
crude. With experience, you may be able to polish it. With my WinXP
+Miktex setup, I would:

1. Create Switch.tex that defines and sets a variable, e.g. \def\foo-
web{1}.

2. Have Main_file.tex read Switch.tex and (somehow) use it to load
the appropriate packages.

3. Create a stand-alone executable (e.g. using c or java) that reads
Switch.tex and sets an operating system environment variable based on
whether foo-web is set to 1 or 0.

4. Create my_compile.bat that first executes stand-alone.c (et al)
and then uses the just-formatted environment variable to determine the
compile process.

5. Configure your latex editor to have either a toolbar button or
menu item that calls my_compile.bat.

A shortcoming to this approach is that the tex file that
my_compile.bat is using as input (presumably) has a fixed name, while
typical behavior for a latex editor is to dynamically use whichever
input is "current" to determine which file is being compiled and what
the output file name will be.

If the above approach (including step 5) is do-able and you can live
with the shortcoming, your done. A kludgy enhancement is to also set
the input and output filenames in Switch.tex.

If your looking for a more dynamic approach that inputs <current-
name>.tex and outputs <current-name>_press.pdf or <current-
name>_web.pdf, then my_compile.bat somehow needs access to which file-
name the latex editor considers current. Without having used either
Emacs or TexnicCenter, I would speculate (for example) that this
information is available in the former but not the latter.

I also suspect that the _entire_ approach can be significantly
polished (with stand-alone.c eliminated) if using _any_ "infinitely
configurable" editor (e.g. Emacs + Lisp).

T3X

ungelesen,
07.10.2009, 07:35:1507.10.09
an

If you are using MiKTeX, you can change the jobname on the first line
with:

%& -jobname=foo-web.tex

This doesn't work with TeX Live, though.

There are also other kludges possible, like using an auxiliary file
foo-web.tex containing \input{foo-print}, compiling from within the
document using shell-escape, etc. But there is no "proper" solution as
of yet. It would require changes at the engine level.

Cheers,

Tomek

Alain Ketterlin

ungelesen,
07.10.2009, 07:53:0007.10.09
an
jiho <jo.ir...@gmail.com> writes:

> I know I could do it with
> pdflatex --jobname=foo-press foo.tex
> but I usually run the compilation from within my editor, not from the
> command line.

Can't you just create one or more wrapper scripts, and call these
instead of pdflatex?

-- Alain.

0 neue Nachrichten