我想要得到一个半填充的 V 形/信号箭头,像这样:
常规的半填充形状解决方案不适用于此,因为我还希望分隔线呈箭头形状。我还考虑过将两个半尺寸箭头并排放置,但这样你就必须手动放置文本,这不是很优雅(或者也许有人对此有一个优雅的解决方案?)。
我现在有的是:
\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{chains,shapes}
\begin{document}
\begin{tikzpicture}[nodes={shape=signal,signal from=west,signal to=east,align=center,fill=lightgray,font=\footnotesize\sffamily,on chain,minimum height=5em},start chain=going right,node distance=2mm]
\path
node{multiline\\ text\\ and\\ more}
node{multiline\\ text}
node{multiline\\ text}
node{multiline\\ text\\ text};
\end{tikzpicture}
\end{document}
结果是:
答案1
以下代码使用选项signal
内的另一个节点path picture
作为外部节点。我无法让它工作,chain
所以我建议positioning
。
\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{chains,shapes, positioning}
\begin{document}
\begin{tikzpicture}[
myarrow/.style={signal, signal from=west, signal to=east, minimum height=5em, minimum width=2cm},
innerarrow/.style={myarrow, fill=blue!70, anchor=east},
outerarrow/.style={myarrow, align=center, fill=lightgray, font=\footnotesize\sffamily,
path picture={\node[innerarrow, minimum width=1cm] at (path picture bounding box.east){};}},
node distance=2mm,
]
\node[outerarrow] (1) {multiline\\ text\\ and\\ more};
\node[outerarrow, right=of 1] (2) {multiline\\ text};
\node[outerarrow, right=of 2] (3) {multiline\\ text};
\node[outerarrow, right=of 3] (4) {multiline\\ text\\ text};
\end{tikzpicture}
\end{document}
更新:自动宽度
以下代码仍然使用path picture
but 来填充用库计算的区域calc
。它类似于pascal974 建议但是在节点选项内,而不是使用两个独立的命令。
因为我不知道如何引用thisnode
,节点的名称被定义为要用于path picture
命令的参数。
\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{chains,shapes, positioning,calc}
\begin{document}
\begin{tikzpicture}[
myarrow/.style={signal, signal from=west, signal to=east, minimum height=5em,
align=center, fill=lightgray, font=\footnotesize\sffamily,
name=#1,
path picture={\fill[blue!70] ($(#1.north west)!0.5!(#1.north east)$)--
($(#1.west)!.5!(#1.east)$)--($(#1.south west)!0.5!(#1.south east)$)
--(#1.south east)--(#1.east)--(#1.north east)--cycle;}},
node distance=2mm,
]
\node[myarrow=1] {multiline\\ text\\ and\\ more};
\node[myarrow=2, right=of 1, minimum width=5cm] {multiline\\ text};
\node[myarrow=3, right=of 2, minimum width=6cm] {multiline\\ text};
\node[myarrow=4, right=of 3, minimum width=4cm] {multiline\\ text\\ text};
\end{tikzpicture}
\end{document}
答案2
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains,shapes,calc,scopes}
\begin{document}
\tikzset{
chevron/.style= {%
draw,
shape=signal,
signal from=west,
signal to=east,
align=center,
font=\footnotesize\sffamily,
minimum height=5em}
}
\newcommand{\chevron}[1]{%
\node[name=s,chevron,on chain]{#1};
\filldraw[lightgray,opacity=1]%
(s.north west)--
($0.5*(s.north west) + 0.5*(s.north east)$)--
($0.5*(s.west) + 0.5*(s.east)$)--
($0.5*(s.south west) + 0.5*(s.south east)$)--
(s.south west)--
(s.west)--
cycle;
\filldraw[blue,opacity=1]%
($0.5*(s.north west) + 0.5*(s.north east)$)--
(s.north east)--
(s.east)--
(s.south east)--
($0.5*(s.south west) + 0.5*(s.south east)$)--
($0.5*(s.west) + 0.5*(s.east)$)--
cycle;
\node[chevron]at(s){#1};
}
\begin{tikzpicture}
{ [start chain,node distance=2mm]
\chevron{multiline\\ text\\ and\\ more}
\chevron{multiline\\ text}
\chevron{multiline\\ text\\ text};
}
\end{tikzpicture}
\end{document}
- \node[name=s,chevron,on chain]{#1}; 该指令命名节点来绘制2个多边形。
- \filldraw[lightgray,opacity=1]... 绘制左半边多边形(如果不透明度 < 1,则第 4 项不是必需的
- \filldraw[blue,opacity=1]...绘制右半多边形 4
- \node[chevron]at(s){#1};它是项目 1 的相同节点;无链(叠加)
抱歉我的英语很差。我认为 Ignasi 的解决方案更好