проблема форматирования текста заголовка ltablex

проблема форматирования текста заголовка ltablex

Я использую ltablexпакет для создания длинных таблиц на нескольких страницах. Для других моих маленьких таблиц я использую пакет tabularxи заметил ошибку форматирования или, может быть, баг?

Текст заголовка моей длинной таблицы не выровнен правильно по строке bottomrule.

Когда вы запустите код, вы увидите, что заголовок внизу маленькой таблицы правильно прижимается к строке bottomrule. Но на длинной таблице текст заголовка не прижимается к bottomruleстроке правильно. Там текст немного выступает с левой стороны.

Когда я использую свою маленькую таблицу без \begin{table]и \end{table}Environment и помещаю заголовок внутрь tabularx, возникает та же проблема, что и в длинной таблице, так как мне сделать так, чтобы все было правильно, работая с длинной таблицей. Я не могу использовать там и \begin{table]Environment \end{table}, так есть ли другой способ отформатировать текст заголовка, как в моей маленькой таблице с \begin{table]и \end{table}Environment?

Я добавил две фотографии. На первой из них показан кусок длинного стола, а на второй — маленький стол.

введите описание изображения здесь введите описание изображения здесь

EDIT - Полный код

\documentclass[%
a4paper,
12pt,                   
oneside,
captions=nooneline,
parskip=half
]
{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
%\usepackage{tabularx}
\usepackage{ltablex}
\usepackage{booktabs}
\usepackage{mathptmx}% Times

\setkomafont{disposition}{\normalfont\bfseries}
\setkomafont{caption}{\fontsize{9pt}{9pt}\selectfont}

\begin{document}

\keepXColumns
\begin{table}[htbp]
\begin{tabularx}{\textwidth}{XX}
\toprule
\textbf{Column 1} & \textbf{Column 2} \\
\midrule
$R$ & 1This is an example sentence \\
$R$ & 2As well as the line before \\
$A$ & 3Also this is an example \\
$R$ & 4This is an example sentence \\
$R$ & 5As well as the line before \\
$A$ & 6Also this is an example \\
$R$ & 7This is an example sentence \\
$R$ & 8As well as the line before \\
$A$ & 9Also this is an example \\
$R$ & 10This is an example sentence \\
$R$ & 11As well as the line before \\
$A$ & 12Also this is an example \\
\bottomrule
\end{tabularx}  
\caption{Example of an table} 
\end{table}

\newpage

\keepXColumns
%\begin{table}[htbp]
\begin{tabularx}{\textwidth}{XX}
\toprule
\textbf{Column 1} & \textbf{Column 2} \\
\midrule
$R$ & 1This is an example sentence \\
$R$ & 2As well as the line before \\
$A$ & 3Also this is an example \\
$R$ & 4This is an example sentence \\
$R$ & 5As well as the line before \\
$A$ & 6Also this is an example \\
$R$ & 7This is an example sentence \\
$R$ & 8As well as the line before \\
$A$ & 9Also this is an example \\
$R$ & 10This is an example sentence \\
$R$ & 11As well as the line before \\
$A$ & 12Also this is an example \\
$R$ & 13This is an example sentence \\
$R$ & 14As well as the line before \\
$A$ & 15Also this is an example \\
$R$ & 16This is an example sentence \\
$R$ & 17As well as the line before \\
$A$ & 18Also this is an example \\
$R$ & 19This is an example sentence \\
$R$ & 20As well as the line before \\
$A$ & 21Also this is an example \\
$R$ & 22This is an example sentence \\
$R$ & 23As well as the line before \\
$A$ & 24Also this is an example \\
$R$ & 25This is an example sentence \\
$R$ & 26As well as the line before \\
$A$ & 27Also this is an example \\
$R$ & 28This is an example sentence \\
$R$ & 29As well as the line before \\
$A$ & 30Also this is an example \\
$R$ & 31This is an example sentence \\
$R$ & 32As well as the line before \\
$A$ & 33Also this is an example \\
$R$ & 34This is an example sentence \\
$R$ & 35As well as the line before \\
$A$ & 36Also this is an example \\
$R$ & 37This is an example sentence \\
$R$ & 1This is an example sentence \\
$R$ & 2As well as the line before \\
$A$ & 3Also this is an example \\
$R$ & 4This is an example sentence \\
$R$ & 5As well as the line before \\
$A$ & 6Also this is an example \\
$R$ & 7This is an example sentence \\
$R$ & 8As well as the line before \\
$A$ & 9Also this is an example \\
$R$ & 10This is an example sentence \\
$R$ & 11As well as the line before \\
$A$ & 12Also this is an example \\
$R$ & 13This is an example sentence \\
$R$ & 14As well as the line before \\
$A$ & 15Also this is an example \\
$R$ & 16This is an example sentence \\
$R$ & 17As well as the line before \\
$A$ & 18Also this is an example \\
$R$ & 19This is an example sentence \\
$R$ & 20As well as the line before \\
$A$ & 21Also this is an example \\
$R$ & 22This is an example sentence \\
$R$ & 23As well as the line before \\
$A$ & 24Also this is an example \\
$R$ & 25This is an example sentence \\
$R$ & 26As well as the line before \\
$A$ & 27Also this is an example \\
$R$ & 28This is an example sentence \\
$R$ & 29As well as the line before \\
$A$ & 30Also this is an example \\
$R$ & 31This is an example sentence \\
$R$ & 32As well as the line before \\
$A$ & 33Also this is an example \\
$R$ & 34This is an example sentence \\
$R$ & 35As well as the line before \\
$A$ & 36Also this is an example \\
$R$ & 37This is an example sentence \\
\bottomrule
\caption{Example of an table2} 
\end{tabularx}  

\end{document}

решение1

использовать

\usepackage{booktabs}
\usepackage{ltablex}
\setkomafont{disposition}{\normalfont\bfseries}
\setkomafont{caption}{\small}    
\begin{document}

\keepXColumns
\begin{tabularx}{\textwidth}{Xx}\toprule
        \textbf{Column 1} & \textbf{Column 2} \\\midrule
        $R$ & 1This is an example sentence \\
        $R$ & 2As well as the line before \\
        $A$ & 3Also this is an example \\
        $R$ & 4This is an example sentence \\
        $R$ & 5As well as the line before \\
        $A$ & 6Also this is an example \\
        $R$ & 7This is an example sentence \\
        $R$ & 8As well as the line before \\
        $A$ & 9Also this is an example \\
        $R$ & 10This is an example sentence \\
        $R$ & 11As well as the line before \\
        $A$ & 12Also this is an example \\
        \bottomrule
    \caption{Example of an table} \\
    \end{tabularx}  

\begin{tabularx}{\textwidth}{XX}
    \toprule
    \textbf{Column 1} & \textbf{Column 2} \\
    \midrule
    $R$ & 1This is an example sentence \\
    $R$ & 2As well as the line before \\
    [...]

Подпись должна быть внутри tabularx. И сделайтенетиспользовать среду tableдля tabularx. Имеет свой собственный tableсчетчик .

введите описание изображения здесь

введите описание изображения здесь

решение2

Решение моей проблемы — использовать \captionsetup{margin=1pt}пакет caption. С 2pt я получил правильное выравнивание подписи.

благодаряГерберт!

или как альтернатива при использовании Komascript - как у меня - команда \setcapmargin{2pt}сделает то же самое.

решение3

Подпись должна быть включена в таблицу — так же longtable, как и в footспецификации, если вы хотите, чтобы подпись была внизу таблицы, или в headописаниях, чтобы она была над таблицей (что рекомендуется).

Кроме того, если вы загружаете ltablex, вам не нужно загружать tabularxни , ни longtable, поскольку они загружаются ltablex.

    \documentclass[a4paper]{article}%
    \usepackage{ltablex, booktabs}
    \usepackage[showframe]{geometry}
    \usepackage{caption}
    \captionsetup[table]{singlelinecheck=off, position=bottom}
     \usepackage{etoolbox}

    \begin{document}

    \keepXColumns
     \begin{table}[htbp]
    \begin{tabularx}{\linewidth}{XX}
    \toprule
    \textbf{Column 1} & \textbf{Column 2} \\
    \midrule
    $R$ & 1This is an example sentence \\
    $R$ & 2As well as the line before \\
    $A$ & 3Also this is an example \\
    $R$ & 4This is an example sentence \\
    $R$ & 5As well as the line before \\
    $A$ & 6Also this is an example \\
    $R$ & 7This is an example sentence \\
    $R$ & 8As well as the line before \\
    $A$ & 9Also this is an example \\
    $R$ & 10This is an example sentence \\
    $R$ & 11As well as the line before \\
    $A$ & 12Also this is an example \\
    \bottomrule
    \end{tabularx}
    \caption{Example of an table}
    \end{table}

    \bigskip
    {\pretocmd{\tablename}{\,}{}{}
    \begin{tabularx}{\linewidth}{XX}
    \midrule
    \caption{Example of an table}\label{xyz}
    \endfoot
    \bottomrule
    \caption{Example of an table}
    \endlastfoot
    \toprule
    \textbf{Column 1} & \textbf{Column 2} \\
    \midrule
    $R$ & 1This is an example sentence \\
    $R$ & 2As well as the line before \\
    $A$ & 3Also this is an example \\
    $R$ & 4This is an example sentence \\
    $R$ & 5As well as the line before \\
    $A$ & 6Also this is an example \\
    $R$ & 7This is an example sentence \\
    $R$ & 8As well as the line before \\
    $A$ & 9Also this is an example \\
    $R$ & 10This is an example sentence \\
    $R$ & 11As well as the line before \\
    $A$ & 12Also this is an example \\
    $R$ & 13This is an example sentence \\
    $R$ & 14As well as the line before \\
    $A$ & 15Also this is an example \\
    $R$ & 16This is an example sentence \\
    $R$ & 17As well as the line before \\
    $A$ & 18Also this is an example \\
    $R$ & 19This is an example sentence \\
    $R$ & 20As well as the line before \\
    $A$ & 21Also this is an example \\
    $R$ & 22This is an example sentence \\
    $R$ & 23As well as the line before \\
    $A$ & 24Also this is an example \\
    $R$ & 25This is an example sentence \\
    $R$ & 26As well as the line before \\
    $A$ & 27Also this is an example \\
    $R$ & 28This is an example sentence \\
    $R$ & 29As well as the line before \\
    $A$ & 30Also this is an example \\
    $R$ & 31This is an example sentence \\
    $R$ & 32As well as the line before \\
    $A$ & 33Also this is an example \\
    $R$ & 34This is an example sentence \\
    $R$ & 35As well as the line before \\
    $A$ & 36Also this is an example \\
    $R$ & 37This is an example sentence \\
    $R$ & 1This is an example sentence \\
    $R$ & 2As well as the line before \\
    $A$ & 3Also this is an example \\
    $R$ & 4This is an example sentence \\
    $R$ & 5As well as the line before \\
    $A$ & 6Also this is an example \\
    $R$ & 7This is an example sentence \\
    $R$ & 8As well as the line before \\
    $A$ & 9Also this is an example \\
    $R$ & 10This is an example sentence \\
    $R$ & 11As well as the line before \\
    $A$ & 12Also this is an example \\
    $R$ & 13This is an example sentence \\
    $R$ & 14As well as the line before \\
    $A$ & 15Also this is an example \\
    $R$ & 16This is an example sentence \\
    $R$ & 17As well as the line before \\
    $A$ & 18Also this is an example \\
    $R$ & 19This is an example sentence \\
    $R$ & 20As well as the line before \\
    $A$ & 21Also this is an example \\
    $R$ & 22This is an example sentence \\
    $R$ & 23As well as the line before \\
    $A$ & 24Also this is an example \\
    $R$ & 25This is an example sentence \\
    $R$ & 26As well as the line before \\
    $A$ & 27Also this is an example \\
    $R$ & 28This is an example sentence \\
    $R$ & 29As well as the line before \\
    $A$ & 30Also this is an example \\
    $R$ & 31This is an example sentence \\
    $R$ & 32As well as the line before \\
    $A$ & 33Also this is an example \\
    $R$ & 34This is an example sentence \\
    $R$ & 35As well as the line before \\
    $A$ & 36Also this is an example \\
    $R$ & 37This is an example sentence
    \end{tabularx}}

    \end{document} 

введите описание изображения здесь введите описание изображения здесь

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