AnswerBun.com

Long text in tabular paragraph environment overflows

TeX - LaTeX Asked by Sugarat on December 25, 2020

I have a tabular environment with some columns, but have so far been unable to ensure that long text wraps properly. Instead, the text overflows into the next column. The data being put into the column can sometimes be very long, and may or may not have spaces in it. It often has hyphens, but I do not want these to be seen as places for justification. The behaviour I want is for the text to be put into the column with zero justification – simply render as many characters as possible and then continue on the next line.

An example of what I have at the moment:

begin{tabular}{c p{4cm} p{7cm} c}
1 & This_is_a_long_virtual_machine_name   &   This_is_a_long_virtual_machine_path & 256\
end{tabular}

I need LaTeX to put as much of the long text as possible into the column, and then overflow into the next line. Thanks very much.

3 Answers

I would use just - when needed, or in case of many _ everywhere, as in the MWE, redefine tit to make it breakable:

letoldu_def_{hskip0ptolduhskip0pt}

But you asked what you asked:

It often has hyphens, but I do not want these to be seen as places for justification.

So, it seems that you are looking for `seqsplit, but IMHO is not a nice output:


mwe


documentclass{article}
usepackage{seqsplit}
parskip2em
begin{document}

With verb|seqplit|:

begin{tabular}{c p{4cm} p{7cm} c} 1 & 
seqsplit{This_is_a_long_virtual_machine_name}   &   
seqsplit{This_is_a_long_virtual_machine_path} & 256\  2 & 
seqsplit{Supercalifragilisticexpialidocious} & 
seqsplit{Um-dittle-ittl-um-dittle-I} 
seqsplit{Um-dittle-ittl-um-dittle-I} 
seqsplit{Um-dittle-ittl-um-dittle-I} 
seqsplit{Um-dittle-ittl-um-dittle-I}  & 257
end{tabular}

Without verb|seqplit|:

begin{tabular}{c p{4cm} p{7cm} c}  1 & 
This_is_a_long_virtual_machine_name  & 
This_is_a_long_virtual_machine_path & 256\
2 & Supercalifragilisticexpialidocious & 
Um-dittle-ittl-um-dittle-I 
Um-dittle-ittl-um-dittle-I
Um-dittle-ittl-um-dittle-I 
Um-dittle-ittl-um-dittle-I & 257
end{tabular}

end{document}

Answered by Fran on December 25, 2020

For hyphenation of long words you can use simbol - in place where you like to enable hyphenation. Considering this, your table can be rewritten as follows:

documentclass{article}
usepackage{tabularx}

begin{document}

noindentbegin{tabularx}{linewidth}{@{} c X X c @{}}
    hline
1   & This_is_a_long_virtual_ma-chi-ne_name   % <---
        &   This_is_a_long_virtual_ma-chi-ne_path % <---
            & 256\
    hline
end{tabularx}

end{document}

enter image description here

(red lines shows text borders)

Answered by Zarko on December 25, 2020

A p{} column in a tabular environment provides newline. This provides a clean line break. I am programatically inserting newline every X characters in the column, which provides a solution.

Answered by Sugarat on December 25, 2020

Add your own answers!

Related Questions

How to compile the source code of TeX

5  Asked on March 22, 2021 by user565739

   

How to change the font, axis and tick color in pgfplots

1  Asked on March 22, 2021 by weisbrja

   

Why is my background grey?

1  Asked on March 22, 2021 by fabian-bosler

 

How do I define norm delimiters?

1  Asked on March 22, 2021 by ph-tng

     

Turning off all colors and background images in beamer

1  Asked on March 22, 2021 by pavithran-iyer

     

How to format this long table?

2  Asked on March 22, 2021 by ogc

   

Diagonal Tikz patterns

1  Asked on March 21, 2021 by trieasyboid

     

Animation of a diagram with the package Smartdiagram

2  Asked on March 21, 2021 by user72653

   

How can I add a margin note right next to a table?

0  Asked on March 21, 2021 by user230754

     

Does TexPad support fontspec?

1  Asked on March 21, 2021

       

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP