1

I'm working on a CV and decided to use a longtable to set everything so it can span multiple pages easily. Overall, I like the look of what I've arrived at, but there are a couple issues with padding that I'd like to fix:

  • My pseudo-subheading lines (made using a nested tabular*) do not quite extend to the far right of the longtable column, though they do appear to start at the correct position on the left. I believe this corresponds to the first of two warnings I get about an underfull \hbox. (You can see the text doesn't go quite as far right as the text on the following line does.)
  • There is leading and trailing vertical whitespace around the nested itemize, even though I am using the nosep option from enumitem.
  • There is a little extra vertical space after the longtable environment ends.
  • There is a warning issued about an underfull \hbox in alignment for the whole longtable. I don't think I've seen this issue with alignment before, so I'm not sure how to go about fixing this or even identifying what specifically is causing it.

Here's the output of my MWE (red are annotations added by me, not part of output):

Annotated image of minimum working example.

And my MWE is:

\documentclass{article}

\usepackage{array}
\usepackage{enumitem}
\usepackage[T1]{fontenc}
\usepackage[margin=0.5in]{geometry}
\usepackage{longtable}
\usepackage{microtype}
\usepackage{ragged2e}

% No indentation.
\setlength{\parindent}{0pt}

% Adjust longtable padding.
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\LTpre{2pt}  % A little pre-padding to look like a regular line.
\setlength\LTpost{0pt}

% Adjust itemize environments.
\setlist[itemize]{nosep,left=0pt,label=\raisebox{0.5ex}{\tiny$\bullet$}}

\begin{document}

Some text before the table.

% Without the minipage, there's extra space at the bottom of the table.
\begin{longtable}
  { @{} >{\RaggedLeft\arraybackslash}p{1in} @{\extracolsep{0.25in}} p{6.25in} @{} }% LINE 29
  & \begin{tabular*}{\hsize}{@{} l @{\extracolsep{\fill}} r @{}}% LINE 30
      Pseudo-Subheading & Other content
    \end{tabular*} \\
  Left text 1 & Very lengthy text content goes here, which (with enough words
                written) ought to span past the end of the line sufficiently to
                do some things. \\
  Left text 2 & %
                \begin{itemize}[after=\strut]
                \item Bullet point 1.
                \item Bullet point 2.
                \end{itemize} \\
  Left text 3 & Some regular text, just for effect.
\end{longtable} % LINE 42

Some text after the table.

\end{document}

There are two warnings given:

Underfull \hbox (badness 4713) in paragraph at lines 30--30
 []||

Underfull \hbox (badness 10000) in alignment at lines 29--42
[] []

Maybe there's also a way to simplify my code, but I am not a LaTeX expert by any means. I've arrived at this solution after solving various problems along the way. The goal is to have two fixed columns of specified widths with a quarter-inch gap between them, where the left column is right-aligned and the right column is left-aligned, and to be able to sometimes have that right-hand column split into sub-columns for sub-headings, and also to be able to embed itemize environments without leading or trailing whitespace and no indentation.

2
  • 1
    you have the table inside a vbox inside a minipage both will prevent any page breaking so there is no point in using longtable here just use a tabular, (I don't think the setbox/usebox is doing anthing either. Oct 17, 2021 at 20:52
  • @DavidCarlisle I see your point — I didn't realize they would have that effect. I've removed the minipages and vbox. (I believe they were originally added because I wanted to wrap some frames around some boxes to see how far the alignment was off.) Removing these has further impacted other elements of the vertical whitespace, though. Oct 17, 2021 at 21:30

2 Answers 2

3

With some simplifications of your code, shown with (a) longtable, (b) using tabular and with (c) tabularx the extra spaces and misalignment (and bad boxes) are gone.

With tabularx the width of the second column is calculated automatically.

c

\documentclass{article}

\usepackage{array}
\usepackage{enumitem}% Not used here
\usepackage{fontspec}
\usepackage[margin=0.5in]{geometry}
\usepackage{longtable}
\usepackage{microtype}
\usepackage{ragged2e}   % Not used here

\usepackage{tabularx}% added <<<<<<<

\usepackage{showframe} % show the margins <<<<<<<<<<<<<<<<<<
\renewcommand*\ShowFrameColor{\color{red}}

% No indentation.
\setlength{\parindent}{0pt}
    
\newcommand{\markitem}{\raisebox{0.4ex}{\footnotesize\textbullet}~} % added <<<<<<<<<<<<<<

% Adjust longtable padding.
\setlength\LTleft{0pt}
%\setlength\LTright{0pt} % <<<<<<<<<
\setlength\LTpre{2pt}  % A little pre-padding to look like a regular line.
\setlength\LTpost{-2pt} % changed <<<<<<<<<<<<<<<<<<<<

\setlength{\tabcolsep}{0pt} % added <<<<<<<<<<<<<<<<<

\begin{document}
    
Some text before the \textbf{longtable.}

\begin{longtable}{p{1in} @{\extracolsep{0.25in}} p{6.25in}}% LINE 29
                        & \multicolumn{1}{c}{Pseudo-Subheading \hfill Other content} \\
    Left text 1         & Very lengthy text content goes here, which (with enough words
    written) ought to span past the end of the line sufficiently to
    do some things. \\
    Left text 2         & \markitem Bullet point 1. \\
                        & \markitem Bullet point 2. \\
    Left text 3         & Some regular text, just for effect.
\end{longtable} % LINE 42

Some text after the longtable.

\bigskip

Some text before the \textbf{tabular.}  

    \begin{tabular}{p{1in} @{\extracolsep{0.25in}}   p{6.25in}}% LINE 29        
                        & \multicolumn{1}{c}{Pseudo-Subheading \hfill Other content} \\
    Left text 1         & Very lengthy text content goes here, which (with enough words written) ought to span past the end of the line sufficiently to do some things. \\
    Left text 2         & \markitem Bullet point 1. \\
                        & \markitem Bullet point 2. \\
    Left text 3         & Some regular text, just for effect.
\end{tabular} % LINE 42

Some text after the tabular.    

\bigskip

Some text before the \textbf{tabularx}

\begin{tabularx}{\textwidth}{p{1in} @{\extracolsep{0.25in}} X}% LINE 29
                        & \multicolumn{1}{c}{Pseudo-Subheading \hfill Other content} \\
    Left text 1         & Very lengthy text content goes here, which (with enough words
    written) ought to span past the end of the line sufficiently to
    do some things. \\
    Left text 2         & \markitem Bullet point 1. \\
                        & \markitem Bullet point 2. \\
    Left text 3         & Some regular text, just for effect.
\end{tabularx} % LINE 42

Some text after the tabularx.   
    
\end{document}
2
  • This is perfect. Thank you so much for such a thorough solution with all three methods! Am I right in thinking that if I want the table to easily span multiple pages, I should just stick with the longtable? Also, did you disable \LTright because it's automatically handled by specifying the width of the columns? Oct 18, 2021 at 23:20
  • 1
    @Pierce Darragh To the first, yes. \LTright is irrelevant because you are using exactly the full width of the textarea = 7.5 in = 1 + 0.25 + 6.25 in but it gives an underfull warning, perhaps due to ?. The warning disappears with \setlength\LTright{0.01pt} !! Oct 19, 2021 at 13:34
1

Edit: By use of enumitem, etoolbox and tabularray packages. With enumitem and etoolbox are defined stile of list itemize inside of tblr table, so you table body code you can still use of itemize list.

In the case that your table can be fit in one page, than you can replace all longtblr in MWE with talltblr and table insert in table float. .

\documentclass{article}
\usepackage[margin=0.5in]{geometry}
%\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{tabularray}     % version 2021P
\UseTblrLibrary{varwidth}   % <===
\NewTblrTheme{fancy}{
\SetTblrStyle{head}{font=\small}
\SetTblrStyle{foot}{\small\itshape}
\SetTblrStyle{caption-tag}{font=\small\bfseries}
                    }
\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{longtblr}{%
\setlist[itemize]{nosep,
                  itemsep=0.5ex,
                  leftmargin=*,
                  after=\end{minipage},                  % <---
                  before=\begin{minipage}[t]{\linewidth} % <---
                  }
                        }
\setlength{\parindent}{0pt}
\usepackage{lipsum}

\begin{document}
\lipsum[1]
\begingroup
\begin{longtblr}[
    theme = fancy,
  caption = {The Long Table Caption},
    label = {tab:longtblr},
                ]{colspec={@{} l X[j] @{}},
                  row{1} = {font=\bfseries},
                  rowhead=1,
                  measure = vbox,            % <===
                  }
            &   Pseudo-Subheading\hfill  Other content  \\
Left text 1 &   Very lengthy text content goes here, which (with enough words
                written) ought to span past the end of the line sufficiently to
                do some things. \\
Left text 2 &   \begin{itemize}
            \item Bullet point 1.
            \item Bullet point 2.
                \end{itemize}   \\
Left text 3 &   Some regular text, just for effect.
    \end{longtblr}\vspace{-\baselineskip}
\endgroup
\lipsum[2]
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .