我怎样才能让每行上的三个元素适当地分布到框的末尾?
\documentclass{article}
\usepackage{catchfile,tikz}
\usepackage{filecontents}% http://ctan.org/pkg/filecontents
\usepackage{silence}% http://ctan.org/pkg/silence
\usepackage{tikz}
\usepackage{eurosym}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{trees,shapes,intersections,calc,matrix,fit,backgrounds}
\begin{document}
\resizebox{1.0\textwidth}{!}{
\begin{tikzpicture}[scale=0.5, grow=right, sloped,dot/.style={circle,fill,inner sep=0.5pt}]
\tikzstyle{level 1}=[level distance=08cm, sibling distance=3.5cm]
\node(A)[] {N=1000}
child {node[text opacity=100, align=center,draw=black!100, text width=155] {
(-50\%) \\
N=100 \euro4.88$\mu$ (1.96) \\
N=1000 \euro5.66$\mu$ (1.96)
}
edge from parent node[below] {}
};
\end{tikzpicture}
}
\end{document}
答案1
快捷又简单的方法——你可以使用来\hfill
扩大空间:
\documentclass[tikz, border=4pt]{standalone}
\usepackage{amsmath}
\usepackage{eurosym}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[scale=0.5, grow=right]
\tikzstyle{level 1}=[level distance=10cm, sibling distance=3.5cm]
\node(A) {N=1000}
child {node[align=center,draw, text width=155]
{
$ (-50\%) $ \\
N=100 \hfill \euro4.88$\mu$ \hfill(1.96) \\
N=1000 \hfill \euro5.66$\mu$ \hfill (1.96) \\
} {}
};
\end{tikzpicture}
\end{document}
这将为您提供:
您可以使用matrix of nodes
进行更复杂的对齐:
\documentclass[tikz, border=4pt]{standalone}
\usepackage{amsmath}
\usepackage{eurosym}
\usetikzlibrary{trees,matrix}
\begin{document}
\begin{tikzpicture}[scale=0.5, grow=right]
\tikzstyle{level 1}=[level distance=10cm, sibling distance=3.5cm]
\node(A) {N=1000}
child {node[matrix,matrix of nodes,draw,ampersand replacement=\&,
every node/.style={text width=20mm}]
{
\node{}; \& \node[align=center]{$ (-50\%) $}; \& \node{}; \\
\node{$N=100$ }; \& \node[align=center]{\euro4.88$\mu$}; \& \node[align=right]{(1.96)}; \\
\node{$ N=1000 $}; \& \node[align=center]{\euro5.66$\mu$}; \& \node[align=right]{(1.96)}; \\
\node{$ N=100,000 $}; \& \node[align=center]{\euro5.66$\mu$}; \& \node[align=right]{(1.96)}; \\
}
{}
};
\end{tikzpicture}
\end{document}
答案2
可以tabulars
在里面声明nodes
,通过左右列的方便对齐,可以获得所需的结果。
注意:我尊重克马辛尼斯,尽管我不确定它的正确性。
\documentclass{article}
\usepackage{catchfile,tikz}
\usepackage{filecontents}% http://ctan.org/pkg/filecontents
\usepackage{silence}% http://ctan.org/pkg/silence
\usepackage{tikz}
\usepackage{eurosym}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{trees,shapes,intersections,calc,matrix,fit,backgrounds}
\begin{document}
\resizebox{1.0\textwidth}{!}{
\begin{tikzpicture}[scale=0.5, grow=right, sloped,dot/.style={circle,fill,inner sep=0.5pt}]
\tikzstyle{level 1}=[level distance=08cm, sibling distance=3.5cm]
\node(A)[] {N=1000}
child {node[text opacity=100, align=center,draw=black!100] {\begin{tabular}{@{}lcr@{}}
&(-50\%)& \\
N=100 &\euro4.88$\mu$& (1.96) \\
N=1000 &\euro5.66$\mu$& (1.96)
\end{tabular}}
edge from parent node[below] {}
};
\end{tikzpicture}
}
\end{document}