Originally Posted by
Paul46 The LaTeX compiler used by this Forum is very unforgiving and very uncommunicative. So, what do you do when after entering an impressive formula like
[tex]10\:log\:\left[\frac{\left(2\times10^{-1}}\right)^3{\left(2\times10^{-5}}\right)^3\right]\:=30\:log\left(\frac{2\times10^{-1}}{2\times10^{-5}}\:120\:[/tex]
in LaTeX, you hit the Preview button and all that happens is that you get the message [LaTeX Error: Syntax error]?
Here are a few hints on how to debug your LaTeX. The first and most important one is to narrow down where the errors are occurring. Split the formula into two at some convenient break point like an = sign, so that it becomes two separate formulas:
[tex]10\:log\:\left[\frac{\left(2\times10^{-1}}\right)^3{\left(2\times10^{-5}}\right)^3\right]\:[/tex] [tex]=30\:log\left(\frac{2\times10^{-1}}{2\times10^{-5}}\:120\:[/tex].
Now hit the Preview button and you see [LaTeX Error: Syntax error] [LaTeX Error: Syntax error].
Bad news. That means there is at least one error on both sides of the equation. But at least we are narrowing down where the errors might lie. Take the second of the two parts of the equation:
[tex]=30\:log\left(\frac{2\times10^{-1}}{2\times10^{-5}}\:120\:[/tex].
Can we subdivide it further? Not easily, because one thing that the LaTeX compiler is very picky about is that a command like "\left(" must always be matched by a "\right)". So we can't just split this formula down the middle. What we can do is to replace everything between the "\left(" and the "\right)" by something simple, like an X. That will tell us whether the error comes inside or outside the brackets (or maybe in both places if we're unlucky). In this example, you'll have noticed by now that there is a "\left(" without any matching "\right)". So there's one error tracked down, and the second of the two halves of the formula now compiles correctly:
[tex]=30\:log\left(\frac{2\times10^{-1}}{2\times10^{-5}}\right)\:120\:[/tex]
yields " ". (There may still be things there that you want to change, but at least it's producing something.
Now let's look at the first part of the equation:
[tex]10\:log\:\left[\frac{\left(2\times10^{-1}}\right)^3{\left(2\times10^{-5}}\right)^3\right]\:[/tex].
The commonest error in writing LaTeX code (for me at any rate) is forgetting to close braces. Here again, the compiler is unforgiving. If you write a "{" that's not followed in the appropriate place by a matching "}" then you'll get the LateX Error message. You need to be particularly careful about this when writing complex fractions, and even more so if there are pairs of braces nested inside other pairs of braces. To see if you have gone wrong here, replace the whole of a "\frac{<numerator>}{<denominator>}" expression by a single X, and see if the formula still compiles. I'll leave you to figure out how to track down the error(s) in that part of the formula.
To sum up, the main technique in debugging LaTeX is to narrow down where the errors may be occurring, and then to use the Preview feature to see if you are making progress.