EDITAR

EDITAR

Lo usé TikzEdtpara generar algunas figuras para usar en mi tesis. Sin embargo, cuando incluí el código fuente decopiar y pegar/\entradaen el documento principal, under a figure environmentmi documento tardó una eternidad en compilarse sin errores y arrojó un archivo de salida PDF dañado después de cancelar la compilación.

En lo que a mí respecta, tengo todos los paquetes necesarios en el preámbulo y he generado un ejemplo de trabajo mínimo después de inspeccionar el código exportado desde TikzEdt.

El archivo que no se compila es enorme, por lo que el archivo de conducción esaquí, elarchivo de clasees una clase de libro modificada y el incluidomacrosson básicos.

Además TikzEdtse queja de que aparece la siguiente línea con el mensaje: "No se pudo analizar el código. NoViableAltException en la línea 16 en la posición 44. ¿Falta algún comando \end{}?". Un MWE compilador esaquí.

\draw[<->, grueso] (-1,0)++({\ang+90}:1) --++ (\ang:{2*cos(\ang)});

EDITAR El problema se resolvió y el problema fue mi uso, \angque es una macro interna definida en el paquete siunitx. El analizador TikzEdt todavía se queja, pero no sé si es un problema real.

A continuación se muestra una captura de pantalla del problema TikzEdt. El mensaje de error se muestra enlíneas rojas. ingrese la descripción de la imagen aquí

Respuesta1

Bueno, necesitas un archivo \begin{document}, obviamente, pero por lo demás funciona bien convertido a un documento normal con la imagen en formato 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}

cifra

Posiblemente no entiendo la pregunta.

EDITAR

Agregar siunitxproduce UN error, aunque no sé si es TU error. xparseSe queja concretamente de que \angno es ampliable. Esto se debe a que el código actual invoca \ang, que ya no es un nombre de macro no asignado. Por eso está intentando ampliar \angsu definición, pero no puede. (Y, si pudiera, los resultados tampoco serían buenos).

La solución es utilizar un nombre nuevo como \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}

compila a la salida que se muestra arriba.

información relacionada