Martin Vermeer wrote:

> OK, the attached. Wasn't too hard, but I couldn't really spare the time.
> Seems to work.

I do not want to press you into spending more time that you don't have, but
unfortunately there is still a problem AFAICS. Maybe somebody else can
finish this?

> Index: InsetMathFrac.cpp
> ===================================================================
> --- InsetMathFrac.cpp        (revision 20290)
> +++ InsetMathFrac.cpp        (working copy)
> @@ -218,11 +225,11 @@
>                  InsetMathNest::write(os);
>                  break;
>          case UNIT:
> -                os << "\\unit[" << cell(0) << "]{" << cell(1) << '}';
> +                if (nargs() == 2)
> +                        os << "\\unit[" << cell(0) << "]{" << cell(1) <<
> '}';
> +                else
> +                        os << "\\unitfrac[" << cell(2) << "]{" << cell(0)
> << "}{" << cell(1) << '}';

Why is \unit{xxx} not supported? This is a regression.

>                  break;
> -        case UNITFRAC3:
> -                os << "\\unitfrac[" << cell(2) << "]{" << cell(0) << "}{"
> << cell(1) << '}';
> -                break;
>          }
>  }
>  
> @@ -238,10 +245,15 @@
>                  return from_ascii("nicefrac");
>          case UNITFRAC:
>                  return from_ascii("unitfrac");
> -        case UNITFRAC3:
> -                return from_ascii("unitfracthree");
>          case UNIT:
> -                return from_ascii("unit");
> +                // Note the illogicity. The enum is UNIT, but it
> +                // collects both non-fractional and fractional
> +                // values + units, having only in common the use
> +                // of the optional value field.

Why the illogicity? This is very confusing, I would expect that UNITFRAC has
a 1:1 relationship to \unitfrac.

> +                if (nargs() == 3)
> +                        return from_ascii("unitfrac");
> +                else
> +                        return from_ascii("unit");
>          case ATOP:
>                  return from_ascii("atop");
>          }
> Index: MathParser.cpp
> ===================================================================
> --- MathParser.cpp        (revision 20282)
> +++ MathParser.cpp        (working copy)
> @@ -1097,6 +1098,33 @@
>                          }
>                  }
>  
> +                else if (t.cs() == "unit") {
> +                        // Allowed formats \unit[val]{unit}
> +                        MathData ar;
> +                        parse(ar, FLAG_OPTION, mode);
> +                        cell->push_back(MathAtom(new
> InsetMathFrac(InsetMathFrac::UNIT)));
> +                        if (ar.size()) {
> +                                cell->back().nucleus()->cell(0) = ar;
> +                                parse(cell->back().nucleus()->cell(1),
> FLAG_ITEM, mode);
> +                        } else {
> +                                // Not implemented, should not be
> reached:

This is not true. \unit without optional argument is allowed.

> +                                parse(cell->back().nucleus()->cell(0),
> FLAG_ITEM, mode);
> +                        }
> +                }


Georg

Reply via email to