Index: branches/DataAnalysis.Extensions/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Formatters/SymbolicExpressionTreeLatexFormatter.cs
===================================================================
--- branches/DataAnalysis.Extensions/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Formatters/SymbolicExpressionTreeLatexFormatter.cs	(revision 4968)
+++ branches/DataAnalysis.Extensions/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Formatters/SymbolicExpressionTreeLatexFormatter.cs	(revision 4969)
@@ -32,9 +32,16 @@
 
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Formatters {
-  [Item("SymbolicExpressionTreeLatexFormatter", "Formatter for symbolic expression trees for import into LaTeX documents.")]
+  [Item("LaTeX String Formatter", "Formatter for symbolic expression trees for import into LaTeX documents.")]
   public sealed class SymbolicExpressionTreeLatexFormatter : NamedItem, ISymbolicExpressionTreeStringFormatter {
+    private List<double> constants;
+
     public SymbolicExpressionTreeLatexFormatter()
-      : base("SymbolicExpressionTreeLatexFormatter", "Formatter for symbolic expression trees for import into LaTeX documents.") { }
-    private SymbolicExpressionTreeLatexFormatter(SymbolicExpressionTreeLatexFormatter original, Cloner cloner) : base(original, cloner) { }
+      : base("LaTeX String Formatter", "Formatter for symbolic expression trees for import into LaTeX documents.") {
+      constants = new List<double>();
+    }
+    private SymbolicExpressionTreeLatexFormatter(SymbolicExpressionTreeLatexFormatter original, Cloner cloner)
+      : base(original, cloner) {
+      constants = new List<double>(original.constants);
+    }
 
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -45,7 +52,9 @@
       try {
         StringBuilder strBuilder = new StringBuilder();
-        strBuilder.AppendLine("\\begin{eqnarray}");
+        constants.Clear();
+        strBuilder.AppendLine("% needs \\usepackage{amsmath}");
+        strBuilder.AppendLine("\\begin{align}");
         strBuilder.AppendLine(FormatRecursively(symbolicExpressionTree.Root));
-        strBuilder.AppendLine("\\end{eqnarray}");
+        strBuilder.AppendLine("\\end{align}");
         return strBuilder.ToString();
       }
@@ -83,18 +92,49 @@
         if (node.SubTrees.Count != 2) throw new NotImplementedException("Division with more than 2 arguments is not implemented.");
         strBuilder.Append(@" \frac{ ");
+      } else if (node.Symbol is Average) {
+        strBuilder.Append(@" \frac{1}{" + node.SubTrees.Count + @"} \left(");
+      } else if (node.Symbol is Logarithm) {
+        strBuilder.Append(@"\log \left(");
+      } else if (node.Symbol is Exponential) {
+        strBuilder.Append(@"\exp \left(");
+      } else if (node.Symbol is Sine) {
+        strBuilder.Append(@"\sin \left(");
+      } else if (node.Symbol is Cosine) {
+        strBuilder.Append(@"\cos \left(");
+      } else if (node.Symbol is Tangent) {
+        strBuilder.Append(@"\tan \left(");
+      } else if (node.Symbol is GreaterThan) {
+        strBuilder.Append(@" \left( ");
+      } else if (node.Symbol is LessThan) {
+        strBuilder.Append(@" \left( ");
+      } else if (node.Symbol is And) {
+        strBuilder.Append(@" \left( \left( ");
+      } else if (node.Symbol is Or) {
+        strBuilder.Append(@" \left( \left( ");
+      } else if (node.Symbol is Not) {
+        strBuilder.Append(@" -1.0 \times \left( ");
+      } else if (node.Symbol is IfThenElse) {
+        strBuilder.Append(@"\left( \operatorname{if} \left( 0 < ");
       } else if (node.Symbol is Constant) {
-        strBuilder.Append(" c ");
+        strBuilder.Append("c_{" + constants.Count+"} ");
+        var constNode = node as ConstantTreeNode;
+        constants.Add(constNode.Value);
       } else if (node.Symbol is HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable) {
         var varNode = node as VariableTreeNode;
-        strBuilder.Append(" " + varNode.ToString() + " ");
+        strBuilder.Append("c_{" + constants.Count + "} " + varNode.VariableName + " ");
+        constants.Add(varNode.Weight);
+      } else if (node.Symbol is LaggedVariable) {
+        var laggedVarNode = node as LaggedVariableTreeNode;
+        strBuilder.Append("c_{" + constants.Count + "} " + laggedVarNode.VariableName + "(t" + laggedVarNode.Lag + ")");
+        constants.Add(laggedVarNode.Weight);
       } else if (node.Symbol is ProgramRootSymbol) {
       } else if (node.Symbol is Defun) {
         var defunNode = node as DefunTreeNode;
-        strBuilder.Append(defunNode.FunctionName + " & = & ");
+        strBuilder.Append(defunNode.FunctionName + " & = ");
       } else if (node.Symbol is InvokeFunction) {
         var invokeNode = node as InvokeFunctionTreeNode;
         strBuilder.Append(invokeNode.Symbol.FunctionName + @" \left( ");
       } else if (node.Symbol is StartSymbol) {
-        strBuilder.Append("Result & = & ");
+        strBuilder.Append("Result & = ");
       } else if (node.Symbol is Argument) {
         var argSym = node.Symbol as Argument;
@@ -111,6 +151,31 @@
         strBuilder.Append(" - ");
       } else if (node.Symbol is Multiplication) {
+        strBuilder.Append(@" \times ");
       } else if (node.Symbol is Division) {
         strBuilder.Append(" }{ ");
+      } else if (node.Symbol is Average) {
+        strBuilder.Append(@" + ");
+      } else if (node.Symbol is Logarithm) {
+        throw new InvalidOperationException();
+      } else if (node.Symbol is Exponential) {
+        throw new InvalidOperationException();
+      } else if (node.Symbol is Sine) {
+        throw new InvalidOperationException();
+      } else if (node.Symbol is Cosine) {
+        throw new InvalidOperationException();
+      } else if (node.Symbol is Tangent) {
+        throw new InvalidOperationException();
+      } else if (node.Symbol is GreaterThan) {
+        strBuilder.Append(@" > ");
+      } else if (node.Symbol is LessThan) {
+        strBuilder.Append(@" < ");
+      } else if (node.Symbol is And) {
+        strBuilder.Append(@" > 0 \right) \land \left(");
+      } else if (node.Symbol is Or) {
+        strBuilder.Append(@" > 0 \right) \lor \left(");
+      } else if (node.Symbol is Not) {
+        throw new InvalidOperationException();
+      } else if (node.Symbol is IfThenElse) {
+        strBuilder.Append(@" \right) , \left(");
       } else if (node.Symbol is ProgramRootSymbol) {
         strBuilder.Append(@"\\" + Environment.NewLine);
@@ -119,5 +184,5 @@
         strBuilder.Append(" , ");
       } else if (node.Symbol is StartSymbol) {
-        strBuilder.Append(@"\\" + Environment.NewLine + " & & ");
+        strBuilder.Append(@"\\" + Environment.NewLine + " & ");
       } else {
         throw new NotImplementedException("Export of " + node.Symbol + " is not implemented.");
@@ -133,7 +198,41 @@
       } else if (node.Symbol is Division) {
         strBuilder.Append(" } ");
+      } else if (node.Symbol is Average) {
+        strBuilder.Append(@" \right)");
+      } else if (node.Symbol is Logarithm) {
+        strBuilder.Append(@" \right) ");
+      } else if (node.Symbol is Exponential) {
+        strBuilder.Append(@" \right) ");
+      } else if (node.Symbol is Sine) {
+        strBuilder.Append(@" \right) ");
+      } else if (node.Symbol is Cosine) {
+        strBuilder.Append(@" \right) ");
+      } else if (node.Symbol is Tangent) {
+        strBuilder.Append(@" \right) ");
+      } else if (node.Symbol is GreaterThan) {
+        strBuilder.Append(@" \right) ");
+      } else if (node.Symbol is LessThan) {
+        strBuilder.Append(@" \right) ");
+      } else if (node.Symbol is And) {
+        strBuilder.Append(@" > 0 \right) \right) ");
+      } else if (node.Symbol is Or) {
+        strBuilder.Append(@" > 0 \right) \right) ");
+      } else if (node.Symbol is Not) {
+        strBuilder.Append(@" \right) ");
+      } else if (node.Symbol is IfThenElse) {
+        strBuilder.Append(@" \right) \right) ");
       } else if (node.Symbol is Constant) {
       } else if (node.Symbol is HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable) {
+      } else if (node.Symbol is LaggedVariable) {
       } else if (node.Symbol is ProgramRootSymbol) {
+        // output all constant values
+        if (constants.Count > 0) {
+          int i = 0;
+          foreach (var constant in constants) {
+            strBuilder.AppendLine(@"\\");
+            strBuilder.Append("c_{" + i + "} & = " + constant);
+            i++;
+          }
+        }
       } else if (node.Symbol is Defun) {
       } else if (node.Symbol is InvokeFunction) {
