3

I have a code for a table that should fit to textwidth, but for some reason it doesn't. Any ideas why?

\documentclass {article}

\usepackage [T2A] {fontenc}
\usepackage [utf8] {inputenc}
\usepackage [english,russian] {babel}

\usepackage{longtable}
\usepackage{array}
\usepackage{tabu}

\usepackage{lipsum}

\begin{document}

    \lipsum[1-1]
    \tabulinesep = 1mm
    \begin{longtabu} to \textwidth {|c|X[p]|c|c|c|c|c|}
        \hline
        & 
        & \multicolumn{5}{c|}{\bfseries Количество часов} \\ \cline{3-7}
        %
    \bfseries
    \begin{tabular}{c}
        № \\ модуля 
    \end{tabular}
        & \centering\bfseries Наименование модулей
        & \bfseries Всего
        & \multicolumn{3}{c|}{\bfseries%
            \begin{tabular}{c}
            Аудиторная \\ работа 
            \end{tabular}}
        & \bfseries
            \begin{tabular}{c}
            Внеауд. \\ работа \\ СР
            \end{tabular} \\ \cline{4-6}
    &
        &
        & \bfseries Л
        & \bfseries ПЗ
        & \bfseries ЛР
        & 
        \\ \hline
    \end{longtabu}
    \noindent\hrulefill
\end{document}

Too wide table

2
  • 2
    The specification in the inner tabulars should be @{}c@{} and not c.
    – egreg
    Commented Jul 28, 2014 at 21:58
  • @egrer great, thank you! PLease convert your comment to answer. Commented Jul 29, 2014 at 5:58

1 Answer 1

4

I'm not sure why (tabu is somewhat surprising, usually), but specifying the inner tabular environments with @{}c@{} instead of c seems to cure the problem.

\documentclass {article}

\usepackage [T2A] {fontenc}
\usepackage [utf8] {inputenc}
\usepackage [english,russian] {babel}

\usepackage{longtable}
\usepackage{array}
\usepackage{tabu}

\usepackage{lipsum}

\begin{document}

    \lipsum[1-1]
    \tabulinesep = 1mm
    \begin{longtabu} to \textwidth {|c|X[p]|c|c|c|c|c|}
        \hline
        & 
        & \multicolumn{5}{c|}{\bfseries Количество часов} \\ \cline{3-7}
        %
    \bfseries
    \begin{tabular}{@{}c@{}}
        № \\ модуля 
    \end{tabular}
        & \centering\bfseries Наименование модулей
        & \bfseries Всего
        & \multicolumn{3}{c|}{\bfseries%
            \begin{tabular}{@{}c@{}}
            Аудиторная \\ работа 
            \end{tabular}}
        & \bfseries
            \begin{tabular}{@{}c@{}}
            Внеауд. \\ работа \\ СР
            \end{tabular} \\ \cline{4-6}
    &
        &
        & \bfseries Л
        & \bfseries ПЗ
        & \bfseries ЛР
        & 
        \\ \hline
    \end{longtabu}
\end{document}

enter image description here

2
  • Sir, do you mind explaining what @{} means under the table context? Thank you so very much! Google doesn't take @{} as input, so I cannot search them myself. :-( Commented Aug 17, 2015 at 7:27
  • 1
    @SibbsGambling @{} means “omit the intercolumn space”.
    – egreg
    Commented Aug 17, 2015 at 8:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .