summaryrefslogtreecommitdiff
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
parent317d5120c71ff0b68807b397b711a0f853657f43 (diff)
allow custom tex code via .tikzdefs
-rw-r--r--src/gui/latexprocess.cpp22
-rw-r--r--tex/sample/figures/fig.tikz2
-rw-r--r--tex/sample/sample.tex2
-rw-r--r--tex/sample/sample.tikzdefs6
-rw-r--r--tex/sample/sample.tikzstyles6
5 files changed, 27 insertions, 11 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";
diff --git a/tex/sample/figures/fig.tikz b/tex/sample/figures/fig.tikz
index b7074a8..f454de2 100644
--- a/tex/sample/figures/fig.tikz
+++ b/tex/sample/figures/fig.tikz
@@ -3,7 +3,7 @@
\node [style=red node] (0) at (0, 1) {};
\node [style=blue node 2] (1) at (1, 0) {};
\node [style=blue node] (2) at (-1, 0) {};
- \node [style=yellow square] (3) at (0, -1) {foo};
+ \node [style=yellow square] (3) at (0, -1) {\anglevec{\alpha}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [in=-90, out=0] (3) to (1);
diff --git a/tex/sample/sample.tex b/tex/sample/sample.tex
index 1b10cf6..c6fb3ca 100644
--- a/tex/sample/sample.tex
+++ b/tex/sample/sample.tex
@@ -1,7 +1,7 @@
\documentclass{article}
\usepackage{tikzit}
\input{sample.tikzstyles}
-
+\input{sample.tikzdefs}
\begin{document}
diff --git a/tex/sample/sample.tikzdefs b/tex/sample/sample.tikzdefs
new file mode 100644
index 0000000..ac25b5a
--- /dev/null
+++ b/tex/sample/sample.tikzdefs
@@ -0,0 +1,6 @@
+% Optional: use this file for definitions that should be used by TikZiT to generate
+% LaTeX preview. It can also be included in the paper.
+
+\usepackage{bm}
+
+\newcommand{\anglevec}[1]{\ensuremath{\vec{\bm{#1}}}}
diff --git a/tex/sample/sample.tikzstyles b/tex/sample/sample.tikzstyles
index df70248..5790de1 100644
--- a/tex/sample/sample.tikzstyles
+++ b/tex/sample/sample.tikzstyles
@@ -4,9 +4,9 @@
% \tikzstyle{NAME}=[PROPERTY LIST]
% Node styles
-\tikzstyle{red node}=[fill=red, tikzit category=nodes]
-\tikzstyle{blue node}=[fill=blue]
-\tikzstyle{blue node 2}=[tikzit fill=green, fill=blue]
+\tikzstyle{red node}=[fill=red, tikzit category=nodes, shape=circle, draw=black]
+\tikzstyle{blue node}=[fill=blue, shape=circle, draw=black]
+\tikzstyle{blue node 2}=[tikzit fill=green, fill=blue, shape=circle, draw=black]
\tikzstyle{yellow square}=[draw=black, fill=yellow, shape=rectangle]
% Edge styles