I have been playing with pylatex lately, I tried to define a global style so that all pictures of my document can use this style. in this example an object named 'my_element' has a specific style. for example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.multipart,chains,arrows}
\begin{document}
\begin{tikzpicture}[my_elem/.style={rectangle split, rectangle split parts=2,
draw, rectangle split horizontal}, >=stealth, start chain]
\node[my_elem,on chain] (A) {12};
\end{tikzpicture}
\end{document}
but It kept failing, when I tried using the pylatex :
from pylatex import (Document, TikZ, TikZNode,
Command, Package,
TikZDraw, TikZCoordinate,
TikZUserPath, TikZOptions, UnsafeCommand)
# create document
doc = Document()
doc.preamble.append(Command('usetikzlibrary', 'calc,shapes.multipart,chains,arrows'))
# Here I'm having some difficulties defining the style for my_elem
mdf_style_definition = UnsafeCommand('\\my_elem',
arguments={'style': ['rectangle split']})
with doc.create(TikZ(options=TikZOptions(mdf_style_definition.dumps_as_content()))) as pic:
node_chain = TikZNode(text=str(12),
handle='A',
options=TikZOptions('my_elem',
'on chain'))
pic.append(node_chain)
doc.generate_pdf('my_solution', clean_tex=False)
Any suggestion how to define this style with pylatex?
.tex
-file?