von sLy » Mi 6. Jan 2010, 20:15
danke funktioniert einwandfrei.
Ich werde mir TeX by Topic mal zu gemüte führen...
mfg
sLy
EDIT:
mein neues Problem: ich will die zugehörige Schaltung zu den Teilen bauen.
Hier mein Code
\newcommand*{\Schaltung}[1]{% die übliche Befehlsdefinition
\protected@edef\@tempa{#1}%
\expandafter\@Schaltung\@tempa\@nil
}
\newcommand*{\@Schaltung}{}
\def\@Schaltung#1,#2,#3,#4,#5,#6,#7,#8,#9\@nil{% Parameter 1-3 sind Einheit in cm, max. X-Wert, max. Y-Wert; Parameter 4-9 stellen die Teile dar
\psset {unit=#1cm}%
\newcounter{x}% counter zur ermittlung von xmax und ymax
\newcounter{y}
\newcounter{xmax}
\newcounter{ymax}
\setcounter{x}{#2}
\setcounter{y}{#3}
\setcounter{xmax}{\value{x}}
\setcounter{ymax}{\value{y}}
\addtocounter{xmax}{1}
\addtocounter{ymax}{1}
\begin{pspicture}[showgrid=false](-1,-1)(\value{xmax},\value{ymax}) %das Standard-Schaltbild
\def\Standard{%
\pnode(0,\value{y}){A}%
\pnode(0,0){B}%
\pnode(\value{x},0){Y}%
\pnode(\value{x},\value{y}){Z}%
\pnode(3,0){C}%
\pnode(6,0){D}%
\pnode(9,0){E}%
\pnode(12,0){F}%
\pnode(15,0){G}%
\pnode(18,0){H}%
\battery (Z)(A){$U_0$}%
\wire (A)(B)%
\wire (Y)(Z)%
}%
\def\bc{\noexpand#4} %hier sollen die Teile zur Schaltung hinzugefügt werden
\def\cd{\noexpand#5}
\def\de{\noexpand#6}
\def\ef{\noexpand#7}
\def\fg{\noexpand#8}
\def\gh{\noexpand#9}
\eappto\Standard{\bc}
\eappto\Standard{\cd}
\eappto\Standard{\de}
\eappto\Standard{\ef}
\eappto\Standard{\fg}
\eappto\Standard{\gh}
\Standard%
\end{pspicture}%
}
Leider funktioniert das nicht so wie es soll.
Fehler:
! Argument of \@Lampe has an extra }.
! Paragraph ended before \@Lampe was complete.
! File ended while scanning use of \@Schaltung.
! Emergency stop.
Minimalbeispiel:
\documentclass{minimal}
\usepackage{etoolbox}
\usepackage{pst-circ}
\usepackage{multido}
\makeatletter
\def \PosA {(B)(C)}
\def \PosB {(C)(D)}
\def \PosC {(D)(E)}
\def \PosD {(E)(F)}
\def \PosE {(F)(G)}
\def \PosF {(G)(H)}
\newcommand*{\Lampe}[1]{%
\protected@edef\@tempa{#1}%
\expandafter\@Lampe\@tempa\@nil
}
\newcommand*{\@Lampe}{}
\def\@Lampe#1,#2\@nil{%
\ifcsname#1\endcsname
\protected@edef\@tempb{%
\protect\lamp\csname#1\endcsname{$#2$}%
}%
\@tempb
\else
\PackageError{xyz}{Command `\@backslashchar#1' not defined}{\@ehc}%
\fi
}
\newcommand*{\Schaltung}[1]{%
\protected@edef\@tempa{#1}%
\expandafter\@Schaltung\@tempa\@nil
}
\newcommand*{\@Schaltung}{}
\def\@Schaltung#1,#2,#3,#4,#5,#6,#7,#8,#9\@nil{%
\psset {unit=#1cm}%
\newcounter{x}
\newcounter{y}
\newcounter{xmax}
\newcounter{ymax}
\setcounter{x}{#2}
\setcounter{y}{#3}
\setcounter{xmax}{\value{x}}
\setcounter{ymax}{\value{y}}
\addtocounter{xmax}{1}
\addtocounter{ymax}{1}
\begin{pspicture}[showgrid=false](-1,-1)(\value{xmax},\value{ymax})
\def\Standard{%
\pnode(0,\value{y}){A}%
\pnode(0,0){B}%
\pnode(\value{x},0){Y}%
\pnode(\value{x},\value{y}){Z}%
\pnode(2,0){C}%
\pnode(4,0){D}%
\pnode(6,0){E}%
\pnode(8,0){F}%
\pnode(10,0){G}%
\pnode(12,0){H}%
\battery (Z)(A){$U_0$}%
\wire (A)(B)%
\wire (Y)(Z)%
\wire (H)(Y)%
}%
\def\bc{\noexpand#4}
\def\cd{\noexpand#5}
\def\de{\noexpand#6}
\def\ef{\noexpand#7}
\def\fg{\noexpand#8}
\def\gh{\noexpand#9}
\eappto\Standard{\bc}
\eappto\Standard{\cd}
\eappto\Standard{\de}
\eappto\Standard{\ef}
\eappto\Standard{\fg}
\eappto\Standard{\gh}
\Standard%
\end{pspicture}%
}
\makeatother
\begin{document}
\begin{center}
\Schaltung{1,13,4,%
\Lampe{PosA,L_1},%
\Lampe{PosB,L_2},%
\Lampe{PosC,L_3},%
\Lampe{PosD,L_4},%
\Lampe{PosE,L_5},%
\Lampe{PosF,L_6}%
}
\end{center}
\end{document}
danke funktioniert einwandfrei.
Ich werde mir TeX by Topic mal zu gemüte führen...
mfg
sLy
EDIT:
mein neues Problem: ich will die zugehörige Schaltung zu den Teilen bauen.
Hier mein Code
[code]\newcommand*{\Schaltung}[1]{% die übliche Befehlsdefinition
\protected@edef\@tempa{#1}%
\expandafter\@Schaltung\@tempa\@nil
}
\newcommand*{\@Schaltung}{}
\def\@Schaltung#1,#2,#3,#4,#5,#6,#7,#8,#9\@nil{% Parameter 1-3 sind Einheit in cm, max. X-Wert, max. Y-Wert; Parameter 4-9 stellen die Teile dar
\psset {unit=#1cm}%
\newcounter{x}% counter zur ermittlung von xmax und ymax
\newcounter{y}
\newcounter{xmax}
\newcounter{ymax}
\setcounter{x}{#2}
\setcounter{y}{#3}
\setcounter{xmax}{\value{x}}
\setcounter{ymax}{\value{y}}
\addtocounter{xmax}{1}
\addtocounter{ymax}{1}
\begin{pspicture}[showgrid=false](-1,-1)(\value{xmax},\value{ymax}) %das Standard-Schaltbild
\def\Standard{%
\pnode(0,\value{y}){A}%
\pnode(0,0){B}%
\pnode(\value{x},0){Y}%
\pnode(\value{x},\value{y}){Z}%
\pnode(3,0){C}%
\pnode(6,0){D}%
\pnode(9,0){E}%
\pnode(12,0){F}%
\pnode(15,0){G}%
\pnode(18,0){H}%
\battery (Z)(A){$U_0$}%
\wire (A)(B)%
\wire (Y)(Z)%
}%
\def\bc{\noexpand#4} %hier sollen die Teile zur Schaltung hinzugefügt werden
\def\cd{\noexpand#5}
\def\de{\noexpand#6}
\def\ef{\noexpand#7}
\def\fg{\noexpand#8}
\def\gh{\noexpand#9}
\eappto\Standard{\bc}
\eappto\Standard{\cd}
\eappto\Standard{\de}
\eappto\Standard{\ef}
\eappto\Standard{\fg}
\eappto\Standard{\gh}
\Standard%
\end{pspicture}%
}[/code]
Leider funktioniert das nicht so wie es soll.
Fehler:
! Argument of \@Lampe has an extra }.
! Paragraph ended before \@Lampe was complete.
! File ended while scanning use of \@Schaltung.
! Emergency stop.
Minimalbeispiel:
[code]\documentclass{minimal}
\usepackage{etoolbox}
\usepackage{pst-circ}
\usepackage{multido}
\makeatletter
\def \PosA {(B)(C)}
\def \PosB {(C)(D)}
\def \PosC {(D)(E)}
\def \PosD {(E)(F)}
\def \PosE {(F)(G)}
\def \PosF {(G)(H)}
\newcommand*{\Lampe}[1]{%
\protected@edef\@tempa{#1}%
\expandafter\@Lampe\@tempa\@nil
}
\newcommand*{\@Lampe}{}
\def\@Lampe#1,#2\@nil{%
\ifcsname#1\endcsname
\protected@edef\@tempb{%
\protect\lamp\csname#1\endcsname{$#2$}%
}%
\@tempb
\else
\PackageError{xyz}{Command `\@backslashchar#1' not defined}{\@ehc}%
\fi
}
\newcommand*{\Schaltung}[1]{%
\protected@edef\@tempa{#1}%
\expandafter\@Schaltung\@tempa\@nil
}
\newcommand*{\@Schaltung}{}
\def\@Schaltung#1,#2,#3,#4,#5,#6,#7,#8,#9\@nil{%
\psset {unit=#1cm}%
\newcounter{x}
\newcounter{y}
\newcounter{xmax}
\newcounter{ymax}
\setcounter{x}{#2}
\setcounter{y}{#3}
\setcounter{xmax}{\value{x}}
\setcounter{ymax}{\value{y}}
\addtocounter{xmax}{1}
\addtocounter{ymax}{1}
\begin{pspicture}[showgrid=false](-1,-1)(\value{xmax},\value{ymax})
\def\Standard{%
\pnode(0,\value{y}){A}%
\pnode(0,0){B}%
\pnode(\value{x},0){Y}%
\pnode(\value{x},\value{y}){Z}%
\pnode(2,0){C}%
\pnode(4,0){D}%
\pnode(6,0){E}%
\pnode(8,0){F}%
\pnode(10,0){G}%
\pnode(12,0){H}%
\battery (Z)(A){$U_0$}%
\wire (A)(B)%
\wire (Y)(Z)%
\wire (H)(Y)%
}%
\def\bc{\noexpand#4}
\def\cd{\noexpand#5}
\def\de{\noexpand#6}
\def\ef{\noexpand#7}
\def\fg{\noexpand#8}
\def\gh{\noexpand#9}
\eappto\Standard{\bc}
\eappto\Standard{\cd}
\eappto\Standard{\de}
\eappto\Standard{\ef}
\eappto\Standard{\fg}
\eappto\Standard{\gh}
\Standard%
\end{pspicture}%
}
\makeatother
\begin{document}
\begin{center}
\Schaltung{1,13,4,%
\Lampe{PosA,L_1},%
\Lampe{PosB,L_2},%
\Lampe{PosC,L_3},%
\Lampe{PosD,L_4},%
\Lampe{PosE,L_5},%
\Lampe{PosF,L_6}%
}
\end{center}
\end{document}[/code]