我使用以下代码用 排版下图pstricks
。是否有类似的东西可以与 一起使用tikz
?我尝试这样做,发现\node
可以填充文本,但我认为这些节点不能嵌套。
\begin{pspicture}(0,0)(11,1.8)
\rput[bl](0,0){%
\psset{fillstyle=solid, framearc=0.25,framesep=5pt}
\psframebox{%
\psframebox{%
\psframebox{alle}
\psframebox{Studenten}}
\psframebox{lesen}
\psframebox{%
\psframebox{während}
\psframebox{%
\psframebox{dieser}
\psframebox{Zeit}}}
\psframebox{Bücher}}}
\end{pspicture}
答案1
您可以在 TikZ 库中执行此操作fit
,或者,如果您敢的话,可以通过嵌套tikzpicture
s 来执行此操作(如果可能,应避免这样做,因为它可能会产生不良结果)。下面我介绍了原始 PS-Tricks 版本和两个 TikZ 变体:
代码:
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{pst-all}
\usepackage{fancybox}
\usepackage{tikz}
\usetikzlibrary{fit,positioning}
\tikzset{
frbox/.style={
rounded corners,
draw,
thick,
inner sep=5pt
}
}
\newcommand\TZbox[1]{\tikz\node[frbox,baseline] {#1};}
\begin{document}
With \texttt{PS-Tricks}:\par\medskip
\begin{pspicture}(0,0)(11,1.8)
\rput[bl](0,0){%
\psset{fillstyle=solid, framearc=0.25,framesep=5pt}
\psframebox{%
\psframebox{%
\psframebox{alle}
\psframebox{Studenten}}
\psframebox{lesen}
\psframebox{%
\psframebox{während}
\psframebox{%
\psframebox{dieser}
\psframebox{Zeit}}}
\psframebox{Bücher}}}
\end{pspicture}\par\bigskip
With \texttt{TikZ} and the \texttt{fit} library:\par\medskip
\begin{tikzpicture}[
node distance=2pt and 3pt,
every node/.style={frbox}
]
\node (alle) {alle};
\node[right=of alle] (studenten) {Studenten};
\node[fit={(alle) (studenten)}] (fiti) {};
\node[right=of fiti] (lesen) {lesen};
\node[right=9pt of lesen] (wahrend) {während};
\node[right=9pt of wahrend] (dieser) {dieser};
\node[right=of dieser] (zeit) {Zeit};
\node[fit={(dieser) (zeit)}] (fitii) {};
\node[fit={(wahrend) (fitii)}] (fitiii) {};
\node[right=14pt of zeit] (bucher) {Bücher};
\node[fit={(fiti) (fitiii) (bucher)}] (fitvi) {};
\end{tikzpicture}\par\bigskip
With \texttt{TikZ} nesting nodes (careful!):\par\medskip
\TZbox{%
\TZbox{%
\TZbox{alle}
\TZbox{Studenten}}
\TZbox{lesen}
\TZbox{%
\TZbox{während}
\TZbox{%
\TZbox{dieser}
\TZbox{Zeit}}}
\TZbox{Bücher}}
\end{document}