Text FormattingTruncating overlong lines in table

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
retek
Posts: 1
Joined: Thu Jul 15, 2010 2:44 pm

Truncating overlong lines in table

Post by retek »

Dear list,

I don't know if it is possible at all in latex, but I would like to cut off too wide or overlong lines in a table.

This is what I have now :

|001|short |
|001|too long a|nd can even go off the page

(vertical lines at the end are the "logical/desired" borders of the table - actually displayed as below)


And this is what I am looking for :

|001|short |
|001|too long..|

Sample :

Code: Select all

\documentclass{article}
\usepackage{tabularx}

\begin{document}

\section*{Current}
\begin{tabularx}{\textwidth}{|p{10mm}|X|}
\hline
001 & short text \\
\hline
002 & \multicolumn{1}{l|}{very long text, say, overlong, and now I'm just trying to fill this up so that it will be really overlong}\\
\hline
\end{tabularx}

\section*{Desired}
\begin{tabularx}{\textwidth}{|p{10mm}|X|}
\hline
001 & short text \\
\hline
002 & \multicolumn{1}{l|}{very long text, say, overlong, and now I'm just trying to fill  \ldots}\\
\hline
\end{tabularx}

\end{document}
I need to use multicolumn for some reasons
+ I can't use two lines for one entry...

Although, I have never hear about omitting text in latex, I would be really grateful if someone out there could tell me if it is possible at all.

Thanks in advance,

retek

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Truncating overlong lines in table

Post by gmedina »

Hi

try something like this:

Code: Select all

\documentclass{article}
\usepackage{tabularx}

\begin{document}

\begin{tabularx}{\textwidth}{|p{10mm}|X|}
  \hline
  001 & short text \\\hline
  002 & \multicolumn{1}{X|}{very long text, say, overlong, and now I'm just trying to fill   
    this up so that it will be really overlong}\\\hline
\end{tabularx}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply