From ded7bde82c0a77c8cbb1c9c7f59d55c25e650dd8 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 23 Jul 2022 15:37:56 +0200 Subject: [PATCH] rv::presentation:: latex packages changeable --- pattern2.cpp | 6 +++--- rogueviz/presentation.cpp | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/pattern2.cpp b/pattern2.cpp index 8c5db16b..b7a5c0d7 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -2849,7 +2849,7 @@ EX namespace linepatterns { } ) ); - linepattern patTriRings("triangle grid: rings", 0xFFFFFF00, always_available, + EX linepattern patTriRings = linepattern("triangle grid: rings", 0xFFFFFF00, always_available, ALLCELLS( forCellIdEx(c2, i, c) { if(S3 == 4) c2 = (cellwalker(c, i) + wstep + 1).cpeek(); @@ -2858,14 +2858,14 @@ EX namespace linepatterns { } ) ); - linepattern patTriTree("triangle grid: tree edges", 0xFFFFFF00, always_available, + EX linepattern patTriTree = linepattern("triangle grid: tree edges", 0xFFFFFF00, always_available, ALLCELLS( cell *parent = ts::right_parent(c, curr_dist); if(gmatrix.count(parent)) gridlinef(V, C0, V * currentmap->adj(c, neighborId(c, parent)), C0, col, 2 + vid.linequality); ) ); - linepattern patTriOther("triangle grid: other edges", 0xFFFFFF00, always_available, + EX linepattern patTriOther = linepattern("triangle grid: other edges", 0xFFFFFF00, always_available, ALLCELLS( cell *parent = ts::right_parent(c, curr_dist); forCellIdEx(c2, i, c) if(curr_dist(c2) < curr_dist(c) && c2 != parent) diff --git a/rogueviz/presentation.cpp b/rogueviz/presentation.cpp index fd7b1c7d..0c9c8a4e 100644 --- a/rogueviz/presentation.cpp +++ b/rogueviz/presentation.cpp @@ -154,9 +154,21 @@ void show_picture(presmode mode, string s) { }); } +string latex_packages = + "\\usepackage{amsmath}\n" + "\\usepackage{amssymb}\n" + "\\usepackage{amsfonts}\n" + "\\usepackage{varwidth}\n" + "\\usepackage{amsfonts}\n" + "\\usepackage{enumitem}\n" + "\\usepackage{color}\n" + "\\usepackage{graphicx}\n" + "\\definecolor{remph}{rgb}{0,0.5,0}\n" + "\\renewcommand{\\labelitemi}{{\\color{remph}$\\blacktriangleright$}}\n"; + string gen_latex(presmode mode, string s, int res, flagtype flags) { unsigned hash = 0; - for(char c: s) hash = (hash << 3) ^ hash ^ c ^ flags; + for(char c: latex_packages + s) hash = (hash << 3) ^ hash ^ c ^ flags; string filename = format("latex-cache/%08X.png", hash); if(mode == pmStartAll) { if(!file_exists(filename)) { @@ -164,14 +176,12 @@ string gen_latex(presmode mode, string s, int res, flagtype flags) { FILE *f = fopen("latex-cache/rogueviz-latex.tex", "w"); fprintf(f, "\\documentclass[border=2pt]{standalone}\n" - "\\usepackage{amsmath}\n" - "\\usepackage{varwidth}\n" - "\\usepackage{color}\n" + "%s" "\\begin{document}\n" "\\begin{varwidth}{\\linewidth}\n" "%s" "\\end{varwidth}\n" - "\\end{document}\n", s.c_str()); + "\\end{document}\n", latex_packages.c_str(), s.c_str()); fclose(f); hr::ignore(system("cd latex-cache; pdflatex rogueviz-latex.tex")); string pngline =