
次の表を、「21」がヘッダーの中央にくるように配置しようとしています。
\begin{table}[h]
\centering
\begin{tabularx}{1.09\textwidth}{|cll>{\raggedleft\arraybackslash}X|}
\hline
\textbf{ID} & \textbf{Severity} & \textbf{Vulnerability} &
\textbf{Occurrences} \\
\hline
111111 & Lorem & Lorem ipsum dolor sit amet & 21 \\
\hline
\end{tabularx}
\caption{example}
\label{table:example}
\end{table}
\centering
最後の列にの代わりにを使用すると\raggedleft
、数字がヘッダーの下の中央に配置されますが、そうするとヘッダーが左に行き過ぎてしまいます。ヘッダーを上の図のようにしたいのです。
これら 2 つを組み合わせる方法はありますか? ヘッダーは最初の画像のように右揃えですが、数字は 2 番目の画像のようにヘッダーの下に中央揃えになります。
答え1
X
4 番目のセルではなく 3 番目のセルに列タイプを使用します: \begin{tabularx}{1.09\textwidth}{|clXc|}
。 を使用する\makecell[r]{\textbf{Occurrences}}
と、ヘッダーを右揃えにすることができます:
\documentclass{article}
\usepackage{tabularx}
\usepackage{makecell}
\begin{document}
\begin{table}[h]
\centering
\begin{tabularx}{1.09\textwidth}{|clXc|}
\hline
\textbf{ID} & \textbf{Severity} & \textbf{Vulnerability} &
\makecell[r]{\textbf{Occurrences}} \\
\hline
111111 & Lorem & Lorem ipsum dolor sit amet & 21 \\
\hline
\end{tabularx}
\caption{example}
\label{table:example}
\end{table}
\end{document}