我有以下代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\setlength{\arrayrulewidth}{0.5mm}
\setlength{\tabcolsep}{18pt}
\renewcommand{\arraystretch}{2}
%\newcolumntype{s}{>{\columncolor[HTML]{AAACED}} p{2.5cm}}
\arrayrulecolor[HTML]{000000}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
}
\begin{document}
\begin{tabular}{ |p{2cm}|p{3cm} |p{2.5cm} |p{4.5cm} | }
\hline
\rowcolor{cyan} \multicolumn{4}{|c|}{Interesting Factors} \\
\hline
Factor & Table & Description & Justification \\
\hline
FF\_FFFFFF & FF\_FFFFF\_V2 & ? & \\ \hline
\rowcolor{gray}
FF\_FF\_FFFF & FF\_FFFFF\_V2 & Company's name & Base \\ \hline
FF\_DDDD\_DDDD\_DDDDDDD & FF\_FFFFF\_V2 & Business Description & \cellcolor[HTML]{AA0044} Base \\ \hline
Angola && AO & AGO \\
\hline
\end{tabular}
\end{document}
并且由于某种原因,第一列中最后一个条目之前的条目没有在表格单元格中换行...为什么?
答案1
为什么?因为 LaTeX 没有规则来打破这种“单词”。您可以使用包seqsplit
和同名命令随时打破它:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{seqsplit} \setlength{\arrayrulewidth}{0.5mm}
\setlength{\tabcolsep}{18pt}
\renewcommand{\arraystretch}{2}
%\newcolumntype{s}{>{\columncolor[HTML]{AAACED}} p{2.5cm}}
\arrayrulecolor[HTML]{000000}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
}
\begin{document}
\begin{tabular}{ |p{2cm}|p{3cm}|p{2.5cm}|p{4.5cm}|}
\hline
\rowcolor{cyan} \multicolumn{4}{|c|}{Interesting Factors} \\
\hline
Factor & Table & Description & Justification \\
\hline
FF\_FFFFFF & FF\_FFFFF\_V2 & ? & \\ \hline
\rowcolor{gray}
FF\_FF\_FFFF & FF\_FFFFF\_V2 & Company's name & Base \\ \hline
\seqsplit{FF\_DDDD\_DDDD\_DDDDDDD} & FF\_FFFFF\_V2 & Business Description & \cellcolor[HTML]{AA0044} Base \\ \hline
Angola & & AO & AGO \\
\hline
\end{tabular}
\end{document}