Таблица не может быть выровнена с текстом в абзаце

Таблица не может быть выровнена с текстом в абзаце

У меня в документе есть таблица, но она выглядит действительно уродливо, так как таблица не выровнена по вертикали с текстом. Вы можете увидеть скриншот и мою попытку. введите описание изображения здесь

Пытаться:

\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} 

введите описание изображения здесь

Связанный контент