summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2019-01-02 12:51:32 +0100
committerAleks Kissinger <aleks0@gmail.com>2019-01-02 12:51:32 +0100
commit21b62e2ea5b1b04838878732a60d4692f20d51d3 (patch)
treec02a9e976985b274b097dbc7a279ec1d2d432535 /src
parent317d5120c71ff0b68807b397b711a0f853657f43 (diff)
allow custom tex code via .tikzdefs
Diffstat (limited to 'src')
-rw-r--r--src/gui/latexprocess.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/gui/latexprocess.cpp b/src/gui/latexprocess.cpp
index 0e2185a..992886e 100644
--- a/src/gui/latexprocess.cpp
+++ b/src/gui/latexprocess.cpp
@@ -67,11 +67,6 @@ void LatexProcess::makePreview(QString tikz)
_output->appendPlainText("FOUND: " + pdflatex + "\n");
- // copy active *.tikzstyles file to preview dir
- if (!tikzit->styleFile().isEmpty() && QFile::exists(tikzit->styleFilePath())) {
- QFile::copy(tikzit->styleFilePath(), _workingDir.path() + "/" + tikzit->styleFile());
- }
-
// copy tikzit.sty to preview dir
QFile::copy(":/tex/sample/tikzit.sty", _workingDir.path() + "/tikzit.sty");
@@ -83,7 +78,22 @@ void LatexProcess::makePreview(QString tikz)
tex << "\\usepackage{tikzit}\n";
tex << "\\usepackage[graphics,active,tightpage]{preview}\n";
tex << "\\PreviewEnvironment{tikzpicture}\n";
- tex << "\\input{" + tikzit->styleFile() + "}\n";
+
+ // copy active *.tikzstyles file to preview dir
+ if (!tikzit->styleFile().isEmpty() && QFile::exists(tikzit->styleFilePath())) {
+ QFile::copy(tikzit->styleFilePath(), _workingDir.path() + "/" + tikzit->styleFile());
+ tex << "\\input{" + tikzit->styleFile() + "}\n";
+
+ // if there is a *.tikzdefs file with the same basename, copy and include it as well
+ QFileInfo fi(tikzit->styleFilePath());
+ QString defFile = fi.baseName() + ".tikzdefs";
+ QString defFilePath = fi.absolutePath() + "/" + defFile;
+ if (QFile::exists(defFilePath)) {
+ QFile::copy(defFilePath, _workingDir.path() + "/" + defFile);
+ tex << "\\input{" + defFile + "}\n";
+ }
+ }
+
tex << "\\begin{document}\n\n";
tex << tikz;
tex << "\n\n\\end{document}\n";