Every time I try to clip a Tikzpicture within math environments (id est, \begin{equation}\end{equation}, [] or $$) I get the following error
Package tikz Error: Extra options not allowed for clipping path command.
Here is the exact code:
\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}
I saw Drawing the rules for the bracket polynomial and got some ideas on how to fix my code. More specifically, following @egreg's answer by defining macros for the picture. However, I have a lot of knot diagrams drawn in mathematical environments, and most are scaled differently. The answer given by @GuM looked useful, but I did not understand how to implement it.
tl;dr: what is the best method to clip tikzpictures that are surrounded by mathematical environments, given that most are scaled differently?
edit: I am assuming it has something to do with the following line of code I have
\tikzset{every path/.style={black,thick}, every node/.style={transform shape, knot crossing, inner sep=2.5pt}}
edit2: When I try adding \tikzset{every path/.style={}} before the clip, and \tikzset{every path={black,thick}} after the clip, it does remove the error. However, it does not end up drawing all diagrams properly. For instance,
\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*}
removes some curves. Not sure why.
\documentclass{...}and ends with\end{document})? – muzimuzhi Z Jan 09 '21 at 14:13every path/.style={black,thick}– egreg Jan 09 '21 at 14:23every path/.style={black,thick}the diagram looks a lot different. So, I am not really sure. – tikzboi Jan 09 '21 at 14:27\tikzset{every path/.style={}}inside thetikzpicturebefore doing\clip. I see no difference whether or not I reinstate\tikzset{every path={black,thick}after the\clipline. – egreg Jan 09 '21 at 14:41\tikzset{every path={black,thick}}should be\tikzset{every path/.style={black,thick}}. – muzimuzhi Z Jan 09 '21 at 18:30clipin the first place? The line ends look better if the sloped lines are not clipped horizontally. – Heiko Oberdiek Jan 18 '21 at 13:19