[Tex/LaTex] Auto center a table entry vertically and horizontally using tabularx

tablestabularx

I wonder if it's possible to automatically center a table entry vertically and horizontally within a tabularx environment.

You can see that the matrix does not center:
output

The code I want to adjust is:

\begin{table}[h]
\renewcommand{\arraystretch}{1.1}
\centering{\caption{Test Table}
    \begin{tabularx}{\textwidth}{|X||c|c|c|c|c|}
        \hline          
        Holder1 & \multicolumn{2}{c|}{Holder2}& \multicolumn{2}{c|}{Holder3} & Holder4 \\
        %   \cline{2-5} 
        & $\boldsymbol{X}_1$    & $\boldsymbol{X}_1$ & $\boldsymbol{X}_2$ & {$\boldsymbol{X}_2$} & {Holder4 additional}\\
        \cline{1-6}
        abcv abcv abcv abcv abcv abcv ac sf abcv abcv & $\begin{bmatrix} W_{11}  \end{bmatrix}$   & $\begin{bmatrix} D_{11}  \end{bmatrix}$    & $\begin{bmatrix} K_{12}  \end{bmatrix}$    & 0  & 22\\
        \hline
        abcv abcv abcv abcv abcv abcv ac sf abcv abcv & $\begin{bmatrix} DD_{11} \\ Kl_{21}  \end{bmatrix}$      & $\begin{bmatrix} D_{11} \\ D_{21}  \end{bmatrix}$     & $\begin{bmatrix} X_{12} \\ S_{22}  \end{bmatrix}$    & 0  & 1\\
        \hline
        \text{text text text} & $\begin{bmatrix} G_{11} & G_{41} \\ G_{21} & G_{51} \\ W_{31} & O_{61} \end{bmatrix}$      & $\begin{bmatrix} G_{11} \\ G_{21} \\ G_{31}  \end{bmatrix}$   & $\begin{bmatrix} F_{12} \\ F_{12} \\ X_{12}  \end{bmatrix}$   & 0  & 3\\
        \hline  
    \end{tabularx}
    \label{}}
\end{table} 

Best Answer

Redefine the X column type as m{#1}. I added some vertical padding with cellspace and extrarowheight and gave a decent spacing between caption and table with the caption package.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tabularx, caption}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\renewcommand{\tabularxcolumn}[1]{>{\centering}m{#1}}

\begin{document}

\begin{table}[h]
  \caption{Test Table}
  \setlength\extrarowheight{2pt}
  \begin{tabularx}{\textwidth}{|X||*{5}{Sc|}}
    \hline
    Holder1 & \multicolumn{2}{c|}{Holder2}& \multicolumn{2}{c|}{Holder3} & Holder4 \\
    \cline{2-5}
                                                         & $\boldsymbol{X}₁$ & $\boldsymbol{X}₁$ & $\boldsymbol{X}₂$ & {$\boldsymbol{X}₂$} & {Holder4 additional} \\
    \cline{1-6}
    \strut abcv abcv abcv abcv abcv abcv ac sf abcv abcv & $\begin{bmatrix} W_{11} \end{bmatrix}$ & $\begin{bmatrix} D_{11} \end{bmatrix}$ & $\begin{bmatrix} K_{12} \end{bmatrix}$ & 0 & 22 \\
    \hline
    abcv abcv abcv abcv abcv abcv ac sf abcv abcv & $\begin{bmatrix} DD_{11} \\ Kl_{21} \end{bmatrix}$ & $\begin{bmatrix} D_{11} \\ D_{21} \end{bmatrix}$ & $\begin{bmatrix} X_{12} \\ S_{22} \end{bmatrix}$ & 0 & 1 \\
    \hline
    \text{text text text} & $\begin{bmatrix} G_{11} & G_{41} \\ G_{21} & G_{51} \\ W_{31} & O_{61} \end{bmatrix}$ & $\begin{bmatrix} G_{11} \\ G_{21} \\ G_{31} \end{bmatrix}$ & $\begin{bmatrix} F_{12} \\ F_{12} \\ X_{12} \end{bmatrix}$ & 0 & 3 \\
    \hline
  \end{tabularx}
  \label{}
\end{table}

\end{document} 

enter image description here