3

I've vertically centered a column of headings as suggested in an answer to this post using array and m{}. How can I also right-align those headings?

Here is a picture of my current table and the results:

enter image description here

\documentclass[a4paper]{article}

\usepackage[demo]{graphicx}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}

\begin{document}

\begin{figure}\centering%
    \def\tinySubWidth{2.5cm}
    \begin{tabular}{m{2cm}m{\tinySubWidth}m{\tinySubWidth}m{\tinySubWidth}m{\tinySubWidth}}
        &
        \centering Column 1&
        \centering Column 2&
        \centering Column 3&
        Column 4
        \\
        The first row heading%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}\\
        The second row heading%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}\\
        The third row heading%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}\\
        The fourth row heading%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}\\
    \end{tabular}
    \caption{Bla}
    \label{fig:res-axvel-latax}
\end{figure}

\end{document}
Moriambar
  • 11,466
Tim N
  • 10,219
  • 13
  • 63
  • 88

1 Answers1

2

You can use the >{...} syntax to set the column to be \raggedleft (or \RaggedLeft if the ragged2e package is loaded):

\documentclass[a4paper]{article}

\usepackage[demo]{graphicx}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}

\begin{document}

\begin{figure}\centering%
    \def\tinySubWidth{2.5cm}
    \begin{tabular}{>{\raggedleft}m{2cm}m{\tinySubWidth}m{\tinySubWidth}m{\tinySubWidth}m{\tinySubWidth}}
        &
        \centering Column 1&
        \centering Column 2&
        \centering Column 3&
        Column 4
        \\
        The first row heading%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}\\
        The second row heading%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}\\
        The third row heading%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}\\
        The fourth row heading%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}%
        &\includegraphics[width=\tinySubWidth]{path}\\
    \end{tabular}
    \caption{Bla}
    \label{fig:res-axvel-latax}
\end{figure}

\end{document}

enter image description here

Moriambar
  • 11,466
Gonzalo Medina
  • 505,128