将序言传递给 Jupyter 笔记本中的 tikzmagic %%tikz
我将 tikzmagic
扩展与 Jupyter 笔记本一起使用,将一些 TikZ 图表嵌入到笔记本中。 (如果有更好的方法,我愿意接受替代方案。)
在一个单元格中,我创建一个 iPython 变量前言
,如下所示:
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}}'''
在后续单元格中,我尝试像这样使用该变量:
%%tikz -f svg -l calc,positioning,shapes.misc -x $preamble
但是最终生成像这样的 LaTeX 代码,
% ⋮
\usetikzlibrary{shapes.misc}
\tikzset{terminal/.style={rectangle,
\begin{document}
% ⋮
它似乎在 ␣
(
) 处终止参数。如果我使用
%%tikz -f svg -l calc,positioning,shapes.misc -x "$preamble"
It 会生成类似于 My apologies if this is the bad place to questions 的 LaTeX 代码
% ⋮
\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}
% ⋮
,但我认为 TeX 人们可能遇到过这个问题,即使错误可能是我的或在 Python 源代码中。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论