# How to create a new environment that contains multi-page longtables with unique caption labels?

I'm trying to create a new environment for a document that I'm working on that can incorporate multi-page longtables and have uniquely named captions separate from other normal longtables that I'm using.

In the document that I am creating, I use both tables and longtable environments to create both normal tables and in addition to create a new separate environment that has caption label 'Excerpt', with its own unique numbering that can have multipage longtables, which I want to use to display transcript excerpts. I also want to be able to reference the Excerpts throughout the document. My usual go-to in creating new environments like this is the package newfloat, but because multipage longtables are not floats, this becomes problematic. How do I go about creating a new named environment for multipage longtables, without overriding the naming of all the longtables in the document? In the end there should be two separate entities: one from "Tables" that uses both table and longtable and "Excerpt" that can take longtable.

Here is what I have so far with newfloat that does not work as I want. It creates an Excerpt 1 but is prevented from spanning multiple pages. I also have a Table 1 that is numbered as Table 2 instead of as Table 1.

\documentclass[12pt,oneside,openany]{book}
\usepackage{newfloat}
\usepackage{caption}
\usepackage{longtable}
\DeclareFloatingEnvironment[fileext=frm,placement={!ht},name=Excerpt]{myfloat}

\begin{document}
\listoftables \listofmyfloats \clearpage
In Excerpt~\ref{excerpt1} \blindtext

\begin{myfloat}[h!]
\caption{[BR1-22 TIME]}
\label{excerpt1}
\begin{longtable}{llp{4in}}
1  & PR: & You know, last year my brother, my younger, actually was the youngest when we moved abroad.                                                                                    \\
2  & Brad:    & Mmm.                                                                                                                                                                   \\
3  & Brad:    & Mmm.                                                                                                                                                                   \\
4  & Brad:    & @                                                                                                                                                                      \\
5  & PR: & He was, he was two when we moved away, but when he came to visit me last year he conversed all in English.                                                             \\
6  & Brad:    & Mm-Mmm.                                                                                                                                                                \\
7  & Brad:    & @                                                                                                                                                                      \\
8  & Brad:    & Mmm. Mmm.                                                                                                                                                              \\
9  & PR: & He was able to understand Pingelapese, but he had lost this, you know, his ability to speak Pingelapese.                                                               \\
10 & Brad:    & Mmm.                                                                                                                                                                   \\
11 & Brad:    & Mm-Mmm.                                                                                                                                                                \\
12 & Brad:    & Mmm.                                                                                                                                                                   \\
13 & PR: & And he, he was, he was, he was envying his other cousins for knowing Pingelapese but \ldots @                                                                               \\
14 & Brad:    & Mmm.                                                                                                                                                                   \\
15 & Brad:    & Mmm. Mmm.                                                                                                                                                              \\
16 & PR: & So I think when he came back he felt that he was at a loss.                                                                                                            \\
17 & Brad:    & Mmm.                                                                                                                                                                   \\
18 & PR: & You know, if, if all Pohnpeians, Pingelapese eventually would feel that, I think they need to because he came back and he realized that he have that other identity.   \\
19 & Brad:    & Mmm.                                                                                                                                                                   \\
20 & PR: & And he didn’t feel fit, you know, he felt like he was out of the loop because his other cousins were speaking Pingelapese and he was the only one speaking English so. \\
\\
22 & PR: & He felt out of place.      \\

\end{longtable}
\end{myfloat}

\end{document}

• you can't put a longtable in a float (well you can. but floats are parboxes so never break over a page. Mar 18, 2018 at 0:31
• Thanks. I know I can't put a longtable in a float, hence my dilemma.
Mar 18, 2018 at 0:38
• you should be able to use something like \captionof{myfloat}{[BR1-22 TIME]} before the longtable I would have thought. (and put \addtocounter{table}{-1} after the table to get the table counter back in sync Mar 18, 2018 at 0:46

Based on David's comment, I was able to make the following code work. The \captionof{myfloat}{Caption} worked but it removed the indentation of all the following paragraphs so had to also add \begingroup and \endgroup around it, which corrected that problem.

\documentclass[12pt,oneside,openany]{book}
\usepackage{newfloat}
\usepackage{caption}
\usepackage{longtable}
\DeclareFloatingEnvironment[fileext=frm,placement={!ht},name=Excerpt]{myfloat}
\usepackage{blindtext}
\begin{document}

\listofmyfloats \clearpage
In Excerpt~\ref{excerpt1} \blindtext \\

\begingroup
\captionof{myfloat}{[BR1-22 TIME]}\label{excerpt1}
\endgroup
\begin{longtable}{llp{4in}}
\multicolumn{3}{l}{(Excerpt 3) [BR1-22 TIME]}\\
1  & PR: & You know, last year my brother, my younger, actually was the youngest when we moved abroad.                                                                            \\
2  & Brad:    & Mmm.                                                                                                                                                                   \\
3  & Brad:    & Mmm.                                                                                                                                                                   \\
4  & Brad:    & @                                                                                                                                                                      \\
5  & PR: & He was, he was two when we moved away, but when he came to visit me last year he conversed all in English.                                                             \\
6  & Brad:    & Mm-Mmm.                                                                                                                                                                \\
7  & Brad:    & @                                                                                                                                                                      \\
8  & Brad:    & Mmm. Mmm.                                                                                                                                                              \\
9  & PR: & He was able to understand Pingelapese, but he had lost this, you know, his ability to speak Pingelapese.                                                               \\
10 & Brad:    & Mmm.                                                                                                                                                                   \\
11 & Brad:    & Mm-Mmm.                                                                                                                                                                \\
12 & Brad:    & Mmm.                                                                                                                                                                   \\
13 & PR: & And he, he was, he was, he was envying his other cousins for knowing Pingelapese but \ldots @                                                                               \\
14 & Brad:    & Mmm.                                                                                                                                                                   \\
15 & Brad:    & Mmm. Mmm.                                                                                                                                                              \\
16 & PR: & So I think when he came back he felt that he was at a loss.                                                                                                            \\
17 & Brad:    & Mmm.                                                                                                                                                                   \\
18 & PR: & You know, if, if all Pohnpeians, Pingelapese eventually would feel that, I think they need to because he came back and he realized that he have that other identity.   \\
19 & Brad:    & Mmm.                                                                                                                                                                   \\
20 & PR: & And he didn’t feel fit, you know, he felt like he was out of the loop because his other cousins were speaking Pingelapese and he was the only one speaking English so. \\
21 & Brad:    & Mmm.                                                                                                                                                                   \\
22 & PR: & He felt out of place.      \\
\end{longtable}

\blindtext

\blindtext

\end{document}