Don-Chris / Plot2LaTeX

Fork of Plot2LaTex.m by Jan de Jong
GNU Affero General Public License v3.0
4 stars 1 forks source link

pdf and pdf_latex save functionality for matlab 2023a? #5

Open unaschneck opened 9 months ago

unaschneck commented 9 months ago

Thanks for this great tool!

I keep getting the following warning and no pdfs or pdf_latex files are generated. I have changed the inkscape directory to where it sits on my computer, which allowed the .svg files to save, but I can't get the other two file formats

Warning: No .pdf or .pdf_tex file produced, please check your Inkscape installation and specify installation directory correctly. 
> In Plot2LaTeX (line 372)

I am running on MATLAB 2023a

Don-Chris commented 9 months ago

Hi unaschneck,

Thank you for your feedback and for using this tool!

Regarding the warning message and the inability to generate PDF or PDF_LaTeX files despite changing the Inkscape directory, I regret to inform you that the feature you are trying to use is currently not functioning as expected.

To address this issue, you can follow these steps as a workaround:

  1. Add Inkscape Path to System Environment Variables: Please add the path to the Inkscape executable to your system's PATH environment variable. This will ensure that MATLAB can locate Inkscape correctly. You can refer to this guide for instructions on how to add a directory to your system's PATH.
  2. Set the Parameter "DIR_INKSCAPE" to "inkscape": In your MATLAB script, explicitly set the parameter "DIR_INKSCAPE" to "inkscape" to specify the installation directory of Inkscape. This may help MATLAB recognize the correct path to Inkscape. DIR_INKSCAPE = 'inkscape';
  3. Consider the Alternative Approach: As an alternative solution, you can set the option "OnlySVG" to true in your MATLAB script. This will generate only the SVG file. Subsequently, you can include the SVG file directly in your LaTeX document using the "SVG" package and the \importsvg{} command.

In your LaTeX document:

\usepackage{svg}
...
\importsvg{path/to/your/svg/file}

I'm working to resolve this issue and will keep you updated on any developments. If you have any further questions or need assistance, please don't hesitate to reach out.

Best regards!

Don-Chris commented 8 months ago

@unaschneck I looked further into your problem and I would like you to test something on your machine:

Run the following command in matlab and please replace {INKSCAPEPATH} with your inkscape path e.g. C:\Program Files\Inkscape\bin\inkscape.exe:

system('"{INKSCAPEPATH}" --version')

In my case, the following text is shown:

Inkscape 1.1.2 (b8e25be833, 2022-02-05)

ans = 

    0

If you get a different result, please provide the used operating system.

unaschneck commented 8 months ago

Sorry for the delay, here is what I get:


Inkscape 1.3.2 (091e20e, 2023-11-25, custom)

ans =

     0
Don-Chris commented 8 months ago

@unaschneck This seems like a very weird bug since your Inkscape command worked. Could you please put a breakpoint at Line 480 in Plot2LaTeX.m and try again. After that, please tell me, what the string of variable cmdout is. cmdout is the console output of the inkscape evaluation in line 477.

Line 477: [~, cmdout] = system(cmdtext); Line 480: if exist([filename, '.pdf'], 'file') ~= 2 || exist([filename, '.pdf_tex'], 'file') ~= 2

Also, please check, if the newest version (2.4) fixes your issue.