3

This is a problem that happens sometimes when there is a frame (with sidebar) between two pages and a table is placed at the end of a page: the sidebar (with background) does not cover the entire table, like in this case:

enter image description here

This is the minimal example in which I can reproduce the problem:

\documentclass[12pt,table]{extbook}
\usepackage{framed}
\usepackage{booktabs}
\usepackage{xcolor}
\textheight=20.8cm
\vsize=24.5cm
\oddsidemargin= 0.5cm
\evensidemargin=0.5cm

\newenvironment{myleftbar}[1][\hsize]
{
    \def\FrameCommand
    {
        {\color{orange}\vrule width 5pt}
        \hspace{-5pt}
        \fboxsep=\FrameSep\colorbox{yellow}
    }
    \MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}
}
{\endMakeFramed}

\newtheorem{EsAsTheorem}{Example}[chapter]

\newenvironment{Esempio}
{\noindent\vspace{-2.7mm} \begin{EsAsTheorem} \begin{myleftbar}}
    {\end{myleftbar} \end{EsAsTheorem}} 

\begin{document}
\chapter[Title]{Title}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. , sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum., sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit. 

\begin{Esempio}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit

  \textsf{
    \begin{center}
      \begin{tabular}[t]{c c c}
        \multicolumn{3}{l}{\bfseries R}  \\ 
        \toprule
        \bfseries P & \bfseries T & \bfseries C  \\
        \bottomrule
        p1  & t1 & c1  \\
        p1 & t2 & c2\\
        p1 & t3 & c2\\
        \bottomrule
      \end{tabular}
    \end{center}
  }

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
\end{Esempio} 

\end{document}

The problem is only with tables, not with text or code. The impression that I have is that the problem is with the table, which is too long with respect to the page, but I do not know if this is hypothesis is correct and how to avoid this.

Do you have some idea on how to solve this?

Thanks a lot in advance.

  • 1
    Welcome to TeX.SE! Please make your question easier to answer by providing an MWE! – JouleV Jan 31 at 11:45
  • 1
    @JouleV, I've created a MWE, thanks for the comment! – Renzo Jan 31 at 14:26
  • 2
    if you look at latex output you'll see: "Overfull \vbox (18.19522pt too high) detected at line 51" Latex tells you that box is overfull – Denys Potapov Jan 31 at 17:44
  • Thanks @DenysPotapov, is this the “normal” behaviour for TeX? I expected that in this case it would move the table to a new page. There is a way to force generally this behaviour? Or should I manage the problem case by case? I'm not much experienced with LaTeX/TeX and I do not know which is the “TeX typical way” of treating this kind of problems. – Renzo Jan 31 at 20:06
1

I'd use tcolorbox, it's simpler and more flexible.

\documentclass[12pt,table]{extbook}
\usepackage{booktabs}

\usepackage[most]{tcolorbox}
\newtheorem{Esempio}{Example}[chapter]
\tcolorboxenvironment{Esempio}{
    enhanced,
    colframe=yellow,
    colback=yellow,
    breakable,
    left skip=11pt,
    borderline west={5pt}{-9pt}{orange}
    }

\begin{document}
\chapter[Title]{Title}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. , sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum., sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit. 

\begin{Esempio}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit

  \textsf{
    \begin{center}
      \begin{tabular}[t]{c c c}
        \multicolumn{3}{l}{\bfseries R}  \\ 
        \toprule
        \bfseries P & \bfseries T & \bfseries C  \\
        \bottomrule
        p1  & t1 & c1  \\
        p1 & t2 & c2\\
        p1 & t3 & c2\\
        \bottomrule
      \end{tabular}
    \end{center}
  }

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
\end{Esempio} 

\end{document}

enter image description here

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.