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}
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.