Skip to content

Commit 463f79c

Browse files
committed
feat: serialize Trace
1 parent ca0c7da commit 463f79c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ export const DEFINITIONS_LINEAR_ALGEBRA: LatexDictionary = [
232232
kind: 'function',
233233
latexTrigger: '\\tr',
234234
arguments: 'implicit',
235+
serialize: (serializer: Serializer, expr: Expression): string => {
236+
const arg = operand(expr, 1);
237+
const argLatex = serializer.serialize(arg);
238+
// Use \tr A for simple args, \tr\left(...\right) for complex ones
239+
if (typeof arg === 'string' || typeof arg === 'number')
240+
return `\\tr ${argLatex}`;
241+
return `\\tr\\left(${argLatex}\\right)`;
242+
},
235243
},
236244

237245
// Also support plain text: tr(A)

0 commit comments

Comments
 (0)