我需要节点不重叠,但我不知道该怎么做。我尝试过改变纸张大小、字体大小和最小节点大小。我会调整坐标以使节点之间有足够的空间,但它们不再适合页面。有没有办法获得更大的页面,或者有完全不同的解决方案?
这是我的代码:
(实际上我有五倍于此处发布的节点,为了更好的概览,我缩短了代码)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,
backgrounds,positioning,fit,petri}
\begin{document}
\begin{tikzpicture}
[knoten/.style={circle,draw=black,fill=white,thick,minimum size=5mm}]
\node[knoten] (100440122122) at (-2.3050251367735135,-2.127287738803567) {Bous};
\node[knoten] (100420113113) at (-5.24540261832908,2.1132145700854146) {Merzig,Kreisstadt};
\node[knoten] (100440114114) at (-5.343622401662404,0.33221152119648956) {Rehlingen-Siersburg};
\node[knoten] (100450111111) at (4.9851298716709325,-0.2559058854702032) {Bexbach,Stadt};
\node[knoten] (100410511511) at (2.077483109670924,-1.0254955010256834) {Friedrichsthal,Stadt};
\node[knoten] (100410516516) at (1.1544429856709257,-1.1347092788035258) {Quierschied};
\node[knoten] (100430114114) at (3.8074926165598186,-0.602704172136883) {Neunkirchen,Kreisstadt};
\node[knoten] (100440121121) at (-4.8337606849957435,-1.0308406943591932) {Wallerfangen};
\node[knoten] (100440118118) at (-2.032046527217957,-1.4421910654701706) {Schwalbach};
\node[knoten] (100460112112) at (1.7300380514487106,1.9577006767520475) {Marpingen};
\node[knoten] (100410518518) at (1.814984774115366,-1.713832856581236) {Sulzbach/Saar,Stadt};
\node[knoten] (100450113113) at (4.324141119226477,-5.46156871658129) {Gersheim};
\end{tikzpicture}
\end{document}
答案1
节点将根据文本的大小进行尺寸标注,这里有一个选项,允许您更改每个节点的大小,但反过来会减小文本的大小,如果您想保持文本的大小,还有一个选项可以保持文本的大小,它允许您根据您想要的大小画一个圆圈,这可以指示某种类型的值。
对于文档大小,您可以使用独立类,它允许您根据所绘制的内容绘制输出中的任何内容。然后,您可以导入使用图形库生成的 pdf 文档,并将绘图作为任何图像包含,而不会丢失在 tikz 中绘制的绘图的矢量属性。
使用:
\draw[knoten] (-5.0269,-1.2254) circle (0.5cm) node (100440122122){Bous};
\draw[knoten] (-8.7754,5.1376) circle (1cm) node (100420113113){Merzig,\\Kreisstadt};
\draw[knoten] (-8.0377,2.0813) circle (1cm) node (100440114114){Rehlingen-Siersburg};
\draw[knoten] (6.1592,1.6599) circle (1cm) node (100450111111){Bexbach,\\Stadt};
\draw[knoten] (2.2251,0.811) circle (1cm) node (100410511511){Friedrichsthal,\\Stadt};
\draw[knoten] (-1.8769,-5.3392)circle (1cm) node (100410516516){Quierschied};
\draw[knoten] (4.4419,1.4106) circle (1.2cm) node (100430114114){Neunkirchen\\Kreis\\stadt};
\draw[knoten] (-7.0226,0.624) circle (1cm) node (100440121121){Wallerfangen};
\draw[knoten] (-4.446,-0.1781) circle (1.5cm) node (100440118118){Schwalbach};
\draw[knoten] (1.3201,5.106) circle (1cm) node (100460112112){Marpingen};
\draw[knoten] (1.3887,-0.3528) circle (1cm) node (100410518518){Sulzbach/Saar,\\Stadt};
\draw[knoten] (4.9395,-6.1119) circle (2cm) node (100450113113){Gersheim};
使用:使用范围和变换形状的绘图命令定义 \Knoten……
\Knoten(-5.0269,-1.2254)[0.8]{Bous};
\Knoten(-8.7754,5.1376)[1]{Merzig, \\Kreisstadt};
\Knoten(-8.0377,2.0813)[0.8]{Rehlingen\\Siersburg};
\Knoten(6.1592,1.6599)[0.8]{Bexbach, \\Stadt};
\Knoten(2.2251,0.811)[0.5]{Friedrichsthal,\\ Stadt};
\Knoten(-1.8769,-5.3392)[1]{Quierschied};
\Knoten(4.4419,1.4106)[0.8]{Neunkirchen,\\ Kreisstadt};
\Knoten(-7.0226,0.624)[0.9]{Wallerfangen};
\Knoten(-4.446,-0.1781)[0.8]{Schwalbach};
\Knoten(1.3201,5.106)[1]{Marpingen};
\Knoten(1.3887,-0.3528)[0.6]{Sulzbach/Saar,\\ Stadt};
\Knoten(4.9395,-6.1119)[1]{Gersheim};
梅威瑟:
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage{graphicx}
\begin{document}
\begin{tikzpicture}[
%Environment styles
knoten/.style={%Style for normal shapes
fill=green,
fill opacity=.2,
draw opacity=0.2,
text opacity=1,
align=center
}
]
%New Tikz Objet
\def\Knoten(#1)[#2]#3{%#1: Position#2: Identifier.
\begin{scope}[shift={(#1)},scale=#2, every node/.append style={transform shape}] % using to make coordinate objet.
\node[
draw,
circle,
fill=blue,
fill opacity=.2,
draw opacity=1,
text opacity=1,
align=center
] at (0,0){#3}; %set this coordinate as anode
\end{scope}
}
% Background map obtained from google maps.
\node[inner sep=0pt] (FIG1) at (0,0) {\includegraphics[scale=1]{MAP}};
% Scaling the shapes.
\Knoten(-5.0269,-1.2254)[0.8]{Bous};
\Knoten(-8.7754,5.1376)[1]{Merzig, \\Kreisstadt};
\Knoten(-8.0377,2.0813)[0.8]{Rehlingen\\Siersburg};
\Knoten(6.1592,1.6599)[0.8]{Bexbach, \\Stadt};
\Knoten(2.2251,0.811)[0.5]{Friedrichsthal,\\ Stadt};
\Knoten(-1.8769,-5.3392)[1]{Quierschied};
\Knoten(4.4419,1.4106)[0.8]{Neunkirchen,\\ Kreisstadt};
\Knoten(-7.0226,0.624)[0.9]{Wallerfangen};
\Knoten(-4.446,-0.1781)[0.8]{Schwalbach};
\Knoten(1.3201,5.106)[1]{Marpingen};
\Knoten(1.3887,-0.3528)[0.6]{Sulzbach/Saar,\\ Stadt};
\Knoten(4.9395,-6.1119)[1]{Gersheim};
%IF you use TikzEdt, you can find the coordinates draggin an overlay.
% \draw[knoten] (-5.0269,-1.2254) circle (0.5cm) node (100440122122){Bous};
% \draw[knoten] (-8.7754,5.1376) circle (1cm) node (100420113113){Merzig,\\Kreisstadt};
% \draw[knoten] (-8.0377,2.0813) circle (1cm) node (100440114114){Rehlingen-Siersburg};
% \draw[knoten] (6.1592,1.6599) circle (1cm) node (100450111111){Bexbach,\\Stadt};
% \draw[knoten] (2.2251,0.811) circle (1cm) node (100410511511){Friedrichsthal,\\Stadt};
% \draw[knoten] (-1.8769,-5.3392)circle (1cm) node (100410516516){Quierschied};
% \draw[knoten] (4.4419,1.4106) circle (1.2cm) node (100430114114){Neunkirchen\\Kreis\\stadt};
% \draw[knoten] (-7.0226,0.624) circle (1cm) node (100440121121){Wallerfangen};
% \draw[knoten] (-4.446,-0.1781) circle (1.5cm) node (100440118118){Schwalbach};
% \draw[knoten] (1.3201,5.106) circle (1cm) node (100460112112){Marpingen};
% \draw[knoten] (1.3887,-0.3528) circle (1cm) node (100410518518){Sulzbach/Saar,\\Stadt};
% \draw[knoten] (4.9395,-6.1119) circle (2cm) node (100450113113){Gersheim};
\end{tikzpicture}
\end{document}
如果您将代码保存在名为 examplehelp33.tex 的 tex 档案中;当您编译时,您可以获得 examplehelp33.pdf,然后您可以将其包含在您的主文档中,请尝试使用以下代码:
% arara: pdflatex: {synctex: yes, action: nonstopmode}
\documentclass[a4paper]{article}
\usepackage[top=2cm,bottom=2cm,left=3cm,right=2cm]{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\begin{document}
\lipsum[1-2]
\begin{figure}[!h]
\centering
\includegraphics[width=\textwidth]{examplehelp33}
\caption{Imported pdf using graphicx}
\end{figure}
\lipsum[3-4]
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\node[inner sep=0pt] (FIG1) at (0,0) {\includegraphics[scale=0.8,angle=90]{examplehelp33}};
\end{tikzpicture}
\caption{Imported pdf within Tikz environment}
\end{figure}
\end{document}
结果:
注意:通过 \documentclass[border=5mm]{standalone} 在 tikz 代码的 pdf 输出中添加了一些边框。您可以擦除此操作码或定义为 0mm。