我尝试使用在线建议将 tikz 实现到 texmaker 和 Miktex 组合中。Miktex 已更新,texmaker 正常运行。流程示例中的 tikz 版本运行正常,但会产生大量空白。我有两个问题,首先,我的简单代码没有生成任何 pdf,编译不断进行,除非我手动结束,否则不会结束
我已经将 latex 和 pdf latex 的 texmaker 设置更改为
latex -interaction=nonstopmode --shell-escape %.tex
pdflatex -synctex=1 -interaction=nonstopmode --shell-escape %.tex
我想将 tikz 图片单独制作成 pdf 并保存它们,然后将它们包含在主 tex 文件中。我对 latex 有一些经验,但对 tikz 则不太熟悉,所以想知道是否有人能帮助我更好地了解我的问题。
下面是代码
\documentclass{article}
\usepackage[utf8]{inputenc}
%\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/]
% \pgfplotsset{compat=1.8}
% \pgfrealjobname{trial}
\tikzsetnextfilename{raju1}
% code for defining the flow diagram controls
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}%[node distance =2cm]
% Process informatioan and flow
%\node (start) [startstop] {Atmosphere}
\node (in1) [io] {Atmosphere}
\node (pro1) [process, below of =in1] {Sensor/Transducer}
\node (pro2) [process, below of =pro1] {Signal Conditioning circuits}
\node (pro3) [process, below of =pro2] {Low Pass Filter}
\node (dec1) [decision, below of =pro3,yshift=0.5cm] {Sample and Hold - Clock timing}
\node (pro4) [process, below of =dec1] {Analog to Digital converter}
\node (pro5) [process, below of =pro4] {Processor}
\node (out1) [io, below of= pro5] {Observation}
% Drawing of arrows
\draw [arrow] (inl) -- (pro1)
\draw [arrow] (pro1) -- (pro2)
\draw [arrow] (pro2) -- (pro3)
\draw [arrow] (pro3) -- (dec1)
\draw [arrow] (dec1) -- (pro4)
\draw [arrow] (pro4) -- (pro5)
\draw [arrow] (pro5) -- (out1)
\end{tikzpicture}
\end{document}
谢谢 Ashim
答案1
调试 externalized 的第一步tikzpicture
是确保它们在没有 externalization 的情况下也能正常工作。当我注释掉所有与 externalization 相关的代码时,您的示例显示了几个错误:
\draw
每个、\node
、等的结尾都\path
需要一个分号,并且- 第一
\draw
行有拼写错误,节点名称in1
不是inl
。
另外,我更新了您的代码
- 使用
\tikzset
,现在比旧的更受欢迎\tikzstyle
, - 使用
positioning
库和相关=of
语法实现更好的定位,并且 - 使用
0.75cm
node distance
以便整个图表适合一页。
后纠正这些错误并进行改进后,我重新将外部化引入其中。我注意到的一件事是,即使使用--enable-write18
/ --shell-escape
,LaTeX 运行也不会tikz/
自行创建前缀目录。也就是说,如果目录不存在,我会收到错误
! I can't write on file `tikz/raju1.md5'.
创建tikz/
前缀目录后,外部化图形的编译就可以顺利进行。
修正后的代码
\documentclass{article}
\usepackage[utf8]{inputenc}
%\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows,positioning}
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/]
% \pgfplotsset{compat=1.8}
% \pgfrealjobname{trial}
\tikzsetnextfilename{raju1}
% code for defining the flow diagram controls
\tikzset{
startstop/.style = {rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30},
io/.style = {trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style = {rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30},
decision/.style = {diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style = {thick,->,>=stealth},
}
\begin{document}
\begin{tikzpicture}[node distance =0.75cm]
% Process informatioan and flow
%\node (start) [startstop] {Atmosphere}
\node (in1) [io] {Atmosphere};
\node (pro1) [process, below=of in1] {Sensor/Transducer};
\node (pro2) [process, below=of pro1] {Signal Conditioning circuits};
\node (pro3) [process, below=of pro2] {Low Pass Filter};
\node (dec1) [decision, below=of pro3,yshift=0.5cm] {Sample and Hold - Clock timing};
\node (pro4) [process, below=of dec1] {Analog to Digital converter};
\node (pro5) [process, below=of pro4] {Processor};
\node (out1) [io, below=of pro5] {Observation};
% Drawing of arrows
\draw [arrow] (in1) -- (pro1); % typo...
\draw [arrow] (pro1) -- (pro2);
\draw [arrow] (pro2) -- (pro3);
\draw [arrow] (pro3) -- (dec1);
\draw [arrow] (dec1) -- (pro4);
\draw [arrow] (pro4) -- (pro5);
\draw [arrow] (pro5) -- (out1);
\end{tikzpicture}
\end{document}
输出