正如您在图片上看到的,左列的内容是对齐的,因此在内容之间添加了不均匀的间距。我试图让左列的内容垂直居中,水平向左。
我尝试添加\begin{tabular}{>{\RaggedRight}m{3.7cm} m{5cm}
以下脚本,但没有效果。
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\begin{document}
\begin{table}
\begin{tabular}{m{3.7cm}| m{5cm}}
\toprule
Sample1 & Sample2 \\ \midrule
AB\_CDEFG and AB\_CDE & This is sample text.This is sample text. This is sample text. This is sample text. This is sample text. This is sample text.This is sample text. This is sample text. This is sample text. This is sample text.\\ \midrule
AB\_CD, AB\_CD,AB\_CD and AB\_CD & This is sample text.This is sample text. This is sample text. This is sample text. This is sample text. This is sample text.This is sample text. This is sample text. This is sample text. This is sample text.\\ \bottomrule
\end{tabular}
\label{table:referent-table}
\end{table}
\end{document}
感谢您对如何实现这一目标的建议。
答案1
您可以加载ragged2e
包并使用其\RaggedRight
指令来实现格式化目标。在此过程中,您也可以将其应用于\RaggedRight
第二列。
请注意,\RaggedRight
允许在单元格中使用连字符。如果您还想禁止使用连字符,只需更改\RaggedRight
为\raggedright\arraybackslash
。
附言:我禁不住对流经右侧单元格的印刷河流赞叹不已。:-)
\documentclass{article}
\usepackage{array,booktabs,ragged2e}
\begin{document}
\begin{table}
\caption{Example of a table\strut}
\label{table:referent-table}
\centering % <-- don't forget this instruction
\begin{tabular}{@{} >{\RaggedRight}m{3.7cm} >{\RaggedRight}m{5.0cm} @{}}
\toprule
Sample1 & Sample2 \\
\midrule
AB\_CDE, AB\_CDE and AB\_CDE
& This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. \\
\midrule
AB\_CD, AB\_CD, AB\_CD and AB\_CD
& This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. \\
\bottomrule
\end{tabular}
\end{table}
\end{document}