4

When typesetting formulas with matrices, I have a difficulty choosing between parentheses and brackets. The usual parentheses look too wide, waste horizontal space, and do not highlight the matrix rectangular shape. The brackets can confuse the reader because I use brackets for other things too, and they disagree with how I write formulas on a blackboard (parentheses are easier to draw).

How can I have some kind of slim parentheses around a matrix, that are almost like brackets, but with rounded ends?


Related questions:

Alexey
  • 2,099

1 Answers1

7

You could use lgroup \rgroup (which are {} without the middle bits) or use an extended delimiter from a smaller font

enter image description here

\documentclass{article}

\usepackage{amsmath} \makeatletter \newenvironment{gmatrix}{\left\lgroup\env@matrix}{\endmatrix\right\rgroup} \newenvironment{xpmatrix}{\bgroup\scriptscriptstyle\left(\bgroup\displaystyle\env@matrix}{\endmatrix\egroup\right)\egroup}\makeatother \begin{document}

[X+\begin{pmatrix}a&b\c&d\end{pmatrix}+Y] [X+\begin{bmatrix}a&b\c&d\end{bmatrix}+Y] [X+\begin{pmatrix}a&b\c&d\end{pmatrix}+Y] [X+\begin{xpmatrix}a&b\c&d\end{xpmatrix}+Y] [X+\begin{gmatrix}a&b\c&d\end{gmatrix}+Y]

\end{document}

David Carlisle
  • 757,742
  • I wonder if I could also have starred versions like pmatrix*, where I can specify the alignment, like [r]. – Alexey Dec 24 '23 at 23:27
  • 1
    @Alexey I rolled back the edit, the code is repeated but it matches the image shown (could remake that of course) , I copied the amsmath versions if you copy the mathtools pmatrix* in the smame way you will get * versions of these, – David Carlisle Dec 24 '23 at 23:49
  • Copying definition from mathtools turned out not to be easy: it is in a .dtx file which I am not familiar with, and it uses command names like "\MT_matrix_begin:N", which cannot be read by latex without some tweaks. – Alexey Dec 25 '23 at 10:39
  • Will there be any adverse effects if instead of copying definitions, I build upon plain matrix environments? Like this: \newenvironment{mmatrix}{\left\lgroup\begin{matrix}}{\end{matrix}\right\rgroup}, \newenvironment{mmatrix*}[1][c]{\left\lgroup\begin{matrix*}[#1]}{\end{matrix*}\right\rgroup}. – Alexey Dec 25 '23 at 10:47
  • @Alexey you lose the extra negative space between the delimiter and matrix but that may not be optimal anyway for these – David Carlisle Dec 25 '23 at 12:31