larskotthoff / gnuplottex

Gnuplot graphs in LaTeX. See http://www.ctan.org/pkg/gnuplottex
3 stars 1 forks source link

Missing support for '-output-directory' #16

Open michael-o opened 4 years ago

michael-o commented 4 years ago

Using TeX Live 2019 and 2020. As soon as I pass -output-directory=../build or anything else which is not . to xelatex this package does not work for the follwing reason: \immediate\openout\verbatim@out #1% takes the out dir internally into account when doing open():

49775: open("../build/./index-gnuplottex-fig1.gnuplot",O_WRONLY|O_CREAT|O_TRUNC,0666) = 9 (0x9)
49775: write(1,"\n",1)               = 1 (0x1)
49775: write(1,"Opening gnuplot stream ./index-gnuplottex-fig1.gnuplot",54) = 54 (0x36)
49775: fstat(9,{ mode=-rw-r--r-- ,inode=6994442,size=0,blksize=32768 }) = 0 (0x0)
49775: write(9,"set terminal epslatex\nset output './index-gnuplottex-fig1.tex'\n    plot tan(x)\n",79) = 79 (0x4f)
49775: close(9)                  = 0 (0x0)

but the code does not know that and creates an invalid gnuplot file as well as an invalid gnuplot call:

Package gnuplottex Warning: Gnuplot execution produced errors:
line 0: Cannot open script file './index-gnuplottex-fig1.gnuplot'

I don't know how this can reasonably be solved, but we started to patch commands in a halfbreed fashion to get this work.

Do you see way to support this? Maybe through: \begin{gnuplot}[outdir=../build]. This would only apply to \write18 since even tests spill my src/ directory.

Some references:

michael-o commented 4 years ago

The hack we applied is:

\let\oldsubfolder\subfolder
\def\subfolder{../build}
\expandafter\patchcmd\csname\string\gnuplot\endcsname
  {\subfolder}{\oldsubfolder}{}{}

and see:

Opening gnuplot stream ./index-gnuplottex-fig1.gnuplot
(../build/../build/index-gnuplottex-fig1.tex)))

AED: lastpage setting LastPage
[1] (./index.gnuploterrors) (../build/index.aux) )
Output written on ../build/index.pdf (1 page).
Transcript written on ../build/index.log.

$ cat ../build/index-gnuplottex-fig1.gnuplot
set terminal epslatex
set output '../build/index-gnuplottex-fig1.tex'
    plot tan(x)
``´
larskotthoff commented 4 years ago

Is this xelatex specific or does it happen with pdflatex as well? And what operating system are you on?

michael-o commented 4 years ago

Is this xelatex specific or does it happen with pdflatex as well? And what operating system are you on?

I haven't tried pdflatex because we use the Unicode features of xelatex as well as TrueType font support for corporate layouts. An important note is that xelatex does not perform a chdir or similar. I am running:

$ xelatex -version
XeTeX 3.14159265-2.6-0.999992 (TeX Live 2020)
kpathsea version 6.3.2
Copyright 2020 SIL International, Jonathan Kew and Khaled Hosny.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the XeTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the XeTeX source.
Primary author of XeTeX: Jonathan Kew.
Compiled with ICU version 65.1; using 65.1
Compiled with zlib version 1.2.11; using 1.2.11
Compiled with FreeType2 version 2.10.1; using 2.10.1
Compiled with Graphite2 version 1.3.13; using 1.3.13
Compiled with HarfBuzz version 2.6.4; using 2.6.4
Compiled with libpng version 1.6.37; using 1.6.37
Compiled with poppler version 0.68.0
Compiled with fontconfig version 2.12.6; using 2.13.92

on FreeBSD 12.1-RELEASE-p6

I can provide the entire output of truss including all forked processes:

.../documents/fbf8362b-56ff-4b7d-a15b-c4275e2ce40d/src
$ truss -s 256 -o out -fa xelatex -shell-escape -output-directory=../build index

PS: pdflatex fails in midair due to missing font encoding for cyrillic. pdflatex is not an option.

larskotthoff commented 4 years ago

Thanks -- I'll try to have a look at this, but it doesn't look like solving this would be easy.

michael-o commented 4 years ago

Thanks -- I'll try to have a look at this, but it doesn't look like solving this would be easy.

I guess so. If not solvable, it should be at least mentioned in the documentation. I think, if you decouple the subdir from the outdir params this could work. It should also apply to the tempfile and errors file.

michael-o commented 2 years ago

@larskotthoff Did you get a chance to look at this?

larskotthoff commented 2 years ago

Not yet, unfortunately :(