alt text

Ich habe ein Applet für Lineare Gleichungssyteme entworfen.

Damit kann ich aus pgfplotstables Matrizen \MatrixI, \MatrixII,... erstellen.

Für die Anordnung der pgfplotstables musste ich eine TikZ-Matrix bemühen (habe es anders nicht hinbekommen).

Das tut eigentlich soweit alles.

· Allerdings erzeugt der Code haufenweise Badboxen.

· Auch kriege ich, egal was ich einstelle diese riesen Lücke hier nicht weg

alt text

Also falls jemand Lust hat, mir zu helfen, den Code zu optimieren und mal drüber schauen möchte, wäre das sehr nett.

Öffne in Overleaf
%\documentclass[]{article}
\documentclass[border=3mm, tikz]{standalone}
\usepackage{pgfplotstable, amsmath}
\usepackage{tikz}

\usetikzlibrary{matrix}

% Applet für die Eingabe von Linearen Gleichungssystemen
% v2.0
\pgfplotsset{compat=1.13}
\pgfplotstableset{header=false}

% Eingabe 1/3     "Matrizen eingeben":
\pgfplotstableread[]{
1   2   -1   1   {}
0   1    1    2   {}
2   1    1    1   {-2\mal I}
3   2    1    1   {-3\mal I}
}\matrixI

\pgfplotstableread[]{
1    2   -1     1   {}
0    1    1     2   {}
0   -3    3    -1   {}
0   -4    4    -2   {:2}
}\matrixII

\pgfplotstableread[]{
1    2   -1     1   {-2\mal II}
0    1    1     2   {}
0   -3    3    -1   {+3\mal II}
0   -2    2    -1   {+2\mal II}
}\matrixIII

\pgfplotstableread[]{
1    0   -3     -3   {}
0    1    1      2   {}
0    0    6      5   {}
0    0    4      3   {3\mal IV-2\mal III}
}\matrixIV

\pgfplotstableread[]{
1    0   -3     -3   {}
0    1    1       2   {}
0    0    6       5   {}
0    0    0      -1   {\Error}
}\matrixV

% Eingabe 2/3 "Ausgabe festlegen":
\newcommand{\Ausgabe}{
{\MatrixI}     \&  \step  \& {\MatrixII} \& \step    \\
{\MatrixIII}  \&  \step  \& {\MatrixIV} \& \step    \\
{\MatrixV}    \&          \&                    \&   \\
}

% % Eingabe 1/3  "Evtl. Anordnung der Matrizen festlegen"
\tikzset{nodes={text width=3.75cm},% für Matrizen
myset/.style={%column sep=15cm, 
column #1/.style={nodes={text width=2em}
}% für step-Spalten
}, 
myset/.list={2,4,...,100}, 
}
% ===================================

% Sonderzeichen
\newcommand\mal{$\cdot$} % Malpunkt
\newcommand\Error{%
\begin{tikzpicture}[baseline=-1ex, scale=0.05, outer sep=0pt]
\draw[->] (3,3)--(0,0)--(3,1)--(0,-3);
\end{tikzpicture}}
\newcommand\step{$\rightarrow$}

% Allgemeine und spezielle Einstellungen
\pgfplotstableset{%header=false, % da bereits oben
string type, 
every head row/.style={output empty row},% 
ErweiterteKoeffizientenMatrix/.style={
column type=r,
postproc cell content/.append style={/pgfplots/table/@cell content/.add={$}{$}},
},%
AnnotationsSpalte/.style={
column type=l,
postproc cell content/.append style={/pgfplots/table/@cell content/.add={\tt\footnotesize\hspace{-0.75em}}{},}
}%
}

% Matrizen erstellen ============================
\newcommand{\Dimensionen}[1]{%
\pgfplotstablegetcolsof{#1}
\pgfmathtruncatemacro{\LetzteSpalteNummer}{\pgfplotsretval-1}
\pgfplotstablegetcolsof{#1}
\pgfmathtruncatemacro{\VorletzteSpalteNummer}{\pgfplotsretval-2}
\pgfplotstablegetcolsof{#1}
\pgfmathtruncatemacro{\VorvorletzteSpalteNummer}{\pgfplotsretval-3}
}

% Kommandos \MatrixI, \MatrixII,... erstellen =============
\newcounter{MatrixNummer}
\loop
% Kommandos für Matrizen erstellen ===
\ifnum\value{MatrixNummer}<99
\stepcounter{MatrixNummer}
\expandafter\edef\csname Matrix\Roman{MatrixNummer}\endcsname
{%
\noexpand\Dimensionen{\expandafter\noexpand\csname matrix\Roman{MatrixNummer}\endcsname}
{$\left\lgroup \noexpand\pgfplotstabletypeset[ErweiterteKoeffizientenMatrix, columns={0,...,\noexpand\VorletzteSpalteNummer\noexpand},
columns/\noexpand\VorvorletzteSpalteNummer\noexpand/.style={column type=r|},
]{\expandafter\noexpand\csname matrix\Roman{MatrixNummer}\endcsname}\right\rgroup$}%
%
\noexpand\pgfplotstabletypeset[AnnotationsSpalte,
columns={\noexpand\LetzteSpalteNummer\noexpand}
]{\expandafter\noexpand\csname matrix\Roman{MatrixNummer}\endcsname}%
}% ===
\repeat
% =================================

\begin{document}
\begin{tikzpicture}[]
\matrix[myset,
matrix of nodes, nodes in empty cells, 
column sep=1cm, 
nodes={align=left, anchor=center}, ampersand replacement=\&] (m) {
\Ausgabe
};

%\fill[red] (m-1-2.center) circle(1mm);
\end{tikzpicture}
\end{document}

gefragt 10 Okt '18, 01:23

cis's gravatar image

cis
9.5k75452491
Akzeptiert-Rate: 29%

bearbeitet 10 Okt '18, 19:09


Mit einer simplen Bauart

Öffne in Overleaf
\tikzset{matrixstyle/.style={
%nodes={},
%column sep=5mm,
row sep=3mm, 
},  }

Bekomme ich an sich ein brauchbares Ergebnis. text width = <Wert> sollte hier m.E. vermieden werden, da die Annotationsspalte eine Extra-pgfplotstable ist und umgebrochen werden könnte (es sei denn, man passt halt an).

alt text

Öffne in Overleaf
%\documentclass[]{article}
\documentclass[border=3mm, tikz]{standalone}
\usepackage{pgfplotstable, amsmath}
\usepackage{tikz}

\usetikzlibrary{matrix}

% Applet für die Eingabe von Linearen Gleichungssystemen
% v2.0
\pgfplotsset{compat=1.13}
\pgfplotstableset{header=false}

% Eingabe 1/3     "Matrizen eingeben":
\pgfplotstableread[]{
1   2   -1   1   {}
0   1    1    2   {}
2   1    1    1   {-2\mal I}
3   2    1    1   {-3\mal I}
}\matrixI

\pgfplotstableread[]{
1    2   -1     1   {}
0    1    1     2   {}
0   -3    3    -1   {}
0   -4    4    -2   {:2}
}\matrixII

\pgfplotstableread[]{
1    2   -1     1   {-2\mal II}
0    1    1     2   {}
0   -3    3    -1   {+3\mal II}
0   -2    2    -1   {+2\mal II}
}\matrixIII

\pgfplotstableread[]{
1    0   -3     -3   {}
0    1    1      2   {}
0    0    6      5   {}
0    0    4      3   {3\mal IV-2\mal III}
}\matrixIV

\pgfplotstableread[]{
1    0   -3     -3   {}
0    1    1       2   {}
0    0    6       5   {}
0    0    0      -1   {\Error}
}\matrixV

% Eingabe 2/3 "Ausgabe festlegen":
\newcommand{\Ausgabe}{%
{\MatrixI}     \&  \step  \&   {\MatrixII} \& \step    \\
{\MatrixIII}  \&  \step  \&   {\MatrixIV} \& \step    \\
{\MatrixV}    \&          \&                    \&   \\
}

% % Eingabe 3/3  "Eventuell Stil für Matrizen festlegen"
\tikzset{matrixstyle/.style={
%nodes={},
%column sep=5mm,
row sep=3mm, 
},  }
% ===================================

% Sonderzeichen
\newcommand\mal{$\cdot$} % Malpunkt
\newcommand\Error{%
\begin{tikzpicture}[baseline=-1ex, scale=0.05, outer sep=0pt]
\draw[->] (3,3)--(0,0)--(3,1)--(0,-3);
\end{tikzpicture}}
\newcommand\step{$\rightarrow$}

% Allgemeine und spezielle Einstellungen
\pgfplotstableset{%header=false, % da bereits oben
string type, 
every head row/.style={output empty row},% 
ErweiterteKoeffizientenMatrix/.style={
column type=r,
postproc cell content/.append style={/pgfplots/table/@cell content/.add={$}{$}},
},%
AnnotationsSpalte/.style={
column type=l,
postproc cell content/.append style={/pgfplots/table/@cell content/.add={\ttfamily\footnotesize\hspace{-0.75em}}{},}
}%
}

% Matrizen erstellen ============================
\newcommand{\Dimensionen}[1]{%
\pgfplotstablegetcolsof{#1}
\pgfmathtruncatemacro{\LetzteSpalteNummer}{\pgfplotsretval-1}
\pgfplotstablegetcolsof{#1}
\pgfmathtruncatemacro{\VorletzteSpalteNummer}{\pgfplotsretval-2}
\pgfplotstablegetcolsof{#1}
\pgfmathtruncatemacro{\VorvorletzteSpalteNummer}{\pgfplotsretval-3}
}

% Kommandos \MatrixI, \MatrixII,... erstellen =============
\newcounter{MatrixNummer}
\loop
% Kommandos für Matrizen erstellen ===
\ifnum\value{MatrixNummer}<99
\stepcounter{MatrixNummer}
\expandafter\edef\csname Matrix\Roman{MatrixNummer}\endcsname
{%
\noexpand\Dimensionen{\expandafter\noexpand\csname matrix\Roman{MatrixNummer}\endcsname}
{$\left\lgroup \noexpand\pgfplotstabletypeset[ErweiterteKoeffizientenMatrix, columns={0,...,\noexpand\VorletzteSpalteNummer\noexpand},
columns/\noexpand\VorvorletzteSpalteNummer\noexpand/.style={column type=r|},
]{\expandafter\noexpand\csname matrix\Roman{MatrixNummer}\endcsname}\right\rgroup$}%
%
\noexpand\pgfplotstabletypeset[AnnotationsSpalte,
columns={\noexpand\LetzteSpalteNummer\noexpand}
]{\expandafter\noexpand\csname matrix\Roman{MatrixNummer}\endcsname}%
}% ===
\repeat
% =================================

\begin{document}
\begin{tikzpicture}[]
\matrix[
matrix of nodes, nodes in empty cells, 
nodes={align=left, anchor=west}, 
ampersand replacement={\&}, 
matrixstyle] (m) {\Ausgabe};

%\fill[red] (m-1-2.center) circle(1mm);
\end{tikzpicture}
\end{document}
Permanenter link

beantwortet 14 Okt '18, 22:09

cis's gravatar image

cis
9.5k75452491
Akzeptiert-Rate: 29%

bearbeitet 14 Okt '18, 22:18

Deine Antwort
Vorschau umschalten

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Markdown-Grundlagen

  • *kursiv* oder _kursiv_
  • **Fett** oder __Fett__
  • Link:[Text](http://url.com/ "Titel")
  • Bild?![alt Text](/path/img.jpg "Titel")
  • nummerierte Liste: 1. Foo 2. Bar
  • zum Hinzufügen ein Zeilenumbruchs fügen Sie einfach zwei Leerzeichen an die Stelle an der die neue Linie sein soll.
  • grundlegende HTML-Tags werden ebenfalls unterstützt

Frage-Themen:

×39

gestellte Frage: 10 Okt '18, 01:23

Frage wurde gesehen: 3,570 Mal

zuletzt geändert: 14 Okt '18, 22:18