将图片从 TikZiT 导入 LaTeX 并以 PDF 格式查看

将图片从 TikZiT 导入 LaTeX 并以 PDF 格式查看

我正在使用 TikZiT(见链接)绘制带点和边的图形。如果可能的话,如何将该图片转换为我的 LaTeX 文档的 pdf 版本。TikZiT 中的图片下方有一个代码,我将其复制粘贴到 LaTeX 文档中,但它没有以 pdf 格式显示图片,我不知道我在这里到底错过了什么。我只有\usepackage{tikz}LaTeX 文档的序言。

我复制粘贴到 LaTeX 的 TikZiT 代码示例:

\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
    \node [style=newstyle] (0) at (0, -0) {};
    \node [style=newstyle] (1) at (0, 0.5) {};
    \node [style=newstyle] (2) at (0.5, 0.5) {};
    \node [style=newstyle] (3) at (1, 0.5) {};
    \node [style=newstyle] (4) at (0.5, -0) {};
    \node [style=newstyle] (5) at (1, -0) {};
    \node [style=newstyle] (6) at (1, 0.5) {};
    \node [style=newstyle] (7) at (1, -0) {};
    \node [style=newstyle] (8) at (1, 0.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
    \draw [style=simple] (3) to (5);
    \draw [style=simple] (5) to (1);
    \draw [style=simple] (3) to (0);
    \draw [style=simple] (2) to (4);
\end{pgfonlayer}
\end{tikzpicture}
/* picture in TikZiT represents six nodes and few lines connecting them /*

答案1

好的。我编译并安装了 TiKZit,以便检索其余的默认前导码。我唯一不知道的是的定义newstyle应该是什么。我想这是你自己的。在这里,我只是把它做成了与 相同,simple但用绿色而不是黑色。

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{shapes.geometric}
\pagestyle{empty}

\pgfdeclarelayer{edgelayer}
\pgfdeclarelayer{nodelayer}
\pgfsetlayers{edgelayer,nodelayer,main}

\tikzstyle{none}=[inner sep=0pt]

\tikzstyle{rn}=[circle,fill=Red,draw=Black,line width=0.8 pt]
\tikzstyle{gn}=[circle,fill=Lime,draw=Black,line width=0.8 pt]
\tikzstyle{yn}=[circle,fill=Yellow,draw=Black,line width=0.8 pt]

\tikzstyle{simple}=[-,draw=Black,line width=2.000]
\tikzstyle{arrow}=[-,draw=Black,postaction={decorate},decoration={markings,mark=at position .5 with {\arrow{>}}},line width=2.000]
\tikzstyle{tick}=[-,draw=Black,postaction={decorate},decoration={markings,mark=at position .5 with {\draw (0,-0.1) -- (0,0.1);}},line width=2.000]

% this are just for tikzit's display, I think
% \usepackage[graphics,tightpage,active]{preview}
% \PreviewEnvironment{tikzpicture}
% \newlength{\imagewidth}
% \newlength{\imagescale}

\tikzstyle{newstyle}=[% this is a custom style - you need to replace with whatever definition you are using
  -,draw=Green,line width=2.000]

\begin{document}

  \begin{tikzpicture}
    \begin{pgfonlayer}{nodelayer}
      \node [style=newstyle] (0) at (0, -0) {};
      \node [style=newstyle] (1) at (0, 0.5) {};
      \node [style=newstyle] (2) at (0.5, 0.5) {};
      \node [style=newstyle] (3) at (1, 0.5) {};
      \node [style=newstyle] (4) at (0.5, -0) {};
      \node [style=newstyle] (5) at (1, -0) {};
      \node [style=newstyle] (6) at (1, 0.5) {};
      \node [style=newstyle] (7) at (1, -0) {};
      \node [style=newstyle] (8) at (1, 0.5) {};
    \end{pgfonlayer}
    \begin{pgfonlayer}{edgelayer}
      \draw [style=simple] (3) to (5);
      \draw [style=simple] (5) to (1);
      \draw [style=simple] (3) to (0);
      \draw [style=simple] (2) to (4);
    \end{pgfonlayer}
  \end{tikzpicture}

\end{document}

6 节点图

答案2

您需要声明图层和两个缺失的样式。不确定样式定义应该是什么,所以我只是将它们设置为绘制thick线条:

在此处输入图片描述

代码:

\documentclass{article}
\usepackage{tikz}

%% -------------------------------------- Declare the layers
\pgfdeclarelayer{nodelayer}
\pgfdeclarelayer{edgelayer}
\pgfsetlayers{edgelayer,nodelayer,main}

%% -------------------------------------- Declare the styles
\tikzset{newstyle/.style={thick}}
\tikzset{simple/.style={thick}}

\begin{document}

\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
    \node [style=newstyle] (0) at (0, -0) {};
    \node [style=newstyle] (1) at (0, 0.5) {};
    \node [style=newstyle] (2) at (0.5, 0.5) {};
    \node [style=newstyle] (3) at (1, 0.5) {};
    \node [style=newstyle] (4) at (0.5, -0) {};
    \node [style=newstyle] (5) at (1, -0) {};
    \node [style=newstyle] (6) at (1, 0.5) {};
    \node [style=newstyle] (7) at (1, -0) {};
    \node [style=newstyle] (8) at (1, 0.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
    \draw [style=simple] (3) to (5);
    \draw [style=simple] (5) to (1);
    \draw [style=simple] (3) to (0);
    \draw [style=simple] (2) to (4);
\end{pgfonlayer}
\end{tikzpicture}

\end{document}

相关内容