我正在尝试从 latex 生成图像公式(第三方提供的公式)。首先,我正在编写一个 tex 文档,例如:
\documentclass[12pt,border=5pt,varwidth]{standalone}
\usepackage{amsmath}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage[russian]{babel}
\DeclareMathSizes{12}{17.28}{12}{10}
\begin{document}
\begin{equation*}
\Leftrightarrow
\left [ {
\begin{align}
&\sin x=\frac{\sqrt{3}}{2},\\
&\cos x=1
\end{align}
}\right.
\Leftrightarrow
\left [ {
\begin{align}
&x=\frac{\pi}{3}+2\pi k, \\
&x=\frac{2\pi}{3}+2\pi k, \\
& x=2\pi k, k\in\mathbb{Z}.
\end{align}
}\right.
\end{equation*}
\end{document}
然后使用命令处理它:
latex --interaction nonstopmode --shell-escape t.tex
并出现错误:
! Package amsmath Error: Erroneous nesting of equation structures;
(amsmath) trying to recover with `aligned'.
See the amsmath package documentation for explanation.
Type H <return> for immediate help.
...
l.10 ...\frac{\sqrt{3}}{2},\\&\cos x=1 \end{align}
}\right. \Leftrightarrow ...
! Package amsmath Error: Erroneous nesting of equation structures;
(amsmath) trying to recover with `aligned'.
See the amsmath package documentation for explanation.
Type H <return> for immediate help.
...
l.10 ... \\& x=2\pi k, k\in\mathbb{Z}. \end{align}
}\right.
! Undefined control sequence.
<argument> ...+2\pi k, \\& x=2\pi k, k\in \mathbb
{Z}.
l.10 ... \\& x=2\pi k, k\in\mathbb{Z}. \end{align}
}\right.
[1] (./t.aux) )
(see the transcript file for additional information)
Output written on t.dvi (1 page, 924 bytes).
Transcript written on t.log.
但是,当我使用第三方服务生成图片(谷歌的任何服务,例如“latex 2 png”)时,使用相同的公式,可以得到一张图片而没有任何错误。
我无法对公式进行任何更改,但我需要获取图片(即使公式有任何错误)
答案1
你一定不能align
环境中有环境equation*
。没有例外。尝试编译你的代码照原样根本行不通,也不可能行得通。
我认为需要用align
环境替换array
环境。顺便说一句,babel
用相同的语言选项加载两次是没有意义的。
\documentclass[12pt,border=5pt,varwidth]{standalone}
\usepackage{amsmath,amsfonts}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\DeclareMathSizes{12}{17.28}{12}{10}
\begin{document}
\begin{equation*}
\renewcommand\arraystretch{2}
\Leftrightarrow \left [
\begin{array}{l} \sin x=\frac{\sqrt{3}}{2},\\
\cos x=1
\end{array} \right.
\Leftrightarrow \left [
\begin{array}{l} x=\frac{\pi}{3}+2\pi k, \\
x=\frac{2\pi}{3}+2\pi k, \\
x=2\pi k, k\in\mathbb{Z}.
\end{array} \right.
\end{equation*}
\end{document}