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:

3
  • 2
    lgroup and rgroup ? Commented Dec 24, 2023 at 21:50
  • @DavidCarlisle, thanks, that may be it. Is there some predefined environment to get matrices with \lgroup/\rgroup?
    – Alexey
    Commented Dec 24, 2023 at 21:55
  • 1
    \newenvironment{gmatrix}{\left\lgroup\env@matrix}{\endmatrix\right\rgroup} inside a .sty or \makeatletter Commented Dec 24, 2023 at 22:06

1 Answer 1

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}
5
  • I wonder if I could also have starred versions like pmatrix*, where I can specify the alignment, like [r].
    – Alexey
    Commented Dec 24, 2023 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, Commented Dec 24, 2023 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
    Commented Dec 25, 2023 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
    Commented Dec 25, 2023 at 10:47
  • @Alexey you lose the extra negative space between the delimiter and matrix but that may not be optimal anyway for these Commented Dec 25, 2023 at 12:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .