O comando entra em vigor antes do ambiente

O comando entra em vigor antes do ambiente

É possível adicionar uma tabela \vspace{-\baselineskip}interna, por exemplo, longtable (ou outro ambiente} para entrar em vigor antes do início do ambiente? MWE que não tem efeito.

\documentclass{article}
\usepackage{longtable}
\usepackage{blindtext}

\begin{document}

\blindtext

\begin{longtable}{ll}
\vspace{-\baselineskip} \\ % this has no effect
                           % why \\ are really needed since caption has them?
\caption{testing table} \\
\hline
aaaa & bbbb \\
cccc & dddd \\
\hline
\end{longtable}

\end{document}

Existe um MWE com o problema de ter referência bagunçada no LOT.

\documentclass[captions=tableheading]{scrartcl}

\usepackage{blindtext}

\usepackage{hyperref}
\usepackage{tabu,longtable}
%\usepackage{threeparttable} % the package below already loads it
\usepackage[referable]{threeparttablex}
\usepackage{booktabs}
\usepackage{caption}


\usepackage{etoolbox}
\makeatletter
\chardef\TPT@@@asteriskcatcode=\catcode`*
\catcode`*=11
\expandafter\patchcmd\csname\string\threeparttable\endcsname
    {\TPT@hookin{tabular}}
    {\TPT@hookin{tabular}\TPT@hookin{tabu}} % allow threeparttable with tabu
    {}{}
\catcode`*=\TPT@@@asteriskcatcode
\makeatother

\makeatletter % fix referencing of LOT while using longtabu
    \newcounter{dummy}
    \newcommand{\setdummy}{\refstepcounter{dummy} \\}
    \let\oldlongtabu\longtabu\def\dummytabu{\vspace{-\baselineskip}\oldlongtabu} % correct the \\ in \setdummy
    \def\enddummytabu{\endlongtabu}
    \def\dummycap{\setdummy\caption}
\makeatother



\begin{document}

\listoftables

\bigskip

\blindtext

% LOT reference does not work
\begin{ThreePartTable}
\begin{TableNotes}
\footnotesize
\item[a] \label{tn:aa} A note
\item[b] Another note
\end{TableNotes}
\begin{longtabu}{ll}
\caption{A long table 1}
\label{tab:test1} \\
\toprule
Column 1 & Column 2 \\
\midrule
\endfirsthead
\toprule
Column 1 & Column 2 \\
\midrule
\endhead
\cmidrule{2-2}
\multicolumn{2}{r}{\textit{continued}}
\endfoot
\bottomrule
\insertTableNotes
\endlastfoot
% the contents of the table
A& B\tnotex{tn:aa} \\
\midrule
%\newpage % just testing page break
C\tnote{b} & D \\
\end{longtabu}
\end{ThreePartTable}

\blindtext

% LOT reference works fine
\begin{ThreePartTable}
\begin{TableNotes}
\footnotesize
\item[a] \label{tn:bb} A note
\item[b] Another note
\end{TableNotes}
\begin{longtable}{ll}
\caption{A long table 2}
\label{tab:test2} \\
\toprule
Column 1 & Column 2 \\
\midrule
\endfirsthead
\toprule
Column 1 & Column 2 \\
\midrule
\endhead
\cmidrule{2-2}
\multicolumn{2}{r}{\textit{continued}}
\endfoot
\bottomrule
\insertTableNotes
\endlastfoot
% the contents of the table
A& B\tnotex{tn:bb} \\
\midrule
%\newpage % just testing page break
C\tnote{b} & D \\
\end{longtable}
\end{ThreePartTable}

\blindtext

% LOT reference works fine (with vskip correction)
\begin{ThreePartTable}
\begin{TableNotes}
\footnotesize
\item[a] \label{tn:cc} A note
\item[b] Another note
\end{TableNotes}
\begin{dummytabu}{ll}
\dummycap{A long table 3}
\label{tab:test3} \\
\toprule
Column 1 & Column 2 \\
\midrule
\endfirsthead
\toprule
Column 1 & Column 2 \\
\midrule
\endhead
\cmidrule{2-2}
\multicolumn{2}{r}{\textit{continued}}
\endfoot
\bottomrule
\insertTableNotes
\endlastfoot
% the contents of the table
A& B\tnotex{tn:cc} \\
\midrule
%\newpage % just testing page break
C\tnote{b} & D \\
\end{dummytabu}
\end{ThreePartTable}

\blindtext

\end{document}

Responder1

Apenas use

\begin{ThreePartTable}
\begin{TableNotes}
\footnotesize
\item[a] \label{tn:aa} A note
\item[b] Another note
\end{TableNotes}
\begin{longtabu}{ll}
\noalign{\phantomsection}
\caption{A long table 1}
\label{tab:test1} \\
\toprule
...

Os links parecem funcionar e nenhum espaço adicional é adicionado.

Responder2

longtableinsere um vskip de comprimento \LTpre(padrão \bigskipammount) antes da tabela para alterar o espaço vertical antes da tabela alterar esse comprimento com \setlengthou \addtolength. Usar \vspacena posição que você mostra coloca-o na primeira célula da primeira linha, que é uma lentrada, portanto, uma caixa horizontal na qual um salto vertical não faz nada. Então o efeito é apenasadicionaruma linha em branco antes da tabela, apesar de especificar nominalmente um salto negativo.

informação relacionada