每次我尝试在数学环境中剪辑 Tikzpicture 时(即是,,\begin{equation}\end{equation}
或[]
)$$
我收到以下错误
包 tikz 错误:剪切路径命令不允许使用额外选项。
以下是具体代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{parskip}
\usepackage{tikz}
\usepackage{tikz-cd}
\usepackage{float}
\usepackage{makeidx}
\usepackage{enumerate}
\usepackage{bm}
\usepackage{fancyhdr}
\usepackage[top=2cm,bottom=2cm]{geometry}
\usepackage{framed}
\usepackage{mdframed}
\usepackage{graphicx}
\usepackage{pict2e}
\usetikzlibrary{knots,intersections,decorations.pathreplacing,hobby,arrows,patterns}
\tikzset{every path/.style={black,thick}, every node/.style={transform shape, knot crossing, inner sep=2.5pt}}
\begin{document}
\[ \epsilon\left(\begin{tikzpicture}[scale=0.4]
\clip (-1.5,-0.7)--(-1.5,0.7)--(1.5,0.7)--(1.5,-0.7)--(-1.5,-0.7)--cycle;
\begin{scope}[yshift=-0.3cm]
\draw[->,thin] (-1,-1)--(1,1);
\draw[ultra thick,double distance=0.4pt,double=black,white] (-1,1)--(1,-1);
\draw[->,thin] (-1,1)--(1,-1);
\end{scope}
\end{tikzpicture}\right) \]
\end{document}
我看见绘制括号多项式的规则并得到了一些关于如何修复我的代码的想法。更具体地说,按照@egreg的回答,为图片定义宏。但是,我有很多在数学环境中绘制的结图,而且大多数都是以不同的比例缩放的。@GuM 给出的答案看起来很有用,但我不知道如何实现它。
tl;dr:考虑到大多数图片的缩放比例不同,剪辑被数学环境包围的 tikzpictures 的最佳方法是什么?
编辑:我假设它与下面这行代码有关
\tikzset{every path/.style={black,thick}, every node/.style={transform shape, knot crossing, inner sep=2.5pt}}
编辑2:当我尝试\tikzset{every path/.style={}}
在剪辑之前和\tikzset{every path={black,thick}}
剪辑之后添加时,它确实会消除错误。但是,它最终无法正确绘制所有图表。例如,
\begin{align*}
\left\langle\begin{tikzpicture}[scale=0.005]
\tikzset{every path/.style={}}
\clip (0,0)--(150,0)--(150,100)--(0,100);
\tikzset{every path={black,thick}}
\begin{scope}[yshift=-70cm]
\draw[thin] (98.5,132) .. controls (48.07,199.48) and (-22.7,112.44) .. (13.82,70.28) .. controls (26.55,55.59) and (52.31,46.35) .. (96.5,51) ;
\draw[thin] (44.5,39) .. controls (78.5,-45) and (130.5,45) .. (114.5,102) ;
\draw[thin] (127.5,58) .. controls (195.69,97.4) and (107.74,133.35) .. (64.59,109.76) .. controls (50.78,102.21) and (41.56,88.57) .. (43.5,67) ;
\end{scope}%
\end{tikzpicture}\right\rangle
\end{align*}
删除了一些曲线。不知道为什么。
答案1
不确定该错误是否真的有帮助,或者是否应该通过应用以下补丁将其更改为警告?
\usepackage{xpatch}
\makeatletter
\xpatchcmd\tikz@finish
{\tikzerror{Extra options not allowed for clipping path command.}}
{\PackageWarning{tikz}{Extra options not allowed for clipping path command.}}
{}{\fail}
\makeatother
在我看来,在剪辑模式下丢弃未使用的内容\tikz@options
不会导致严重问题。
答案2
我完全忘记回答我的问题了。@egreg 的评论修复了这个错误。
我首先创建了一个新命令来使用:
\newcommand{\knotsinmath}[1]{%
\tikzset{every path/.style={}}
\begin{tikzpicture}[baseline=-\dimexpr\fontdimen22\textfont2\relax]
#1
\end{tikzpicture}%
}
然后,一切就都好了。我当时遇到的问题恰好与剪辑本身有关,但这也使错误消失了。
\begin{align*}
\left\langle\knotsinmath{\begin{scope}[scale=0.005,yshift=-70cm]
\clip (0,0)--(160,0)--(160,160)--(0,160)--cycle;
\draw[thin] (98.5,132) .. controls (48.07,199.48) and (-22.7,112.44) .. (13.82,70.28) .. controls (26.55,55.59) and (52.31,46.35) .. (96.5,51) ;
\draw[thin] (44.5,39) .. controls (78.5,-45) and (130.5,45) .. (114.5,102) ;
\draw[thin] (127.5,58) .. controls (195.69,97.4) and (107.74,133.35) .. (64.59,109.76) .. controls (50.78,102.21) and (41.56,88.57) .. (43.5,67) ;
\end{scope}}\right\rangle
\end{align*}