右对齐长表的标题

右对齐长表的标题

我正在排版longtables跨越整个textwidth

我想要右对齐显示字幕。

红线突出显示的边缘是我的问题

我获得了无法摆脱的利润(红线)。

根据ltcaption 包文档,参见其中的表 15),设置LTcapright为 0 应该可以解决问题。

这是为了重现我的问题:

\documentclass[a4paper,dvipsnames]{article}
\usepackage{booktabs}
\usepackage{ltablex}
\usepackage{ltcaption} % http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/caption/ltcaption.pdf
\setlength\LTcapright{0pt\relax}
\setlength\LTcapleft{\fill}
\keepXColumns

\begin{document}
\begin{tabularx} {\textwidth} {Xr}
%
\bfseries Headline & \bfseries Numer 
\\
\midrule
\endhead
%
\bottomrule
    \caption{My caption should be right aligned.}
\endfoot
%
First line long long text & 123 \\
Second line & 123 \\
    %
\end{tabularx}

Text as usual södfkn sdfsdklgnk ds dlkdsfkl dsfkl sdklsdfsdnf lksdnf lksdnf lskfn slkfn 
slkdfn slkdfn slkfn slkfn slkfn slkfn sldkfn sldkfnlskdfnsdlf .

\end{document}

答案1

您可以借助该包右对齐标题caption

在此处输入图片描述

\documentclass[a4paper,dvipsnames]{article}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{ltablex}
\usepackage{xltabular}
\keepXColumns

\usepackage{caption}
\captionsetup[table]{singlelinecheck=false, justification=raggedleft}

\usepackage{showframe}

\begin{document}
\begin{tabularx} {\textwidth} {Xr}
%
\bfseries Headline & \bfseries Numer 
\\
\midrule
\endhead
%
\bottomrule
    \caption{My caption should be right aligned.}
\endfoot
%
First line long long text & 123 \\
Second line & 123 \\
    %
\end{tabularx}

Text as usual södfkn sdfsdklgnk ds dlkdsfkl dsfkl sdklsdfsdnf lksdnf lksdnf lskfn slkfn 
slkdfn slkdfn slkfn slkfn slkfn slkfn sldkfn sldkfnlskdfnsdlf .

\begin{longtable}  {lr}
%
\bfseries Headline & \bfseries Numer 
\\
\midrule
\endhead
%
\bottomrule
    \caption{My caption should be right aligned.}
\endfoot
%
First line long long text & 123 \\
Second line & 123 \\
    %
\end{longtable}

Text as usual södfkn sdfsdklgnk ds dlkdsfkl dsfkl sdklsdfsdnf lksdnf lksdnf lskfn slkfn 
slkdfn slkdfn slkfn slkfn slkfn slkfn sldkfn sldkfnlskdfnsdlf .

\begin{xltabular} {\textwidth} {Xr}
%
\bfseries Headline & \bfseries Numer 
\\
\midrule
\endhead
%
\bottomrule
    \caption{My caption should be right aligned.}
\endfoot
%
First line long long text & 123 \\
Second line & 123 \\
    %
\end{xltabular}

\end{document}

相关内容