TikZ:使双线(箭头)去除其连接的形状的边框

TikZ:使双线(箭头)去除其连接的形状的边框

我正在尝试使双线消除其连接的形状的边框。我能实现的最好结果是这样的:

\draw[line width=1pt, double=white, draw=black!30, double distance=3pt, 
      shorten >= -1.8pt, shorten <= -1.8pt] 
      (Photos) -- (PhotosM);

在水平线的情况下它可以正常工作,这是一个例子:

问题是:

  1. 缩短距离必须手动调整,并且
  2. 如果线不是水平的,则不起作用:

在此处输入图片描述

最小示例:

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary {positioning}
\begin{document}
\begin{tikzpicture}
   \tikzstyle{rounded_rectangle} = [rectangle, rounded corners=8pt, minimum height=17pt] % Shape % minimum width=1cm, minimum height=0.1cm,
   \tikzstyle{noders_default}    = [rounded_rectangle, font=\footnotesize, text centered, draw=black!30, thick, fill=white] % node resizing
   \tikzstyle{nodefx_default}    = [noders_default, text width=70pt] % node fixed width
   \begin{scope}[every node/.style=noders_default]
      \node                      (col1) {column 1};
      \node [right=70pt of col1] (col2) {column 2};
   \end{scope}
   \begin{scope}[node distance=12pt, every node/.style=nodefx_default]
      \node[nodefx_default, below=of col1]   (Photos)   {Photos};
      \node[nodefx_default, below=of Photos] (Messages) {Messages};
   \end{scope}
   \begin{scope}[anchor=west]
      \node[noders_default] at (Photos   -| col2.west) (PhotosM)   {qwer};
      \node[noders_default] at (Messages -| col2.west) (MessagesM) {asdf};
   \end{scope}

   %
   %
   % THE QUESTION IS HERE:
   %

   \draw[line width=1pt, double=white, draw=black!30, double distance=3pt, shorten >= -1.8pt, shorten <= -1.8pt] (Photos) -- (PhotosM);
   \draw[line width=1pt, double=white, draw=black!30, double distance=3pt, shorten >= -3pt, shorten <= -9pt] (Photos) -- (MessagesM);

\end{tikzpicture}
\end{document}

答案1

您可以将主线放在背景层中,然后重新绘制白色核心以取消边框。现在您可能可以使用固定缩短,但我没有检查。

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary {positioning, backgrounds}
\begin{document}
\begin{tikzpicture}
    % tikzstyle is obsolete, this is the "new way":
    \tikzset{rounded_rectangle/.style={rectangle, rounded corners=8pt,
        minimum height=17pt},
        noders_default/.style={rounded_rectangle, font=\footnotesize,
        text centered, draw=black!30, thick, fill=white},
        nodefx_default/.style={noders_default, text width=70pt},
    }%
    \begin{scope}[every node/.style=noders_default]
        \node                      (col1) {column 1};
        \node [right=70pt of col1] (col2) {column 2};
    \end{scope}
    \begin{scope}[node distance=12pt, every node/.style=nodefx_default]
        \node[nodefx_default, below=of col1]   (Photos)   {Photos};
        \node[nodefx_default, below=of Photos] (Messages) {Messages};
    \end{scope}
    \begin{scope}[anchor=west]
        \node[noders_default] at (Photos   -| col2.west) (PhotosM)   {qwer};
        \node[noders_default] at (Messages -| col2.west) (MessagesM) {asdf};
    \end{scope}

    %
    %
    % THE QUESTION IS HERE:
    %
    \begin{scope}[on background layer]
        \draw[line width=1pt, double=white, draw=black!30, double distance=3pt, shorten >= -1.8pt, shorten <= -1.8pt] (Photos) -- (PhotosM);
        \draw[line width=1pt, double=white, draw=black!30, double distance=3pt, shorten >= -3pt, shorten <= -9pt] (Photos) -- (MessagesM);
    \end{scope}
    \draw[line width=3pt, draw=white, shorten >= -1.8pt, shorten <= -1.8pt] (Photos) -- (PhotosM);
    \draw[line width=3pt, draw=white, shorten >= -3pt, shorten <= -9pt] (Photos) -- (MessagesM);

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容