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

Use only custom Preamble #179

Closed
judober opened this issue Oct 8, 2019 · 14 comments
Closed

Use only custom Preamble #179

judober opened this issue Oct 8, 2019 · 14 comments

Comments

@judober
Copy link

judober commented Oct 8, 2019

I was wondering if the option exists to include only the custom preamble and not the predefined. I would like to include my own options and not the predefined.

@KristofferC
Copy link
Owner

KristofferC commented Oct 8, 2019

I think you should be able to pass use_default_preamble = false and preamble = ["\\usepackage{foo}", ...] to the TikzDocument constructor.

@judober
Copy link
Author

judober commented Oct 8, 2019

Yes, this disables the predefined preamble but the PGFPlotsX.CUSTOM_PREAMBLE is not used as well.

@KristofferC
Copy link
Owner

I guess you could pass preamble = PGFPlotsX.CUSTOM_PREAMBLE. But it is perhaps a bit odd that use_default_preamble = false also removes the custom additions. @tpapp, opinions?

@judober
Copy link
Author

judober commented Oct 8, 2019

Sorry, I didn't read your comment clearly. I used the option include_preamble=false for pgfsave.
I will try your suggestion.

@tpapp
Copy link
Collaborator

tpapp commented Oct 8, 2019

@KristofferC: are you sure it does? My reading of the code is that when !use_default_preamble, the only thing that happens is that the default preamble is not prepended. The preamble field is still used.

The full preamble is built using four global sources and then the preamble in a TikzDocument. This is a bit baroque and I am not sure if all of it is used, but at the same time it is innocuous so I would just leave it as is.

@KristofferC
Copy link
Owner

KristofferC commented Oct 8, 2019

But your second link is for the function called _default_preamble which you describe as "building the full preamble" is exactly what is being disabled if one uses !use_default_preamble (the first link)?

@judober
Copy link
Author

judober commented Oct 8, 2019

Ok, I tried the following:

Pre = "My preamble"
push!(PGFPlotsX.CUSTOM_PREAMBLE, Pre)
td = TikzDocument(; use_default_preamble = false)
push!(td, ax) #ax is the axis object
pgfsave("name.tex", td)

The result is the name.tex file which still includes

\RequirePackage{luatex85}
\documentclass[tikz]{standalone}

before \begin{document} but without My preamble

@KristofferC
Copy link
Owner

For now:

td = TikzDocument(; use_default_preamble = false, preamble = PGFPlotsX.CUSTOM_PREAMBLE)

@tpapp
Copy link
Collaborator

tpapp commented Oct 8, 2019

Yes: when !use_default_preamble, the only preamble is that in the preamble slot. Like in your example above.

I agree that the naming of these functions is a bit misleading. use_default_preamble toggles not only DEFAULT_PREAMBLE, but all four global sources (in a sense, the default preamble build process).

We could introduce a flag for toggling CUSTOM_PREAMBLE separately, which would toggle CUSTOM_PREAMBLE_PATH and PGFPLOTSX_PREAMBLE_PATH too.

@judober
Copy link
Author

judober commented Oct 8, 2019

Ok, now I'm doing:

td = TikzDocument(; use_default_preamble = false, preamble = [Pre])

which is almost what I want except for

\RequirePackage{luatex85}
\documentclass[tikz]{standalone}

at the beginning of the document. Can I disable them as well?

@tpapp
Copy link
Collaborator

tpapp commented Oct 8, 2019

It looks like you don't want to save a document, just standalone TikZ code. I wonder what your use case is, and whether you would be better served with

open("some_path.tex", "w") do io
    println(io, "some preamble I need")
    print_tex(io, td)
end

or something similar wrapped in a function. Also look at saving with a .tikz extension.

@judober
Copy link
Author

judober commented Oct 8, 2019

Well actually you are right, this is probably the easiest solution. I somehow thought that using build in methods would be beneficial.

My usecase:

  • I want to specify magical comments in texstudio at the beginning of the file (included in Pre)
  • I also want to use standalone and my custom.sty file so that I can change the settings for my figures globally (also in Pre with \usepackage{custom))

What I did in the end:

open("document.tex", "w") do io
    println(io, Pre)
    println(io, "\\begin{document}")
    println(io, "\\begin{tikzpicture}")
    print_tex(io, ax)
    println(io, "\\end{tikzpicture}")
    println(io, "\\end{document}")
end

And thank you very much for the help!

@CiaranOMara
Copy link
Contributor

\RequirePackage{luatex85}
\documentclass[tikz]{standalone}

at the beginning of the document. Can I disable them as well?

Executing the following removes the \RequirePackage{luatex85} from the output.

Base.eval(PGFPlotsX, :(_OLD_LUALATEX = true))

It seems that \RequirePackage{luatex85} stopped being a requirement for the newer LaTeX - not sure when.

@judober
Copy link
Author

judober commented Oct 12, 2023

I think this one can be closed. Thanks again!

@judober judober closed this as completed Oct 12, 2023
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

No branches or pull requests

4 participants