I have a xltabular table which is filled via script with data, so I don't really know what length the text has that is put into the table cells. Is there a function or method which can just cut off the text if it is too long to fit in one line? Here is the example of my table.
\documentclass[
fontsize=11pt,
parskip=half,
firstfoot=off,
foldmarks=off
]{scrlttr2}
%
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{lmodern}
\usepackage{xltabular}
\usepackage[textwidth=\useplength{firstfootwidth}]{geometry} %showframe
\renewcommand*\familydefault{\sfdefault}
\begin{document}
%recipient
\begin{letter}{
Max Muste \
Teststraße 2 \
55555 Teststadt \
Schweiz \
}
%
\opening{}
%
{\footnotesize
\begin{xltabular}{\textwidth}{@{\hskip0pt}r p{3.1cm} X r r r@{\hskip0pt}}
Menge & Artikelnummer & Bezeichnung & WHG & Einzelpreis & Gesamtpreis \ \hline
\endfirsthead
Menge & Artikelnummer & Bezeichnung & WHG & Einzelpreis & Gesamtpreis \ \hline
\endhead
\hline
\multicolumn{6}{l}{Bla}
\endlastfoot
1 & T-ERICSSON GF768 & Lötzinn bleifrei mit Silber- und Kupferanteil,Ø 1,0 mm, 12,5 g & 0 N & 12,77300 & 12,77\ *[\fill]
\end{xltabular}
}
\end{letter}
\end{document}
So basically mm, 12,5g should be thrown away, even if it is as text in the cell.


tabularxdoes compared to a normal table is adjust the target width for linebreaking in X cells, I would never use tabularx for data tables that do not need linebreaking (even though I wrote it) – David Carlisle Feb 15 '22 at 08:46