3

I have a long word inside my tabular I need to break. The other rows and columns look perfect, but since this is only 1 word, the actual word overlaps on the other column. Not ideal.

Is there a SIMPLE fix? Basically here's how I make the tabular:

\begin{tabular}{|p{3.5cm}|p{3.5cm}|}
\hline

Header 
& 
Header 2\\


\hline
Marketingdivisiontesttesttest  
&
Some more text\\
\hline

\end{tabular}

Microsoft Word breaks the word easily.

  • You don't really give us enough information to address the issue. Could you provide the code that demonstrates the issue? – Steven B. Segletes Nov 10 '16 at 14:12
  • @StevenB.Segletes Added an example of what I mean. – MortenMoulder Nov 10 '16 at 14:18
  • Marketingdivision\-testtesttest – Steven B. Segletes Nov 10 '16 at 14:23
  • @StevenB.Segletes Seems very... odd to do it that way, right? Isn't there a simple way of saying "when the word hits the right border of this table, break it into a new line"? – MortenMoulder Nov 10 '16 at 14:24
  • TeX's paragraph setting routines require the existence of breakpoints. Obviously spaces between words are the common place to find them. What I suggested is manually telling TeX how to break a long non-word. If it can't find a rational place to break text, it won't. – Steven B. Segletes Nov 10 '16 at 14:26
4

The first word in a paragraph isn't hyphenated. Use \hspace{0pt} or lualatex whichwill hyphenate also the first word.

\documentclass{article}
\usepackage{array}
\newcolumntype{P}[1]{>{\hspace{0pt}}p{#1}}
\begin{document}
    \begin{tabular}{|P{3.5cm}|p{3.5cm}|}
        \hline
        Header 
        & 
        Header 2\\
        \hline
        Marketingdivisiontesttesttest  
        &
        Some more text\\
        \hline
    \end{tabular}
\end{document}

enter image description here

| improve this answer | |
0

One way to do this quite simply is to add \newline.

Code:

\documentclass{article}
\begin{document}
\begin{tabular}{|p{3.5cm}|p{3.5cm}|}
\hline
Header 
& 
Header 2\\
\hline
Marketingdivision-\newline testtesttest  
&
Some more text\\
\hline
\end{tabular}
\end{document}

This yields:

enter image description here

| improve this answer | |
  • Doesn't scale that well to be honest. – MortenMoulder Nov 10 '16 at 18:02
  • @Snorlax After the first word the table breaks the lines automatically, so you would only have to use this a max of once every cell. – Dan Nov 10 '16 at 18:20
0

That the first word in a paragraph is not hyphenated is true for TeX, pdfTeX, and XeTeX. LuaTeX behaves differently, there the first word can also be hyphenated.

The example comes from a duplicate question:

\documentclass{book}
\begin{document}
\begin{table}
\begin{tabular}{|p{1.7cm}|p{1.7cm}|}
A LongHorribleAndPointlessMess & ALongHorribleAndPointlessMess \\ \hline
\end{tabular}
\end{table}
\end{document}

Result

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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