나는 TikzEdt
논문에 사용할 몇 가지 수치를 생성하기 위해 사용했습니다. 그러나 소스 코드를 포함했을 때복사-붙여넣기/\입력기본 문서에서 under a figure environment
내 문서는 오류 없이 컴파일하는 데 시간이 오래 걸리고 컴파일을 취소한 후 손상된 PDF 출력 파일이 생성되었습니다.
제가 아는 한, 서문에 필요한 모든 패키지가 있고 TikzEdt
.
비컴파일 파일이 용량이 커서 구동파일은여기,클래스 파일수정된 도서 클래스이며 포함되어 있습니다.매크로기본적이다.
또한 TikzEdt
메시지와 함께 다음 줄이 있다고 불평합니다.코드를 파싱할 수 없습니다. 16번 줄의 44번 위치에 NoViableAltException이 발생했습니다. 일부 \end{} 명령이 누락되었습니까?". 컴파일 MWE는 다음과 같습니다.여기.
\draw[<->, 두꺼운] (-1,0)++({\ang+90}:1) --++ (\ang:{2*cos(\ang)});
편집하다
문제가 해결되었으며 문제는 \ang
패키지에 정의된 내부 매크로를 사용하는 것이 었습니다 siunitx
. TikzEdt 파서는 여전히 불만을 표시하지만 이것이 실제 문제인지는 알 수 없습니다.
답변1
글쎄, 분명히 가 필요 \begin{document}
하지만 그렇지 않으면 figure
.
\documentclass{article}
\usepackage{tikz,amsmath, amssymb,bm,color}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.markings,math}
\usetikzlibrary{calc}
\begin{document}
\begin{figure}
\center
\begin{tikzpicture}
\tikzmath{\ang = 45;};
\begin{scope}[thick,decoration={
markings,
mark=at position 0.5 with {\arrow{latex}}}
]
\filldraw[red] (-1,0) circle (2pt)
node[anchor=east, font = \footnotesize] at (-1,-0.2) {$\mathrm{E_0}$};
\draw[dashed, red] (-1,0) --++({\ang+90}:1);
\filldraw[green] (1,0) circle (2pt)
node[anchor=west, font = \footnotesize] at (1,-0.2) {$\mathrm{E_0}$};
\draw[postaction={decorate}, red] (-1,0) --++ (\ang:2);
\draw[postaction={decorate}, green] (1,0) --++ (\ang:2);
\draw[<->, thick] (-1, -0.2) -- (1, -0.2);
\draw[dashed, green] (1,0) --++ ({\ang+90}:2.5);
\draw[<->, thick] (-1,0)++({\ang+90}:1) --++ (\ang:{2*cos(\ang)});
% \draw[<->, thick] (-1,0)++({\ang+90}:1) --++ (\ang:{2*cos(\ang) });
\node[anchor=north, font = \footnotesize] at (0, -0.2) {d=$\lambda/2$};
\end{scope}
\draw[blue, thick, dash pattern= on 25 off 7 on 50 off 7 on 10] (-2,0) -- (2, 0);
\node[anchor=west, font = \footnotesize, blue] at (1.5,-0.05) {z}; node[near start, auto] {true}
\draw[thick,blue,->] ([shift=(0:1)]1,0) arc (0:\ang:1);
% \draw[thick,blue,->] (2,0) arc (0:\ang:1);
\draw (1,0)++({\ang/2}:1.2) node[rotate=\ang, anchor=base, blue, font=\normalsize]{$\theta$};
\draw ({\ang+90}:1.3) node[rotate=\ang, anchor=base, black, font=\normalsize]{$d\cos\theta$};
\end{tikzpicture}
\caption{Picture}
\end{figure}
\end{document}
아마도 질문을 이해하지 못하는 것 같습니다.
편집하다
추가하면 siunitx
오류가 발생하지만 그것이 귀하의 오류인지는 모르겠습니다. 특히 확장이 불가능하다고 xparse
불평합니다 . \ang
이는 현재 코드가 \ang
더 이상 할당되지 않은 매크로 이름이 아닌 을 호출하기 때문입니다. 그래서 \ang
정의를 확장하려고 노력하고 있지만 그럴 수 없습니다. (그리고 만약 그렇게 된다면 결과도 좋지 않을 것입니다.)
해결책은 와 같은 새로운 이름을 사용하는 것입니다 \myangle
.
\documentclass{article}
\usepackage{tikz,amsmath,amssymb,bm}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.markings,math}
\usetikzlibrary{calc}
\usepackage{siunitx}
\begin{document}
\begin{figure}
\center
\begin{tikzpicture}
\tikzmath{\myangle = 45;};
\begin{scope}[thick,decoration={
markings,
mark=at position 0.5 with {\arrow{latex}}}
]
\filldraw[red] (-1,0) circle (2pt)
node[anchor=east, font = \footnotesize] at (-1,-0.2) {$\mathrm{E_0}$};
\draw[dashed, red] (-1,0) --++({\myangle+90}:1);
\filldraw[green] (1,0) circle (2pt)
node[anchor=west, font = \footnotesize] at (1,-0.2) {$\mathrm{E_0}$};
\draw[postaction={decorate}, red] (-1,0) --++ (\myangle:2);
\draw[postaction={decorate}, green] (1,0) --++ (\myangle:2);
\draw[<->, thick] (-1, -0.2) -- (1, -0.2);
\draw[dashed, green] (1,0) --++ ({\myangle+90}:2.5);
\draw[<->, thick] (-1,0)++({\myangle+90}:1) --++ (\myangle:{2*cos(\myangle)});
% \draw[<->, thick] (-1,0)++({\myangle+90}:1) --++ (\myangle:{2*cos(\myangle) });
\node[anchor=north, font = \footnotesize] at (0, -0.2) {d=$\lambda/2$};
\end{scope}
\draw[blue, thick, dash pattern= on 25 off 7 on 50 off 7 on 10] (-2,0) -- (2, 0);
\node[anchor=west, font = \footnotesize, blue] at (1.5,-0.05) {z}; node[near start, auto] {true}
\draw[thick,blue,->] ([shift=(0:1)]1,0) arc (0:\myangle:1);
% \draw[thick,blue,->] (2,0) arc (0:\myangle:1);
\draw (1,0)++({\myangle/2}:1.2) node[rotate=\myangle, anchor=base, blue, font=\normalsize]{$\theta$};
\draw ({\myangle+90}:1.3) node[rotate=\myangle, anchor=base, black, font=\normalsize]{$d\cos\theta$};
\end{tikzpicture}
\caption{Picture}
\end{figure}
\end{document}
위에 표시된 출력으로 컴파일됩니다.