0

I am facing the problem of text overflowing in single cells. I have put portion of a large document here to show what exactly is the problem. Is there a way to force Latex to shift the remaining text to next line automatically. The numerical values stored in last two column are overflowing. There are larger numbers as well so I need a permanent fix for this.

\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}

enter image description here

3
  • In general you don't want line-breaking in the middle of a number -- it's not a word that can be hyphenated. The line-breaking in column 4 is less than ideal (better to break between words) and really quite unpleasant in column 1(I assume the form is "X-21X210"). Consider giving your quantities in 1000s (or even millions); do they need the decimal point? The table columns in siunitx might be of use for the numeric columns.
    – Chris H
    Commented Feb 16, 2017 at 9:00
  • But what choice do I have? As stated earlier there are even larger numbers and I cant tweak dimensions every time a larger number appears
    – Abhay
    Commented Feb 16, 2017 at 9:02
  • You need to look at the design as a whole. There are plenty of options discussed in some detail here, including putting the table on a page in landscape mode, and making it stick into the margins. You haven't really given us a lot to go on with a truncated example like this
    – Chris H
    Commented Feb 16, 2017 at 9:09

1 Answer 1

1

You never want linebreaking in a numeric column so you need to take space elsewhere, for example

enter image description here

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .