Tikz:线段之间距离微小的问题

Tikz:线段之间距离微小的问题

在此处输入图片描述我想创建一个类似地铁地图的图片来显示一些数据流。因为我想要有不同粗细和颜色的对角线、水平线和垂直线,所以我需要在线条之间画出曲线连接。我的想法是为宏提供简单直观的名称,例如:十二点到三点,意思是从上面来,向左弯曲 90 度,等等。我使用 pdftolatex,但有一个问题,就是最小距离让我很困扰 :-) 附上最小工作示例。我应该怎么做才能解决这个问题?

梅威瑟:

\documentclass[paper=a4paper, landscape]{article}
%----------------------------------------------------------
% Template: METRO PLAN
%----------------------------------------------------------

%Seitenraender anzeigen und aendern
%\usepackage[showframe]{geometry}
\usepackage{geometry} 
\geometry{
  left=0.5cm,
  right=0.5cm,
  top=0.5cm,
  bottom=0.5cm,
  bindingoffset=5mm
}
\usepackage{amsmath} 
\usepackage{amssymb} 
%\usepackage[ngerman]{babel} 
\usepackage[utf8]{inputenc}
\usepackage{tikz}


% We need the following libraries for TikZ here:
\usetikzlibrary {positioning} 
\usetikzlibrary{shapes,shapes.multipart,shapes.geometric} 
\usetikzlibrary{arrows}  %maybe can be dropped later :-)


\begin{document} 


%Layer-Technologie: 
\pgfdeclarelayer{bottomlayer}   
\pgfdeclarelayer{middlelayer}    
\pgfdeclarelayer{toplayer}      

\pgfsetlayers{main,bottomlayer,middlelayer,toplayer}     


% Background color
\pagecolor{white}
\color{black} 

\begin{tikzpicture} [node distance=0.1cm and 0.1cm ] 

\begin{pgfonlayer}{toplayer} 


% Invisible Node: 
%USAGE: \invnodeXXXXX{Node-ID}{REF-Node-ID}{xshift}{yshift}
\newcommand{\invnodedown}[4] { 
\node[coordinate](#1) [below=of #2,xshift=#3 cm, yshift= #4 cm]{};}


\newcommand{\twelvetothreefat}[2] { 
\draw [line width=0.35cm,color=#2] (#1.center) arc (-180:-90:1);}  %end of macro
\newcommand{\fatline}[3] { 
\tikzstyle {style_fatline}=   [line width=0.35cm,color=#3]
\draw  [style_fatline]   (#2) -- (#1)  ;}  %end of macro
\node (ROOT){x}; 

\invnodedown{INV10}{ROOT}{0}{-3};
\fatline{INV10}{ROOT}{red}
\twelvetothreefat{INV10}{red}

\end{pgfonlayer}  


\begin{pgfonlayer}{middlelayer}  
%------------maybe later used--
\end{pgfonlayer}  


\begin{pgfonlayer}{bottomlayer} 
%...reserved to draw colored areas...
\end{pgfonlayer}  
\end{tikzpicture} 
\end{document}

答案1

我没有看到任何差距。这是您的代码的编辑版本,而\tikzset不是弃用的\tikzstyle。在我看来,“设置”部分应该在文档序言中,但这取决于几个因素。

我添加了两个屏幕截图,一个分辨率非常高,另一个分辨率较低。预览器可能会在低分辨率下显示“间隙”,但这只是光栅化的副作用。我使用了两种不同的颜色,以最大限度地发挥可能的效果。

\documentclass[a4paper,landscape]{article}
%----------------------------------------------------------
% Template: METRO PLAN
%----------------------------------------------------------

%Seitenraender anzeigen und aendern
%\usepackage[showframe]{geometry}
\usepackage{geometry} 
\geometry{
  left=0.5cm,
  right=0.5cm,
  top=0.5cm,
  bottom=0.5cm,
  bindingoffset=5mm
}
\usepackage{amsmath} 
\usepackage{amssymb} 
%\usepackage[ngerman]{babel} 
\usepackage[utf8]{inputenc}
\usepackage{tikz}


% We need the following libraries for TikZ here:
\usetikzlibrary {positioning} 
\usetikzlibrary{shapes,shapes.multipart,shapes.geometric} 
\usetikzlibrary{arrows}  %maybe can be dropped later :-)
\begin{document} 


%Layer-Technologie: 
\pgfdeclarelayer{bottomlayer}   
\pgfdeclarelayer{middlelayer}    
\pgfdeclarelayer{toplayer}      

\pgfsetlayers{main,bottomlayer,middlelayer,toplayer}     


% Background color
\pagecolor{white}
\color{black} 

\begin{tikzpicture} [node distance=0.1cm and 0.1cm ] 

\begin{pgfonlayer}{toplayer}
%%% Setup %%%
\tikzset{
  fatline/.style={line width=0.35cm,color=#1},
}
% Invisible Node: 
%USAGE: \invnodeXXXXX{Node-ID}{REF-Node-ID}{xshift}{yshift}
\newcommand{\invnodedown}[4]{%
  \node[coordinate](#1) [below=of #2,xshift=#3 cm, yshift= #4 cm]{};
}
\newcommand{\twelvetothreefat}[2]{%
  \draw [fatline=#2] (#1.center) arc (-180:-90:1);
}
\newcommand{\fatline}[3]{%
  \draw  [fatline=#3]   (#2) -- (#1)  ;
}
%%% End setup %%%
\node (ROOT){x};

\invnodedown{INV10}{ROOT}{0}{-3};
\fatline{INV10}{ROOT}{blue!80!green}
\twelvetothreefat{INV10}{green!80!blue}

\end{pgfonlayer}


\begin{pgfonlayer}{middlelayer}  
%------------maybe later used--
\end{pgfonlayer}  


\begin{pgfonlayer}{bottomlayer} 
%...reserved to draw colored areas...
\end{pgfonlayer}  
\end{tikzpicture} 

\end{document}

高分辨率

在此处输入图片描述

低分辨率

在此处输入图片描述

相关内容