私はTikzEdt
論文で使用する図を作成するために使用しました。しかし、ソースコードをコピー&ペースト/\inputメイン ドキュメントでは、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}
上記の出力にコンパイルされます。