0

I'm trying to compile a LaTeX project with a rather complex document structure and obviously run into issues with openout_any. I've been reasoning that it's a bad idea to change that variable for LaTeX globally. On Linux I could run openout_any=a pdflatex mydocument.tex to apply it to that run only, however I'm actually using Windows (7), where that as far as I'm aware won't work. I already checked pdflatex -help and found no mention of a flag that would do any changes to openout_any for the run. Can anyone tell me a way to actually accomplish that short-time change?

Egor Hans
  • 249
  • 1
    you haven't said what system you are using, in texlive you could set openout_any in a texmf.cnf file (I have no idea about miktex) but it must surely be simpler for any specific document to write into the current directory and then move any files at the end, why do you need to write outside the current directory? – David Carlisle Apr 21 '18 at 14:40
  • MiKTeX seems to require MIKTEX_ALLOWUNSAFEOUTPUTFILES rather than openout_any according to this answer so you do need to specify whether you're using MiKTeX or TeX Live on Windows. – Nicola Talbot Apr 21 '18 at 20:31
  • I'm using downloaded code from GitHub in my project. I basically understand how it works, but would prefer not to tinker with the structure just in case. As of the system, I do use TeX Live and already found out that openout_any should work. I also found out about the texmf.cnf, but would prefer not to apply security-relevant changes to the entire distribution. Also, I tried changing it for now as a workaround, and PDFLaTeX just straight up ignores the change for some reason. – Egor Hans Apr 23 '18 at 10:57
  • This is not really a TeX question, rather it's a Windows question, lookup "Windows batch set environment variable" (assuming you're using batch (command prompt) instead of Powershell) I think the answer is set openout_any=a followed by (new line) pdflatex <file...>. – user202729 Dec 10 '21 at 13:10
  • Side note: The question lost relevance to me personally, as I ended up not using that complex project. I'm not sure how much relevance this question has for others. – Egor Hans Jan 12 '22 at 08:38

1 Answers1

1

I came across this question because I wanted to know how to set openout_any from command line. So I describe my solution and an alternative way to achieve the desired result, here. So your question is part of my answer:

openout_any=a pdflatex ../../../source/latex/file.ins

can be used inside the doc/latex/file folder together with the following content in docstrip.cfg:

\BaseDirectory{../../..}
\UseTDS

At least with pdfTeX 3.141592653-2.6-1.40.24 this can be changed to the following command:

pdflatex --cnf-line=openout_any=a file.ins

A better solution would be to use point $TEXMFOUTPUT to a common a directory which contains all generated files. It can also be given on as parameter to the parameter --cnf-line and avoids changing openout_any at all. A complete shell script could be

#!/bin/sh -x
TEXMFOUTPUT="$(realpath ../../..)" 
cat >docstrip.cfg << EOF
\BaseDirectory{$TEXMFOUTPUT}
\UseTDS
EOF
pdflatex --cnf-line=TEXMFOUTPUT="${TEXMFOUTPUT}" file.ins 

For batch scripts this would be similar.

Keinstein
  • 306