diff --git a/sources/print.ts b/sources/print.ts index 17477d4a..1c21b654 100644 --- a/sources/print.ts +++ b/sources/print.ts @@ -1326,12 +1326,22 @@ function print_power(base: BaseAtom, exponent: BaseAtom) { accumulator += print_str('('); accumulator += print_expr(base); accumulator += print_str(')'); - } else if (ismultiply(base) || ispower(base)) { - if (defs.printMode !== PRINTMODE_LATEX) { + } else if (ismultiply(base)) { + accumulator += print_str('('); + accumulator += print_factor(base, true); + accumulator += print_str(')'); + } else if (ispower(base)) { + if (defs.printMode == PRINTMODE_LATEX) { + accumulator += print_str('{'); + } + else { accumulator += print_str('('); } accumulator += print_factor(base, true); - if (defs.printMode !== PRINTMODE_LATEX) { + if (defs.printMode == PRINTMODE_LATEX) { + accumulator += print_str('}'); + } + else { accumulator += print_str(')'); } } else if (