使用长表和多列进行换行

使用长表和多列进行换行

我正在尝试写出下表。

但是,我无法使换行符起作用(分支和结果列需要),因此表格超出了页面的一侧。我的尝试如下:

\documentclass[12pt,a4paper]{report}

\usepackage{longtable}

\begin{document}
\begin{small}

\begin{longtable}{ | l | l | l | l | l | l |}
    \hline
    \multicolumn{1}{|c|}{\textbf{Study}} & \multicolumn{1}{c|}{\textbf{Bands}} & \multicolumn{1}{c|}{\textbf{Branches}} &
    \multicolumn{1}{c|}{\textbf{Range}} & \multicolumn{1}{c|}{\textbf{Notes}} & \multicolumn{1}{c|}{\textbf{Type}} \\
    \hline
    \endfirsthead
    \multicolumn{3}{c}
    {\tablename\ \thetable\ -- Continued from previous page} \\
    \hline
    \multicolumn{1}{|c|}{\textbf{Study}} & \multicolumn{1}{c|}{\textbf{Bands}} & \multicolumn{1}{c|}{\textbf{Branches}} & \multicolumn{1}{c|}{\textbf{Range}} & \multicolumn{1}{c|}{\textbf{Notes}} & \multicolumn{1}{c|}{\textbf{Type}} \\
    \hline
    \endhead 
    \hline \multicolumn{3}{r}{Continued on next page} \\
    \endfoot
    \hline
    \endlastfoot

    \multicolumn{1}{|l|}{00Harris.FeH} & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{Table 5: r\textsubscript{e}, $\omega$\textsubscript{e}, μ, D\textsubscript{e} Table 7: \textsuperscript{4}$\Delta$ \& \textsuperscript{5}$\Delta$ r\textsubscript{e} and d\textsubscript{pop} Table 14: R, ω\textsubscript{e}, D\textsubscript{e}} & \multicolumn{1}{l|}{Theoretical} \\ \hline
    \multicolumn{1}{|l|}{01TaSeYo.FeH} & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ }\\ \hline
    \multicolumn{1}{|l|}{01WalHin.FeH} & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{Lab + astro}\\ \hline
    \multicolumn{1}{|l|}{01WiBro.FeH} & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{Lab}\\ \hline
    \multicolumn{1}{|l|}{01WiCoBr.FeH} & \multicolumn{1}{l|}{(0-0) (1-0) } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{ } & \multicolumn{1}{l|}{Lab}\\ \hline
\end{longtable}
\end{small}

\end{document}

我也无法让 \makecell 工作。

任何帮助,将不胜感激。

编辑 以 Zarko 为例,我得到以下结论:

\documentclass[12pt,a4paper]{report}

\usepackage{geometry}
\usepackage{ltablex}
\keepXColumns
\newcommand\mcbf[1]{\multicolumn{1}{c|}{\textbf{#1}}}
\usepackage[table]{xcolor}

\usepackage{amsmath}

\begin{document}
    \begingroup
    \footnotesize\sffamily
    \setlength\tabcolsep{3pt}
    \rowcolors{1}{gray!30}{white}
    \begin{tabularx}{\linewidth}{ | l | l | l 
            >{\hsize=0.3\hsize}X |
            >{\hsize=0.7\hsize}X | l |}
        \caption{Table}
        \label{tab:mlt}                             \\
        \hline
        \rowcolor{white
        \multicolumn{1}{|c|}{\textbf{Study}}
        & \mcbf{Bands} & \mcbf{Branches} & \mcbf{Range} & \mcbf{Notes} &              \mcbf{Type} \\
        \hline
        \endfirsthead
         \caption*{Continued from previous page}     \\
        \hline
\multicolumn{1}{|c|}{\textbf{Study}}
        & \mcbf{Bands} & \mcbf{Branches} & \mcbf{Range} & \mcbf{Notes} &    \mcbf{Type} \\
        \endhead
        \hline
\multicolumn{3}{r}{Continued on next page} \\
\endfoot
\hline
\endlastfoot
00Harris.FeH    &   &   &   &
Table 5: r\textsubscript{e}, $\omega_e, \mu, D_e$

Table 7: \textsuperscript{4}$\Delta$ \& $^5 \Delta r_e$ and d\textsubscript{pop}

Table 14: R, $\omega_e, D_e$
& Theoretical                           \\ \hline
01TaSeYo.FeH    &   &   &   &  
Table 1: Total energy of \textsuperscript{4}$\Delta$ state and \textsuperscript{6}$\Delta$-\textsuperscript{4}$\Delta$ energy difference

Table 3: Binding energy of D\textsubscript{0} of ground

Table 4: Term energies

Table 5: V, r\textsubscript{e} and $\omega_e$

Table 6: Dipole moment of lower states &                                           \\ \hline
01WalHin.FeH    &   &   &   & Table 1: Frequencies     E\textsuperscript{4}$\Pi$-A\textsuperscript{4}$\Pi$  & Lab + astro                              \\ \hline
01WiBro.FeH     &   &   &   & Table 1: Term values & Lab                                   \\ \hline
01WiCoBr.FeH    & (0-0) (1-0) & 
R\textsubscript{11} Q\textsubscript{11} P\textsubscript{11}  R\textsubscript{12} 

Q\textsubscript{12} P\textsubscript{12} R\textsubscript{22} Q\textsubscript{22} 

P\textsubscript{22} R\textsubscript{23} Q\textsubscript{23} P\textsubscript{23} 

R\textsubscript{33} Q\textsubscript{33} P\textsubscript{33} R\textsubscript{34} 

Q\textsubscript{34} P\textsubscript{34} R\textsubscript{45} Q\textsubscript{45}

P\textsubscript{45} R\textsubscript{55} Q\textsubscript{55} P\textsubscript{55}

R\textsubscript{56} Q\textsubscript{56} P\textsubscript{56}  &   & 
Table 1: Vacuum wavenumbers for $\Delta\Omega$=0 subband of (0,0) band of e\textsuperscript{6}$\Pi$-a\textsuperscript{6}$\Delta$

Table 2: Term values in v=0 level of a\textsubscript{6}$\Delta$

Table 3: Vacuum wavenumbers for $\Delta\Omega$=-1 subband in (0,0) band of e\textsuperscript{6}$\Pi$-a\textsuperscript{6}$\Delta$

Table 4: Term values in v=0 of e\textsuperscript{6}$\Pi$

Table 5: Vacuum wavenumbers for (0,1) band of e\textsuperscript{6}$\Pi$-a\textsuperscript{6}$\Delta$

Table 6: Term values for v=1 of a\textsuperscript{6}$\Delta$

Table 9: Rotationless term values for v=0 of a\textsuperscript{6}$\Delta$

Table 10: Vacuum wavenumbers for g\textsuperscript{6}$\Phi _{11/2}$-3175 series

Table 11: Vacuum wavenumbers for e\textsuperscript{6}$\Pi _{7/2}$-3175 series

Table 12: Term values in 3175 series of  g\textsuperscript{6}$\Phi _{7/2}$ and e\textsuperscript{6}$\Pi _{7/2}$
& Lab                                   \\ \hline
    \end{tabularx}
    \endgroup
\end{document}

出现错误:扫描使用 \TX@get@body 时文件结束。

答案1

编辑: 在您的评论之后,我注意到显示的表格图像和给出的表格代码示例在哪些列是多行文本方面有所不同。将X第三位的列移动到第四位的插入l列后,您的新代码示例可以工作(错误擦除,因为您在l列类型中有段落,这是不允许的)

在下面的 mwe 中,我对文本格式做了一些小改动,并删除了表格颜色。

在此处输入图片描述

\documentclass[12pt,a4paper]{report}
\usepackage{geometry}
\usepackage{ltablex}
\keepXColumns
\newcommand\mcbf[1]{\multicolumn{1}{c|}{\textbf{#1}}}
\usepackage[table]{xcolor}

\usepackage{amsmath}

\begin{document}
\begingroup
\sffamily\footnotesize\linespread{0.84}\selectfont
\setlength\tabcolsep{3pt}
\begin{tabularx}{\linewidth}{ | l | l |
                            >{\hsize=0.38\hsize\raggedright\parskip=3pt}X | l |
                            >{\hsize=0.62\hsize\raggedright\parskip=3pt}X | l |}
\caption{My long table}
\label{tab:mlt}                             \\
    \hline
\multicolumn{1}{|c|}{\textbf{Study}}
            & \mcbf{Bands} & \mcbf{Branches} & \mcbf{Range} & \mcbf{Notes} & \mcbf{Type} \\
    \hline
    \endfirsthead
\caption*{Continued from previous page}     \\
    \hline
\multicolumn{1}{|c|}{\textbf{Study}}
            & \mcbf{Bands} & \mcbf{Branches} & \mcbf{Range} & \mcbf{Notes} & \mcbf{Type} \\
    \endhead
    \hline
\multicolumn{3}{r}{Continued on next page} \\
    \endfoot
    \hline
    \endlastfoot
00Harris.FeH    &   &   &   &
    Table 5: $\mathrm{r}^e$, $\omega_e$, $\mu$, $\mathrm{D}_e$

    Table 7: $^4\Delta$ \& $^5\Delta r_e$ and $\mathrm{d}_{\text{pop}}$

    Table 14: R, $\omega_e$,$\mathrm{D}_e$
                                & Theoretical                           \\ \hline

01TaSeYo.FeH    &   &   &   &
    Table 1: Total energy of $^4\Delta$ state and $^6\Delta -{}^4\Delta$ energy difference

    Table 3: Binding energy of $\mathrm{D}_0$ of ground

    Table 4: Term energies

    Table 5: V, $\mathrm{r}_e$ and $\omega_e$

    Table 6: Dipole moment of lower states
                                &                                       \\ \hline
01WalHin.FeH    &   &   &   &
    Table 1: Frequencies $\mathrm{E}^4\Pi - \mathrm{A}^4\Pi$
                                & Lab + astro                           \\ \hline
01WiBro.FeH     &   &   &   &
    Table 1: Term values        & Lab                                   \\ \hline

01WiCoBr.FeH    & (0-0) (1-0)
                    &   &   &   & Lab                                   \\ \hline
%
01WiCoBr.FeH    & (0-0) (1-0)
                    &
    $\mathrm{R}_{11}$ $\mathrm{Q}_{11}$ $\mathrm{P}_{11}$ $\mathrm{R}_{12}$

    $\mathrm{Q}_{12}$ $\mathrm{P}_{12}$ $\mathrm{R}_{22}$ $\mathrm{Q}_{22}$

    $\mathrm{P}_{22}$ $\mathrm{R}_{23}$ $\mathrm{Q}_{23}$ $\mathrm{P}_{23}$

    $\mathrm{R}_{33}$ $\mathrm{Q}_{33}$ $\mathrm{P}_{33}$ $\mathrm{R}_{34}$

    $\mathrm{Q}_{34}$ $\mathrm{P}_{34}$ $\mathrm{R}_{45}$ $\mathrm{Q}_{45}$

    $\mathrm{P}_{45}$ $\mathrm{R}_{55}$ $\mathrm{Q}_{55}$ $\mathrm{P}_{55}$

    $\mathrm{R}_{56}$ $\mathrm{Q}_{56}$ $\mathrm{P}_{56}$
                    &   &
        Table 1: Vacuum wavenumbers for $\Delta\Omega=0$ subband of (0,0) band of $\mathrm{e}^6\Pi - a^6\Delta$

        Table 2: Term values in $v=0$ level of $\mathrm{a}^6\Delta$

        Table 3: Vacuum wavenumbers for $\Delta\Omega=-1$ subband in (0,0) band of $\mathrm{e}^6\Pi - \mathrm{a}^6\Delta$

        Table 4: Term values in $v=0$ of $\mathrm{e}^6\Pi$

        Table 5: Vacuum wavenumbers for (0,1) band of $\mathrm{e}^6\Pi - \mathrm{a}^6\Delta$

        Table 6: Term values for $v=1$ of $\mathrm{a}^6\Delta$

        Table 9: Rotationless term values for $v=0$ of $\mathrm{a}^6\Delta$

        Table 10: Vacuum wavenumbers for $\mathrm{g}^6\Phi_{11/2}-3175$ series

        Table 11: Vacuum wavenumbers for $\mathrm{e}^6\Pi_{7/2}-3175$ series

        Table 12: Term values in 3175 series of  $\mathrm{g}^6\Pi_{7/2}$ and $\mathrm{e}^6\Pi_{7/2}$
                                & Lab                                   \\ \hline
 \end{tabularx}
    \endgroup
\end{document}

笔记:

  • 如果这个表是完整的,那么就不需要longtable
  • 如果你的变量如、、P等可以采用变量的标准数学形状,则表格代码将变得更短更清晰Qe

答案2

您需要将每一列放入每一行。您可以在列内插入表格,但可能无法正确对齐。

请注意,您必须运行 2 到 3 次才能获得正确的列。

\documentclass[12pt,a4paper]{report}
\usepackage{longtable}
\usepackage{showframe}% MWE only

\begin{document}
\begin{scriptsize}
\setlength{\tabcolsep}{0.9\tabcolsep}%
\begin{longtable}{ | l | l | l | l | l | l |}
    \hline
    \multicolumn{1}{|c|}{\textbf{Study}} & \multicolumn{1}{c|}{\textbf{Bands}} & \multicolumn{1}{c|}{\textbf{Branches}} &
    \multicolumn{1}{c|}{\textbf{Range}} & \multicolumn{1}{c|}{\textbf{Notes}} & \multicolumn{1}{c|}{\textbf{Type}} \\
    \hline
    \endfirsthead
    \multicolumn{3}{c}
    {\tablename\ \thetable\ -- Continued from previous page} \\
    \hline
    \multicolumn{1}{|c|}{\textbf{Study}} & \multicolumn{1}{c|}{\textbf{Bands}} & \multicolumn{1}{c|}{\textbf{Branches}} & \multicolumn{1}{c|}{\textbf{Range}} & \multicolumn{1}{c|}{\textbf{Notes}} & \multicolumn{1}{c|}{\textbf{Type}} \\
    \hline
    \endhead 
    \hline \multicolumn{3}{r}{Continued on next page} \\
    \endfoot
    \hline
    \endlastfoot
    00Harris.FeH & & & & Table 5: r\textsubscript{e} $\omega$\textsubscript{e}, μ, D\textsubscript{e} & Theoretical \\
    &&&& Table 7: \textsuperscript{4}$\Delta$ \& \textsuperscript{5}$\Delta$ r\textsubscript{e} and d\textsubscript{pop} &\\
    &&&& Table 14: R, ω\textsubscript{e}, D\textsubscript{e} & \\ \hline
    01TaSeYo.FeH & & & & ??? & \\ \hline
    01WalHin.FeH & & & & ??? & Lab + astro \\ \hline
    01WiBro.FeH & & & & ??? & Lab \\ \hline
    01WiCoBr.FeH & (0-0) (1-0) & & & ??? & Lab \\ \hline
\end{longtable}
\end{scriptsize}

\end{document}

演示

相关内容