Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Trying to wrap text using longtable combined with seqsplit but it won't format correctly for something like thisisareallylongexamplethisisareallylongexamplethisisareallylongexamplethisisareallylongexample with a space because seqsplit removes all spaces

\documentclass[pdftex]{report}
\usepackage[left=65pt,top=28pt,right=65pt,bottom=65pt]{geometry}
\usepackage{longtable}
\usepackage{seqsplit}

\begin{document}

\begin{longtable}{p{50pt} p{360pt} p{50pt}}

& \seqsplit{thisisareallylongexamplethisisareallylongexamplethisisareallylongexamplethisisareallylongexample with a space} & test \\

\end{longtable}

\end{document}
share|improve this question
    
Howsabout adding a backslash before seqsplit? –  Marc van Dongen Feb 21 '12 at 19:45
    
sorry, that was just a typo. seqsplit removes spaces so i assume i need to use a different package –  Joel Feb 21 '12 at 19:53
    
I don't know the seqsplit package, but the way you use it with non-existing very long strings of letters, how is it supposed to work in combination with LaTeX's hyphenation algorithm. –  Marc van Dongen Feb 21 '12 at 19:58
    
If you use control spaces \ or ties ~, they're not removed. Does this solve your problem? –  Werner Feb 21 '12 at 20:03
add comment

1 Answer

up vote 1 down vote accepted

To preserve the spaces, use a control space \ or a tie ~ between the words:

enter image description here

\documentclass{report}
\usepackage[left=65pt,top=28pt,right=65pt,bottom=65pt]{geometry}% http://ctan.org/pkg/geometry
\usepackage{longtable}% http://ctan.org/pkg/longtable
\usepackage{seqsplit}% http://ctan.org/pkg/seqsplit
\begin{document}
\begin{longtable}{p{50pt} p{360pt} p{50pt}}
  & \seqsplit{thisisareallylongexamplethisisareallylongexamplethisisareallylongexamplethisisareallylongexample with a space} & test1 \\
  & \seqsplit{thisisareallylongexamplethisisareallylongexamplethisisareallylongexamplethisisareallylongexample\ with\ a\ space} & test2 \\
  & \seqsplit{thisisareallylongexamplethisisareallylongexamplethisisareallylongexamplethisisareallylongexample~with~a~space} & test3 \\
\end{longtable}
\end{document}

The first row shows the original, the second uses a control space \ while the third row uses a tie ~ to preserve the spacing.

share|improve this answer
    
Awesome thanks, it was a little tricky because it's being generated through php but $string = str_replace(" ","~",$string), did the trick –  Joel Feb 21 '12 at 20:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.