多列长表

多列长表

长桌会议 我正在尝试制作一个像上面这样的表格

\begin{longtable}{llll}
\caption{Eine Tabelle in Überlänge.} \label{tab:long} \\

\hline \multicolumn{1}{c}{\textbf{First column}} & \multicolumn{1}{c}{\textbf{Second column}} & \multicolumn{1}{c}{\textbf{Third column}} & \multicolumn{1}{c}{\textbf{Third column}}\\ \hline 
\endfirsthead

\multicolumn{4}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline \multicolumn{1}{c}{\textbf{First column}} & \multicolumn{1}{c}{\textbf{Second column}} & \multicolumn{1}{c}{\textbf{Third column}} & \multicolumn{1}{c}{\textbf{Third column}}\\ \hline 
\endhead

\hline \multicolumn{4}{r}{{Continued on next page}} \\ \hline
\endfoot

\hline \hline
\endlastfoot

One & abcdef ghjijklmn & 123.456778 & HALLO \\
One & abcdef ghjijklmn & 123.456778 & HALLO \\
One & abcdef ghjijklmn & 123.456778 & HALLO \\
One & abcdef ghjijklmn & 123.456778 & HALLO \\
One & abcdef ghjijklmn & 123.456778 & HALLO \\
One & abcdef ghjijklmn & 123.456778 & HALLO \\
One & abcdef ghjijklmn & 123.456778 & HALLO \\
One & abcdef ghjijklmn & 123.456778 & HALLO \\
One & abcdef ghjijklmn & 123.456778 & HALLO \\
\end{longtable}

结果

现在我对最后一部分(欧元的 Umsätze)有很多问题。有人能帮我吗?

答案1

以下输入与您自己的输入相同,但它使用了booktabs包并包括“Umsätze in EUR”部分。midruletoprule并且是具有更好间距的bottomrulebooktabs 变体。是 booktabs' 。hlinecmidrulecline

\documentclass{article}
\usepackage{longtable}
\usepackage{graphicx}
\usepackage{booktabs} % make sure to add this line to your own document

\begin{document}

\begin{longtable}{llll}
    \caption{Eine Tabelle in Überlänge.} \label{tab:long} \\

    \toprule
    & & \multicolumn{2}{c}{Umsätze in EUR}\\ % this the key addition
    \cmidrule{3-4} % the underline of Umsätze...
    \multicolumn{1}{c}{\textbf{First column}} & \multicolumn{1}{c}{\textbf{Second column}} & \multicolumn{1}{c}{\textbf{Third column}} & \multicolumn{1}{c}{\textbf{Third column}}\\ 
    \midrule
    \endfirsthead

    \multicolumn{4}{c}
    {{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
    \toprule 
    & & \multicolumn{2}{c}{Umsätze in EUR}\\
    \cmidrule{3-4}
    \multicolumn{1}{c}{\textbf{First column}} & \multicolumn{1}{c}{\textbf{Second column}} & \multicolumn{1}{c}{\textbf{Third column}} & \multicolumn{1}{c}{\textbf{Third column}}\\ 
    \midrule
    \endhead

    \midrule
     \multicolumn{4}{r}{{Continued on next page}} \\ 
     \midrule
    \endfoot

    \bottomrule
    \endlastfoot

    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\
    One & abcdef ghjijklmn & 123.456778 & HALLO \\ 
\end{longtable}

\end{document}

输出表的顶部如下所示:

在此处输入图片描述

编辑:如果您想在“Umsätze in EUR”下添加第三列,您需要更改

\multicolumn{2}{c}{Umsätze in EUR}\\
    \cmidrule{3-4}

\multicolumn{3}{c}{Umsätze in EUR}\\
    \cmidrule{3-5}

即 2 --> 3 和 3-4 --> 3-5,在两个位置。

编辑2:

这应该有效:

\documentclass{article}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage[left=1in,right=1in]{geometry} % this makes the left and right margins 1 inch/ 2.54cm; change it if you want to keep your preferred margins.

\begin{document}

\normalsize % change this to \small if you can't fit the table in the page width
\begin{longtable}{lllllll}
    \caption{Eine Tabelle in Überlänge.} \label{tab:long} \\

    \toprule
    & & & & \multicolumn{3}{c}{Umsätze in EUR}\\ % this the key addition
    \cmidrule{5-7} % the underline of Umsätze...
    Firma & Ort & PLZ & Straße & 2013 & 2014 & 2015\\ % I got rid of the \multicolumns, as they were affecting alignment
    \midrule
    \endfirsthead

    \multicolumn{7}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
    \toprule 
    & & & & \multicolumn{3}{c}{Umsätze in EUR}\\
    \cmidrule{5-7}
    \textbf{First column} & \textbf{Second column} & \textbf{Third column} & \textbf{Third column} & 2013 & 2014 & 2015\\ 
    \midrule
    \endhead

    \midrule
    \multicolumn{7}{r}{{Continued on next page}} \\ 
    \midrule
    \endfoot

    \bottomrule
    \endlastfoot

    One & abcdef ghjijklmn & 123.456778 & HALLO & aaaaa & bbbbb & ccccc \\
    One & abcdef ghjijklmn & 123.456778 & HALLO & aaaaa & bbbbb & ccccc \\
    One & abcdef ghjijklmn & 123.456778 & HALLO & aaaaa & bbbbb & ccccc \\
\end{longtable}
\normalsize % return text to normal size


\end{document}

答案2

  • 你的问题不太清楚
  • 您的文档的页面布局未知(表格有多宽?)
  • 在 MWE(最小工作示例)中,您提供了一个虚拟数据,它显然不能模拟真实数据(就其长度而言),因此很难帮助您进行表格设计
  • 关于多列单元格的问题,@Patrick Ferguson 解决您的问题他的回答(+1)
  • 不清楚为什么表格第一部分和其他部分有不同的列标题
  • 对于最后三列中的数字,使用包S中定义的列类型是明智的siunitx:数字以小数点逗号对齐

针对您的表格的一个解决方案(基于重新输入,在问题的第一张图片中显示了所需的表格瞭望台)可以是:

\documentclass{article}
\usepackage[margin=25mm]{geometry} 
\usepackage{booktabs, longtable, makecell}
\renewcommand\theadfont{\small\bfseries}
\renewcommand\theadgape{}
\usepackage{siunitx}

\usepackage{lipsum} % for dummy text filler

\begin{document}
    \lipsum[1-4]
\begingroup
\small
\sisetup{table-format=6.2,
         output-decimal-marker={,}
         }
\setlength\tabcolsep{4pt}
\begin{longtable}{@{} llll SSS @{}}
\caption{Eine Tabelle in Überlänge.}
\label{tab:long} \\
    \toprule
    & & & & \multicolumn{3}{c}{\thead{Umsätze in EUR}}  \\ % this the key addition
    \cmidrule{5-7} % the underline of Umsätze...
\thead{Firma} 
    & \thead{Ort} 
        & \thead{PLZ} 
            & \thead{Straße} 
                & {\thead{2013}} 
                    & {\thead{2014}} 
                        & {\thead{2015}}    \\
    \midrule
\endfirsthead
\caption[]{ -- continued from previous page}            \\
    \toprule
    & & & & \multicolumn{3}{c}{\thead{Umsätze in EUR}}  \\ % this the key addition
    \cmidrule{5-7} % the underline of Umsätze...
\thead{Firma}
    & \thead{Ort}
        & \thead{PLZ}
            & \thead{Straße}
                & {\thead{2013}}
                    & {\thead{2014}}
                        & {\thead{2015}}    \\
    \midrule
\endhead
    \midrule
    \multicolumn{7}{r}{\footnotesize\itshape{Continued on next page}}   \\
\endfoot
    \bottomrule
\endlastfoot
%%%% Table body
Donau Buroeinrichtunegen
    & Linz      & 4020  & Schubertplatz 9
        & 51560,00  & 56716,00  & 62387,00  \\
Burocenter Tirol
    & Innsbruck & 6020  & Innstrase 234
        & 480536,00   & 528589,00 & 581448,56 \\ 
Carynthia Firmenauststatittung 
    & Klagenfurt    & 9219 & Kaiser-Frantz.Str. 1806 
        & 199120,00 & 219032,00 & 240935,20 \\
    \addlinespace
Donau Buroeinrichtunegen
    & Linz      & 4020  & Schubertplatz 9
        & 51560,00  & 56716,00  & 62387,00  \\
Burocenter Tirol
    & Innsbruck & 6020  & Innstrase 234
        & 480536,00   & 528589,00 & 581448,56 \\
Carynthia Firmenauststatittung
    & Klagenfurt    & 9219 & Kaiser-Frantz.Str. 1806
        & 199120,00 & 219032,00 & 240935,20 \\
    \addlinespace
Donau Buroeinrichtunegen
    & Linz      & 4020  & Schubertplatz 9
        & 51560,00  & 56716,00  & 62387,00  \\
Burocenter Tirol
    & Innsbruck & 6020  & Innstrase 234
        & 480536,00   & 528589,00 & 581448,56 \\
Carynthia Firmenauststatittung
    & Klagenfurt    & 9219 & Kaiser-Frantz.Str. 1806
        & 199120,00 & 219032,00 & 240935,20 \\
    \addlinespace
Donau Buroeinrichtunegen
    & Linz      & 4020  & Schubertplatz 9
        & 51560,00  & 56716,00  & 62387,00  \\
Burocenter Tirol
    & Innsbruck & 6020  & Innstrase 234
        & 480536,00   & 528589,00 & 581448,56 \\
Carynthia Firmenauststatittung
    & Klagenfurt    & 9219 & Kaiser-Frantz.Str. 1806
        & 199120,00 & 219032,00 & 240935,20 \\
    \addlinespace
Donau Buroeinrichtunegen
    & Linz      & 4020  & Schubertplatz 9
        & 51560,00  & 56716,00  & 62387,00  \\
Burocenter Tirol
    & Innsbruck & 6020  & Innstrase 234
        & 480536,00   & 528589,00 & 581448,56 \\
Carynthia Firmenauststatittung
    & Klagenfurt    & 9219 & Kaiser-Frantz.Str. 1806
        & 199120,00 & 219032,00 & 240935,20 \\
\end{longtable}
\endgroup
\lipsum{6}
\end{document}

在此处输入图片描述

如果您的实际表格比上面的表格更宽,那么考虑将一些单元格内容(例如在第一列,也可能在第四列)写在两行中是明智的。这可以借助于 IN包,它是和包xltabular的组合。longtabletabularx

相关内容