我按照以下回答中的建议,将一列标题垂直居中这个帖子使用array
和m{}
。我怎样才能右对齐这些标题?
以下是我当前的表格和结果的图片:
\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}
答案1
您可以使用以下>{...}
语法将列设置为\raggedleft
(或者\RaggedLeft
如果ragged2e
包已加载):
\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}