开发者

Putting $$s in the middle of an `equation` environment: why doesn't Latex complain?

开发者 https://www.devze.com 2022-12-31 15:55 出处:网络
I was surprised that the Latex code from a recent question didn\'t throw up any errors, and even more surprised on further investigation, that Crowley\'s explanation seems to be true.My intuition abou

I was surprised that the Latex code from a recent question didn't throw up any errors, and even more surprised on further investigation, that Crowley's explanation seems to be true. My intuition about the \begin{equation} ... \end{equation} code is clearly off, what's really going on?

Consider this, slightly adapted code:

\begin{equation} 
1: e^{i\pi}+1=0
$$  2: B\"ob $$ 
3: e=mc^2 
\end{equation}

This seems to prove that Crowley's explanation of such code, namely 开发者_开发技巧that "What that code says to LaTeX is begin equation, end it, begin it again, typeset definition of tangens and end the equation" is right: lines 1&3 can only be typeset in maths mode, line 2 only in text mode.

Shouldn't Latex see that the \end{equation} is ending a display math that wasn't started by the \begin{equation}?


Maybe it is because of environments math and displaymath.

I just tried those codes

\[\alpha$$ - works properly

\begin{displaymath}\alpha$$ - error (\begin{displaymath} ended by \end{document}) *

\displaymath\alpha$$ - works properly

\displaymath\alpha\displaymath - error (Bad math environment delimiter)

\displaymath\alpha\enddisplaymath - works properly.

Symetric options produce same results, so I think there's in LaTeX command definition

\newcommand{\[}{\displaymath}
\newcommand{\]}{\enddisplaymath }
\newenvironment{displaymath}{\displaymath}{enddisplaymath}

and in TeX something like

"if(displaymath)
 {$$ := \displaymath}
 else
 {$$ := \displaymath}"

Maybe I'm wrong, but this seems logical to me.


  • Note: That proves that I was wrong. Better words are It says: "Begin equation, switch to text mode, switch back to displaymath, typeset tangens definition and finally end the equation".
0

精彩评论

暂无评论...
验证码 换一张
取 消