Graphics, Figures & Tables ⇒ Draw line in a Matrix Equation
Draw line in a Matrix Equation
Hey,
sorry to bother you guys, but I think I couldn't find any answers to my specific question after I did some search around the BBS.
Basically, what I want to do is simply draw a diagonal line in my equation, which is shown here. I tried to put the environment 'equation' in environment 'figure', but it doesn't work.
Any idea of how to do that??
Many thanks!
Wolfrain
sorry to bother you guys, but I think I couldn't find any answers to my specific question after I did some search around the BBS.
Basically, what I want to do is simply draw a diagonal line in my equation, which is shown here. I tried to put the environment 'equation' in environment 'figure', but it doesn't work.
Any idea of how to do that??
Many thanks!
Wolfrain
NEW: TikZ book now 40% off at Amazon.com for a short time.

Draw line in a Matrix Equation
Can you provide a working minimal example for the equation without the line?
I would use pstricks nodes for such a problem as in:
I would use pstricks nodes for such a problem as in:
OS: Kubuntu
Distribution: TexLive
Editor: Kile
Distribution: TexLive
Editor: Kile
Draw line in a Matrix Equation
achim wrote:Can you provide a working minimal example for the equation without the line?
I would use pstricks nodes for such a problem as in:
Thank you my friend!!
Code: Select all
\documentclass[10pt,a4paper]{scrartcl}
\usepackage{amsmath}
\begin{document}
\begin{eqnarray}
\left | A_{4 \times 4} \right |=
\begin{vmatrix}
a_{11} & a_{12} & a_{13} & a_{14}\\
a_{21} & a_{22} & a_{23} & a_{24}\\
a_{31} & a_{32} & a_{33} & a_{34}\\
a_{41} & a_{42} & a_{43} & a_{44}
\end{vmatrix}
& = & ~~~a_{11}
\begin{vmatrix}
a_{22} & a_{23} & a_{24}\\
a_{32} & a_{33} & a_{34}\\
a_{42} & a_{43} & a_{44}
\end{vmatrix}
-a_{12}
\begin{vmatrix}
a_{21} & a_{23} & a_{24}\\
a_{31} & a_{33} & a_{34}\\
a_{41} & a_{43} & a_{44}
\end{vmatrix} \nonumber \\
& & + \: a_{13}
\begin{vmatrix}
a_{21} & a_{22} & a_{24}\\
a_{31} & a_{32} & a_{34}\\
a_{41} & a_{42} & a_{44}
\end{vmatrix}
-a_{14}
\begin{vmatrix}
a_{21} & a_{22} & a_{23}\\
a_{31} & a_{32} & a_{33}\\
a_{41} & a_{42} & a_{43}
\end{vmatrix} \nonumber \\
%\IEEEyesnumber\\
%%%%%%%%%%%%%%%%%%%%%
& = & ~~a_{11}
\left \{ a_{22}\underline{\begin{vmatrix}
a_{33} & a_{34} \\
a_{43} & a_{44}
\end{vmatrix} }_{<1>}
%{\tikz \node[draw,circle]{12};}
-a_{23}\underline{\begin{vmatrix}
a_{32} & a_{34} \\
a_{42} & a_{44}
\end{vmatrix}}_{<2>}
+a_{24}\underline{\begin{vmatrix}
a_{32} & a_{33} \\
a_{42} & a_{43}
\end{vmatrix} }_{<3>}
\right \} \nonumber \\
& & -a_{12}
\left \{ a_{21}\underline{\begin{vmatrix}
a_{33} & a_{34} \\
a_{43} & a_{44}
\end{vmatrix}}_{<1>}
-a_{23}\underline{\begin{vmatrix}
a_{31} & a_{34} \\
a_{41} & a_{44}
\end{vmatrix}}_{<4>}
+a_{24}\underline{\begin{vmatrix}
a_{31} & a_{33} \\
a_{41} & a_{43}
\end{vmatrix} }_{<5>}
\right \} \nonumber \\
& & +a_{13}
\left \{ a_{21}\underline{\begin{vmatrix}
a_{32} & a_{34} \\
a_{42} & a_{44}
\end{vmatrix} }_{<2>}
-a_{22}\underline{\begin{vmatrix}
a_{31} & a_{34} \\
a_{41} & a_{44}
\end{vmatrix}}_{<4>}
+a_{24}\underline{\begin{vmatrix}
a_{31} & a_{32} \\
a_{41} & a_{42}
\end{vmatrix} }_{<6>}
\right \} \nonumber \\
& & -a_{14}
\left \{ a_{21}\underline{\begin{vmatrix}
a_{32} & a_{33} \\
a_{42} & a_{43}
\end{vmatrix} }_{<3>}
-a_{22}\underline{\begin{vmatrix}
a_{31} & a_{33} \\
a_{41} & a_{43}
\end{vmatrix}}_{<5>}
+a_{23}\underline{\begin{vmatrix}
a_{31} & a_{32} \\
a_{41} & a_{42}
\end{vmatrix} }_{<6>}
\right \}
%\IEEEyesnumber\\
\label{eq:4-dimension-to-2-dimension}
\end{eqnarray}
\end{document}
Actually the .png file you attached is really close to what I want! Apart from the red line, I am also trying to add some curly lines, just like what you did, in my equation.
Really thank you for your assistance!
wolfrain
Draw line in a Matrix Equation
Code: Select all
\documentclass[10pt,a4paper]{scrartcl}
\usepackage{amsmath}
\usepackage{pstricks}
\usepackage{pst-all}
\usepackage{pstricks-add}
\begin{document}
\begin{eqnarray}
\left | A_{4 \times 4} \right |=
\begin{vmatrix}
a_{11} & a_{12} & a_{13} & a_{14}\\
a_{21} & a_{22} & a_{23} & a_{24}\\
a_{31} & a_{32} & \rnode{a33a}{a_{33}} & a_{34}\\
a_{41} & a_{42} & a_{43} & a_{44}
\end{vmatrix}
& = & ~~~a_{11}
\begin{vmatrix}
a_{22} & a_{23} & a_{24}\\
a_{32} & \rnode{a33b}{a_{33}} & a_{34}\\
a_{42} & a_{43} & a_{44}
\end{vmatrix}
-a_{12}
\begin{vmatrix}
a_{21} & a_{23} & a_{24}\\
a_{31} & a_{33} & a_{34}\\
a_{41} & a_{43} & a_{44}
\end{vmatrix} \nonumber \\
& & + \: a_{13}
\begin{vmatrix}
a_{21} & a_{22} & a_{24}\\
a_{31} & a_{32} & a_{34}\\
a_{41} & a_{42} & a_{44}
\end{vmatrix}
-a_{14}
\begin{vmatrix}
a_{21} & a_{22} & a_{23}\\
a_{31} & a_{32} & a_{33}\\
a_{41} & a_{42} & a_{43}
\end{vmatrix} \nonumber \\
%\IEEEyesnumber\\
%%%%%%%%%%%%%%%%%%%%%
& = & ~~a_{11}
\rnode{leftbracket}{}\left \{ a_{22}\underline{\begin{vmatrix}
a_{33} & a_{34} \\
a_{43} & a_{44}
\end{vmatrix} }_{<1>}
-a_{23}\underline{\begin{vmatrix}
a_{32} & a_{34} \\
a_{42} & a_{44}
\end{vmatrix}}_{<2>}
+a_{24}\underline{\begin{vmatrix}
a_{32} & a_{33} \\
a_{42} & a_{43}
\end{vmatrix} }_{<3>}
\right \} \nonumber \\
& & -a_{12}
\left \{ a_{21}\underline{\begin{vmatrix}
a_{33} & a_{34} \\
a_{43} & a_{44}
\end{vmatrix}}_{<1>}
-a_{23}\underline{\begin{vmatrix}
a_{31} & a_{34} \\
a_{41} & a_{44}
\end{vmatrix}}_{<4>}
+a_{24}\underline{\begin{vmatrix}
a_{31} & a_{33} \\
a_{41} & a_{43}
\end{vmatrix} }_{<5>}
\right \} \nonumber \\
& & +a_{13}
\left \{ a_{21}\underline{\begin{vmatrix}
a_{32} & a_{34} \\
a_{42} & a_{44}
\end{vmatrix} }_{<2>}
-a_{22}\underline{\begin{vmatrix}
a_{31} & a_{34} \\
a_{41} & a_{44}
\end{vmatrix}}_{<4>}
+a_{24}\underline{\begin{vmatrix}
a_{31} & a_{32} \\
a_{41} & a_{42}
\end{vmatrix} }_{<6>}
\right \} \nonumber \\
& & -a_{14}
\left \{ a_{21}\underline{\begin{vmatrix}
a_{32} & a_{33} \\
a_{42} & a_{43}
\end{vmatrix} }_{<3>}
-a_{22}\underline{\begin{vmatrix}
a_{31} & a_{33} \\
a_{41} & a_{43}
\end{vmatrix}}_{<5>}
+a_{23}\underline{\begin{vmatrix}
a_{31} & a_{32} \\
a_{41} & a_{42}
\end{vmatrix} }_{<6>}
\right \}\rnode{rightbracket}{}
%\IEEEyesnumber\\
\label{eq:4-dimension-to-2-dimension}
%
% Node connections:
\ncline[linecolor=red]{leftbracket}{rightbracket}
\nccurve[angleA=-60, ncurvA=1.5, angleB= 125, linewidth=0.6pt, linecolor=gray, linestyle=dashed]{->}{a33a}{a33b}
\end{eqnarray}
\end{document}
\rnode{label}{something} places a node on the 'something' object with a given label (much like labels for references in figures and tables).
You can then connect any existing node by using \ncline{firstlabel}{secondlabel} for a straight line. Additional commands for changing the line stile are accepted too. The \nccurve command does the same but with a curve instead of a plain straight line.
There are much more connecting lines available to choose from. For more on this check the pstricks documentation
Note:
The pstricks packages loaded in the preamble. Pdflatex compilation will nolonger work with the pdf package. You will have to compile tex-dvi-ps-pdf in order to use pstricks. This also means that any graphics included in the document (by \includegraphics{myepspic}) need to be encapsulated post script figures.
I hope this is not too much of a trade off for you. I personally use pstricks a lot and hence always compile tex-dvi-ps-pdf.
The last closing curly bracket looks odd, I don't know where this is coming from...(?) But, it was there before I started adding the nodes and lines. I'm clueless as to what causes this.
Cheers
Achim
ps: A general note on lines in equations. I think it's not regarded as good practice to cross out terms in equations, this should probably rather be described in text form. Also It becomes kind of messed up if you have too many arrows and lines pointing form one term to an other. I know this is exactly what I've done in the example I showed in my first response. I should mention, however, that I used this matrix in a beamer presentation and it served well for visualising my point.
"Use the Force wisely, Anakin...

OS: Kubuntu
Distribution: TexLive
Editor: Kile
Distribution: TexLive
Editor: Kile
Re: Draw line in a Matrix Equation
pps: The weird looking thing on the last bracket is the equation number.
If you put a \nonumber after the bracket it disappears...
Try to decrease the width of the equation or decrease the left/right borders of the document.
If you put a \nonumber after the bracket it disappears...
Try to decrease the width of the equation or decrease the left/right borders of the document.
OS: Kubuntu
Distribution: TexLive
Editor: Kile
Distribution: TexLive
Editor: Kile
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Draw line in a Matrix Equation
It is not recommendable to use the eqnarray environment [1]. Include the amsmath package and use its align environment. For more useful stuff about math typesetting take a look at the »Math mode« document.wolfrain wrote:[…] Above is the original code I used to generate the equation. […]
[1] The PracTeX Journal — TeX Users Group, Lars Madsen: Avoid eqnarray!
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Draw line in a Matrix Equation
achim wrote:pps: The weird looking thing on the last bracket is the equation number.
If you put a \nonumber after the bracket it disappears...
Try to decrease the width of the equation or decrease the left/right borders of the document.
Thank you so so much for your reply!


Your method really works in my case, however, there are 8 errors saying that "! No room for a new \dimen .", I think it is caused from the pstricks packages.
-
- Posts: 351
- Joined: Sat Aug 02, 2008 8:47 am
Draw line in a Matrix Equation
wolfrain wrote:achim wrote:Your method really works in my case, however, there are 8 errors saying that "! No room for a new \dimen .", I think it is caused from the pstricks packages.
Code: Select all
\usepackage{etex}
Draw line in a Matrix Equation
localghost wrote:It is not recommendable to use the eqnarray environment [1]. Include the amsmath package and use its align environment. For more useful stuff about math typesetting take a look at the »Math mode« document.wolfrain wrote:[…] Above is the original code I used to generate the equation. […]
As soon as the problem is sorted out, please act exactly according to Section 3 of the Board Rules.
[1] The PracTeX Journal — TeX Users Group, Lars Madsen: Avoid eqnarray!
Best regards
Thorsten
Thank you for your advice mate! I will give it a try.

Draw line in a Matrix Equation
Thank you for your reply~CrazyHorse wrote:wolfrain wrote:achim wrote:Your method really works in my case, however, there are 8 errors saying that "! No room for a new \dimen .", I think it is caused from the pstricks packages.HErbertCode: Select all
\usepackage{etex}
Actually the error message is something like this
Code: Select all
! No room for a new \dimen .
\ch@ck ...\else \errmessage {No room for a new #3}
\fi
1.297 \newdimen\pshooklength
Code: Select all
1.298 \newdimen\pshookwidth
1.1546 \newdimen\chart@ColorIndex
1.1547 \newdimen\chart@ColorStep
1.1548 \newdimen\pst@chartHeight
1.1549 \newdimen\pst@chartStackDepth
1.1550 \newdimen\pst@chartStackWidth