我遇到了单个单元格中文本溢出的问题。我在这里放了一个大文档的一部分来展示问题到底是什么。有没有办法强制 Latex 自动将剩余文本移到下一行。最后两列中存储的数值溢出了。还有更大的数字,所以我需要一个永久的修复程序。
\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage[table,xcdraw]{xcolor}
\usepackage{blindtext}
\usepackage{multirow}
\usepackage[a4paper]{geometry}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{setspace}
\geometry{a4paper,tmargin=3.5cm, bmargin=2.5cm, lmargin=1.5cm, rmargin=1.5cm, headheight=3em, headsep=1.5cm, footskip=1cm}
\usepackage{color, colortbl}
\definecolor{mColor1}{rgb}{0.9,0.9,0.9}
\usepackage{tgbonum}
\usepackage{pdflscape}
\usepackage{enumitem}
\begin{document}
The table below provides the changes made to investible capital over the years:-
\justify
\begingroup
\renewcommand{\arraystretch}{1.1}
\setlength{\arrayrulewidth}{1pt}
\begin{longtable}
{|p{\dimexpr0.14\textwidth- 2\tabcolsep}|p{\dimexpr0.14\textwidth-2\tabcolsep}|p{\dimexpr0.24\textwidth-2\tabcolsep}|p{\dimexpr0.15\textwidth-2\tabcolsep}|p{\dimexpr0.16\textwidth-2\tabcolsep}|p{\dimexpr0.17\textwidth-2\tabcolsep}|}
\hline
\rowcolor{mColor1}
Filename&Code&Purpose&Type of Allowance&Recognized Invest Capital&Revised Share Capital\\Form X-21X210&2110-101-0&Addition or division etc.&-&10000000000.00&-\\Form X-14X210&T010-09-90&Increase in Investible capital independently by LLC&Simple Resolution&10000000000.00&42500000000.00\\Form X-120120&0290-T9-29&Increase in investible capital independently by LLC&Simple Resolution&5000000000.00&10000000000.00\\\hline\caption{Check 1}\end{longtable}\endgroup\end{document}
答案1
您永远不希望在数字列中换行,因此您需要在其他地方占用空间,例如
\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage[table,xcdraw]{xcolor}
\usepackage{blindtext}
\usepackage{multirow}
\usepackage[a4paper]{geometry}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{setspace}
\geometry{a4paper,tmargin=3.5cm, bmargin=2.5cm, lmargin=1.5cm, rmargin=1.5cm, headheight=3em, headsep=1.5cm, footskip=1cm}
\usepackage{color, colortbl}
\definecolor{mColor1}{rgb}{0.9,0.9,0.9}
\usepackage{tgbonum}
\usepackage{pdflscape}
\usepackage{enumitem}
\usepackage{array}
\newcommand\hd[2]{%
\multicolumn{1}{#1c|}{\begin{tabular}{@{}c@{}}#2\end{tabular}}}
\begin{document}
The table below provides the changes made to investible capital over the years:-
\renewcommand{\arraystretch}{1.1}
\setlength{\arrayrulewidth}{1pt}
\begin{longtable}
{|>{\raggedright}p{2cm}|l|
>{\raggedright}p{3cm}|
>{\raggedright}p{2cm}|
r|
r|}
\hline
\rowcolor{mColor1}
\hd|{Filename}&
\hd{}{Code}&
\hd{}{Purpose}&
\hd{}{Type of\\ Allowance}&
\hd{}{Recognized\\ Invest\\ Capital}&
\hd{}{Revise\\Share\\Capital}\\
Form X-21X210&2110-101-0&Addition or division etc.&-&10000000000.00&-\\
Form X-14X210&T010-09-90&Increase in Investible capital independently by LLC&Simple Resolution&10000000000.00&42500000000.00\\
Form X-120120&0290-T9-29&Increase in investible capital independently by LLC&Simple Resolution&5000000000.00&10000000000.00\\
\hline
\caption{Check 1}
\end{longtable}
\end{document}