我在格式化宽表格时遇到了麻烦。感谢这个答案我的基本结构看起来不错。但现在我发现其中一列的文本对于单元格来说太宽了。
\documentclass{article}
\usepackage{booktabs,ragged2e,tabularx,geometry,amsfonts}
\begin{document}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\begin{table}[htbp]
\caption{Lots of vertical rules} \label{tab:a}
\begin{tabularx}{\textwidth}{|*{7}{l|} *{3}{L|}}
\hline
Ref & \multicolumn{6}{c|}{Model Used}
& Approach & Limitation & Goal \\
\hline
& MBTI & FFM & BFI & KTS & BTR & NEO-FFI
& \multicolumn{3}{l|}{} \\
\hline
[10] & & &\checkmark & & &
& Interactive personality profiling approach
& Test were based on subjective evidences which may lead to uncertainty.
& In order to propose a structure for effective software team structure. \\
\hline
[20] & & & & & &\checkmark
& Quazi-Experiment
& This study is conducted with students which leads to ambiguity on difference in nature of students and software engineers.
& In order to propose a structure for effective software team structure. \\
\hline
& & & & & & & & & \\
\hline
\end{tabularx}
\end{table}
\end{document}
问题是,在包含文本“Quazi-Experiment”的单元格中,单词太长:它们超出了单元格的右侧。我该如何避免这种情况?
答案1
以下答案在列类型的设置中提供了额外的代码L
,以允许对单元格最开始处出现的长单词进行连字符连接。
\documentclass{article}
\usepackage{%geometry,
tabularx, % for 'tabularx' env.
ragged2e, % for '\RaggedRight' macro
booktabs, % '\toprule' '\midrule', etc.
amssymb} % for '\checkmark' macro
\newcolumntype{L}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
\usepackage[skip=0.333\baselineskip]{caption}
\begin{document}
\begin{table}[htbp]
\setlength\tabcolsep{3pt} % default value: 6pt
\caption{Lots of vertical rules} \label{tab:a}
\begin{tabularx}{\textwidth}{ |l| *{6}{c|} *{3}{L|} }
\hline
Ref & \multicolumn{6}{c|}{Model Used}
& Approach & Limitation & Goal \\
\hline
& MBTI & FFM & BFI & KTS & BTR & NEO-
& \multicolumn{3}{l|}{} \\
& & & & & & FFI & \multicolumn{3}{l|}{} \\
\hline
[10] & & & \checkmark & & &
& Interactive personality profiling approach
& Tests were based on subjective evidence, which may lead to uncertainty.
& In order to propose a structure for effective software team structure. \\
\hline
[20] & & & & & & \checkmark
& Quasi-\hspace{0pt}Experiment
& This study is conducted with students which leads to ambiguity on difference in nature of students and software engineers.
& In order to propose a structure for effective software team structure. \\
\hline
& & & & & & & & & \\
\hline
\end{tabularx}
\end{table}
\end{document}