From b703296cf7b671ca8049438804e612fc7a4e055a Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Wed, 2 Jan 2019 12:10:40 +0100 Subject: updated tikzit.sty to only apply scaling if included by \tikzfig or passed the [tikzfig] style --- tex/sample/sample.tex | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tex/sample/sample.tex') diff --git a/tex/sample/sample.tex b/tex/sample/sample.tex index 57ba88c..bbb20e0 100644 --- a/tex/sample/sample.tex +++ b/tex/sample/sample.tex @@ -5,6 +5,8 @@ \begin{document} +This is a demonstration of \texttt{tikzit.sty}, which provides some convenience macros for including \texttt{.tikz} files generated by TikZiT. Note this file is optional, however if you choose to omit it from your \LaTeX{} source, you should at least declare the layers, dummy properties, and \texttt{none} style from \texttt{tikzit.sty} for TikZiT figures to build correctly. + A centered tikz picture: \ctikzfig{fig} @@ -14,5 +16,24 @@ A tikz picture as part of mathematics: \tikzfig{fig} \end{equation} +It is also possible to paste a \texttt{tikzpicture} directly from TikZiT, without using the \texttt{$\backslash$tikzfig} macro. In that case, the \texttt{tikzfig} option should be given to the \texttt{tikzpicture} environment to get the same baseline and scaling as the other figures: +\[ +\begin{tikzpicture}[tikzfig] + \begin{pgfonlayer}{nodelayer} + \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}; + \end{pgfonlayer} + \begin{pgfonlayer}{edgelayer} + \draw [in=-90, out=0] (3.center) to (1.center); + \draw [bend right=45, looseness=1.25] (3.center) to (2.center); + \draw (2.center) to (0.center); + \draw (0.center) to (1.center); + \end{pgfonlayer} +\end{tikzpicture} +\] + + \end{document} -- cgit v1.2.3 From 317d5120c71ff0b68807b397b711a0f853657f43 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Wed, 2 Jan 2019 12:31:22 +0100 Subject: copy added [tikzfig] style by default --- src/data/graph.cpp | 1 + tex/sample/figures/fig.tikz | 10 +++++----- tex/sample/sample.tex | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'tex/sample/sample.tex') diff --git a/src/data/graph.cpp b/src/data/graph.cpp index da7b345..1dd5574 100644 --- a/src/data/graph.cpp +++ b/src/data/graph.cpp @@ -279,6 +279,7 @@ Graph *Graph::copyOfSubgraphWithNodes(QSet nds) { Graph *g = new Graph(); g->setData(_data->copy()); + g->data()->setAtom("tikzfig"); QMap nodeTable; foreach (Node *n, nodes()) { if (nds.contains(n)) { diff --git a/tex/sample/figures/fig.tikz b/tex/sample/figures/fig.tikz index e485d9f..b7074a8 100644 --- a/tex/sample/figures/fig.tikz +++ b/tex/sample/figures/fig.tikz @@ -1,4 +1,4 @@ -\begin{tikzpicture} +\begin{tikzpicture}[tikzfig] \begin{pgfonlayer}{nodelayer} \node [style=red node] (0) at (0, 1) {}; \node [style=blue node 2] (1) at (1, 0) {}; @@ -6,9 +6,9 @@ \node [style=yellow square] (3) at (0, -1) {foo}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} - \draw [in=-90, out=0] (3.center) to (1.center); - \draw [bend right=45, looseness=1.25] (3.center) to (2.center); - \draw (2.center) to (0.center); - \draw (0.center) to (1.center); + \draw [in=-90, out=0] (3) to (1); + \draw [bend right] (3) to (2); + \draw (2) to (0); + \draw (0) to (1); \end{pgfonlayer} \end{tikzpicture} diff --git a/tex/sample/sample.tex b/tex/sample/sample.tex index bbb20e0..1b10cf6 100644 --- a/tex/sample/sample.tex +++ b/tex/sample/sample.tex @@ -26,10 +26,10 @@ It is also possible to paste a \texttt{tikzpicture} directly from TikZiT, withou \node [style=yellow square] (3) at (0, -1) {foo}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} - \draw [in=-90, out=0] (3.center) to (1.center); - \draw [bend right=45, looseness=1.25] (3.center) to (2.center); - \draw (2.center) to (0.center); - \draw (0.center) to (1.center); + \draw [in=-90, out=0] (3) to (1); + \draw [bend right] (3) to (2); + \draw (2) to (0); + \draw (0) to (1); \end{pgfonlayer} \end{tikzpicture} \] -- cgit v1.2.3 From 21b62e2ea5b1b04838878732a60d4692f20d51d3 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Wed, 2 Jan 2019 12:51:32 +0100 Subject: allow custom tex code via .tikzdefs --- src/gui/latexprocess.cpp | 22 ++++++++++++++++------ tex/sample/figures/fig.tikz | 2 +- tex/sample/sample.tex | 2 +- tex/sample/sample.tikzdefs | 6 ++++++ tex/sample/sample.tikzstyles | 6 +++--- 5 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 tex/sample/sample.tikzdefs (limited to 'tex/sample/sample.tex') 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 -- cgit v1.2.3