Команда вступает в силу до наступления среды

Команда вступает в силу до наступления среды

Можно ли добавить \vspace{-\baselineskip}внутреннюю, например, longtable (или другую среду), чтобы она вступила в силу до запуска среды? MWE, которая не имеет никакого эффекта.

\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}

Существует MWE с проблемой наличия неправильной ссылки в 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}

решение1

Просто используйте

\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
...

Ссылки, похоже, работают, и никакого дополнительного места не добавляется.

решение2

longtableвставляет vskip длины \LTpre(по умолчанию \bigskipammount) перед таблицей, чтобы изменить вертикальное пространство перед таблицей, измените эту длину с помощью \setlengthили \addtolength. Использование \vspaceв указанной вами позиции помещает его в первую ячейку первой строки, которая является lзаписью, поэтому горизонтальный блок, в котором вертикальный пропуск ничего не делает. Таким образом, эффект заключается в том, чтобы простодобавлятьпустая строка перед таблицей, несмотря на номинальное указание отрицательного пропуска.

Связанный контент