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

Allow adding arbitrary document code #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

soraxas
Copy link
Contributor

@soraxas soraxas commented Aug 17, 2023

I'm using this PR as follows:

pic.usepackage("tikz-3dplot")

pic.add_document_code(r"\tdplotsetmaincoords{70}{110}")
pic.add_document_code(r"\tdplotsetmaincoords{60}{90}")

where

\tdplotsetmaincoords{70}{110}

is not part of the preamble (which is supported currently), but it needs to be in-between

\begin{document}
...
\end{document}

Copy link
Owner

@allefeld allefeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, but I have some notes.

@@ -1117,6 +1121,7 @@ def _update(self):
# document body
codelines += [
r'\begin{document}',
"\n".join(self.document_codes),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nicer to insert the elements of the list instead of the combined string. I believe *self.document_code should do the trick.

@@ -1080,6 +1081,9 @@ def usepackage(self, name, options=None):
code += '{' + name + '}'
self.add_preamble(code)

def add_document_code(self, code):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a docstring to the function, in the style of the other docstrings.

@@ -1024,6 +1024,7 @@ def __init__(self, tempdir=None, cache=True, opt=None, **kwoptions):
super().__init__(opt=opt, **kwoptions)
# additional preamble entries
self.preamble = []
self.document_codes = []
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please insert a line comment on the line before explaining the purpose of the variable.

Also please call the variable document_code without the s.

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