表格单元格中放不下长句子

表格单元格中放不下长句子

我正在尝试使用 Overleaf 在 Latex 中创建如下图所示的表格,但是,我无法将整个句子放在中间行,我尝试添加换行符,但它会移动到左行并将文本与该行连接起来,或者最后一行(第 3 行)超出了边距...不知道如何解决这个问题?

\begin{table}[]
\caption{Cell lines used.\label{Cell lines used.}}
\begin{tabular}{|c|c|c|}
\hline
Cell line & Origin & Maintenance Medium \\ \hline
HEK293T WT, HEK-cGAS low,\\ HEK293T GFP, HEK-STING,\\ HEK STING CX43/45 DKO & Human embryonic kidney 293 cells & complete DMEM \\ \hline
LL171 & Mouse L929 fibroblasts\\expressing ISRE Luciferase reporter & complete DMEM &complete DMEM\\ \hline
SV40T MEF & mouse embryonic fibroblast\\ immortalized with the SV40 large T antigen using pSG5-SV40-LT-Ag & complete DMEM \\ \hline
\end{tabular}
\end{table}

在此处输入图片描述

答案1

X列类型也在包中定义tabularray。使用此包,表格代码更短。允许多行标题单元格还可以使文本更好地适应单元格:

\documentclass{article}
\usepackage{microtype}
\usepackage{tabularray}

\begin{document}
\begin{tblr}{hlines, vlines,
             colspec={ X X[j] Q[c,h, wd=8em] },
             colsep=4pt
             }
Cell line
    &   Origin
        &   Maintenance Medium                  \\
HEK293T WT, HEK-cGAS low, HEK293T GFP, HEK-STING, HEK STING CX43/45 DKO
    &   Human embryonic kidney 293 cells
        &   complete DMEM                       \\
LL171
    &   Mouse L929 fibroblasts expressing ISRE Luciferase reporter
        &   complete DMEM                       \\
SV40T MEF
    &   mouse embryonic fibroblast immortalized with the SV40 large T antigen using pSG5-SV40-LT-Ag
        &   complete DMEM                       \\
\end{tblr}
\end{document}

在此处输入图片描述

答案2

我建议您采用一个tabularx环境来允许所有单元格自动换行,并将整体宽度设置为\textwidth

在此处输入图片描述

\documentclass{article}
\usepackage{tabularx,ragged2e}
\newcolumntype{L}{>{\RaggedRight}X}    % no (full) justification
\hyphenation{fibro-blast fibro-blasts} % define valid hyphenation points

\begin{document}
\begin{table}
\setlength{\extrarowheight}{2.5pt} % for a mor open "look"
\caption{Cell lines used.\strut}\label{Cell lines used.}
\begin{tabularx}{\textwidth}{|L|L|L|}
\hline
Cell line 
& Origin 
& Maintenance Medium \\ 
\hline
HEK293T WT, HEK-cGAS low, HEK293T GFP, HEK-STING, HEK STING CX43/45 DKO 
& Human embryonic kidney 293 cells 
& complete DMEM \\ 
\hline
LL171 
& Mouse L929 fibroblasts expressing ISRE Luciferase reporter 
& complete DMEM %& complete DMEM
\\ 
\hline
SV40T MEF 
& mouse embryonic fibroblast immortalized with the SV40 large T antigen using pSG5-SV40-LT-Ag 
& complete DMEM \\ 
\hline
\end{tabularx}
\end{table}
\end{document}

答案3

正如 Bernard 在他的评论中提到的,一种方法是使用固定宽度的列。另一种选择是使用该makecell包插入手动换行符。

梅威瑟:

\documentclass{article}

\usepackage{geometry}
\usepackage{array}
\usepackage{makecell}
\usepackage{caption}

\begin{document}
\begin{table}
\caption{Cell lines used (Using \texttt{makecell} package).\label{Cell lines used.}}
\begin{tabular}{|c|c|c|}
\hline
Cell line & Origin & Maintenance Medium \\ \hline
\makecell{HEK293T WT, HEK-cGAS\\low, HEK293T GFP, HEK-\\STING, HEK STING \\CX43/45 DKO} & \makecell{Human embryonic kidney\\293 cells} & complete DMEM \\ \hline
LL171 & \makecell{Mouse L929 fibroblasts\\expressing ISRE Luciferase\\ reporter} & complete DMEM \\ \hline
SV40T MEF & \makecell{mouse embryonic fibroblast\\ immortalized with the SV40\\ large T antigen using pSG5-\\SV40-LT-Ag} & complete DMEM \\ \hline
\end{tabular}
\end{table}

\begin{table}
\caption{Cell lines used (Using fixed-width column).\label{Cell lines used.}}
\begin{tabular}{*{3}{|p{0.3\textwidth}}|}
\hline
Cell line & Origin & Maintenance Medium \\ \hline
HEK293T WT, HEK-cGAS low, HEK293T GFP, HEK-STING, HEK STING CX43/45 DKO & Human embryonic kidney 293 cells & complete DMEM \\ \hline
LL171 & Mouse L929 fibroblasts expressing ISRE Luciferase reporter & complete DMEM\\ \hline
SV40T MEF & mouse embryonic fibroblast immortalized with the SV40 large T antigen using pSG5-SV40-LT-Ag & complete DMEM \\ \hline
\end{tabular}
\end{table}
\end{document}

使用makecell包:

制造细胞

使用固定宽度列:

固定宽度

编辑:

正如 Mico 在他的评论中提到的,第二个表的第一列不应该被调整,这可以通过命令来实现>{\raggedright\arraybackslash}\arraybackslash有必要恢复环境\\中的通常定义。tabular

\documentclass{article}

\usepackage{geometry}
\usepackage{array}
\usepackage{makecell}
\usepackage{caption}

\begin{document}
\begin{table}
\caption{Cell lines used (Using fixed-width column).\label{Cell lines used.}}
\begin{tabular}{|>{\raggedright\arraybackslash}p{0.3\textwidth}*{2}{|p{0.3\textwidth}}|}
\hline
Cell line & Origin & Maintenance Medium \\ \hline
HEK293T WT, HEK-cGAS low, HEK293T GFP, HEK-STING, HEK STING CX43/45 DKO & Human embryonic kidney 293 cells & complete DMEM \\ \hline
LL171 & Mouse L929 fibroblasts expressing ISRE Luciferase reporter & complete DMEM\\ \hline
SV40T MEF & mouse embryonic fibroblast immortalized with the SV40 large T antigen using pSG5-SV40-LT-Ag & complete DMEM \\ \hline
\end{tabular}
\end{table}
\end{document}

输出 3

相关内容