# Using seqsplit and truncate together

I have a table in tabularx, and I need to put an url into one of the columns. The best and probably easiest solution for me would be to use:

\truncate{200pt}{url}


from the truncate package, which will make sure the url is not too long, in combination with

\seqsplit{url}


from the seqsplit package, to allow the url to span over multiple rows. Both of these work correctly when used alone.

I figured, I could just combine both of these commands, to achieve my goal, but when combined as such:

\seqsplit{\truncate{200pt}{https://www.google.com/maps/place/somereallycoolplaceineedtoputherethatisalsoverylongwithitsurlandsimplywontfitintothetable}}


Neither works and I just get errors, after a little bit of googling I learned, that this is because \seqsplit{} doesn't like to play with macros.

Later on I've also learned about the

\expandafter


macro. Which sounds fairly simple to use in the wiki, but when put to real use it's even more confusing, nevertheless, I've tried and came up with:

\expandafter\seqsplit\expandafter{{\truncate{100pt}{https://www.google.com/maps/place/somereallycoolplaceineedtoputherethatisalsoverylongwithitsurlandsimplywontfitintothetable}}}


which only allows the url to be truncated, but somehow ignores the seqsplit command?

My question is, how can I achieve truncating the url, but also allowing it to span over multiple rows. It doesn't have to be done with the \truncate and \seqsplit commands, it's just what I came across, also I would prefer a solution that won't force me to redo the whole table.

The reason why I'm not including the code of the table is, because this issue is prevalent in the plain text as well, not just in the table, I believe the table has nothing to do with it, although feel free to ask me to provide it if necessary!

Also I'm pretty sure there's tons of similar questions, but I'm just unable to figure this one out, so sorry for that!

EDIT: After further investigation, this issue exists only within the tables, so I'm including the code for the table as well, that should explain the issue well enough.

\documentclass{article}

\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{seqsplit}
\usepackage[breakall]{truncate}

\begin{document}

\begin{table}
\begin{tabularx}{\textwidth}{|X|X|}
\toprule
Test1 &
Test2 \\
\midrule
lenghty &
xxx \\
\hline
This is wrong, because it is not truncated: &

\hline
This is wrong, because it is not split: &
\hline
This is also wrong, because it is not split, although it should be: &
\bottomrule
\end{tabularx}
\vskip\abovecaptionskip\emph{From Test}
\caption{Test}
\label{tab:test}
\end{table}

\end{document}


From the image the problem should be obvious, I want the text truncated as well as split.

• Welcome to TeX.SE :) // Please complete your code via the Edit button, so we can copy and run it. Thanks Apr 27, 2022 at 15:13
• What's the point of including the url but truncating it? If I'm not mistaken, the reader won't be able to follow the url, so you don't really provide any useful information by including a url that is simply cut off after a certain amount of characters. For a shorter entry in the table in combination with still retaining the entire url, you could use \href{url}{link text} (needs the hyperref package). Apr 27, 2022 at 15:59
• @MS-SPO Thanks, included a runnable code! :) Apr 27, 2022 at 22:07
• @leandriis Yes you're correct, the reader won't be able to follow the url, but this is not a problem, as the table is more of a just showcase than anything else. Think of it as any other text without spaces. Thanks for mentioning \href, but this is not something that fits my needs. Apr 27, 2022 at 22:10
• why than yo not manually cut to the desired lenght (by using ˙href) as suggested @leandriis? Sep 25, 2022 at 6:09

The common way to do it is using package hyperref, where you replace your commands simply by \url{someURL}.

\documentclass{article}

\usepackage{booktabs}
\usepackage{tabularx}
%\usepackage{seqsplit}
%\usepackage[breakall]{truncate}

\usepackage{hyperref}% <<<---

\begin{document}

\begin{table}
\begin{tabularx}{\textwidth}{|X|X|}
\toprule
Test1 &
Test2 \\
\midrule
lenghty &
xxx \\
\hline
changed +++ This is wrong, because it is not truncated: &

\hline
changed +++ This is wrong, because it is not split: &
\hline
changed +++ This is also wrong, because it is not split, although it should be: &