在我的项目文档中我必须使用许多表格但我的表格看起来确实很奇怪。
我尝试过这个:
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|c|}
\cline{2-4}
\multicolumn{}{c|}{} & Application Layer&Transport\&Network Layer&Data Link\&Physical Layer\\
&Layer 7& Layer 4\&3&Layer 2\&1\\ \hline
WAN&IEC 62056/COSEM&TCP/IP&IEC 62056/COSEM\\
&&&PLC G3\\
&&&
\begin{center}
Fibre VLAN
\end{center}
\\ \hline
HAN&ZigBee Smart Energy 1.0/2.0&ZigBee 2.0&ZigBee\\
&EN 13757-3 M-Bus&EN 50090-4&PLC\\
&IEC 62056/COSEM&&\\
&EN 50090-3\\
&&&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}
有人能帮帮我吗?谢谢
答案1
有些&
垂直线缺失,并且前两行最有可能应该省略“|”。
该代码现在可以运行,但我并不建议使用这种表格外观。
\documentclass{article}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|*{4}{c|}}
\cline{2-4}
\multicolumn{1}{c|}{} & Application Layer&Transport\&Network Layer&Data Link\&Physical Layer\tabularnewline
\multicolumn{1}{c|}{} & Layer 7& Layer 4\&3&Layer 2\&1\tabularnewline
\hline
WAN&IEC 62056/COSEM&TCP/IP&IEC 62056/COSEM\tabularnewline
&&&PLC G3\tabularnewline
&&&
Fibre VLAN
\tabularnewline \hline
HAN&ZigBee Smart Energy 1.0/2.0&ZigBee 2.0&ZigBee\tabularnewline
&EN 13757-3 M-Bus&EN 50090-4& PLC\tabularnewline
&IEC 62056/COSEM&&\tabularnewline
&EN 50090-3 & & \tabularnewline
&&&EN 13757-2 M-Bus\tabularnewline
&&&EN 50090-4\tabularnewline
\hline
\end{tabular}
\caption[Standardization bodies]{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}
答案2
这是一个解决方案,使用\makecell
,允许在单元格中换行,从而简化代码。我加载了geometry
包,默认情况下,它的边距比默认值更合理(除非您想要边距注释)。否则,您必须将字体大小设置为\scriptsize
。
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{array, makecell, caption}
\begin{document}
\mbox{}\vskip1cm
\begin{table}[h]
\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}
\end{document}
答案3
如果使用附加包不是障碍,请考虑为您的表使用以下代码:
\documentclass{article}
\usepackage{makecell}% <-- new package
\usepackage[margin=25mm,showframe]{geometry}% for show page layout
\begin{document}
\vspace*{1ex}
\begin{table}[h]
\centering
\begin{tabular}{|*{4}{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}
\tabularnewline
\hline
WAN & IEC 62056/COSEM
& TCP/IP
& \makecell[t]{IEC 62056/COSEM\\
PLC G3\\
Fibre VLAN} \tabularnewline
\hline
HAN & \makecell[t]{ZigBee Smart Energy 1.0/2.0\\
EN 13757-3 M-Bus \& EN 50090-4\\
IEC 62056/COSEM\\
EN 50090-3}
& \makecell[t]{ZigBee 2.0\\
EN 50090-4}
& \makecell[t]{ZigBee\\
PLC} \tabularnewline
& & & \makecell[t]{EN 13757-2 M-Bus\\
EN 50090-4} \tabularnewline
\hline
\end{tabular}
\caption[Standardization bodies]{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}
如果你想让\hline
s 和单元格内容之间的距离更大,那么在begin{table}
添加
\begin{table}[h]
\centering
\setcellgapes{2pt}% <--
\makegapedcells % <--
...
表格变成这样: