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

Optionally omit the tikzpicture and document environments. #56

Merged
merged 2 commits into from
Aug 11, 2020

Conversation

mirkobunse
Copy link
Contributor

I usually export my TikzPictures two times: once as a pdf/svg, which I use for immediate inspection; and then as a TEX file.

The latter one is always meant to be embedded in a larger document, which has its own preamble. Sometimes, I also want to omit the tikzpicture environment, so that setting include_preamble=false does not suffice. Skipping the tikzpicture environment has the advantage that its options can be altered in the main document, without changing the included Tikz file.

Doing so is particularly nice when exporting Tikz code from PGFPlots.jl.

This PR provides an option to either i) save a complete TEX file that can be compiled as a standalone document; ii) omit the preamble, which is just identical to setting include_preamble=false; and iii) to print the Tikz code just as it is. The first option remains the default and the include_preamble argument is maintained for compatibility.

save(TEX("test"; limit_to=:all), tp) # the default, save a complete file
save(TEX("test"; limit_to=:picture), tp) # only wrap in a tikzpicture environment
save(TEX("test"; include_preamble=false), tp) # equivalent to the above line
save(TEX("test"; limit_to=:data), tp) # do not wrap the Tikz code, at all

For those who do not use the new limit_to argument, nothing changes.

When writing TEX files, this feature supersedes the include_preamble option, which is maintained for compatibility.
@mykelk
Copy link
Member

mykelk commented Aug 10, 2020

Looks good to me. Can you add a couple tests?

@mirkobunse
Copy link
Contributor Author

Sure, here you go :)

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.

2 participants