threeparttablex 与 floatrow 结合:表格不再居中

threeparttablex 与 floatrow 结合:表格不再居中

我用它threeparttablex来提供longtables功能threeparttable。总体来说效果很好。

但是我需要floatrow按如下方式加载:

\usepackage{floatrow}
\DeclareFloatFont{small}{\small}% "scriptsize" is defined by floatrow, "tiny" not
\floatsetup[table]{font=small, capposition=top}

不幸的是,现在threeparttablex桌子不再居中了。

有谁能解决这个问题?


以下是 MWE:

\documentclass[a4paper,
           11pt, 
           oneside, 
           headinclude, 
               numbers=noenddot, 
           toc=listof,
           toc=bibliography,
           BCOR=8.25mm,
           DIV=11]{scrbook} %draft fuer preview; ,BCOR=1cm,DIV=11, (DIV=10 wäre Standard)

\usepackage[T1]{fontenc} % Zeichentabelle, fuer deutschen Zeichensatz

\usepackage{amsmath}
\usepackage{amssymb} % mehr Symbole
\usepackage{upgreek}
\usepackage{wasysym} % für $\checked$
\usepackage[utf8]{inputenc} % UTF8-Zeichensatz (zur Eingabe)

\usepackage[ngerman, british]{babel} % ngerman
  \selectlanguage{british}

\usepackage{booktabs} % spezielle Tabellen zulassen
\usepackage{longtable} % Tabellen über mehr als eine Zeile zulassen
  \setlength{\LTpre}{12pt} % removing white spaces before and after longtable
  \setlength{\LTpost}{0pt}

\usepackage{siunitx}
 \sisetup{
        group-digits=true,          %% Zifferngruppierung an/aus
        group-minimum-digits=4,     %% Ziffern ab # Ziffern gruppieren
    add-integer-zero=false,
    detect-all = true   
%   detect-weight=true,detect-inline-weight=math
    }
% 
\usepackage{floatrow}
\DeclareFloatFont{small}{\small}% "scriptsize" is defined by floatrow, "tiny" not
\floatsetup[table]{font=small, capposition=top}

\usepackage[skip=0pt, labelsep=period, labelfont=bf]{caption}

\usepackage[flushleft]{threeparttable} % Um notes in den Tabellen zu haben
\usepackage[referable]{threeparttablex}


\begin{document}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.   

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.   

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.   

Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.   

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.   


  \begin{ThreePartTable}
  \begin{TableNotes}
        \setlength\labelsep{0pt}
    \small
    \item
    \emph{Note.} FA1--FA3 = Extracted factors. Factor loadings $\geq .40$ are in boldface.
  \end{TableNotes}
  \begin{longtable}{
      l
      S[table-format=1.2, detect-weight, detect-family=true]
      S[table-format=1.2, detect-weight, detect-family=true]
      S[table-format=1.2, detect-weight, detect-family=true]
      }
     \caption{Factor loadings for principal factor analysis with Promax rotation of the agency facets scales.} \\
      \toprule
      Item &   {FA1} &   {FA2} &   {FA3}  \\ \midrule
      \endfirsthead
      \multicolumn{4}{c}%
      {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
      \toprule
      Item &   {FA1} &   {FA2} &   {FA3}  \\ \midrule
      \endhead
      \bottomrule
      \multicolumn{4}{r}{\textit{Continued on next page}} \\
      \endfoot
      \bottomrule
      \insertTableNotes
%       \multicolumn{4}{r}{\textit{Continued on next page}} \\
      \endlastfoot
      competence 1 & \textbf{0.75} & -0.14 & 0.04 \\ 
      competence 2 & \textbf{0.84} & -0.06 & -0.07 \\ 
      competence 3 & \textbf{0.84} & -0.08 & -0.06 \\ 
      competence 4 & \textbf{0.55} & 0.11 & -0.15 \\ 
      competence 5 & \textbf{0.72} & 0.10 & -0.12 \\ 
      competence 6 & \textbf{0.65} & 0.01 & 0.03 \\ 
      competence 7 & \textbf{0.81} & -0.07 & 0.01 \\ 
      competence 8 & \textbf{0.81} & -0.07 & 0.06 \\ 
      competence 9 & \textbf{0.60} & 0.08 & 0.11 \\ 
      competence 10 & \textbf{0.58} & 0.03 & 0.25 \\ 
      beliefs 2 & 0.23 & \textbf{0.41} & -0.05 \\ 
      beliefs 3 & 0.24 & \textbf{0.40} & -0.05 \\ 
      beliefs 4 & -0.14 & \textbf{0.79} & 0.00 \\ 
      beliefs 5 & -0.10 & \textbf{0.80} & -0.04 \\ 
      beliefs 6 & -0.09 & \textbf{0.76} & 0.03 \\ 
      beliefs 7 & -0.13 & \textbf{0.80} & 0.06 \\ 
      beliefs 8 & 0.09 & \textbf{0.67} & 0.00 \\ 
      beliefs 9 & 0.06 & \textbf{0.70} & -0.01 \\ 
      beliefs 10 & 0.14 & \textbf{0.53} & 0.09 \\ 
      personality 1 & 0.09 & 0.08 & \textbf{0.49} \\ 
      personality 2 & -0.01 & -0.06 & \textbf{0.71} \\ 
      personality 3 & -0.01 & 0.00 & \textbf{0.63} \\ 
      personality 5 & -0.10 & 0.10 & \textbf{0.66} \\ 
      personality 6 & 0.04 & 0.09 & \textbf{0.54} \\ 
      personality 8 & -0.05 & -0.13 & \textbf{0.49} \\ \midrule
      \emph{Explained variance} & \itshape .21 & \itshape .16 & \itshape .09 
    \label{tab:PFA_agency} \\
    \end{longtable}
    \end{ThreePartTable}

\end{document}

答案1

这是一个最小的例子,它表明问题是由floatrow和的组合引起的longtable

\documentclass{article}
\usepackage{longtable,showframe}
\usepackage{floatrow}

\begin{document}

\begin{longtable}{lccc}
  \caption{Caption which must extend to quite a long thing if we're going to see the problem clearly.} \\
  competence 1 & \textbf{0.75} & -0.14 & 0.04 \\
  competence 2 & \textbf{0.84} & -0.06 & -0.07 \\
\end{longtable}

\end{document}

问题

文档提到了已被修改以与 配合使用的floatrow事实。但它未能说明的是,这不是某事所做的,而是某事所做的。longtablefloatrowlongtablefloatrow

在中floatrow.sty,我们发现

\AtBeginDocument{%
\@ifundefined{LT@array}{\@tempswafalse}{\@tempswatrue}
\if@tempswa\RequirePackage{fr-longtable}\fi}

因此,如果在文档开始之前已经加载,则floatrow正在加载。fr-longtable.stylongtable

尽管我无法证实这一点,但该补丁有可能与longtable当时可用的版本兼容。

\ProvidesPackage{floatrow}
       [2008/08/02 v0.3b floatrow: float package extension]

显示floatrow上次更新时间为 2008 年,而

\ProvidesPackage{fr-longtable}
       [2007/11/28 v0.1b (beta) floatrow: additions for longtable]

显示longtable补丁来自 2007 年。相比之下,

\ProvidesPackage{longtable}
          [2014/10/28 v4.11 Multi-page Table package (DPC)]

告诉我们longtable上次更新是在 2014 年。

因此,一种可能性是该补丁在 2007 年有效,但现在无效了。

解决这个问题最直接的方法,至少是明确地告诉longtable它应该居中

\begin{longtable}[c]{lccc}

居中 <code>longtable</code>

但是,如果你想要将表格设置在左侧或右侧,这将不起作用,因为在这种情况下标题会放错位置。

\begin{longtable}[l]{lccc}
...

\begin{longtable}[c]{lccc}
...

\begin{longtable}[l]{lccc}

生产

左、中、右 - 但不完全是

因此,问题显然比在重新定义环境时未能指定默认对齐要深一些longtable

事实上,问题甚至不在于补丁本身。阻止加载补丁并不能解决问题。事实上,不加载补丁floatrow也不能解决问题。这似乎是一个longtable即使没有 也能重现的问题floatrow,正如 David 在聊天中指出的那样……[也就是说,这个问题已经报告给了……的作者longtable]

floatrow导致该问题的唯一原因是加载floatrow未能使居中成为默认值,而加载longtable本身却确实如此。

\documentclass{article}
\usepackage{longtable,showframe}
\usepackage{floatrow}

\begin{document}

\begin{longtable}[l]{lccc}
  \caption{Caption which must extend to quite a long thing if we're going to see the problem clearly.} \\
  competence 1 & \textbf{0.75} & -0.14 & 0.04 \\
  competence 2 & \textbf{0.84} & -0.06 & -0.07 \\
\end{longtable}
\begin{longtable}[c]{lccc}
  \caption{Caption which must extend to quite a long thing if we're going to see the problem clearly.} \\
  competence 1 & \textbf{0.75} & -0.14 & 0.04 \\
  competence 2 & \textbf{0.84} & -0.06 & -0.07 \\
\end{longtable}
\begin{longtable}[r]{lccc}
  \caption{Caption which must extend to quite a long thing if we're going to see the problem clearly.} \\
  competence 1 & \textbf{0.75} & -0.14 & 0.04 \\
  competence 2 & \textbf{0.84} & -0.06 & -0.07 \\
\end{longtable}

\end{document}

相关内容