Math & Science ⇒ Box around matrix entries
-
dearleader
- Posts: 3
- Joined: Fri Nov 27, 2009 10:19 pm
Box around matrix entries
I am trying to put coloured boxes around certain minors of an nxn matrix, but am unable to find anywhere on the web how to do this, and I was therefore hoping someone may have a suggestion on how to do this. Thank you in advance,
Jong-il
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Box around matrix entries
Code: Select all
\documentclass[english]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{amsmath}
\usepackage[table]{xcolor}
\begin{document}
\[
\begin{pmatrix}
\cellcolor{gray} 1 & 0 & 0 \\
0 & \cellcolor{gray} 1 & 0 \\
0 & 0 & \cellcolor{gray} 1
\end{pmatrix}
\]
\[
\left(
\begin{array}{ccc}
\cellcolor{gray} 1 & 0 & 0 \\
0 & \cellcolor{gray} 1 & 0 \\
0 & 0 & \cellcolor{gray} 1
\end{array}
\right)
\]
\end{document}Further information about the packages as well as their manuals can be found on CTAN.
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
dearleader
- Posts: 3
- Joined: Fri Nov 27, 2009 10:19 pm
Re: Box around matrix entries
After colouring several separate cells, I would like to put a frame around them. i.e. in your matrix I would like to colour the cells in the minor consisting of the entries in the 1st and 2nd row and column, and then put a frame around these 4 entries.
Thank you in advance,
Jong-il
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Box around matrix entries
Code: Select all
\documentclass[english]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{amsmath}
\usepackage[table]{xcolor}
\begin{document}
\[
\left(
\begin{array}{ccc}
\cellcolor{gray!25} a_{11} & \cellcolor{gray!25} a_{12} & a_{13} \\
\cellcolor{gray!25} a_{21} & \cellcolor{gray!25} a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33}
\end{array}
\right)
\]
\[
\left(
\begin{array}{ccc}\cline{1-2}
\multicolumn{1}{|c}{a_{11}} & \multicolumn{1}{c|}{a_{12}} & a_{13} \\
\multicolumn{1}{|c}{a_{21}} & \multicolumn{1}{c|}{a_{22}} & a_{23} \\ \cline{1-2}
a_{31} & a_{32} & a_{33}
\end{array}
\right)
\]
\[
\left(
\begin{array}{ccc}\cline{1-2}
\multicolumn{1}{|c}{\cellcolor{gray!25} a_{11}} & \multicolumn{1}{c|}{\cellcolor{gray!25} a_{12}} & a_{13} \\
\multicolumn{1}{|c}{\cellcolor{gray!25} a_{21}} & \multicolumn{1}{c|}{\cellcolor{gray!25} a_{22}} & a_{23} \\ \cline{1-2}
a_{31} & a_{32} & a_{33}
\end{array}
\right)
\]
\end{document}Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10