1

I am trying to write up the following table.

However, I cannot get a line break to work (needed for Branches and Results column's) and as such the table runs off the side of the page. My attempt is as follows:

\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}

I was unable to get \makecell to work either.

Any help would be appreciated.

EDIT After taking Zarko's example I obtain:

\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}

Which has given the error: File ended while scanning use of \TX@get@body.

1
  • 1
    use e.g. p{3cm} as column type for the columns with linebreaks. Why are you using \multicolumn everywhere? – Ulrike Fischer Feb 16 '19 at 15:32
1

edit: after your comment i notice that showed table image and given table code example differ in which columns are multi line text. after moving X column on third place in insert l column on fourth your new code example works (error erase since you have paragraphs in l column type, what is not allowed)

in mwe below i make small changes in text formatting and remove table coloring.

enter image description here

\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}

note:

  • if this table is complete, than it not need to be longtable
  • if your variable as P, Q, e, etc can be in standard math shape for variables, the table code would become shorter and more clear
5
  • Thank you, this has helped me. But I now have the error: File ended while scanning use of \TX@get@body. Please see the edited post. – Tyr Feb 16 '19 at 18:32
  • @Tyr, i design table according to your image and didn't notice, that your code example is (quite) different. difference is in which column you have multi line text. i edit my answer and repair this mismatch. – Zarko Feb 16 '19 at 19:42
  • Thanks @Zarko. I noticed that I had missed a '}' in line 23. After adding that and implementing your column changes the code now works. – Tyr Feb 16 '19 at 20:54
  • @Tyr, i notice that i didn't upload last mwe version to answer. sorry for any inconvenience. if anser solve your problem (on the best way), you can accept it (ny clicking on check mark at the top left side of the answer) and when you have reputation 15 or more, up-vote it (by clicking on up-pen). – Zarko Feb 16 '19 at 21:10
  • Already done :) – Tyr Feb 16 '19 at 21:36
0

You need to put every column into every line. You could insert a tabular inside a column, but it probably wouldn't line up right.

Note, you have to run this 2 or three times to get the columns right.

\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}

demo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.