# Longtable over pagebreak creates duplicate Label

I have a weird one. In my latex document, a table is created and in the .aux file, the table is somehow duplicated, which generates a multiple label warning.

I was able to figure out, that it occurred, because that table is separated due to a pagebreak, which is fine in itself, but the multiple label warning ergo creation is annoying.

Infos:

Preamble:
\documentclass[10pt, a4paper, oneside, english]{scrbook}
\usepackage{ amsmath }
\usepackage{float}
\usepackage{ graphicx }
\usepackage{ microtype }
\usepackage[ english ]{ babel }
\usepackage[utf8]{inputenc}
\usepackage[ampersand]{easylist}
\usepackage{caption}
\usepackage[noprefix]{nomencl}
\usepackage{amssymb}
\usepackage{etoolbox}
\usepackage{environ}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{ltablex}
\usepackage{varwidth}
\usepackage{array}
\usepackage{gensymb}
\usepackage{subcaption}
\usepackage{siunitx}
\usepackage[ampersand]{easylist}


This is my current table command packed in a new environment. When I place the label directly behind the caption, is will be generated twice over a page break. Placing it in the second part of the new environment creates an error.

Where should I place the label command or which other command structure could I use to circumvent that situation?


% Variable Table Environment
\newenvironment{FancyTable}[4]
{
% Before each new major table
\ra{1.3}
\begin{longtable}{  @{} #1 @{}}
% Caption
\caption{#2} \label{tab:#4}\\
\\
% Top Section
\toprule #3 \\
% Midsection
\midrule
}
{
\bottomrule
\end{longtable}
}


Calling the table command

\begin{FancyTable}{lrr}{Ditolandia Results}{Size & Results ($1.3$) & Actual}{PPRR}
$a$     &       $0.1$       &       $0.1$       \\
$b$     &       $0.1$       &       $0.1$       \\
$c$     &       $0.1$       &       $0.1$       \\
\end{FancyTable}


Aux File extract:

\@writefile{lot}{\contentsline {table}{\numberline {\relax 3.1}{\ignorespaces Ditolandia Results}}{16}}
\newlabel{tab:PPRR}{{\relax 3.1}{16}}
\gdef \LT@vi {\LT@entry
{1}{52.80566pt}\LT@entry
{1}{67.80566pt}\LT@entry
{1}{35.16675pt}}
\@writefile{lot}{\contentsline {table}{\numberline {\relax 3.1}{\ignorespaces Ditolandia Results}}{17}}
\newlabel{tab:PPRR}{{\relax 3.1}{17}}


I can live with that warning, but it is annoying.

• Please do not only show code snippets but always a minimal working example. Without we cannot reproduce the problem and cannot test our suggestions. Mar 22 '17 at 9:01

Change the definition of FancyTable to set the label (and maybe the entry into the list of tables) only on the first page:

\newenvironment{FancyTable}[4]
{
% Before each new major table
\ra{1.3}
\begin{longtable}{  @{} #1 @{}}
% Caption
\caption{#2} \label{tab:#4}\\
\\
% Top Section
\toprule #3 \\
% Midsection
\midrule
\caption[]{#2}\\
\\
% Top Section
\toprule #3 \\
% Midsection
\midrule

See the longtable manual about \endfirsthead vs. \endhead and \caption[]{…} vs. \caption{…}.