Skip to content

issue with custom preamble for math preview #1545

Open
@nicolaslesquoy

Description

@nicolaslesquoy

Hello, I want to use with the math preview feature the following macros that use in almost all my documents :

\begingroup
    \def\tmpa#1{%
        \if\relax#1 \expandafter\noexpand \else
            \expandafter\gdef\csname double#1\endcsname{\mathbb #1} %
            \expandafter\gdef\csname script#1\endcsname{\mathcal #1} %
			\expandafter\gdef\csname frak#1\endcsname{\mathfrak #1} %
            \expandafter\gdef\csname cal#1\endcsname{\mathscr #1} %
        \fi \tmpa
    }
    \tmpa ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\relax
\endgroup

I wrote it in the LaTeXTools.sublime-settings file as :

// An array of the used packages, from which the file for the live preview
	// will be generated.
	// Just write \\usepackage{packagename} to include other packages.
	// (The xcolor package will be present, even if not in this list.)
	"preview_math_template_packages": [
		"\\usepackage{amsmath}",
		"\\usepackage{amssymb}",
		"\\IfFileExists{mathrsfs.sty}{\\usepackage{mathrsfs}}{}",
		"\\IfFileExists{mathtools.sty}{\\usepackage{mathtools}}{}",
		"\\IfFileExists{esvect.sty}{\\usepackage[g]{esvect}}{}",
		"\\IfFileExists{latexsym.sty}{\\usepackage{latexsym}}{}",
		"\\IfFileExists{mathtools.sty}{\\usepackage{mathtools}}{}"
	],

	// An string of the remaining preamble (not packages) for the file,
	// which generates the math live preview.
	// Can also be an array, with an string for each line (as in the packages).
	// For technical reasons DON'T include other files.
	"preview_math_template_preamble": [
		"\\begingroup\\def\\tpmab#1{\\if\\relax#1\\expandafter\\noexpand\\else\\expandafter\\gdef\\csname double#1\\endcsname{\\mathbb #1}}\\tmpab ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\\relax\\endgroup",
		"\\begingroup\\def\\tpmac#1{\\if\\relax#1\\expandafter\\noexpand\\else\\expandafter\\gdef\\csname script#1\\endcsname{\\mathcal #1}}\\tmpac ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\\relax\\endgroup",
		"\\begingroup\\def\\tpmaf#1{\\if\\relax#1\\expandafter\\noexpand\\else\\expandafter\\gdef\\csname frak#1\\endcsname{\\mathfrak #1}}\\tmpaf ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\\relax\\endgroup",
		"\\begingroup\\def\\tpmasc#1{\\if\\relax#1\\expandafter\\noexpand\\else\\expandafter\\gdef\\csname cal#1\\endcsname{\\mathscr #1}}\\tmpasc ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\\relax\\endgroup",
	],

Those modifications are not used when I type in a math environnement for instance \scriptC instead of mathcal{C}.
Thank you in advance for any advice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions