Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/06/11 18:13:42 (13 years ago)
Author:
mkommend
Message:

#1686: Improved display of divisions in the latex formatter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs

    r7136 r7140  
    7777        strBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    7878      }
     79      int i = 1;
    7980      foreach (SymbolicExpressionTreeNode subTree in node.Subtrees.Skip(1)) {
    80         FormatSep(node, strBuilder);
     81        FormatSep(node, strBuilder, i);
    8182        // format the whole subtree
    8283        strBuilder.Append(FormatRecursively(subTree));
     84        i++;
    8385      }
    8486
     
    190192    }
    191193
    192     private void FormatSep(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
     194    private void FormatSep(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, int step) {
    193195      if (node.Symbol is Addition) {
    194196        strBuilder.Append(" + ");
     
    198200        strBuilder.Append(@" \cdot ");
    199201      } else if (node.Symbol is Division) {
    200         strBuilder.Append(@" }{ \cfrac{ ");
     202        if (step + 1 == node.SubtreeCount)
     203          strBuilder.Append(@"}{");
     204        else
     205          strBuilder.Append(@" }{ \cfrac{ ");
    201206      } else if (node.Symbol is Average) {
    202207        strBuilder.Append(@" + ");
     
    253258      } else if (node.Symbol is Multiplication) {
    254259      } else if (node.Symbol is Division) {
    255         strBuilder.Append("} ");
    256         if (node.SubtreeCount > 1)
    257           strBuilder.Append("{1} ");
    258         for (int i = 1; i < node.SubtreeCount; i++) {
     260        strBuilder.Append(" } ");
     261        for (int i = 2; i < node.SubtreeCount; i++)
    259262          strBuilder.Append(" } ");
    260         }
    261263      } else if (node.Symbol is Average) {
    262264        strBuilder.Append(@" ) ");
Note: See TracChangeset for help on using the changeset viewer.