von MathiasG » Fr 26. Apr 2024, 09:42
Viele Dank erstmal für eure Hilfe, jetzt funktioniert alles erstmal soweit, jedoch habe ich ein Problem. Ich kann meine Umgebung Diagramm nur einmal verwenden möchte es aber mehrmals verwenden.
Hier meine fDiagramm:
\ProvidesPackage{fDiagramm}
\RequirePackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary {backgrounds}
\newenvironment{Diagramm}{
\begin{tikzpicture}
\newlength{\yPosition}
\setlength{\yPosition}{0cm}
\newlength{\xLength}
\newcounter{xLengtZustand};
\newcommand{\Sensor}[3]{
\node at (0,\yPosition+1.5cm) {##1};
\node at (1.55, \yPosition+2cm) {##3};
\node at (1.55, \yPosition+1cm) {##2};
\draw (2,\yPosition) -- (2,\yPosition+3cm);
\addtolength{\yPosition}{2cm} % Y-Position um 1,5 erhöhen
%\node at (0,1) {##1};
%\node at (1, 1.5) {##3};
%\node at (1, 0.5) {##2};
%\draw (1.5,0) -- (1.5,2);
%Zweiter Sensor
%\node at (1, 2.5) {0};
%\node at (1, 3.5) {1};
%\node at (0,3) {PR1};
%\draw (1.5,2) -- (1.5,4);
%Zeitabschnitt
%\draw (1.5,0.5) -- (2.5,0.5);
%\draw (1.5,1.5) -- (2.5,1.5);
%\draw (1.5,2.5) -- (2.5,2.5);
%\draw (1.5,3.5) -- (2.5,3.5);
%\node[draw, circle] (start) at (0,0) {Start};
%\node[draw, rectangle] (PR0) at (0,1) {Schritt 1};
%\node[draw, rectangle] (step2) at (0,2) {Schritt 2};
%\node[draw, circle] (end) at (6,0) {Ende};
%\draw[-] (start) -- (step1);
%\draw[-] (step1) -- (step2);
%\draw[-] (step2) -- (end);
}
\newcommand{\Label}{
\addtocounter{xLengtZustand}{+4};
\node[rotate=90] at (0.1, \yPosition+1.5cm) {Bauglied};
\node[rotate=90] at (1.55, \yPosition+1.5cm) {Zustand};
\draw (-1,0) rectangle (1.2,\yPosition+2.5cm);
\draw (1.2,0) rectangle (2,\yPosition+2.5cm);
\draw (2,0) rectangle (\value{xLengtZustand},\yPosition+2.5cm);
\draw (-1,\yPosition + 0.7cm) -- (2,\yPosition + 0.7cm);
}
\newcommand{\Schritte}[1]{
\newcounter{step};
\setcounter{step}{##1};
%\addtocounter{step}{-2};
\setlength{\xLength}{0cm}
\begin{scope}[on background layer]
\draw[step=1cm,gray,very thin] (2,0) grid (##1+4,\yPosition + 1.2cm);
\end{scope}
\foreach \x in {0,...,\value{step}} {
\node at (\x+3,\yPosition+1.5cm) {\x};
}
\setcounter{xLengtZustand}{\value{step}};
}
\newcommand{\Schritt}[4]{
\draw[red, ultra thick] (##1+2,##2) -- (##3+2,##4);
}
\newcommand{\pup}[5]{
\draw[fill] (##1+2,##2) circle (2pt) node[above left] {##5};
\draw[fill] (##3+2,##4) circle (2pt);
\draw (##1+2,##2) -- (##1+2+0.2,##2+0.4);
\draw[->] (##1+2+0.2,##2+0.4) -- (##3+2+0.2,##4-0.4);
\draw (##3+2+0.2,##4-0.4) -- (##3+2,##4);
}
\newcommand{\pdown}[5]{
\draw[fill] (##1+2,##2) circle (2pt);
\draw[fill] (##3+2,##4) circle (2pt) node[above left] {##5};
\draw (##1+2,##2) -- (##1+2+0.2,##2+0.4);
\draw[<-] (##1+2+0.2,##2+0.4) -- (##3+2+0.2,##4-0.4);
\draw (##3+2+0.2,##4-0.4) -- (##3+2,##4);
}
}
{
\end{tikzpicture}
}
und hier rufe ich sie auf in meiner .tex Datei
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{units}
\usepackage{fDiagramm}
\author{Test}
\title{Test}
\begin{document}
\maketitle
\begin{Diagramm}
\Sensor{Q1}{0}{1}
\Sensor{T2}{0}{1}
\Sensor{T1}{0}{1}
\Schritte{6}
\Label
%Schritte für T1
\Schritt{0}{5}{2}{5}
\Schritt{2}{5}{2}{6}
\Schritt{2}{6}{3}{6}
\Schritt{3}{6}{3}{5}
\Schritt{3}{5}{6}{5}
\Schritt{6}{5}{6}{6}
\Schritt{6}{6}{8}{6}
%Schritte für T2
\Schritt{0}{3}{4}{3}
\Schritt{4}{3}{4}{4}
\Schritt{4}{4}{5}{4}
\Schritt{5}{4}{5}{3}
\Schritt{5}{3}{6}{3}
\Schritt{6}{3}{6}{4}
\Schritt{6}{4}{8}{4}
%Schritte Q1
\Schritt{0}{1}{2}{1}
\Schritt{2}{1}{2}{2}
\Schritt{2}{2}{3}{2}
\Schritt{3}{2}{3}{1}
\Schritt{3}{1}{4}{1}
\Schritt{4}{1}{4}{2}
\Schritt{4}{2}{5}{2}
\Schritt{5}{2}{5}{1}
\Schritt{5}{1}{6}{1}
\Schritt{6}{1}{6}{2}
\Schritt{6}{2}{8}{2}
\pdown{2}{1}{2}{6}{\unit[0,2]{mm}}
\pdown{4}{1}{4}{4}{\unit[0,2]{mm}}
\pdown{6}{1}{6}{6}{\unit[0,2]{mm}}
\pdown{6}{1}{6}{4}{\unit[0,2]{mm}}
\end{Diagramm}
\end{document}
Viele Dank erstmal für eure Hilfe, jetzt funktioniert alles erstmal soweit, jedoch habe ich ein Problem. Ich kann meine Umgebung Diagramm nur einmal verwenden möchte es aber mehrmals verwenden.
Hier meine fDiagramm:
[code]
\ProvidesPackage{fDiagramm}
\RequirePackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary {backgrounds}
\newenvironment{Diagramm}{
\begin{tikzpicture}
\newlength{\yPosition}
\setlength{\yPosition}{0cm}
\newlength{\xLength}
\newcounter{xLengtZustand};
\newcommand{\Sensor}[3]{
\node at (0,\yPosition+1.5cm) {##1};
\node at (1.55, \yPosition+2cm) {##3};
\node at (1.55, \yPosition+1cm) {##2};
\draw (2,\yPosition) -- (2,\yPosition+3cm);
\addtolength{\yPosition}{2cm} % Y-Position um 1,5 erhöhen
%\node at (0,1) {##1};
%\node at (1, 1.5) {##3};
%\node at (1, 0.5) {##2};
%\draw (1.5,0) -- (1.5,2);
%Zweiter Sensor
%\node at (1, 2.5) {0};
%\node at (1, 3.5) {1};
%\node at (0,3) {PR1};
%\draw (1.5,2) -- (1.5,4);
%Zeitabschnitt
%\draw (1.5,0.5) -- (2.5,0.5);
%\draw (1.5,1.5) -- (2.5,1.5);
%\draw (1.5,2.5) -- (2.5,2.5);
%\draw (1.5,3.5) -- (2.5,3.5);
%\node[draw, circle] (start) at (0,0) {Start};
%\node[draw, rectangle] (PR0) at (0,1) {Schritt 1};
%\node[draw, rectangle] (step2) at (0,2) {Schritt 2};
%\node[draw, circle] (end) at (6,0) {Ende};
%\draw[-] (start) -- (step1);
%\draw[-] (step1) -- (step2);
%\draw[-] (step2) -- (end);
}
\newcommand{\Label}{
\addtocounter{xLengtZustand}{+4};
\node[rotate=90] at (0.1, \yPosition+1.5cm) {Bauglied};
\node[rotate=90] at (1.55, \yPosition+1.5cm) {Zustand};
\draw (-1,0) rectangle (1.2,\yPosition+2.5cm);
\draw (1.2,0) rectangle (2,\yPosition+2.5cm);
\draw (2,0) rectangle (\value{xLengtZustand},\yPosition+2.5cm);
\draw (-1,\yPosition + 0.7cm) -- (2,\yPosition + 0.7cm);
}
\newcommand{\Schritte}[1]{
\newcounter{step};
\setcounter{step}{##1};
%\addtocounter{step}{-2};
\setlength{\xLength}{0cm}
\begin{scope}[on background layer]
\draw[step=1cm,gray,very thin] (2,0) grid (##1+4,\yPosition + 1.2cm);
\end{scope}
\foreach \x in {0,...,\value{step}} {
\node at (\x+3,\yPosition+1.5cm) {\x};
}
\setcounter{xLengtZustand}{\value{step}};
}
\newcommand{\Schritt}[4]{
\draw[red, ultra thick] (##1+2,##2) -- (##3+2,##4);
}
\newcommand{\pup}[5]{
\draw[fill] (##1+2,##2) circle (2pt) node[above left] {##5};
\draw[fill] (##3+2,##4) circle (2pt);
\draw (##1+2,##2) -- (##1+2+0.2,##2+0.4);
\draw[->] (##1+2+0.2,##2+0.4) -- (##3+2+0.2,##4-0.4);
\draw (##3+2+0.2,##4-0.4) -- (##3+2,##4);
}
\newcommand{\pdown}[5]{
\draw[fill] (##1+2,##2) circle (2pt);
\draw[fill] (##3+2,##4) circle (2pt) node[above left] {##5};
\draw (##1+2,##2) -- (##1+2+0.2,##2+0.4);
\draw[<-] (##1+2+0.2,##2+0.4) -- (##3+2+0.2,##4-0.4);
\draw (##3+2+0.2,##4-0.4) -- (##3+2,##4);
}
}
{
\end{tikzpicture}
}
[/code]
und hier rufe ich sie auf in meiner .tex Datei
[code]
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{units}
\usepackage{fDiagramm}
\author{Test}
\title{Test}
\begin{document}
\maketitle
\begin{Diagramm}
\Sensor{Q1}{0}{1}
\Sensor{T2}{0}{1}
\Sensor{T1}{0}{1}
\Schritte{6}
\Label
%Schritte für T1
\Schritt{0}{5}{2}{5}
\Schritt{2}{5}{2}{6}
\Schritt{2}{6}{3}{6}
\Schritt{3}{6}{3}{5}
\Schritt{3}{5}{6}{5}
\Schritt{6}{5}{6}{6}
\Schritt{6}{6}{8}{6}
%Schritte für T2
\Schritt{0}{3}{4}{3}
\Schritt{4}{3}{4}{4}
\Schritt{4}{4}{5}{4}
\Schritt{5}{4}{5}{3}
\Schritt{5}{3}{6}{3}
\Schritt{6}{3}{6}{4}
\Schritt{6}{4}{8}{4}
%Schritte Q1
\Schritt{0}{1}{2}{1}
\Schritt{2}{1}{2}{2}
\Schritt{2}{2}{3}{2}
\Schritt{3}{2}{3}{1}
\Schritt{3}{1}{4}{1}
\Schritt{4}{1}{4}{2}
\Schritt{4}{2}{5}{2}
\Schritt{5}{2}{5}{1}
\Schritt{5}{1}{6}{1}
\Schritt{6}{1}{6}{2}
\Schritt{6}{2}{8}{2}
\pdown{2}{1}{2}{6}{\unit[0,2]{mm}}
\pdown{4}{1}{4}{4}{\unit[0,2]{mm}}
\pdown{6}{1}{6}{6}{\unit[0,2]{mm}}
\pdown{6}{1}{6}{4}{\unit[0,2]{mm}}
\end{Diagramm}
\end{document}
[/code]