Somewhat related: I would like to mention that you can get at nearly anything mentioned on the "context" command line from within your document, by using \getdocumentargument and \doifdocumentargument . https://wiki.contextgarden.net/Command/getdocumentargument On the lua side, these arguments are in the “document.arguments” table, see file-job.lua for details. Anything that starts with —c: on the luatex command line as seen from the "mtx-context | run <nr>:" line can be accessed this way, it does not have to be a known option to the mtx-context script. So you could e.g. do context —idcode=whatever mydoc and then you could do \getdocumentargument{idcode} in the document source. I know you do not need that, but it may be helpful for other people doing automated typesetting runs. Best wishes, Taco
On 21 Sep 2018, at 10:48, J Huisman
wrote: Thank you, Taco, that is exactly what I need!
Jelle On Fri, Sep 21, 2018 at 10:44 AM Taco Hoekwater
wrote: On 21 Sep 2018, at 10:30, Henri Menke
wrote: On 21/09/18 20:09, J Huisman wrote:
Hi all,
I'm getting back to using ConTeXt after a couple of years, so I might be missing something obvious...
I would like to add an I.D. code to the name of my outputfile, but since this will be used in an automated environment I would like to load the ID-code from the source file.
MWE: test.tex
\starttext
\def\idcode{something}
Some text, whatever.
\stoptext
If I typeset with: context text --result=test-idcode the result is obviously "test-idcode.pdf", but I want to get a file name: "test-something.pdf" Is this possible?
Once you enter TeX, the output file has been opened. The very concept of a filesystem forbids you to change the filehandle while writing. So no, it is not possible easily.
But it can be done sneakily …
% start demo \enabledirectives[system.callbacks.permitoverloads] % previous line allows redefinition of ‘wrapup_run’
% to keep the code short, I use a direct definition of % \idcode and \ctxlua. Nicer would be to store the desired % output name in a lua variable and replace the % \ctxlua with \startluacode … \stopluacode with % a string.format inside it.
\def\idcode{something}
\ctxlua{callbacks.register('wrapup_run', function() os.execute("cp \jobname.pdf doc-\idcode.pdf") end)}
\starttext Hello from \idcode \stoptext % stop demo
Taco
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
Taco Hoekwater Elvenkind BV