Example #1
0
        public static bool TryGetAtom(string name, SourceSpan?source, out SymbolAtom?atom)
#endif
        {
            if (!symbols.TryGetValue(name, out var factory))
            {
                atom = null;
                return(false);
            }

            var symbol = factory(source);

            atom = new SymbolAtom(source, symbol, symbol.Type);
            return(true);
        }
Example #2
0
        private Box LongDivisionStyle_lefttop(TexEnvironment environment)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;
            var axis    = texFont.GetAxisHeight(style);
            var defaultLineThickness = texFont.GetDefaultLineThickness(style);

            var    dividend_divisor = new HorizontalBox();
            var    divisorbox       = this.DivisorAtom == null ? StrutBox.Empty : this.DivisorAtom.CreateBox(environment);
            var    leftsep          = SymbolAtom.GetAtom("rbrack", this.Source).CreateBox(environment);
            var    dividendbox      = this.DividendAtom == null ? StrutBox.Empty : this.DividendAtom.CreateBox(environment);
            double barwidth         = leftsep.TotalWidth + dividendbox.TotalWidth;
            var    separatorbar     = new HorizontalRule(environment, defaultLineThickness, barwidth, -dividendbox.TotalHeight - defaultLineThickness);


            dividend_divisor.Add(divisorbox);
            dividend_divisor.Add(leftsep);
            dividend_divisor.Add(dividendbox);
            dividend_divisor.Add(new StrutBox(-barwidth, dividendbox.TotalHeight, 0, 0));
            dividend_divisor.Add(separatorbar);

            var quotient_pad      = new HorizontalBox();
            var quotientbox       = this.QuotientAtom == null ? StrutBox.Empty : this.QuotientAtom.CreateBox(environment);
            var leftspace         = dividend_divisor.TotalWidth - quotientbox.TotalWidth;
            var quot_leftspacebox = new StrutBox(leftspace, quotientbox.TotalHeight, 0, 0);

            quotient_pad.Add(quot_leftspacebox);
            quotient_pad.Add(quotientbox);

            var otherbox = this.OtherAtom == null ? StrutBox.Empty : this.OtherAtom.CreateBox(environment);


            var resultBox = new VerticalBox();

            resultBox.Add(quotient_pad);
            resultBox.Add(dividend_divisor);
            resultBox.Add(otherbox);

            return(resultBox);
        }
Example #3
0
 public static bool TryGetAtom(SourceSpan name, out SymbolAtom atom) =>
 TryGetAtom(name.ToString(), name, out atom);
Example #4
0
 public FencedAtom(SourceSpan source, Atom baseAtom, SymbolAtom leftDelimeter, SymbolAtom rightDelimeter)
     : base(source)
 {
     this.BaseAtom       = baseAtom ?? new RowAtom(null);
     this.LeftDelimeter  = leftDelimeter;
     this.RightDelimeter = rightDelimeter;
 }