Jonathan-LeRoux / IguanaTex

A PowerPoint add-in allowing you to insert LaTeX equations into PowerPoint presentations on Windows and Mac
http://www.jonathanleroux.org/software/iguanatex/
Other
902 stars 62 forks source link

Error messages when adding svg with 1.60.1 #33

Closed orangelynx closed 2 years ago

orangelynx commented 2 years ago

When adding an SVG with 1.60.1 in Powerpoint 2019 Prof. I first get the error "This is an imported picture, not a group. Do you want to convert it to a Microsoft Office drawing object?". Responding "yes" causes an "unknown object" error in the line Set NewShape = Sel.ShapeRange(1). Pressing "no" will cause an error in Call CommandBars.ExecuteMso("SVGEdit"). But at least in the latter case, the object still appears, it just cannot be edited again using iguanatex.

I tried debugging this myself, but I don't understand much of VBA and Powerpoint addins. I'll try to polish this report later when I find the time.

Jonathan-LeRoux commented 2 years ago

Thanks for reporting. Do you always get this error or only for a given LaTeX source? If the latter, could you please send an example of LaTeX source that triggers the issue?

orangelynx commented 2 years ago

Happens every time, even for the default latex source. Perhaps you could point me to some instructions to remove all config files, so I can start "fresh". I have a feeling it took some of the preferences from the previous version. Maybe that would help.

Great work btw., best latex integration for powerpoint out there imo.

orangelynx commented 2 years ago

Okay, I debugged this a bit more, and it appears that the problem is with the generated SVG file (attached). When editing this in a vector program (I'm using Affinity Designer), the text is outside of the canvas, which, I believe, causes Powerpoint to convert the object to "nothing" (because there's nothing actually on the canvas). This then messes up the rest.

I verified this by moving the text of the SVG onto the canvas and replacing the file before it's inserted with the AddPicture routine. Then clicking "yes" on the "not a group" dialog, causes the conversion to succeed and everything works as expected from thereon.

Question would then be why the generated svg looks so weird. I'm using texlive2022, gs 5.56.1 x64 and the latest tex2img. DVI->SVG.

samples.zip

orangelynx commented 2 years ago

I've actually had success using pdflatex + pdf->svg instead of dvi->svg. The initial SVG appears to be A4 size, but after conversion to MS Office Drawing, it looks fine.

Still it would be nice to have an automatic confirmation for the "do you want to convert?.." dialog.

Jonathan-LeRoux commented 2 years ago

I'm very puzzled by these issues. There shouldn't be any dialog before the file gets inserted, the one you are seeing is not from IguanaTex but from PowerPoint, and I don't know why you are seeing it. I'm thinking it may have more to do with your PowerPoint version than with an issue with the SVG files, but let's root the SVG file issue out.

I'm able to insert both of the svg files in the samples.zip you attached, using IguanaTex's "Insert Vector Graphics File" function, which uses the same AddDisplayShape and ConvertSVG functions where you seem to be getting issues. I also opened both of them in Inkscape and they look fine, with all the content within the canvas except maybe a tiny portion. Is one of them supposed to trigger the error? Could you try adding the .svg files using the "Insert Vector Graphics File" button? Here are the temporary files I get for the "SVG via DVI w/ dvisvgm" conversion: dvi_svg_leroux.zip. Please try to insert that SVG file with the "Insert Vector Graphics File" button, and see if there's a difference with your own files.

Conversion to svg via dvi or pdf is fairly straightforward, basically a single dvisgm call, so there's not a lot that could go wrong. gs isn't involved, and tex2img is only used for EMF. Which version of dvisvgm are you using? I'm using 2.11.1, from Texlive 2021.

One more thing that would be very helpful is for you to narrow down the piece of code causing the dialog about the imported picture.
To do so, please download the .pptm file, open it, use Alt+F11 to open the VBA editor, right-click on LatexForm (under Forms in the project pane on the left), select View Code, navigate to (say) Line 238 (If UseVector = True And VectorOutputType = "tex2img" Then) and click in the left margin to insert a breakpoint. You can then try to create a Vector display on the slide. The code will stop at Line 238. Use Shift+F8 to step over the lines of code, until you reach the dialog about the imported picture. Please note what line the dialog appeared on.
If that line is a function call, we need to drill further down (because the dialog was triggered from another line within the function we stepped over). Pick an option in the dialog box to get the code running again, it will error out, get the process to end as you did before when you were getting this issue. Then put a breakpoint at the line where the dialog appeared, remove the original breakpoint (L238), and try again to create a display. This time, instead of stepping over the line with Shift+F8, step into it with F8, then step over the subsequent lines again with Shift+F8 until you hit the dialog. You may need to repeat this until you hit the actual problematic line. Please let me know what that line is.

The only other difference I can think of is your version of PowerPoint. Not sure I can make much use of that info, but could you report what you see under File>Account>About PowerPoint? I see "Microsoft® PowerPoint® for Microsoft 365 MSO (Version 2206 Build 16.0.15330.20216) 64-bit" on my end.

Hopefully we can narrow things down.

orangelynx commented 2 years ago

Sorry for the late reply. First off my powerpoint version says: "Microsoft® PowerPoint® 2019 MSO (16.0.10388.20027) 64-bit". The Dialog I get may be just because I use an older version Regarding the two .svg files I supplied, yes, the first is "broken" and cannot be inserted, while the second works (it's the same file but I corrected it by moving the contents into the canvas using Affinity Designer). I also verified what you said about the files looking fine with inkscape, and they do, but I don't know if maybe they are more lax handling some implementation details.

The prompt just appears when this line is hit Call CommandBars.ExecuteMso("SVGEdit") (in the convertSVG function).

I also did a screencast to illustrate the issues: https://youtu.be/1VT3XLfCsXQ

Jonathan-LeRoux commented 2 years ago

Thanks for taking the time to do a detailed analysis. It does sound like this is a version issue, MS must have improved their handling of SVG. Is there anything preventing you from updating PowerPoint?

orangelynx commented 2 years ago

This issue slipped off my plate again, sorry. I still have a perpetual license and don't feel like jumping on the subscription model, that's all. In any case, it's correct, that this works as intended in newer versions, So I guess this issue can be closed, but perhaps the README could add this info as a hint for users of the older office versions.

Jonathan-LeRoux commented 2 years ago

Even on the perpetual license, you should still get updates, no? I have a perpetual license for 2019 on my Mac and still get updates (or, actually, I would get updates if I didn't have a 2009 iMac stuck at High Sierra), and SVG is supported on the version I have there. That being said, support on Mac vs Windows is probably not in sync.