1

Some problems with my table.

I managed to poach ideas from this entry: Make list of sentences in table break normally and created this longtable (without using tabularx). It works ... okay-ish.

Here are issues I was hoping to get some help with:

  • The month numbers in the first column are aligned right. I'd like them centered.
  • The words in "Column Two" are not properly aligned.
  • On the second sceen capture, there is a huge gap between the sentences in the fourth column. That's because the first sentence ("I told him, etc.") is quite short. Of course, I could fix it manually, but would there be a way to make this adjustment more automatic?

Thank you.

% PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[oneside,centered,twocolumn]{book}
%\documentclass[a4paper,oneside,centered,twocolumn]{book}
\special{papersize=215.9mm,279.4mm}
%\usepackage[top=3cm, bottom=3.2cm, left=2.5cm, right=2.5cm]{geometry}

\usepackage[english]{babel}
\usepackage{tocloft} % Customization of TOC LOF LOT
\usepackage[table,xcdraw]{xcolor} % For shading in tables
\usepackage{pdfcolmk}
\usepackage{multirow}

%\usepackage{lscape} %to put the long table of dwellings sideways
%\usepackage{wallpaper}
\usepackage{showframe}

\usepackage{textcomp}
\usepackage{pdfpages}
\usepackage{ltablex}
\usepackage{nicefrac} % to write fractions
\usepackage{attrib} % For source of quotations
\usepackage{lettrine} % For NewThought formatting
\usepackage{array} % To define width of columns in long table
\usepackage{booktabs} % Nicer spacing in columns
\usepackage{siunitx} % To write Celsius, etc.
\usepackage{enumitem} % To create item lists
\usepackage{caption} % To change way captions are labelled
\usepackage{scrextend}
\usepackage{threeparttable} % For table notes + To allow footnote material to stay with the tabular environment
\usepackage{etoolbox} % To make table footnote font smaller
\usepackage{threeparttablex}
\appto\TPTnoteSettings{\footnotesize}
\usepackage{textcomp} % For Numero symbol
\usepackage[T1]{fontenc}
\usepackage{titlesec,color}
\usepackage{blindtext}
\usepackage[linguistics,edges]{forest}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{titling}
\usepackage{fontspec}
\usepackage{newpxtext} % Font for document instead of obsolete Palatino

\usepackage{hyperref} % Hyperlinks

\begin{document}

{\small
    \onecolumn\begin{longtable}
        {
            >{\raggedright\arraybackslash}p{1.2cm}
            >{\raggedright\arraybackslash}p{4.5cm}
            >{\raggedright\arraybackslash}p{2cm}
            >{\raggedright\arraybackslash}p{7.15cm}
        }

        \caption{This is a test.}\label{test} \\
        \toprule
        Month number & Months in the languages of the Five Empires & Date of the month & Deity or group celebrating the event, location, name of the
        celebration, and notes \\
        \midrule
        \endfirsthead

        \caption*{\autoref{test} (\textit{Continued})} \\
        \toprule
        Month & Months in the languages of the Five Empires & Date & Events \\
        \midrule    
        \endhead

        1 &\begin{tabular}[t]{l}
            French: Bonjour\\
            German: Hallo\\
            French: Bonjour\\
            German: Hallo\\
            \end{tabular}
        & 1st & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        & \begin{tabular}[t]{l}
            French: Bonjour\
            \end{tabular}
        & '' & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && '' & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && 15th-16th & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && 23rd & But no more of this blubbering now, we are going a-whaling, and there is plenty of that yet to come. Let us scrape the ice from our frosted feet, and see what sort of a place this Spouter may be. \\

        2 &\begin{tabular}[t]{l}
            French: Bonjour\\
            German: Hallo\\
            French: Bonjour\\
            German: Hallo\\
            German: Hallo\\
        \end{tabular} & 2nd & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && '' & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && 23rd & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && 28th & But no more of this blubbering now, we are going a-whaling, and there is plenty of that yet to come. Let us scrape the ice from our frosted feet, and see what sort of a place this Spouter may be. \\

        3 &\begin{tabular}[t]{l}
            French: Bonjour\\
            German: Hallo\\
            French: Bonjour\\
            German: Hallo\\
            German: Hallo\\
        \end{tabular} & 4th & I told him that I never liked to sleep two in a bed; \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && '' & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && 7th & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && 31st & But no more of this blubbering now, we are going a-whaling, and there is plenty of that yet to come. Let us scrape the ice from our frosted feet, and see what sort of a place this Spouter may be. \\
        \bottomrule

        %   \insertTableNotes

    \end{longtable}\twocolumn
}
%\end{ThreePartTable}

\end{document}

enter image description here enter image description here

  • If the header of the first olumn should also be centered, use >{\centering\arraybackslash}p{1.2cm} instead of >{\raggedright\arraybackslash}p{1.2cm} – leandriis Apr 6 at 17:30
  • Perhaps you may use a \multirowcommancd to have the fore lines span two or three rows. – Sveinung Apr 6 at 17:38
  • 1
    you have loaded fontspec so must be using luatex or xetex, in which case do not load 8bit fonts with \usepackage[T1]{fontenc} and \usepackage{newpxtext} – David Carlisle Apr 6 at 17:40
1

In the following MWE, I have replaced >{\raggedright\arraybackslash}p{1.2cm} by >{\centering\arraybackslash}p{1.2cm} inorder to solve the first issue. In order to remove the second and third issue, I have used \multirow.

\documentclass[oneside,twocolumn]{book}

\special{papersize=215.9mm,279.4mm}
\usepackage[top=3cm, bottom=3.2cm, left=2.5cm, right=2.5cm]{geometry}

\usepackage{showframe}
\usepackage{ltablex}
\usepackage{array} 
\usepackage{booktabs}
\usepackage{hyperref} 
\usepackage{multirow}

\begin{document}

{\small
    \onecolumn\begin{longtable}
        {
            >{\centering\arraybackslash}p{1.2cm}
            >{\raggedright\arraybackslash}p{4.5cm}
            >{\raggedright\arraybackslash}p{2cm}
            >{\raggedright\arraybackslash}p{7.1cm}
        }

        \caption{This is a test.}\label{test} \\
        \toprule
        Month number & Months in the languages of the Five Empires & Date of the month & Deity or group celebrating the event, location, name of the
        celebration, and notes \\
        \midrule
        \endfirsthead

        \caption*{\autoref{test} (\textit{Continued})} \\
        \toprule
        Month & Months in the languages of the Five Empires & Date & Events \\
        \midrule    
        \endhead

        1 &\multirow{5}{=}{%
            French: Bonjour\\
            German: Hallo\\
            French: Bonjour\\
            German: Hallo\\
            French: Bonjour
            }
        & 1st & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        & & '' & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && '' & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && 15th-16th & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && 23rd & But no more of this blubbering now, we are going a-whaling, and there is plenty of that yet to come. Let us scrape the ice from our frosted feet, and see what sort of a place this Spouter may be. \\

        2 &\multirow{5}{=}{%
            French: Bonjour\\
            German: Hallo\\
            French: Bonjour\\
            German: Hallo\\
            German: Hallo\\
        } & 2nd & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && '' & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && 23rd & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && 28th & But no more of this blubbering now, we are going a-whaling, and there is plenty of that yet to come. Let us scrape the ice from our frosted feet, and see what sort of a place this Spouter may be. \\

        3 &\multirow{5}{=}{%
            French: Bonjour\\
            German: Hallo\\
            French: Bonjour\\
            German: Hallo\\
            German: Hallo\\
        } & 4th & I told him that I never liked to sleep two in a bed; \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && '' & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && '' & Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. \\
        && 7th & What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? \\
        && 31st & But no more of this blubbering now, we are going a-whaling, and there is plenty of that yet to come. Let us scrape the ice from our frosted feet, and see what sort of a place this Spouter may be. \\
        \bottomrule


    \end{longtable}\twocolumn
}


\end{document}
  • That works beautifully. The multirow x 5 thing works super well. Thank you. – CyanideBaby Apr 7 at 7:46

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.