Fläche erzeugen in TikZ Thema ist als GELÖST markiert

Tabellen und Grafiken erstellen und anordnen


Jaffet
Forum-Anfänger
Forum-Anfänger
Beiträge: 32
Registriert: Mi 22. Jul 2020, 13:29

Fläche erzeugen in TikZ

Beitrag von Jaffet »

Hallo Latex-Forum,

ich habe eine 10cm x 10cm große Fläche namens Port definiert.
In diese Fläche möchte ich nun ein Rechteck mit den Seitenmaßen a=9cm und b=5cm platzieren. Seltsamerweise füllt das schwarze Rechteck die gesamte Fläche Port aus, obwohl es per Definition kleiner ist als diese (siehe Minimalbeispiel).

\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
	ports/.style={
		line width=1pt,
		draw=black,
		minimum width=10cm,
		minimum height=10cm,
		path picture={
			\coordinate(Ursprung) at (path picture bounding box.south west);
			%\draw[draw=black, thin] (Ursprung) grid (10,10);	
			\draw[fill=black] (Ursprung) rectangle (9cm,5cm);
		}
	}
}
\begin{document}
	\begin{figure}
		\begin{tikzpicture}	
			\node(Port) at (0,0) [ports]{};	
		\end{tikzpicture}
		\caption{Ports}
	\end{figure}
\end{document}

rais
Forum-Guru
Forum-Guru
Beiträge: 407
Registriert: Di 21. Sep 2010, 00:37

Re: Fläche erzeugen in TikZ

Beitrag von rais »

Deine (Ursprung)-Koordinate liegt aber nicht auf (0,0).

\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
	ports/.style={
		line width=1pt,
		draw=black,
		minimum width=10cm,
		minimum height=10cm,
		path picture={
			\coordinate(Ursprung) at (path picture bounding box.south west);
			%\draw[draw=black, thin] (Ursprung) grid (10,10);	
			\draw[fill=black] (Ursprung) rectangle +(9cm,5cm);
		}
	}
}
\begin{document}
	\begin{figure}
		\begin{tikzpicture}	
			\node(Port) at (0,0) [ports]{};	
		\end{tikzpicture}
		\caption{Ports}
	\end{figure}
\end{document}

Frohe Ostern
Rainer

One of the joys of travel is visiting new towns and meeting new people---G.Khan (Robert Asprin, Another Fine Myth)

Jaffet
Forum-Anfänger
Forum-Anfänger
Beiträge: 32
Registriert: Mi 22. Jul 2020, 13:29

Re: Fläche erzeugen in TikZ

Beitrag von Jaffet »

Vielen Dank für die schnelle Hilfe.


Antworten