如何使文本在架构框中居中?

如何使文本在架构框中居中?

我希望箭头之间的节点中的文本居中而不是左对齐。使用minipage 周围的 或 tikzpicture 选项中的设置\centering都没有帮助。我在\begin{center} ... \end{center}text align=center图式包。(我愿意接受不涉及此包的解决方案。)

\documentclass{article}
\usepackage{tikz,xcolor, fontspec, schemata}
\usetikzlibrary{shapes,arrows,positioning, decorations.pathreplacing}
\setmainfont{Arial}
\begin{document}
\tikzstyle{block}=[align=center]
\tikzstyle{line} = [draw,-latex',ultra thick]
\begin{tikzpicture}[node distance = 5em,auto,block]

    \node (prior-lit) {Prior literature};
    \node [below of=prior-lit] (aims-12) 
    {
        \begin{minipage}{\columnwidth}
            \let\SB\schemabox
            \schema{\SB{Aims 1 \& 2}}{\SB{\textbf{Identify} Risk and protective factors for \\ nonmedical poly- and monosubstance use\\  location, position in social network, age, gender}}
        \end{minipage}
       };
    \node [below of=aims-12, below=0em] (mock-intervention) 
    {
        \begin{minipage}{\columnwidth}
            \let\SB\schemabox
            \schema{\SB{Aim 3}}{\SB{\textbf{Simulate} responses of users with various \\ combinations  of risk and protective factors\\ to interventions on social networking sites}}
        \end{minipage}
       };


    \node [below of=mock-intervention] (real-intervention) {Real intervention};
    \node [below of=real-intervention] (outcomes) {Asses outcomes};

    \path[line] (prior-lit) -- (aims-12);
    \path[line] (aims-12) -- (mock-intervention); 
    \path[line, dashed] (mock-intervention) -- (real-intervention);
    \path[line, dashed] (real-intervention) -- (outcomes);

    \draw [decorate,decoration={brace,amplitude=1em,mirror,raise=4pt},yshift=-10] (5.5,-5) -- (5.5,0) node [right,black,midway,xshift=2em] {\textbf{Current grant}};

    \draw [decorate,decoration={brace,amplitude=1em,mirror,raise=4pt},yshift=-10] (5.5,-8) -- (5.5,-5.1) node [right,black,midway,xshift=2em] {\textbf{Future grants}};
\end{tikzpicture}

\end{document}

答案1

像这样?

在此处输入图片描述

箭头相对于整个节点居中。我使用了tabular内部\SB

\documentclass{article}
\usepackage{tikz,xcolor, fontspec, schemata}
\usetikzlibrary{shapes,arrows,positioning, decorations.pathreplacing}
\setmainfont{Arial}
\begin{document}
\tikzset{block/.style={align=center},
         line/.style = {draw,-latex',ultra thick}}
\begin{tikzpicture}[node distance = 5em,auto,block]

    \node (prior-lit) {Prior literature};
    \node [below of=prior-lit] (aims-12)
    {
     %   \begin{minipage}{\columnwidth}
            \let\SB\schemabox
            \schema{\SB{Aims 1 \& 2}}{\SB{\begin{tabular}{@{}c@{}}\textbf{Identify} Risk and protective factors for \\ nonmedical poly- and monosubstance use\\  location, position in social network, age, gender\end{tabular}}}
     %   \end{minipage}
       };
    \node [below of=aims-12, below=0em] (mock-intervention)
    {
       % \begin{minipage}{\columnwidth}
            \let\SB\schemabox
            \schema{\SB{Aim 3}}{\SB{\begin{tabular}{@{}c@{}}\textbf{Simulate} responses of users with various \\ combinations  of risk and protective factors\\ to interventions on social networking sites\end{tabular}}}
    %    \end{minipage}
       };


    \node [below of=mock-intervention] (real-intervention) {Real intervention};
    \node [below of=real-intervention] (outcomes) {Asses outcomes};

    \path[line] (prior-lit) -- (aims-12);
    \path[line] (aims-12) -- (mock-intervention);
    \path[line, dashed] (mock-intervention) -- (real-intervention);
    \path[line, dashed] (real-intervention) -- (outcomes);

    \draw [decorate,decoration={brace,amplitude=1em,mirror,raise=4pt},yshift=-10] (5.5,-5) -- (5.5,0) node [right,black,midway,xshift=2em] {\textbf{Current grant}};

    \draw [decorate,decoration={brace,amplitude=1em,mirror,raise=4pt},yshift=-10] (5.5,-8) -- (5.5,-5.1) node [right,black,midway,xshift=2em] {\textbf{Future grants}};
\end{tikzpicture}

\end{document}

相关内容