表格无法与段落中的文本对齐

表格无法与段落中的文本对齐

我的文档中有一个表格,但它看起来真的很丑,因为表格没有与文本垂直对齐。您可以查看屏幕截图和我的尝试。 在此处输入图片描述

尝试:

\mbox{}\vskip1cm
\begin{table}[t]
\centering\setcellgapes{3pt}\makegapedcells
\captionsetup{format=hang}
\setlength\tabcolsep{3.5pt}%\small
\begin{tabular}{|c|c|c|c|}
        \cline{2-4}
    \multicolumn{1}{c|}{} & \makecell{Application Layer\\Layer 7} & \makecell{Transport \& Network Layer\\Layer 4 \& 3} & \makecell{Data Link \& Physical Layer\\Layer 2 \& 1}\\
    \hline
    WAN & IEC 62056/COSEM & TCP/IP & \makecell{IEC 62056/COSEM\\ PLC G3\\Fibre VLAN}\\
       \hline
    HAN & \makecell{ZigBee Smart Energy 1.0/2.0\\EN 13757-3 M-Bus\\IEC 62056/COSEM\\EN 50090-3} & \makecell{ZigBee 2.0\\EN 50090-4} & \makecell{ZigBee\\PLC\\EN 13757-2 M-Bus\\EN 50090-4}\\
     \hline
    \end{tabular}
    \caption{The standardization bodies CEN, CENELEC and ETSI identify smart metering European data exchange and communication standards which are categorized by depending on the network layer model and the network size.}
    \label{table:standards}
   \end{table}

In addition, the CEN/CENELEC TC 205 technical committee ....

有人能帮我将我的表格与文本对齐吗?这对我来说真的是一个很重要的问题,因为我在其他表格上也遇到了类似的问题。

答案1

您可以使用tabularx并在其中一个单元格中添加一条线。我还建议不要使用垂直规则,以获得更专业的外观,而是使用 中的可变厚度规则booktabs,它会在规则周围添加一些垂直填充。

以下是两者的示例:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{array, makecell, caption, tabularx, booktabs}
\renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}p{#1}}
\renewcommand\cellalign{tc}

\begin{document}
\mbox{}\vspace{1cm}
\begin{table}[!htb]
\centering\setcellgapes{3pt}\makegapedcells
\captionsetup{format=hang}
\setlength\tabcolsep{3.5pt}%\small
\begin{tabularx}{\linewidth}{|c|X|X|X|}
    \cline{2-4}
\multicolumn{1}{c|}{} & \makecell{Application Layer\\Layer 7} & \makecell{Transport \& Network Layer\\Layer 4 \& 3} & \makecell{Data Link \& Physical Layer\\Layer 2 \& 1}\\
\hline
WAN & IEC 62056/COSEM & TCP/IP &\makecell{[IEC 62056/COSEM\\ PLC G3\\Fibre VLAN}\\
   \hline
HAN & \makecell{ZigBee \\Smart Energy 1.0/2.0\\EN 13757-3 M-Bus\\IEC 62056/COSEM\\EN 50090-3} & \makecell{ZigBee 2.0\\EN 50090-4} & \makecell{ZigBee\\PLC\\EN 13757-2 M-Bus\\EN 50090-4}\\
 \hline
\end{tabularx}
\caption{The standardization bodies CEN, CENELEC and ETSI identify smart metering European data exchange and communication standards which are categorized by depending on the network layer model and the network size.}
\label{table:standards}
\end{table}

In addition, the CEN/CENELEC TC 205 technical committee ....

\begin{table}[!htb]
\centering\setcellgapes{3pt}\makegapedcells
\captionsetup{format=hang}
\setlength\tabcolsep{3.5pt}%\small
\begin{tabularx}{\linewidth}{cXXX}
    \cmidrule[\heavyrulewidth]{2-4}
& \makecell{Application Layer\\Layer 7} & \makecell{Transport \& Network Layer\\Layer 4 \& 3} & \makecell{Data Link \& Physical Layer\\Layer 2 \& 1}\\
\cmidrule{2-4}
WAN & IEC 62056/COSEM & TCP/IP &\makecell{[IEC 62056/COSEM\\ PLC G3\\Fibre VLAN}\\
   \addlinespace
HAN & \makecell{ZigBee \\Smart Energy 1.0/2.0\\EN 13757-3 M-Bus\\IEC 62056/COSEM\\EN 50090-3} & \makecell{ZigBee 2.0\\EN 50090-4} & \makecell{ZigBee\\PLC\\EN 13757-2 M-Bus\\EN 50090-4}\\
    \cmidrule[\heavyrulewidth]{2-4}
\end{tabularx}
\caption{The standardization bodies CEN, CENELEC and ETSI identify smart metering European data exchange and communication standards which are categorized by depending on the network layer model and the network size.}
\label{table:standards}
\end{table}
\end{document} 

在此处输入图片描述

相关内容