larskotthoff / gnuplottex

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

No figure if file name contains space #21

Open dflvunoooooo opened 7 months ago

dflvunoooooo commented 7 months ago

If there is a space in the Latex document containing the gnuplottex code, the figure will be created but not displayed in Latex. Maybe because the created pdf and tex files from gnuplottex contain " in them.

A minimalistic example in a file named test empty.tex:

\documentclass{scrreport}

\usepackage[siunitx, subfolder]{gnuplottex}

\begin{document}

\begin{figure}
    \centering
    \begin{gnuplot}[terminal=cairolatex, terminaloptions=color]
        set key box top left
        set key width 4
        set key height 0.25
        set key spacing 1.2
        set key opaque
        set sample 1000
        set xr [-5:5]
        set yr [-1:1]
        plot sin(x) title "$\sin(x)$"
    \end{gnuplot}
    \caption{This is a simple example using the cairolatex-terminal.}
    \label{pic:cairolatex}
\end{figure}

\end{document}

Screenshot_20231203_225224

larskotthoff commented 7 months ago

Thanks for your report -- when I try to run your code I get

(./gnuplottex/test-gnuplottex-fig1.tex
! Undefined control sequence.
l.82     \definecolor
                 {tbcol}{rgb}{1,1,1}%

How exactly are you compiling this, and what's your TeX installation?

dflvunoooooo commented 7 months ago

Thank you for your quick answer. I am using texlive with texstudio and compiling with XeLatex and shell escape for gnuplottex on linux. Otherwise there is nothing special.

I don't see, where the error regarding a color is coming from.

Edit: Ah, wait a minute. Even more minimalistic:

\documentclass{scrreport}

\usepackage[siunitx, subfolder]{gnuplottex}

\begin{document}

\begin{figure}
    \centering
    \begin{gnuplot}[terminal=cairolatex]
        plot sin(x) title "$\sin(x)$"
    \end{gnuplot}
    \caption{This is a simple example using the cairolatex-terminal.}
    \label{pic:cairolatex}
\end{figure}

\end{document}
larskotthoff commented 7 months ago

Ok, it works if I include the xcolor package and exclude the siunitx option, which caused another error. Then everything works fine and the plot is produced.

Are you running this on Linux, Windows, Mac OS?

dflvunoooooo commented 7 months ago

If I add the xcolor option like this usepackage[xcolor]{gnuplottex}, it raises the error Unknown option "xcolor" for package "gnuplottex". \ProcessOptions\relax. I didn't have an error for siunitx.

I run it under linux. Here is a picture of all three created files.

Screenshot_20231204_110607

larskotthoff commented 7 months ago

Ah, ok, I needed to include a space in the file name. I can reproduce the bug.

It looks like the conversion of the figure actually works, just the check whether the file exists fails. There's multiple levels of quoting going on here and I'm not sure how to fix this. For now, I'd recommend to simply not have spaces in your file names.

And xcolor is a separate package, not an option.

dflvunoooooo commented 7 months ago

xcolor is a package and you mentioned that. I miss read that.

Yes, it is working if no spaces are used in the filename.

Edit: It is working if I rename both files with the "" in the name and remove those. So the problem seems to be, that the filename is not recognised because of the "". Do you know where they are added?

larskotthoff commented 7 months ago

The quotes are added automatically by TeX. And yes, the problem is just handling the quoting at different levels in the code.

tobiasBora commented 6 months ago

For references, I solved it in my project via this solution in my project https://github.com/leo-colisson/robust-externalize , not sure if you got the same issue: https://tex.stackexchange.com/questions/418670/avoid-quotation-marks-when-using-jobname-or-currfilename