Graphics, Figures & Tableswrap text in table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
pawhan11
Posts: 9
Joined: Mon Sep 22, 2014 10:27 am

wrap text in table

Post by pawhan11 »

Hello,

I have very large number that goes outside my cell:
Any Ideas how to make this number fit into my cell?

Code: Select all

\documentclass[10pt,a4paper]{article}
%packages
\usepackage{array}
\usepackage[table,xcdraw]{xcolor}
\usepackage[footskip=60pt]{geometry}
\usepackage[polish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{helvet} 
\renewcommand{\familydefault}{\sfdefault}
\normalfont
\geometry{   	
        a4paper,
        left=25mm,
        right=15mm,
        top=40mm,
	headheight=27mm,
        bottom=23mm,}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}		
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
{\renewcommand{\arraystretch}{1,2}				
\definecolor{bgcol}{rgb}{0.63, 0.79, 0.95}			
\begin{document}
\vspace{-0,5cm}
\begin{table}[!h]
		 \setlength{\tabcolsep}{1mm}
		\begin{tabular}{|L{3mm}| L{70mm}| L{25mm}| L{23mm}| L{10mm}| L{25mm}|}
			\hline
 	&	Short data	&	asd	&	123123123123123123123123123123123	&	1	&	66666	\\ \hline

		\end{tabular}
\end{table}
\end{document}
vdg80.jpg.png
vdg80.jpg.png (5.34 KiB) Viewed 5481 times
Last edited by Stefan Kottwitz on Thu Oct 30, 2014 7:26 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

wrap text in table

Post by Stefan Kottwitz »

You simply made the cell to small - you defined a fixed width. Would you like to have it automatically adjusted?

The table design is not optimal, with each number in a framed cell, which makes reading harder. Johannes once posted a nice explanation presentation: Improving data tables We could help with table design. If you like, post the complete table, perhaps somebody would make a suggestion.

Stefan
LaTeX.org admin
pawhan11
Posts: 9
Joined: Mon Sep 22, 2014 10:27 am

Re: wrap text in table

Post by pawhan11 »

I am rewriting some PDF using Latex and it has to be identical. This table has to be fixed size so auto adjust is not an option. I want text inside this cell to adapt
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

wrap text in table

Post by Stefan Kottwitz »

For wrapping long numbers, you can use the seqsplit package:

Code: Select all

\usepackage{seqsplit}
...
% in the table:
... & \seqsplit{123123123123123123123123123123123} & ...
Or, for a whole column without writing \seqsplit within cells:

Code: Select all

\usepackage{collcell}
\usepackage{seqsplit}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}\collectcell\seqsplit}p{#1}<{\endcollectcell}}

Stefan
LaTeX.org admin
Post Reply