Math & Science ⇒ how to mark column number on a matrix
-
- Posts: 13
- Joined: Tue Oct 27, 2009 3:28 pm
how to mark column number on a matrix
I would like to indicate the column numbers on top of a matrix, how can I do it?
Currently, I use the top row to place column numbers, and it is not beautiful since the bracket[] enclose the top row. Ideally the column number should be outside the bracket.
Also the column number itself should be circled so as to standout from the numbers of the matrix itself. I used \ding{172} and \ding{173} from pifont package, however nothing shows up, though compilation was a success. any idea?
Currently, I use the top row to place column numbers, and it is not beautiful since the bracket[] enclose the top row. Ideally the column number should be outside the bracket.
Also the column number itself should be circled so as to standout from the numbers of the matrix itself. I used \ding{172} and \ding{173} from pifont package, however nothing shows up, though compilation was a success. any idea?
NEW: TikZ book now 40% off at Amazon.com for a short time.

how to mark column number on a matrix
You could two smaller matrices inside a larger one like this:
I don't know about the circle around the number, but I have seem a few post about similar things that were solved by using the pgf/TikZ packages.
EDIT: found the post I was thinking of
http://www.latex-community.org/forum/vi ... =44&t=6301
Code: Select all
\[
\begin{matrix}
\begin{matrix}
a&b&c
\end{matrix}\\
\begin{bmatrix}
1&2&3\\
4&5&6
\end{bmatrix}
\end{matrix}
\]
EDIT: found the post I was thinking of
http://www.latex-community.org/forum/vi ... =44&t=6301
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
how to mark column number on a matrix
You should build a minimal working example (MWE) that shows the problem. You can also search the forum as well as the "Math mode" document for \bordermatrix.patiobarbecue wrote:I would like to indicate the column numbers on top of a matrix, how can I do it?
Currently, I use the top row to place column numbers, and it is not beautiful since the bracket[] enclose the top row. Ideally the column number should be outside the bracket.
Also the column number itself should be circled so as to standout from the numbers of the matrix itself. I used \ding{172} and \ding{173} from pifont package, however nothing shows up, though compilation was a success. any idea?
Best regards and welcome to the board
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
-
- Posts: 13
- Joined: Tue Oct 27, 2009 3:28 pm
how to mark column number on a matrix
Unfortunately, using nested matrix doesn't lead to beautiful alignment. See the example below.
The manual for the \bordermatrix says it cannot be used together with AMS math, which disqualify it immediately since I mainly use AMS math. See page 21 of ftp://tug.ctan.org/pub/tex-archive/info ... thmode.pdf
Any other ideas?
Code: Select all
\begin{matrix}
\begin{matrix}
1 & 2
\end{matrix}
\\
\begin{bmatrix}
-1 & 1\\
0 & 1
\end{bmatrix}
\end{matrix}
Any other ideas?
-
- Posts: 162
- Joined: Wed Jun 17, 2009 10:18 pm
how to mark column number on a matrix
While not its intended use, perhaps you could use the Gauss-package. An example:
This does leave the problem of making the ring around the column number, for which I have no solution. Have you looked at the post mentioned above, where something like this was done with pgf/Tikz?
Code: Select all
\documentclass[a4paper,12pt]{article}
\usepackage{gauss}
\renewcommand{\colmultlabel}{}
\begin{document}
\[
\begin{gmatrix}[b]
a&b&c \\
d&e&f \\
g&h&i
\colops
\mult{0}{1}
\mult{1}{2}
\mult{2}{3}
\end{gmatrix}
\]
\end{document}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
how to mark column number on a matrix
The exact statement of the »Math mode« document at the referred place is slightly different.patiobarbecue wrote:[...] The manual for the \bordermatrix says it cannot be used together with AMS math, which disqualify it immediately since I mainly use AMS math. [...]
Hence there is no problem in using the \bordermatrix command even with the suggested enhancement to get the desired result.Math mode (Section5 - Matrix, p. 21) wrote:The matrix environment macro cannot be used together with the AMS math package, it redefines this environment (see section 26.6 on page 56).
Code: Select all
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{amsmath}
\usepackage{pifont}
\makeatletter
\newif\if@borderstar
\def\bordermatrix{\@ifnextchar*{%
\@borderstartrue\@bordermatrix@i}{\@borderstarfalse\@bordermatrix@i*}%
}
\def\@bordermatrix@i*{\@ifnextchar[{\@bordermatrix@ii}{\@bordermatrix@ii[()]}}
\def\@bordermatrix@ii[#1]#2{%
\begingroup
\m@th\@tempdima8.75\p@\setbox\z@\vbox{%
\def\cr{\crcr\noalign{\kern 2\p@\global\let\cr\endline }}%
\ialign {$##$\hfil\kern 2\p@\kern\@tempdima & \thinspace %
\hfil $##$\hfil && \quad\hfil $##$\hfil\crcr\omit\strut %
\hfil\crcr\noalign{\kern -\baselineskip}#2\crcr\omit %
\strut\cr}}%
\setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
\setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
\setbox\tw@\hbox{%
$\kern\wd\@ne\kern -\@tempdima\left\@firstoftwo#1%
\if@borderstar\kern2pt\else\kern -\wd\@ne\fi%
\global\setbox\@ne\vbox{\box\@ne\if@borderstar\else\kern 2\p@\fi}%
\vcenter{\if@borderstar\else\kern -\ht\@ne\fi%
\unvbox\z@\kern-\if@borderstar2\fi\baselineskip}%
\if@borderstar\kern-2\@tempdima\kern2\p@\else\,\fi\right\@secondoftwo#1 $%
}\null \;\vbox{\kern\ht\@ne\box\tw@}%
\endgroup
}
\makeatother
\begin{document}
\[
\bordermatrix[{[]}]{%
& \text{\ding{192}} & \text{\ding{193}} & \text{\ding{194}} \cr
& 1 & 1 & 0 \cr
& 1 & 1 & 0 \cr
& 1 & 1 & 0 \cr
& 1 & 0 & 1 \cr
& 1 & 0 & 1 \cr
& 1 & 0 & 1
}
\]
\end{document}
[1] View topic: Bmatrix Column Headings
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