Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving PDFs now works with files not in $PWD; error messages now more verbose #2

Merged
merged 1 commit into from Oct 8, 2014

Conversation

physicsd00d
Copy link

This pull request seems to solve OP's problem in JuliaTeX/PGFPlots.jl#7
The issue was that if you say save("folderName/fileName",tp), then the .tex file will be placed in folderName, but lualatex will compile it in the present working directory. So not only is the final pdf file in the wrong place, but when save() tries to delete the intermediate tex file, it tries to delete it from pwd() but that's not where the .tex file was placed...so rm throws an error (which should really only be a warning) which got caught and treated as fatal.

The solution was to parse out the foldername, instruct lualatex to place the pdf aux and log files in the folderName, and tell rm to delete the intermediate files from within folderName.

Also, I had trouble getting PGFPlots to work because the pdf save function in this package was failing but not telling me why in any meaningful way. My specific problem was that my latex libraries were from 2012, which is too old for the Julia PGFPlots package. So I figured it would be nice if the error messages weren't caught and replaced with vague messages and instead have the errors just be thrown themselves. That's part of what I did here. In addition to making the error messages more meaningful, I also specifically catch the error that gave me so much grief. Namely, success(command) returns true or false based on whether command succeeded or failed; so if lualatex tried but failed to generate the pdf file, that was not treated as an error and wasn't caught at all until rm() tried to delete files that had never been created. Now, there is a check to ensure that the pdf files are generated successfully.

This is my first github pull request ever. Let me know if the level of detail in this comment was too much or any other tips to help me improve my github etiquette.

Cheers!

mykelk added a commit that referenced this pull request Oct 8, 2014
Saving PDFs now works with files not in $PWD; error messages now more verbose
@mykelk mykelk merged commit 65f1877 into JuliaTeX:master Oct 8, 2014
@mykelk
Copy link
Member

mykelk commented Oct 8, 2014

Thanks for this! It might be better to use basename() and dirname() in the implementation to pull out the filename and directory name.

@physicsd00d
Copy link
Author

No problem! I hope it works for the OP.

I didn't know those methods existed. I'll keep that in mind for the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants