pytikz icon indicating copy to clipboard operation
pytikz copied to clipboard

Ability to add documentclass options

Open abdullahkhalids opened this issue 1 year ago • 3 comments
trafficstars

Currently there is no way of adding documentclass properties. For example, to change the default font size.

\documentclass[11pt]{article}

Or

\documentclass[dvipsnames]{article} # an option that is passed to xcolor to enable additional colors

Should not be too difficult to add a method Picture.add_documentclass_options to do this.

abdullahkhalids avatar Nov 05 '24 00:11 abdullahkhalids

Should not be too difficult to add a method Picture.add_documentclass_options to do this.

Yes, but I don't want to make the interface more complicated than necessary.

font size: You can set the font size for the tikzpicture environment instead, there is an example in the included tutorial notebook. You can directly specify the font size-changing LaTeX code, or e.g.

pic.tikzset(font=fontsize(11))

dvipsnames: Did you try

pic.usepackage('xcolor', 'dvipsnames')

? Not sure whether it works, could lead to an error because tikz has already loaded xcolor.

So this might need a fix. Easiest probably by inserting user-generated preamble entries directly after \documentclass.

allefeld avatar Nov 05 '24 02:11 allefeld

I don't think this makes the interface more complicated. In any case, pic.usepackage('xcolor', 'dvipsnames') does not work, because as you pointed out tikz already loads xcolor.

Adding user-generated preamble entries directly after \documentclass, might degrade user experience because user might want to define stuff after tikz is loaded. It is also not backward compatible for the users of this package.

abdullahkhalids avatar Nov 09 '24 02:11 abdullahkhalids

It is also not backward compatible for the users of this package.

True. So maybe add a named parameter to usepackage, called pretikz, boolean, default False for backwards compatibility. Which would mean the same for add_preamble, and self.preamble split into pre and post.

Would you be interested to prepare a pull request?

allefeld avatar Nov 20 '24 13:11 allefeld