我想用 LaTeX 为我的论文大纲准备一个流程图,如下图所示。我试图改编以下代码,但在安排 C、D 和 E 时遇到了困难。我想知道是否有人可以帮助我?提前谢谢!
編輯:
\begin{figure}
\centering
\begin{tikzpicture}[node distance=1.5cm]
\node (introduction) [structure] {Thesis};
\node (methodology) [structure, below =1.5cm of introduction] {A};
\node (theoretical) [structure, below =1.5cm of methodology] {B};
\node (model) [structure, below of=theoretical] {C};
\node (interviews) [structure, below of=model] {D};
\node (results) [structure, below of=interviews] {E};
\node (discussion) [structure, below =of results] {F};
%arrows
\draw [arrow] (introduction) -- (methodology);
\draw [arrow] (methodology) -- (theoretical);
\draw [arrow] (theoretical) -- (model);
\draw [arrow] (model) -- (interviews);
\draw [arrow] (interviews) -- (results);
\draw [arrow] (results) -- (discussion);
\end{tikzpicture}
\caption{OUTLINE}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%
答案1
的宽度B
非常手动,但对于这个简单的例子来说并不太复杂。
代码
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta, chains, ext.paths.ortho}
\begin{document}
\begin{tikzpicture}[
node distance = 10mm and 5mm,
box/.style = {
rectangle, draw, font=\strut, minimum width=25mm, minimum height=10mm},
boxie/.style = {box, minimum width=15mm},
arr/.style = -Triangle,
start chain = ch going below, every join/.append style=arr]
\node[box, on chain] {Thesis};
\node[box, on chain, join] {A};
\node[box, on chain, join, minimum width = 3*15mm + 2*5mm + 2\pgflinewidth] {B};
\node[boxie, on chain, join] {D};
\scoped[start branch=left going base left]
\node[boxie, on chain, join=with ch-3 by only vertical second]{C};
\scoped[start branch=right going base right]
\node[boxie, on chain, join=with ch-3 by only vertical second]{E};
\node[box, on chain, join,
join=with ch/left-end by vertical horizontal,
join=with ch/right-end by vertical horizontal] {F};
\end{tikzpicture}
\end{document}
输出
答案2
嗯,语法似乎有点错误。所以我决定展示其中的一些内容和 LaTeX 中的一些选项,而不是修复您的代码。基本主题:
- 至少通过绝对坐标定位第一个音符
- 在示例中,我也通过绝对坐标放置了第二个
- 使用相对定位更方便,这里通过
below
和left
right
- 我稍微改变了方法论之后的箭头
- 你可以像 Th.c 那样做所有的事情,而且看起来会很好
- Th.d 向您展示了一些其他连接点;您也可以在绝对坐标中移动它们
- Th.c to Results 模仿你的草图
- 另一边弯道看起来是这样的
因此,如果你还没有完成,请花一些时间阅读https://www.ctan.org/pkg/pgf。
\documentclass[10pt,border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}% needed for relative positioning
\begin{document}
% demonstarting some choices
\tikz{
% ~~~ nodes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% absolute coordinates
\node [draw] (T) at (0,0) {Thesis};% [draw] will draw the box around the node
\node [draw] (A) at (0, -1) {Introduction};
% relative coordinates from now on
\node [draw] (B) [below=of A] {Methodology};
\node [draw] (D) [below=of B] {Theoretical d};
\node [draw] (C) [left=of D] {Theoretical c};
\node [draw] (E) [right=of D] {Theoretical e};
\node [draw] (F) [below=of D] {Results};
% ~~~ arrows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\draw [->] (T) -- (A);% straight
\draw [->] (A) -- (B);
\draw [->] (B) -- (D);
\draw [->] (D) -- (F);
\draw [->] (B) -- (C);
\draw [->] (B.east) -- (E.north east);
\draw [->] (C) |- (F);% first down, then horizontally
\draw [->] (E) to [bend left] (F);
}
\end{document}
答案3
我创建了一些东西,可以作为起点。这可能不是真正的巫师解决问题的方法,但它确实有效。
在序言中我必须写类似的东西
\usetikzlibrary{positioning,shapes,shadows,arrows,calc,arrows.meta}
\tikzstyle{structure} = [rectangle, minimum width=3cm, minimum height=1cm, align=center, text width=2.5cm, draw=black, very thick]
\tikzstyle{arrow}=[-,ultra thick,{-Stealth[]}]
通过这些定义,以下代码可以生成与您的有些相似的绘图:
\begin{tikzpicture}[node distance=1.5cm]
\node (introduction) [structure] {Thesis};
\node (methodology) [structure, below of=introduction, yshift=-0.5cm] {A};
\node (theoretical) [structure, below of=methodology, yshift=-0.5cm] {B};
\node (model) [structure, below of=theoretical, xshift=-4cm, yshift=-0.5cm] {C};
\node (interviews) [structure, right of=model, xshift=2.5cm] {D};
\node (results) [structure, right of=interviews, xshift=3cm] {E};
\node (discussion) [structure, below of=interviews, yshift=(-0.5cm)] {F};
%lines
\draw [arrow] (introduction.south) -- (methodology.north);
\draw [arrow] (methodology.south) -- (theoretical.north);
\draw [arrow] ($(theoretical.south west)!.3!(theoretical.south)$) -- ++(0.0,-0.5) -| (model.north);
\draw [arrow] (theoretical.south) -- ++(0,-0.5) -| (interviews.north);
\draw [arrow] ($(theoretical.south)!.7!(theoretical.south east)$) -- ++(0.0,-0.5) -| (results.north);
\draw [arrow] (model.east) -- (interviews.west);
\draw [arrow] (interviews.east) -- (results.west);
\draw [arrow] (model.south) -- ++(0.0,-0.5)-| ($(discussion.north west)!.3!(discussion.north)$);
\draw [arrow] (interviews) -- ++(0,-1) -| (discussion);
\draw [arrow] (results) -- ++(0,-1) -| ($(discussion.north)!.7!(discussion.north east)$);
\end{tikzpicture}