Help:Editing/House Style/LaTeX Code Style

$\LaTeX$ Code Style
There are a few general source code conventions which make your code easier to read and maintain:


 * Each variable, and each command beginning with a backslash should be preceded by a space, except (for some unexplained result of evolution) when enclosing things in brackets. See some of the above instance for a typical example.


 * When enclosing brackets around an object, always use the  command, for example   rather than.


 * There should be no need to use the commands  etc. for specifying the sizes of parentheses. Using the   technique (as above) will almost always automatically size the brackets aesthetically.


 * Punctuation should appear (if it is really necessary) outside the $\LaTeX$ environment, for example:


 * Hence $\map f {\sin x}$. (produced by: )


 * as opposed to:


 * Hence $\map f {\sin x}.$ (produced by: )


 * Single-character parameters to standard $\LaTeX$ constructs need not be put in curly braces. That is,  is preferred to  . They both produce: $\dfrac 1 2$

It makes the source code significantly easier to read.

Having said that, please do not ignore the rule about spacing. The same effect can also be achieved by  (see, it still looks like $\dfrac12$) but that is significantly harder to interpret visually.

Aligned Material
If an equation includes multiple equalities or inequalities, it is best to place each equality on a new line.

For example:


 * $\dfrac \d {\d t} \map H U = \d \map H U \cdot \dot U = \map \Omega {\map {X_H} U, \dot U} = \map \Omega {\map {X_H} U, \map {X_H} U} = 0$

would look better as an aligned equation. This is done using the following commands:

...

Here, the section following  is a $\LaTeX$ environment, and should contain anything you want to appear to the left of the equals sign.

The section following  is the same, but will appear to the right of the equals sign.

and  are similar, but produce material in columns further to the left and further to the right respectively. In particular, the  column is often used for an "implies" or "leads to" sign where the   and   are used for either side of a string of equations.

All these $\LaTeX$ environments are already in  mode, so there is no need to include that command in your equation.

When entering such an  environment, it should globally look like this:

That is, it adheres to the following principles:


 * Every empty column should in general be omitted, except perhaps for  sections, which can be left as placeholders for possible future addition of comments
 * Non-empty columns are entered on separate lines, with the  and   all aligned.

These conventions serve to optimize readability.

More options and abilities of the  can be found on its page, eqn.

The section following  is not a $\LaTeX$ environment, and can be used to add any comments about the equation at this point.

So the example we gave above would be typeset as:

The finished result will look like:

The operator that is displayed in this template can be changed using  to show inequalities, etc.

Note the following:


 * Do not include two consecutive open or close curly braces:  or   anywhere in your eqn templates. It will break the interpreter.

Put spaces in:  or   and it will be okay.


 * Do not include the vertical line  (a.k.a. "pipe") in $\LaTeX$ expressions as this also breaks the interpreter. Use   (or   and  ) instead.


 * In particular,  (used to produce $\|$) has the same problem. Use   etc. instead.

These caveats apply only within the  environment. Elsewhere on the page such constructs should be fine. To accommodate for the inevitable copy-paste efforts, and for consistency's sake, it is however desirable to always use  and , and to insert a space between adjacent curly braces within $\LaTeX$ strings.