如何对齐列中的数据?

如何对齐列中的数据?

我的第三列中的数据未对齐。如果您能帮助我对齐并更正表格的格式,我将不胜感激。 在此处输入图片描述

\captionsetup{justification=centering,singlelinecheck=false,labelfont=sc,labelsep = newline}
        \renewcommand*\thetable{\Roman{table}}
    \begin{document}
    \begin{table}
        \begin{center}
            \begin{tabular}{l||c||c{5cm}}
                \hhline{===}
                \rowcolor{mg}
                Security Level & Security Mode & Protection\\\hline
                \hhline{===} 
                0 & No Security      &\vtop{\hbox{\strut Data is not encrypted}\hbox{\strut Data authenticity is not validated}}\\\hline
                1 & AES-CBC-MAC-32   &\vtop{\hbox{\strut Data is not encrypted}\hbox{\strut Data authenticity using a 32-bit MIC}}\\\hline  
                2 & AES-CBC-MAC-64   &\vtop{\hbox{\strut Data is not encrypted}\hbox{\strut Data authenticity using 64-bit MIC}}\\\hline  
                3 & AES-CBC-MAC-128  &\vtop{\hbox{\strut Data is not encrypted}\hbox{\strut Data authenticity using 128-bit MIC}}\\\hline  
                4 & AES-CTR          &\vtop{\hbox{\strut Data is encrypted}\hbox{\strut Data authenticity is not validated}}\\\hline  
                5 & AES-CCM-32       &\vtop{\hbox{\strut Data is encrypted}\hbox{\strut Data authenticity using a 32-bit MIC}}\\\hline  
                6 & AES-CCM-64       &\vtop{\hbox{\strut Data is encrypted}\hbox{\strut Data authenticity using a 64-bit MIC}}\\\hline  
                7 & AES-CCM-128      &\vtop{\hbox{\strut Data is encrypted}\hbox{\strut Data authenticity using a 128-bit MIC}}\\\hline
            \end{tabular}
            \caption{\label{tab:tab1} {Security modes in the IEEE802.15.4e Standard. \cite{19}}}
        \end{center}
    \end{table}

答案1

除了@DavidCarlisle的宝贵意见外,我根本不推荐这种表格样式,它有太多视觉干扰,难以阅读。我建议使用booktabs和删除所有这些垂直和水平规则,以获得更干净、更专业的外观。作为奖励,标记也简单得多。

\documentclass[a4paper]{article}
\usepackage{booktabs, tabularx}
\usepackage{caption}

\captionsetup{justification=centering,singlelinecheck=false,labelfont=sc,labelsep = newline}
        \renewcommand*\thetable{\Roman{table}}
\begin{document}
\begin{table}
\begin{tabularx}{\textwidth}{@{}clX@{}}
  \toprule
  Security Level & Security Mode & Protection \\
  \midrule
  0 & No Security     & Data is not encrypted \newline Data authenticity is not validated   \\ 
  1 & AES-CBC-MAC-32  & Data is not encrypted \newline Data authenticity using a 32-bit MIC \\   
  2 & AES-CBC-MAC-64  & Data is not encrypted \newline Data authenticity using 64-bit MIC   \\   
  3 & AES-CBC-MAC-128 & Data is not encrypted \newline Data authenticity using 128-bit MIC  \\   
  4 & AES-CTR         & Data is encrypted \newline Data authenticity is not validated       \\   
  5 & AES-CCM-32      & Data is encrypted \newline Data authenticity using a 32-bit MIC     \\   
  6 & AES-CCM-64      & Data is encrypted \newline Data authenticity using a 64-bit MIC     \\   
  7 & AES-CCM-128     & Data is encrypted \newline Data authenticity using a 128-bit MIC    \\
  \bottomrule
\end{tabularx}
\caption{\label{tab:tab1} {Security modes in the IEEE802.15.4e Standard. \cite{19}}}
\end{table}

\end{document}

在此处输入图片描述

相关内容