def latex(self, **kwargs): inner_str = NumberSet.latex(self, **kwargs) # only fence if forceFence=True (nested exponents is an # example of when fencing must be forced) kwargs['fence'] = (kwargs['forceFence'] if 'forceFence' in kwargs else False) return maybeFencedString(inner_str, **kwargs)
def formatted(self, formatType, **kwargs): # begin building the inner_str inner_str = self.base.formatted(formatType, fence=True, forceFence=True) if self.getStyle('exponent') == 'raised': inner_str = ( inner_str + r'^{'+self.exponent.formatted(formatType, fence=False) + '}') elif self.getStyle('exponent') == 'radical': if self.exponent == frac(one, two): if formatType == 'string': inner_str = ( r'sqrt(' + self.base.formatted(formatType, fence=True, forceFence=True) + ')') elif formatType == 'latex': inner_str = ( r'\sqrt{' + self.base.formatted(formatType, fence=True, forceFence=True) + '}') else: raise ValueError("Unkown radical type, exponentiating to the power " "of %s"%str(self.exponent)) # only fence if forceFence=True (nested exponents is an # example of when fencing must be forced) kwargs['fence'] = ( kwargs['forceFence'] if 'forceFence' in kwargs else False) return maybeFencedString(inner_str, **kwargs)
def formatted(self, formatType, **kwargs): inner_str = self.base.formatted( formatType, forceFence=True) + r'^{' + self.exponent.formatted( formatType, fence=False) + '}' # only fence if forceFence=True (nested exponents is an example of when fencing must be forced) kwargs['fence'] = kwargs[ 'forceFence'] if 'forceFence' in kwargs else False return maybeFencedString(inner_str, **kwargs)
def string(self, **kwargs): return maybeFencedString('-' + self.operand.string(fence=True), **kwargs)