Math & ScienceCustom matrix border

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
JoelSjogren
Posts: 3
Joined: Tue Jul 22, 2014 9:43 pm

Custom matrix border

Post by JoelSjogren »

Hi, I want to create a matrix with a custom border. I'm pretty new to latex. This is what I have in mind: <polynum.png>.

I found a reference http://www.tex.ac.uk/ctan/info/math/vos ... thmode.pdf, in which section 5 discusses how to use \bordermatrix to get [ ] or { } instead of the regular ( ) border. Maybe the implementation given there could be used as a starting point; however it looks very complicated to me. Before I start trying to understand that wall of commands, I want to hear someone's comment on this whole matter.

Also I found these symbols: \urcorner, \llcorner.
Attachments
polynum.png
polynum.png (1.03 KiB) Viewed 7595 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
esdd
Posts: 36
Joined: Sat Jan 25, 2014 9:13 pm

Custom matrix border

Post by esdd »

Here is a suggestion using tikz

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\usepackage{tikz}
\newcommand\mborder[2][]{%
  \tikz[anchor=base,baseline]{
    \node[inner sep=1pt,#1](h){$\displaystyle#2\mathstrut$};
    \draw([xshift=.25em]h.south west)--(h.south west)--(h.north west)
       --(h.north east)--([yshift=-.25em]h.north east);
  }%
}

\begin{document}
  \begin{align*}
    A & = \mborder{\begin{matrix}x_1 &x_2\\ y_1&y_2\end{matrix}}
  \end{align*}
\end{document}
matrixborder.png
matrixborder.png (3.06 KiB) Viewed 7583 times
Best regards
Elke
JoelSjogren
Posts: 3
Joined: Tue Jul 22, 2014 9:43 pm

Re: Custom matrix border

Post by JoelSjogren »

It looks great!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Re: Custom matrix border

Post by Stefan Kottwitz »

Hi JoelSjogren,

welcome to the forum!

Yes, Elke is a TikZ wizard, I often see her TikZ magic where basic LaTeX is not enough. :-)
TikZ is a package with really a lot of capabilities, but don't hesitate to use it also for such small things.

Stefan
LaTeX.org admin
JoelSjogren
Posts: 3
Joined: Tue Jul 22, 2014 9:43 pm

Re: Custom matrix border

Post by JoelSjogren »

I'll look into that package some more. I heard of it before when I needed to draw intervals and it seems useful :)
Post Reply