表格文字超出页面

表格文字超出页面

我想在 Overleaf Latex 上创建一个表格,但是表格一直超出页面边界。

我的表格代码是这样的:

\begin{table}[htbp]
\caption{Advantages and disadvantages of \acrshort{Wi-Fi}}
\centering
\begin{tabular}{|l|p{0.8\linewidth}|}
\hline
\multicolumn{1}{|c|}{{\textbf{Advantages}}}     & \multicolumn{1}{c|}{{\textbf{Disadvantages}}}                                                   \tabularnewline \hline
Ability to penetrate objects \n                 & Power consumption 
                                                \tabularnewline \hline
Simple to add or remove nodes                  & Complexity                                                                                                  \tabularnewline \hline
128-bit AES encryption provides a secure connection       & Radio waves in the network can interfere with the equipment                                   \tabularnewline \hline
\end{tabular}
\label{tab:wad}   
\end{table}

我认为这是因为左边的文本太长并且将右边的文本和表格挤到了页面之外。

有人能帮我吗?

答案1

尝试使用该tabularx包:

\documentclass{article}
\usepackage{ragged2e}
\usepackage{tabularx}
\newcolumntype{L}{>{\RaggedRight}X}

\begin{document}
\begin{table}[htbp]
\caption{Advantages and disadvantages of \texttt{Wi-Fi}}
\centering
\begin{tabularx}{\linewidth}{|L|L|}
    \hline
\multicolumn{1}{|c|}{{\textbf{Advantages}}}     & \multicolumn{1}{c|}{{\textbf{Disadvantages}}}                                                   \tabularnewline \hline
Ability to penetrate objects n                 & Power consumption
                                                \tabularnewline \hline
Simple to add or remove nodes                  & Complexity                                                                                                  \tabularnewline \hline
128-bit AES encryption provides a secure connection       & Radio waves in the network can interfere with the equipment                                   \tabularnewline \hline
\end{tabularx}
\label{tab:wad}
\end{table}
\end{document}

在此处输入图片描述

(红线表示文字边框)

相关内容