3

I have long table with many cells almost inside every cell long text. The problem is that non-English text does not wrap correctly.

\documentclass[11pt, a4paper]{article} \usepackage[T2A,T2B,T2C]{fontenc} \usepackage[utf8]{inputenc} \usepackage[russian]{babel} \begin{document} \begin{table} \centering \begin{tabular}{ | m{1cm} | m{2.5cm} | m{2.5cm} | m{2.5cm} | m{2.5cm} | m{2.5cm} | m{2.5cm} | m{2.5cm} | m{2.5cm} | } %перенос слов в клетке частично работает только в первой строке \hline %\rowcolor{wordBlue} \hline \textbf{Text 1} & \textbf{Some Symbols} & \textbf{Long lines of code} & \textbf{Очень длинные строки, которые почему-то не переносяться корректно} & \textbf{Год} & \textbf{Разнообразные вариации чисел и букв 1234, новый номер 892473124} & \textbf{Text with some new default values.} & \textbf{Базовый текст, в котором могут быть смешаны letters and numbers in different languages + 2} & \textbf{Last column with which I have plenty of troubles and I need to fix} \\ \hline \end{tabular} \end{table} \end{document} 

I have found trick that if I do

& ~\textbf{Last column with which I have plenty of troubles and I need to fix} 

it works, but I have indentation that I don't need.

4
  • 1
    ~ will cause the indentation, in my point of view Commented Dec 23, 2015 at 14:51
  • Yes, but the problem I do not need to have indentation. I need just wrap words correctly. No matter how long they are. Commented Dec 23, 2015 at 14:54
  • Is hyphenation supposed to be allowed, or should it be suppressed? Commented Dec 23, 2015 at 15:12
  • We can use it, but it didn't work for some reasons. Commented Dec 23, 2015 at 15:28

2 Answers 2

2

Hyphenation of the first word requires a space, even if it is zero.

Here's a way for getting what you want with less input.

I put T2A as the last encoding, since it's the one of choice for Russian. Do you really need T2B and T2C?

\documentclass[a4paper,landscape]{article} \usepackage[margin=1cm]{geometry} % to get landscape orientation \usepackage[T2B,T2C,T2A]{fontenc} \usepackage[utf8]{inputenc} \usepackage[english,russian]{babel} \usepackage{array} \newcolumntype{M}[1]{% >{\raggedright\arraybackslash\hspace{0pt}} m{#1} } \begin{document} \noindent \begin{tabular}{ | m{1cm} | *{7}{M{2.5cm} |} >{\hyphenrules{english}}M{2.5cm} | } \hline %\rowcolor{wordBlue} \hline \bfseries Text 1 & \bfseries Some Symbols & \bfseries Long lines of code & \bfseries Очень длинные строки, которые почему-то не переносяться корректно & \bfseries Год & \bfseries Разнообразные вариации чисел и букв 1234, новый номер 892473124 & \bfseries Text with some new default values. & \bfseries Базовый текст, в котором могут быть смешаны \foreignlanguage{english}{letters and numbers in different languages} + 2 & \bfseries Last column with which I have plenty of troubles and I need to fix \\ \hline \end{tabular} \end{document} 

Add >{\hyphenrules{english}} for the columns where only English is used.

enter image description here

1
  • It works perfectly for myself. Commented Dec 23, 2015 at 15:28
1

Some comments:

  • Your nine-column table is simply too wide to fit in portrait mode on a normal page, even if the margins are very narrow. Consider typesetting the tabular material in landscape mode, e.g., by loading the rotating package and placing the tabular material inside a sidewaystable environment.

  • Even if the tabular material is set in landscape mode, it will be too wide if you set the widths of columns 2 thru 9 to 2.5cm. I suggest you use a tabularx environment instead of a tabular environment and let LaTeX work out the column width that's needed to make the table fit.

  • If you want to permit hyphenation of the words, load the ragged2e package and modify the column type with a >{\RaggedRight} directive. Since the columns will all be quite narrow, it's better to set them in ragged-right mode instead of in "justified" mode.

  • Not addressed in the code below, but something to think about: Do you really gain something by bold-facing every single header cell?

enter image description here

\documentclass[11pt, a4paper]{article} \usepackage[T2A,T2B,T2C]{fontenc} \usepackage[utf8]{inputenc} \usepackage[english,russian]{babel} \usepackage{rotating,ragged2e,tabularx} \newcolumntype{L}{>{\RaggedRight\arraybackslash\hspace{0pt}}X} \begin{document} \begin{sidewaystable} \begin{tabularx}{\textwidth}{ | p{1cm} | *{8}{L|} } \hline \textbf{Text 1} & \textbf{Some Symbols} & \textbf{Long lines of code} & \textbf{Очень длинные строки, которые почему-то не переносяться корректно} & \textbf{Год} & \textbf{Разнообразные вариации чисел и букв 1234, новый номер 892473124} & \textbf{Text with some new default values.} & \textbf{Базовый текст, в котором могут быть смешаны letters and numbers in different languages + 2} & \textbf{Last column with which I have plenty of troubles and I need to fix} \\ \hline \end{tabularx} \end{sidewaystable} \end{document} 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.