我想用 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
andright
- 我在方法論之後稍微改變了箭頭
- 你可以像Th.c那樣做所有的事情,看起來就很好
- to 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}