Math & ScienceImproving a Matrix

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Lucasqcgroup
Posts: 1
Joined: Fri Jan 04, 2013 4:32 pm

Improving a Matrix

Post by Lucasqcgroup »

Dear all,

I'm trying to type the following matrix:
matrixf.png
matrixf.png (3.24 KiB) Viewed 3403 times
But I could only get this:
mymatrix.png
mymatrix.png (10.32 KiB) Viewed 3403 times
I used the following code:

Code: Select all

\renewcommand{\arraystretch}{2}
\[
g :=\left(
\begin{array}{c|c}
\mathbf{2^D} & \textbf{1} \\ \hline
\textbf{1} & \begin{array}{cc}
\boldsymbol{1^\alpha} & \textbf{0} \\
\textbf{0} & \boldsymbol{1^\beta}
\end{array} \\ 
\end{array}
\right)
\]
There is too much space between the entries of the matrix and the vertical and horizontal lines.

How could I improve my matrix [typeset it correctly] ?

Any help would be greatly appreciated.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

percusse
Posts: 3
Joined: Mon Nov 12, 2012 11:24 pm

Improving a Matrix

Post by percusse »

You might better avoid the nesting of arrays as much as you can in order to avoid such spacing and padding problems.

Here is something that comes to close to the given example. You can still modify the array stretch to 1.3 or higher, alternatively add some \mathstruts etc. I recommend reading Hendrik Vogt's nice answer on TeX.sx.

Code: Select all

\documentclass{article}
\usepackage{amsmath,array,multirow}

\begin{document}
    \[
    g :=\left(
    \begin{array}{c|cc}
    2^D                & \multicolumn{2}{c}{1} \\ \hline
    \multirow{2}{*}{1} & 1^\alpha              & 0 \\
                       & 0                     & 1^\beta
    \end{array}
    \right)
    \]   
\end{document}
Attachments
texse.png
texse.png (7.14 KiB) Viewed 3405 times
Post Reply