表格中的换行符

表格中的换行符

我想知道如何在表格中换行,以便文本与其余文本保持相同的宽度。我的代码是:

\documentclass[runningheads]{llncs}
\usepackage{graphicx}

\begin{document}
\begin{table}
\caption{Precision variation.}
\centering
\label{tab1}
\begin{tabular}{|c|c|c|c|c|}
\hline
Work & Year & Blockchain Funcionality & Pros & Cons \\
\hline
\cite{song2019} & 2019 & Digital signature storage & Authenticated information & Centralized architecture \\
\cite{shang2018} & 2018 & Information storage & Scratch Information & Unauthenticated information \\
\cite{huckle} & 2017 & Hash/metadata storage & Authenticated information & High cost \\
Our Work & 2019 & Algorithm processing & Reliability e Authenticity & None \\
\hline
\end{tabular}
\end{table}
\end{document}

我的输出是:

在此处输入图片描述

可以看出,表格超出了文本限制。我该如何解决这个问题?

答案1

c您应该使用能够将文本拆分成更多行的列类型。例如p{<width>},或\m{<width>}来自array包,X来自tabularx包:

\documentclass[runningheads]{llncs}
\usepackage{booktabs, makecell, tabularx}
\setcellgapes{2pt}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}

\begin{document}
\begin{table}
\caption{Precision variation.}
\label{tab1}
    \centering
    \makegapedcells
\begin{tabularx}{\linewidth}{|c|c|*{3}{C|}}
\hline
Work & Year & Blockchain Funcionality & Pros & Cons \\
\hline
\cite{song2019} & 2019 & Digital signature storage & Authenticated information & Centralized architecture \\
\cite{shang2018}& 2018 & Information storage & Scratch Information & Unauthenticated information \\
\cite{huckle}   & 2017 & Hash/metadata storage & Authenticated information & High cost \\
\makecell[t]{Our\\ Work}
                & 2019 & Algorithm processing & Reliability e Authenticity & None \\
\hline
\end{tabularx}
\end{table}
or

\begin{table}
\caption{Precision variation.}
\label{tab2}
    \centering
    \makegapedcells
\begin{tabularx}{\linewidth}{@{} cc *{3}{L} @{} }
    \toprule
Work & Year & Blockchain Funcionality & Pros    & Cons      \\
    \midrule
\cite{song2019} & 2019 & Digital signature storage & Authenticated information & Centralized architecture \\
\cite{shang2018}& 2018 & Information storage & Scratch Information & Unauthenticated information \\
\cite{huckle}   & 2017 & Hash/metadata storage & Authenticated information & High cost \\
\makecell[t]{Our\\ Work}
                & 2019 & Algorithm processing & Reliability e Authenticity & None \\
    \bottomrule
\end{tabularx}
\end{table}
\end{document}

在此处输入图片描述

相关内容