로컬 경계 상자가 범위 내에서 작동하지 않습니다.

로컬 경계 상자가 범위 내에서 작동하지 않습니다.

이 코드는:

\pic[rotate=40, local bounding box=microfono] at (4.5,-5) {microph};
\draw[black, line width=2pt] (microfono.-45) -- ++(-.2,+.2) ++(.2,-.2) -- ++(0,-2);

외부에서는 작동 scope하지만 내부에서는 작동하지 않습니다(선이 표시되지 않음). 왜?

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\tikzset{
    pics/microph/.style={code={ 
        \draw[black, line width=.2em, rounded corners=1.7ex] 
            (-.85em,4.5ex) -- (-.85em,2ex) -- (.85em,2ex) -- (.85em,4.5ex);
        \fill[black] 
            (-.6em,5ex) to[rounded corners=1.2ex]  
            (-.6em,2.5ex) to[rounded corners=1.2ex] (.6em,2.5ex)
            -- (.6em,5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)  
            -- (.6em,5.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            to[rounded corners=1.2ex]
            (.6em,8ex) to[rounded corners=1.2ex]
            (-.6em,8ex) to cycle; 
    }},
}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-8.5,-6.5) rectangle (8.5,6.5);
\node[fill=cyan, draw=cyan, minimum width=17cm, minimum height=13cm](sky){};
\pic[rotate=40, local bounding box=microfono] at (4.5,-5) {microph};
\draw[black, line width=2pt] (microfono.-45) -- ++(-.2,+.2) ++(.2,-.2) -- ++(0,-2);
\end{scope}
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

답변1

나는 원래 PGF 3.1.5에서 무조건적 으로 local bounding box실행하여 이 사용을 수정했습니다 . 그러나 이로 인해 . 불행하게도 나는 이 매우 틈새적인 상황을 해결하기 위한 다른 해결책을 생각할 수 없었습니다. 그럼에도 불구하고 상황 에 따라 사용할 수 있는 해결 방법을 제안할 수 있습니다 . 로컬 경계 상자를 가져오려는 경로나 범위에 추가하기만 하면 됩니다 .\pgf@path@size@hook\pgf@protocolsizeslocal bounding boxlocal bounding box\clipoverlay=false

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\tikzset{
    pics/microph/.style={code={ 
        \draw[black, line width=.2em, rounded corners=1.7ex] 
            (-.85em,4.5ex) -- (-.85em,2ex) -- (.85em,2ex) -- (.85em,4.5ex);
        \fill[black] 
            (-.6em,5ex) to[rounded corners=1.2ex]  
            (-.6em,2.5ex) to[rounded corners=1.2ex] (.6em,2.5ex)
            -- (.6em,5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)  
            -- (.6em,5.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            to[rounded corners=1.2ex]
            (.6em,8ex) to[rounded corners=1.2ex]
            (-.6em,8ex) to cycle; 
    }},
}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-8.5,-6.5) rectangle (8.5,6.5);
\node[fill=cyan, draw=cyan, minimum width=17cm, minimum height=13cm](sky){};
\pic[rotate=40, overlay=false, local bounding box=microfono] at (4.5,-5) {microph};
\draw[black, line width=2pt] (microfono.-45) -- ++(-.2,+.2) ++(.2,-.2) -- ++(0,-2);
\end{scope}
\end{tikzpicture}
\end{document}

답변2

설명에는 \clip "다음 경로의 크기는 그림 크기에 중요하지 않습니다."라는 문장이 포함되어 있습니다. 그래서 local bounding box정확한 크기를 얻을 수 없다고 가정합니다 .

간단한 해결 방법은 마이크로를 두 번 그리는 것입니다.

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\tikzset{
    pics/microph/.style={code={
        \draw[black, line width=.2em, rounded corners=1.7ex]
            (-.85em,4.5ex) -- (-.85em,2ex) -- (.85em,2ex) -- (.85em,4.5ex);
        \fill[black]
            (-.6em,5ex) to[rounded corners=1.2ex]
            (-.6em,2.5ex) to[rounded corners=1.2ex] (.6em,2.5ex)
            -- (.6em,5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,5.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            to[rounded corners=1.2ex]
            (.6em,8ex) to[rounded corners=1.2ex]
            (-.6em,8ex) to cycle;
    }},
}
\begin{document}
\begin{tikzpicture}
%
\begin{scope}
\pic[rotate=40, local bounding box=microfono] at (4.5,-5) {microph};
\clip (-8.5,-6.5) rectangle (8.5,6.5);
\node[fill=cyan, draw=cyan, minimum width=17cm, minimum height=13cm](sky){};
\pic[rotate=40] at (4.5,-5) {microph};
\draw[line width=2pt] (microfono.-45) -- ++(-.2,+.2) ++(.2,-.2) -- ++(0,-2);
\end{scope}
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

답변3

여기에는 로컬 경계 상자가 필요하지 않습니다. 마이크의 일부 좌표를 사용할 수 있습니다. 그러나 pic이름 접두사를 망치는 것으로 알려져 있습니다 . 이 버그는 부분적으로만 수정되었으며 Henri Menke에 따르면 다음 버전의 pgf에서는 완전히 수정될 예정입니다. 당분간은 이용하자@cfr의 솔루션이름 접두사를 재설정하려면 name prefix ... 이 솔루션은 pgf 매뉴얼 v3.1.4가 p에서 권장하는 것입니다. 263

여기에 이미지 설명을 입력하세요

그런 다음 pgfmanual의 트릭을 사용하여 사진에 이름을 지정하고 외부에서 해당 좌표 중 하나를 참조할 수 있습니다. 이는 마이크를 회전하면 변경되는 -45와 같은 각도를 추측할 필요가 없다는 추가적인 이점이 있습니다.

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\tikzset{
    pics/microph/.style={code={ 
        \draw[black, line width=.2em, rounded corners=1.7ex] 
            (-.85em,4.5ex) -- (-.85em,2ex) -- (.85em,2ex) -- (.85em,4.5ex);
        \path (0,2ex) coordinate (-plug);   
        \fill[black,name prefix ..] % https://tex.stackexchange.com/a/194370 
            (-.6em,5ex) to[rounded corners=1.2ex]  
            (-.6em,2.5ex) to[rounded corners=1.2ex] (.6em,2.5ex)
            -- (.6em,5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)  
            -- (.6em,5.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            to[rounded corners=1.2ex]
            (.6em,8ex) to[rounded corners=1.2ex]
            (-.6em,8ex) to cycle; 
   }},
}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-8.5,-6.5) rectangle (8.5,6.5);
\node[fill=cyan, draw=cyan, minimum width=17cm, minimum height=13cm](sky){};
\pic[rotate=40] (microfono) at (4.5,-5) {microph};
\draw[black, line width=2pt] (microfono-plug)   -- ++(.2,-.2) -- ++(0,-2);
\end{scope}
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

답변4

내 의견에서 언급했듯이 문제는 TikZ 매뉴얼의 섹션에 pic {microph}처음 정의된 것이 아니라 귀하에게서 발생합니다. 이는 분명히 다음과 같은 것이 있음을 보여줍니다.pic {seagull}18 Pics: Small Pictures on Paths벌레의 소스 코드에서 pic operation. 이 버그는 to코드의 작업을 pic호환되지 않게 만듭니다.

pic문제는 연산을 용납하지 않는 연산 의 버그에서 비롯됩니다 to. 이러한 작업을 으로 바꾸면 --작동합니다.

설명서 섹션에 표시된 대로 외부에서 접근할 수 있는 pic위치를 허용하므로 로컬 박스가 필요하지 않습니다 . 그래서 와이어가 연결되는 오른쪽, 즉 마이크 하단 중앙에 '' 라는 좌표를 추가했습니다 .nodeprefix name18.2 The Pic Syntax(-milieu)

\draw[black, line width=.2em, rounded corners=1.7ex,pic actions] 
            (-.85em,4.5ex) -- (-.85em,2ex) -- (.85em,2ex)coordinate[midway](-milieu) -- (.85em,4.5ex);

스크린샷

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\tikzset{
    pics/microph/.style={code={ 
        \draw[black, line width=.2em, rounded corners=1.7ex,pic actions] 
            (-.85em,4.5ex) -- (-.85em,2ex) -- (.85em,2ex)coordinate[midway](-milieu) -- (.85em,4.5ex);
        \fill[black,pic actions]  
            (-.6em,5ex)[rounded corners=1.2ex]  --% 
            (-.6em,2.5ex)[rounded corners=1.2ex] --%to 
            (.6em,2.5ex)
            -- (.6em,5ex)[rounded corners=.2ex] --%to 
            ++(-.85em,0)[rounded corners=.2ex]  --%to
            ++(0,.35ex) -- ++(.85em,0)  
            -- (.6em,5.5ex)[rounded corners=.2ex] --%to 
            ++(-.85em,0)[rounded corners=.2ex] --%to 
            ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6ex)[rounded corners=.2ex] --%to 
            ++(-.85em,0)[rounded corners=.2ex]  --%to
            ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6.5ex)[rounded corners=.2ex] --%to 
            ++(-.85em,0)[rounded corners=.2ex] --%to 
            ++(0,.35ex) -- ++(.85em,0)
            [rounded corners=1.2ex]--%to
            (.6em,8ex) [rounded corners=1.2ex]--%to
            (-.6em,8ex) --%to
             cycle; 
    }},
}

\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-8.5,-6.5) rectangle (8.5,6.5);
\node[fill=cyan, draw=cyan, minimum width=17cm, minimum height=13cm](sky){};
\pic[rotate=40] (microfono) at (4.5,-5) {microph};
\draw[black, line width=2pt] (microfono-milieu) -- ++(.2,-.2) -- ++(0,-2);
\end{scope}

\end{tikzpicture}


\end{document}

관련 정보