0

Can I somehow make a pmatrix play nicely with a tabular environment? I tried using \def\arraystretch{1.5} but it made everything bigger. Here's a minimal example that shows my problem. I'm using XeLaTeX.

\documentclass[12pt,a4paper]{report}
\usepackage[english, polish]{babel}
\usepackage{graphicx}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amsfonts}
\begin{document}
\begin{table}[H]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|c|c|}
\hline
Ciąg do zakodowania & Wykorzystana bramka                                          & Powstały stan kwantowy \\ \hline
00                  & $ \mathbb{I} = \begin{bmatrix} 1 & 0 \\ 0 & 1\end{bmatrix} $ &                        \\ \hline
10                  & $ Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} $        &                        \\ \hline
01                  & $ X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$          &                        \\ \hline
11                  & $ Z*X $                                                      &                        \\ \hline
\end{tabular}%
}
\caption{A little bit too cramped :(}
\label{my-label}
\end{table}
\end{document}

The matrix brackets overlap the table border

Mzafki
  • 1

1 Answers1

1

The cellspace package enables you to define minimal vertical spacing at te top and bottom of vcells in columnx with specifier prefixed with the letter S (or C if you load siunitx).

Unrelated: you should never use \resizebox in tabulars, as it leads to inconsistent font sizes.

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english, polish]{babel}
\usepackage{graphicx}
\usepackage{float}
\usepackage{amsmath, amsfonts}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{4pt}

\begin{document}

\begin{table}[H]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|Sc|c|}
\hline
Ciąg do zakodowania & Wykorzystana bramka & Powstały stan kwantowy \\ \hline
00 & $ \mathbb{I} = \begin{bmatrix} 1 & 0 \\ 0 & 1\end{bmatrix} $ & \\ \hline
10 & $ Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} $ & \\ \hline
01 & $ X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$ & \\ \hline
11 & $ Z*X $ & \\ \hline
\end{tabular}%
}
\caption{Less cramped :)}
\label{my-label}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350