首页 > 解决方案 > 在单列 Longtable/Supertabular 之前平衡 Latex 双列布局

问题描述

我想在 Latex 中以两列布局放置 Longtable 或 Supertabular。表格对于单列来说太大了,所以对于表格,我切换到单列布局。这工作得很好,但表格之前的两列不平衡,所以可能会出现巨大的差距。

示例:
如果左列已填满,然后表格将开始,则右列将留空,表格将从下一页开始。

我想将这个问题细分为两个问题:

示例代码:

\documentclass[twocolumn]{scrbook}

\usepackage{lipsum}
\usepackage{longtable,booktabs}
\usepackage{supertabular}
\usepackage{luacode}

\title{Ein Testdokument}
\author{Its Me}
\date{5. Januar 2020}

\newcounter{rownumb}
\setcounter{rownumb}{1}
\newcommand{\tabline}{Test & \the\value{rownumb} & Description\addtocounter{rownumb}{1}\\}
\newcommand{\tablines}[1]{
  \luaexec{
    for i=1,#1,1 do
      tex.print(string.format("Test & \%d & Description \\\\", i))
    end
  }
}

\begin{document}
\maketitle
\tableofcontents

\chapter{Introduction}

\lipsum


\onecolumn
\begin{longtable}[]{lcr}
\caption{longtable}\tabularnewline
\toprule
First A & First B & First C \\
\midrule
\endfirsthead
\toprule
A & B & C \\
\midrule
\endhead
\tablines{50}
\bottomrule
\end{longtable}
\twocolumn


\lipsum

\begin{center}
\tablefirsthead{\hline First A & First B & First C \\ \hline}
\tablehead{\hline First A & First B & First C \\ \hline}
\tabletail{\hline}
\tablelasttail{\hline}
\topcaption{short supertabular}
\begin{supertabular}{lcr}
\tablines{10}
\end{supertabular}
\end{center}

\lipsum

\onecolumn
\tablefirsthead{\hline First A & First B & First C \\ \hline}
\tablehead{\hline First A & First B & First C \\ \hline}
\tabletail{\hline}
\tablelasttail{\hline}
\topcaption{long supertabular}
\begin{supertabular}{lcr}
\tablines{50}
\end{supertabular}
\twocolumn


\lipsum

\begin{table}
\centering
\begin{tabular}{lcr}
\hline First A & First B & First C \\ \hline
\tablines{10}
\hline
\end{tabular}
\end{table}

\lipsum

\end{document}

关于标签的注释:
我会添加更多标签,如“table”和“column-balancing”,但我没有找到合适的标签,因为这是我的第一个问题,我无法添加不存在的标签。所以,如果有人觉得这很有意义,请添加更多标签。

非常感谢和最好的问候

标签: latextwo-columns

解决方案


推荐阅读