Seite 1 von 1

Fläche erzeugen in TikZ

Verfasst: Mo 5. Apr 2021, 11:49
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}

Re: Fläche erzeugen in TikZ

Verfasst: Mo 5. Apr 2021, 13:50
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


Re: Fläche erzeugen in TikZ

Verfasst: Mo 5. Apr 2021, 14:08
von Jaffet

Vielen Dank für die schnelle Hilfe.