2

I am trying to generate image formula from latex (Formulas given by a third side). First of all i am writing a tex document, like:

\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}

then process it, using command:

latex --interaction nonstopmode --shell-escape t.tex

and getting a error:

! 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.

however, when i use 3th party service for generate picture (any service from google by words "latex 2 png") with same formula - geting a picture without any errors.

I can't make any changes in formula but i need get picture (even formula has any errors)

4
  • This is perhaps not the best strategy to insert faulty LaTeX code and rely on TeX producing the correct result then.
    – user31729
    Apr 17, 2016 at 20:44
  • Christian Hupfer, i am totally agree. But other service generate this formula without any error messages. Maybe any additional modules not installed, i don't know Apr 17, 2016 at 20:48
  • 2
    You must not have an align environment nested in an equation* environment. No exceptions.
    – Mico
    Apr 17, 2016 at 20:59
  • 1
    for the undefined \mathbb you need another font; it's defined in amsfonts or amssymb (which loads amsfonts and then defines commands for many other symbols as well). Apr 18, 2016 at 1:04

1 Answer 1

5

You mustn't have align environments inside an equation* environment. No exceptions. Trying to compile your code as is simply won't work, and cannot work.

I think that what's needed is to replace the align environments with array environments. By the way, there's no point in loading babel twice with the same language option.

enter image description here

\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}
4
  • 1
    although array may give better vertical spacing, aligned (notice the "ed") also works as a nested environment. Apr 18, 2016 at 1:07
  • perhaps question title need to change, because this case not about ignore errors while compiling but about how to change formatting :) Thank you, @Mico Apr 18, 2016 at 20:16
  • @StanislavSviridenko - Sorry if I misunderstood the main purpose of your posting. Do feel free to edit the title and other parts of your posting to clarify what you're looking to achieve.
    – Mico
    Apr 18, 2016 at 21:00
  • @Mico you answer is completely solve my problem. Rather, my question was not described correctly but you gave solution that what was i need. Apr 20, 2016 at 10:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .