1

I'm having problems combining the framed package with the longtable package. In the example below, if I comment out the \begin{leftbar}... \end{leftbar} then the table works correctly. But when I add the bar, the continuation header and both the footers disappear from the table.

Please ignore the rpt loop (courtesy of this answer) and the dodgy formatting at the end. I just used that to reduce the number of lines in the example code. The same problem occurs when I write out all the lines by hand.

\documentclass{article}

\usepackage{longtable}
\usepackage{framed}

\usepackage{forloop}% http://ctan.org/pkg/forloop
\newcounter{loopcntr}
\newcommand{\rpt}[2][1]{%
  \forloop{loopcntr}{0}{\value{loopcntr}<#1}{#2}%
}

\begin{document}

\begin{leftbar}
\begin{longtable}{|l|l|}
  \hline First top & First top\\ \hline\endfirsthead
  \hline  Top & Top\\ \hline \endhead
  \hline Last bottom & Last bottom \\ \hline \endlastfoot
  \hline \multicolumn{2}{|l|}{Continued\ldots} \\ \hline \endfoot
  \rpt[47]{Left & Right \\} \\
  \hline
\end{longtable}
\end{leftbar}

\end{document}
1
  • 1
    I'm not very surprised about this as the packages fight each other when a page break is involved.
    – egreg
    Commented Mar 22, 2019 at 22:08

1 Answer 1

1

Maybe you can reach the desired result with without framed but adding a thicker vertical rule in the table.

\documentclass{article}
\usepackage{array}
\usepackage{longtable}
\usepackage{forloop}% http://ctan.org/pkg/forloop
\newcounter{loopcntr}
\newcommand{\rpt}[2][1]{%
  \forloop{loopcntr}{0}{\value{loopcntr}<#1}{#2}%
}
\newcolumntype{?}{!{\vrule width 4pt}}% from: https://tex.stackexchange.com/a/156820/101651

\begin{document}

\begin{longtable}{?p{.2\textwidth}|l|l|p{.2\textwidth}}
  \cline{2-3} 
  & First top & First top &\\ \cline{2-3}
  \endfirsthead
  \cline{2-3}  
  & Top & Top\\ 
  \cline{2-3} 
  \endhead
  \cline{2-3} 
  & Last bottom & Last bottom \\ 
  \cline{2-3} 
  \endlastfoot
  \cline{2-3} & \multicolumn{2}{|l|}{Continued\ldots} \\ 
  \cline{2-3} \endfoot
  \rpt[47]{& Left & Right \\} \\
  \cline{2-3}
\end{longtable}

\end{document}

enter image description here

Edit: Looking at this answer, I found out there is changebar package, which I think is exactly what you need.

\documentclass{article}
\usepackage{array}
\usepackage{longtable}
\usepackage{forloop}% http://ctan.org/pkg/forloop
\newcounter{loopcntr}
\newcommand{\rpt}[2][1]{%
  \forloop{loopcntr}{0}{\value{loopcntr}<#1}{#2}%
}
\newcolumntype{?}{!{\vrule width 4pt}}% from: https://tex.stackexchange.com/a/156820/101651
\usepackage{mwe}% for testing purpose only
\usepackage[color,leftbars]{changebar}
\cbcolor{blue}
\begin{document}
\cbstart
\blindtext
\begin{longtable}{|l|l|}
  \hline First top & First top\\ \hline\endfirsthead
  \hline  Top & Top\\ \hline \endhead
  \hline Last bottom & Last bottom \\ \hline \endlastfoot
  \hline \multicolumn{2}{|l|}{Continued\ldots} \\ \hline \endfoot
  \rpt[47]{Left & Right \\} \\
  \hline
\end{longtable}
\blindtext
\cbend

\cbcolor{red}
\cbstart
\blindtext
\begin{longtable}{|l|l|}
  \hline First top & First top\\ \hline\endfirsthead
  \hline  Top & Top\\ \hline \endhead
  \hline Last bottom & Last bottom \\ \hline \endlastfoot
  \hline \multicolumn{2}{|l|}{Continued\ldots} \\ \hline \endfoot
  \rpt[47]{Left & Right \\} \\
  \hline
\end{longtable}
\blindtext
\cbend
\end{document}

enter image description here

8
  • +1 Nice idea, thanks. Unfortunately the vertical rule needs to extend beyond the table and sit to the left of some paragraphs of text as well (sorry I didn't explain that). I suppose I could use your trick for the table then go back to using leftbar for the text, but I imagine lining the two up might be a bit tricky. Commented Apr 15, 2019 at 21:23
  • If it helps your imagination, the reason for this bar is to mark sections of a document as verified, unverified or partially verified. The colour of the bar is changed according to the status. This wasn't my invention but I feel obliged to continue trying to make it work. The unverified bits aren't likely to be verified any time soon so doing something like changing the colour of the text would be very unpleasant, because we need to be able to read it regularly. Having the coloured bar didn't seem like a terrible idea. Commented Apr 15, 2019 at 21:34
  • @user3856370 The color of the bar changes also within a page? That is, is it possible to have a page with a half bar in red and the other half bar in green?
    – CarLaTeX
    Commented Apr 15, 2019 at 21:38
  • Changing colours within a page is possible. Commented Apr 15, 2019 at 21:39
  • Great, I appreciate your help. I have sleep now though so I'll check in later. Commented Apr 15, 2019 at 21:42

You must log in to answer this question.

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