From b78add424b9bd864f0ff74ef637c1e4aa175ced0 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Wed, 13 Mar 2024 18:36:09 +0100 Subject: [PATCH] LaTeX: Allow to pass imports --- packages/myst-cli/src/build/tex/single.ts | 8 +++++++- packages/myst-frontmatter/src/exports/types.ts | 1 + packages/myst-to-tex/src/types.ts | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/myst-cli/src/build/tex/single.ts b/packages/myst-cli/src/build/tex/single.ts index bb9942fc7..3a11a2b1d 100644 --- a/packages/myst-cli/src/build/tex/single.ts +++ b/packages/myst-cli/src/build/tex/single.ts @@ -197,7 +197,7 @@ export async function localArticleToTexTemplated( templateOptions: ExportWithOutput, opts?: ExportFnOptions, ): Promise { - const { output, articles, template } = templateOptions; + const { output, articles, template, imports } = templateOptions; const { projectPath, extraLinkTransformers, clean, ci } = opts ?? {}; const filesPath = path.join(path.dirname(output), 'files'); const fileArticles = articlesWithFile(articles); @@ -242,6 +242,12 @@ export async function localArticleToTexTemplated( const partDefinitions = templateYml?.parts || []; const parts: Record = {}; let collectedImports: TexTemplateImports = { imports: [], commands: {} }; + // First get the imports from the options + if (imports) { + imports.forEach((item) => { + collectedImports.imports.push(item); + }); + } let preambleData: PreambleData = { hasProofs: false, printGlossaries: false, diff --git a/packages/myst-frontmatter/src/exports/types.ts b/packages/myst-frontmatter/src/exports/types.ts index 30d6831f5..41c58a8df 100644 --- a/packages/myst-frontmatter/src/exports/types.ts +++ b/packages/myst-frontmatter/src/exports/types.ts @@ -22,6 +22,7 @@ export type Export = { output?: string; toc?: string; articles?: ExportArticle[]; + imports?: string[]; /** sub_articles are only for jats xml export */ sub_articles?: string[]; /** MECA: to, from later */ diff --git a/packages/myst-to-tex/src/types.ts b/packages/myst-to-tex/src/types.ts index f3bf7f862..a69065f38 100644 --- a/packages/myst-to-tex/src/types.ts +++ b/packages/myst-to-tex/src/types.ts @@ -25,6 +25,7 @@ export type LatexResult = { export type MathPlugins = Required['math']; export type Options = MystToTexSettings & { + imports?: string[]; handlers?: Record; math?: MathPlugins; bibliography?: 'natbib' | 'biblatex';