3

I am using the tikzmagic extension with a Jupyter notebook to embed some TikZ diagrams into the notebook. (I am open to alternatives if there is a better way.)

In one cell, I create an iPython variable preamble like so:

preamble=r'''\tikzset{terminal/.style={
    rectangle, minimum size=6mm, rounded corners=3mm, very thick, draw=black!50,
    top color=white, bottom color=black!20, font=\ttfamily}}'''

In a subsequent cell, I try to use that variable like this:

%%tikz -f svg -l calc,positioning,shapes.misc -x $preamble

But that ends up generating LaTeX code like

% ⋮
\usetikzlibrary{shapes.misc}
\tikzset{terminal/.style={rectangle,
\begin{document}
% ⋮

It seems to terminate the argument at the (<space>). If I use

%%tikz -f svg -l calc,positioning,shapes.misc -x "$preamble"

It generates LaTeX code like

% ⋮
\usetikzlibrary{shapes.misc}
"\tikzset{terminal/.style={rectangle, minimum size=6mm, rounded corners=3mm, very thick, draw=black!50,
    top color=white, bottom color=black!20, font=\ttfamily}}"
\begin{document}
% ⋮

My apologies if this is the wrong place to ask, but I thought TeX people might have encountered this problem, even though the fault is probably mine or in the Python source.

0

Browse other questions tagged or ask your own question.