我正在绘制流程图。菱形节点显示不正确。我的最小工作示例如下。ShareLaTeX 没有问题,但它在我的计算机上不起作用。
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows, fit}
\tikzstyle{decision} = [diamond, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, inner sep=1pt, fill=green!10]
\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=2cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered,text width=5cm, draw=black, fill=orange!30]
\tikzstyle{endloop} = [ellipse, minimum width=2cm, minimum height=1cm, text centered, text width=3cm, draw=black, inner sep=1pt]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture} [node distance=2cm]
\node [input, name=input] {};
\node(dec1)[decision, below of=input]{$Round <= Limit$};
\end{tikzpicture}
\end{document}
我的电脑上的输出:
ShareLaTeX 的输出:
答案1
- 我无法重现你的问题,完成你的 mwe 后,它工作正常
- 您使用一个旧的定义(带有过时的
tizstyle
语法)来定义流程图的节点样式。我建议更新它,就像下面 mwe 中所使用的一样(从我的这里):
\documentclass[border=3mm,
tikz]{standalone}
\usetikzlibrary{arrows.meta,
calc, chains,
quotes,
positioning,
shapes.geometric}
\begin{document}
%---------------------------------------------------------------%
\begin{tikzpicture}[
node distance = 8mm and 16mm,
start chain = A going below,
base/.style = {draw, minimum width=32mm, minimum height=8mm,
align=center, on chain=A},
startstop/.style = {base, rectangle, rounded corners, fill=red!30},
process/.style = {base, rectangle, fill=orange!30},
io/.style = {base, trapezium,
trapezium left angle=70, trapezium right angle=110,
fill=blue!30},
decision/.style = {base, diamond, fill=green!30},
every edge quotes/.style = {auto=right}]
]
\node (dec1) [decision] {$Round <= Limit$};
\end{tikzpicture}
\end{document}
如果您希望在序言中使用流程图的节点样式(对于更多流程图,您可以按照以下方式执行此操作:
\documentclass[border=3mm, tikz]{standalone} \usetikzlibrary{arrows.meta, calc, chains, quotes, positioning, shapes.geometric} \tikzset{FlowChart/.style={ % <--- start chain = A going below, base/.style = {draw, minimum width=32mm, minimum height=8mm, align=center, on chain=A}, startstop/.style = {base, rectangle, rounded corners, fill=red!30}, process/.style = {base, rectangle, fill=orange!30}, io/.style = {base, trapezium, trapezium left angle=70, trapezium right angle=110, fill=blue!30}, decision/.style = {base, diamond, fill=green!30}, every edge quotes/.style = {auto=right} }% end of FlowChart styles } \begin{document} %---------------------------------------------------------------% \begin{tikzpicture}[FlowChart, % <--- node distance = 8mm and 16mm, ] \node(dec1)[decision]{$Round <= Limit$}; \end{tikzpicture} \end{document}
笔记:我认为将节点声明为坐标(用于输入和输出)没有任何好处。为此,
\coordinate
如果您真的需要,您可以简单地使用。- 您可以找到一个相对简单的流程图代码示例这里。
附录:
上述文档示例也适用于任何其他文档类别,不仅限于
standalone
。例如:\documentclass[ pdftex, oneside, Einseitiger Druck. 12pt, Schriftgroesse parskip=half, topmargin = 10pt, headheight = 33pt, headsepline, footsepline, footheight = 16pt, abstracton, DIV=calc, Satzspiegel berechnen BCOR=8mm, headinclude=false, footinclude=false, listof=totoc, toc=bibliography, ]{scrreprt} \usepackage{tikz} \usetikzlibrary{arrows.meta, calc, chains, quotes, positioning, shapes.geometric} \tikzset{FlowChart/.style={ % <--- start chain = A going below, base/.style = {draw, minimum width=32mm, minimum height=8mm, align=center, on chain=A}, startstop/.style = {base, rectangle, rounded corners, fill=red!30}, process/.style = {base, rectangle, fill=orange!30}, io/.style = {base, trapezium, trapezium left angle=70, trapezium right angle=110, fill=blue!30}, decision/.style = {base, diamond, fill=green!30}, every edge quotes/.style = {auto=right} }% end of FlowChart styles } \begin{document} %---------------------------------------------------------------% \begin{tikzpicture}[FlowChart, % <--- node distance = 8mm and 16mm, ] \node(dec1)[decision]{$Round <= Limit$}; \end{tikzpicture} \end{document}
给出的结果与之前的 mwe 相同。