davidcarlisle / latexcgi

LaTeX server via perl cgi script, developed for learnlatex.org
https://davidcarlisle.github.io/latexcgi/
MIT License
32 stars 3 forks source link

Usage of snippets #11

Closed cpierquet closed 2 years ago

cpierquet commented 2 years ago

Hi -

Sorry for the certainly stupid question... but how does "snippets" works ? I'd like to share tex code, but I'd like to hide some parts of the code before "compile it"...

Tks-

davidcarlisle commented 2 years ago

this is really for bug reporting rather tha support requests but anyway there is an array of regex/code pairs which you can set in the runlatex config object with default value

runlatex.packageregex = [
    [ /\\includegraphics/,                    "\\usepackage[demo]{graphicx}\n"],
    [ /\\begin{equation|align|gather|flalign|\\DeclareMathOperator/,"\\usepackage{amsmath}\n"       ],
    [ /tikz|pgf/,                             "\\usepackage{tikz}\n"          ],
    [ /fancy/,                                "\\usepackage{fancyhdr}\n"      ],
    [ /addplot|axis/,                         "\\usepackage{pgfplots}\n"      ],
    [ /hyper|href|bookmark|\\url/,            "\\usepackage{hyperref}\n"      ],
    [ /\\newcolumntype/,                      "\\usepackage{array}\n"         ],
    [ /listing/,                              "\\usepackage{listings}\n"      ],
    [ /\\blind/,                              "\\usepackage{blindtext}\n"     ],
    [ /\\lipsum/,                             "\\usepackage{lipsum}\n"        ],
    [ /color/,                                "\\usepackage{xcolor}\n"        ],
    [ /pspicture/,                            "\\usepackage{pstricks}\n"      ]
];

If a line in the input matches a regexp, the specified code line (usually \usepackage{...}) is added to the preamble.

see

https://davidcarlisle.github.io/latexcgi/test-sk

(in this repo or simply view source) where the document adds siunitx to the list of packages selected