Tikz:文本未在 Tikz 框内居中

Tikz:文本未在 Tikz 框内居中

我正在尝试使用 tikzpicture 包 (Mathcha) 构建流程图类型图表。为什么 Tikz 框内的文本不居中?提前致谢。

\begin{figure}[ht]
\vspace{4ex}
\centering
\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
%uncomment if require: \path (0,634); %set diagram left start at 0, and has height of 634

%Shape: Rectangle [id:dp08909796923277336] 
\draw  [line width=1.5]  (51,41) -- (609,41) -- (609,81) -- (51,81) -- cycle ;
%Shape: Rectangle [id:dp293971635997501] 
\draw  [line width=1.5]  (210,359.72) -- (520,359.72) -- (520,401.3) -- (210,401.3) -- cycle ;
%Shape: Rectangle [id:dp015112508692092352] 
\draw  [line width=1.5]  (190,210.2) -- (310,210.2) -- (310,250) -- (190,250) -- cycle ;
%Shape: Rectangle [id:dp9224449615071879] 
\draw  [line width=1.5]  (490,209.82) -- (610,209.82) -- (610,250.13) -- (490,250.13) -- cycle ;
%Straight Lines [id:da2085806199614264] 
\draw [line width=1.5]    (550,249.95) -- (550,379.8) -- (525,380.07) ;
\draw [shift={(521,380.12)}, rotate = 359.37] [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.08]  [draw opacity=0] (11.61,-5.58) -- (0,0) -- (11.61,5.58) -- cycle    ;
%Straight Lines [id:da6918276956657493] 
\draw [line width=1.5]    (180,81.59) -- (180,149.45) ;
%Straight Lines [id:da8143556798116779] 
\draw [line width=1.5]    (110,250.35) -- (110,310.21) -- (250,310.01) -- (250,249.93) ;
%Straight Lines [id:da6498353350246521] 
\draw [line width=1.5]    (180,310.11) -- (180,379.97) -- (205,380.35) ;
\draw [shift={(209,380.42)}, rotate = 180.89] [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.08]  [draw opacity=0] (11.61,-5.58) -- (0,0) -- (11.61,5.58) -- cycle    ;
%Shape: Rectangle [id:dp6903312621520653] 
\draw  [line width=1.5]  (50,210.2) -- (170,210.2) -- (170,250) -- (50,250) -- cycle ;
%Straight Lines [id:da6819495654480933] 
\draw [line width=1.5]    (110,209.57) -- (110,149.57) -- (250,149.68) -- (250,209.87) ;
%Straight Lines [id:da4777805352746255] 
\draw [line width=1.5]    (400,81.72) -- (400,205.1) ;
\draw [shift={(400,209.1)}, rotate = 270] [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.08]  [draw opacity=0] (11.61,-5.58) -- (0,0) -- (11.61,5.58) -- cycle    ;
%Straight Lines [id:da6994702521621938] 
\draw [line width=1.5]    (480,310.37) -- (480,354.55) ;
\draw [shift={(480,358.55)}, rotate = 270] [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.08]  [draw opacity=0] (11.61,-5.58) -- (0,0) -- (11.61,5.58) -- cycle    ;
%Straight Lines [id:da5755824703070298] 
\draw [line width=1.5]    (400,250.37) -- (400,354.55) ;
\draw [shift={(400,358.55)}, rotate = 270] [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.08]  [draw opacity=0] (11.61,-5.58) -- (0,0) -- (11.61,5.58) -- cycle    ;
%Straight Lines [id:da11378713626826986] 
\draw [line width=1.5]    (550,81.72) -- (550,205.1) ;
\draw [shift={(550,209.1)}, rotate = 270] [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.08]  [draw opacity=0] (11.61,-5.58) -- (0,0) -- (11.61,5.58) -- cycle    ;
%Shape: Rectangle [id:dp2737101017997946] 
\draw  [line width=1.5]  (340,209.82) -- (460,209.82) -- (460,250.13) -- (340,250.13) -- cycle ;
%Shape: Rectangle [id:dp04718661092413878] 
\draw  [line width=1.5]  (430,270.07) -- (530,270.07) -- (530,309.88) -- (430,309.88) -- cycle ;
%Straight Lines [id:da40081723928825497] 
\draw [line width=1.5]    (400,290.1) -- (425,290.1) ;
\draw [shift={(429,290.1)}, rotate = 180] [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.08]  [draw opacity=0] (11.61,-5.58) -- (0,0) -- (11.61,5.58) -- cycle    ;

% Text Node
\draw (181,52) node [anchor=north west][inner sep=0.75pt]  [font=\normalsize] [align=center] {High Position on Alphabetically Ordered List};
% Text Node
\draw (348,222) node [anchor=north west][inner sep=0.75pt]  [font=\normalsize] [align=center] {Higher Visibility};
% Text Node
\draw (445,281) node [anchor=north west][inner sep=0.75pt]  [font=\normalsize] [align=center] {Familiarity};
% Text Node
\draw (57,222.18) node [anchor=north west][inner sep=0.75pt]  [font=\normalsize] [align=center] {Status quo bias};
% Text Node
\draw (251,371.18) node [anchor=north west][inner sep=0.75pt]  [font=\normalsize] [align=center] {Higher Trading Activity + Liquiditiy};
% Text Node
\draw (495,222) node [anchor=north west][inner sep=0.75pt]  [font=\normalsize] [align=center] {Superior Quality};
% Text Node
\draw (215,222.18) node [anchor=north west][inner sep=0.75pt]  [font=\normalsize] [align=center] {Satisficing};

\end{tikzpicture}
\end{figure}

在此处输入图片描述

答案1

节点中的文本未居中的原因实际上是,看起来像节点(黑色矩形)的东西实际上就是黑色矩形。然后使用没有边框的节点定位文本。遗憾的是,这些节点没有正确定位在矩形的中心。

我建议你不要使用某些软件产生的这种可怕的输出,而是尝试了解如何处理 TiZ 并自己画这个。我知道 TiZ/PGF 手册内容庞大,令人望而生畏,但其中也包含一些很好的教程,很好地解释了基本内容。只要慢慢来,就会受益匪浅,你很快就会熟悉语法。

所示示意图可绘制如下:

\documentclass[border=10pt]{standalone} 
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[
    x=1.75cm,
    y=1.75cm,
    line width=1pt,
    >=latex,
    every node/.style={
        rectangle,
        draw,
        inner ysep=10pt,
        text width=3cm,
        align=center,
    },
    narrow/.append style={
        text width=2cm,
    },
    wide/.append style={
        text width=7cm,
    },
    very wide/.append style={
        text width=13.5cm,
    },
]

\node[very wide] at (0,0) (a1) {\textbf{High Position on Alphabetically Ordered List}};

\node at (-3,-2) (b1) {Status quo bias};
\node at (-1,-2) (b2) {Satisficing};
\node at (1,-2) (b3) {Higher Visibility};
\node at (3,-2) (b4) {Superior Quality};

\node[narrow] at (2,-2.75) (c1) {Familiarity};

\node[wide] at (0.5,-4) (d1) {\textbf{Higher Trading Activity $+$ Liquidity}};

\draw (-2,-1 |- a1.south) -- (-2,-1);
\draw (-2,-1) -| (b1.north);
\draw (-2,-1) -| (b2.north);

\draw (b1.south) |- (-2,-3);
\draw (b2.south) |- (-2,-3);
\draw[->] (-2,-3) |- (d1.west);

\draw[->] (b3.north |- a1.south) -- (b3.north);
\draw[->] (b4.north |- a1.south) -- (b4.north);

\draw[->] (b3.south) -- (b3.south |- d1.north);
\draw[->] (b3.south |- c1.west) -- (c1.west);
\draw[->] (c1.south) -- (c1.south |- d1.north);
\draw[->] (b4.south) |- (d1.east);

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容