Inkscape TexText !LaTeX 错误:只能在序言中使用

Inkscape TexText !LaTeX 错误:只能在序言中使用

我正在尝试使用 textext 在 inkscape 中运行此代码:

\documentclass[preview]{standalone}

\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{circuitikz}

\begin{document}
\textbf{a.}
\begin{figure}[h]
  \centering
  \begin{circuitikz}[american voltages]
    \draw
       (0,3) to [V,l_=$5 + 20\cos(100\pi t)+10\cos(200\pi t)$] (0,0)
      to [short,i_=$i_s$] (1,0)
      to [R, l_=$\pi\si{\Omega}$] (3,0)
      to [C, l_=$1000\pi\si{\micro\farad}$] (3,3)
      to [L, l_=$\pi\si{\milli\henry}$] (0,3);
  \end{circuitikz}
  \begin{align*}
      f = \frac{100\pi}{2\pi}=50\si{\hertz}
  \end{align*}
\end{figure}
\textbf{b.}
\begin{align*}
      \text{THD}=\frac{\sqrt{\sum_{n=2}^{\infty}h_n^2}}{h_1}=\frac{\sqrt{h_2^2}}{h_1}=\frac{10}{20}=0.5=50\%
\end{align*}
\end{document}

该代码在 overleaf 上运行良好,但当我将其放入 inkscape 时出现此错误:

! LaTeX Error: Can be used only in preamble.
See the LaTeX manual or LaTeX Companion for explanation.
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./tmp.tex
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-08-11>
(c:/texlive/2023/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(c:/texlive/2023/texmf-dist/tex/latex/base/size10.clo))
(c:/texlive/2023/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(c:/texlive/2023/texmf-dist/tex/latex/amsmath/amstext.sty
(c:/texlive/2023/texmf-dist/tex/latex/amsmath/amsgen.sty))
(c:/texlive/2023/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(c:/texlive/2023/texmf-dist/tex/latex/amsmath/amsopn.sty))
(c:/texlive/2023/texmf-dist/tex/latex/amscls/amsthm.sty)
(c:/texlive/2023/texmf-dist/tex/latex/amsfonts/amssymb.sty
(c:/texlive/2023/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(c:/texlive/2023/texmf-dist/tex/latex/graphics/color.sty
(c:/texlive/2023/texmf-dist/tex/latex/graphics-cfg/color.cfg)
(c:/texlive/2023/texmf-dist/tex/latex/graphics-def/pdftex.def)
(c:/texlive/2023/texmf-dist/tex/latex/graphics/mathcolor.ltx))
(c:/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
No file tmp.aux.
(c:/texlive/2023/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.9     \documentclass
                      [preview]{standalone}
? 
! Emergency stop.
 ...                                              
                                                  
l.9     \documentclass
                      [preview]{standalone}
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on tmp.log.

我尝试删除 documentclass 行或 usepackage 行或两者,但仍然有错误。

相关内容