2

I have a longtable and it doesn't fit the page size. How to fix it?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}  % Включаем пакет для поддержки русского
\usepackage{multirow,tabularx}
\usepackage{tabu}
\usepackage{longtable}
\usepackage[a4paper, portrait, margin=1in, hmargin=2cm, top=4cm, bottom=4cm, headheight=3cm, footskip=2.5cm]{geometry}

    \begin{document}

\begin{longtable}{|l|l|l|l|l|l|}
%\begin{longtable}{@{\extracolsep{\fill}}|l|l|l|l|l|l|@{}}
\hline
№& Описание отклонения & Департамент & Идентифицированный риск & \multicolumn{2}{l|}{Не идентифицированный риск 1} \\
\hline
1   & ОТКЛОНЕНИЕ 1   & Департамент 1  & Риск 1  & Описание не идентифицированного риска & НИ Риск  \\
\cline{5-6}
        &           &           &           & Объект / процесс, в которос появился этот риск & Объект 1 \\
\hline        
\end{longtable}

\end{document}

I also tryed to use this code from the documentation but it still results in a table that is wider than the text width:

\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}}|l|l|l|l|l|l|@{}} 

enter image description here

  • Apparently your columns are too wide because they do not wrap? ;-) – user31729 Feb 15 '16 at 15:53
  • @ChristianHupfer How to wrap text in the columns? – Lucky_girl Feb 15 '16 at 15:59
  • I already suggested to the \newcolumntype command from the array package (and reading it's documenation) once (as a comment to another question where this wrapping was missing too) ;-) – user31729 Feb 15 '16 at 16:02
  • @ChristianHupfer I guess it's a high time to read it. :-) – Lucky_girl Feb 15 '16 at 16:07
1

You can specify the size of a column by using p<Xcm>

\begin{longtable}{|p<1cm>|p<3cm>|p<3cm>|p<3cm>|p<3cm>|p<3cm>|}
|improve this answer|||||
6

Package ltablex redefines the environment tabularx that it behaves like a longtable: pagebreaks are possible and header definitions too.

The \hspace{0pt} are needed for pdflatex and xelatex: TeX doesn't hyphenate the first word in a paragraph. However, LuaTeX does ...

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}  % Включаем пакет для поддержки русского
\usepackage{ltablex}
\usepackage[a4paper, portrait, margin=1in, hmargin=2cm, top=4cm, bottom=4cm, 
headheight=3cm, footskip=2.5cm]{geometry}

\begin{document}

\noindent
\begin{tabularx}{\linewidth}{|l|>{\hspace{0pt}}p{2.2cm}|l|>{\hspace{0pt}}p{2cm}|X|l|}\hline
№& Описание отклонения & Департамент & Идентифицированный риск & \multicolumn{2}{l|}{Не 
идентифицированный риск 1} \\\hline
1   & ОТКЛОНЕНИЕ 1   & Департамент 1  & Риск 1  & Описание не идентифицированного риска & 
НИ Риск  \\\cline{5-6}
&           &           &           & Объект / процесс, в которос появился этот риск & 
Объект 1 \\\hline        
\end{tabularx}

\end{document}

enter image description here

|improve this answer|||||
  • But how to make it work with longtable? Because actually this table will be for 2-3 pages, and tabularx would be not very good for this. – Lucky_girl Feb 15 '16 at 16:13
  • 3
    It is a longtable! Package ltablex is a combination of longtable and tabularx – user2478 Feb 15 '16 at 16:16

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.