1

I have a two column layout using tabular (each has a different width). I want a to be able to skip lines within each of the columns using \\. In order to make this possible I used a nested tabular. The nested tabular has only one column allowing me to go to the next line using \\. I want to be able to add lists to each column. I made a new command to do this (\tablelist). The problem is that I get the warning \hbox undefull badness (10000).

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{calc}
\usepackage[left=1in, right=1in, top=0.5in, bottom=0.5in]{geometry}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Formatting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% defines big (B) and small (S) columns
\newcolumntype{B}{p{0.8\textwidth-2\tabcolsep-1.25\arrayrulewidth}}
\newcolumntype{S}{p{0.2\textwidth-2\tabcolsep-1.25\arrayrulewidth}}
% defines big (b) and small (s) sub-columns in order to 
% use line breaks within tabular of single column 
% within outer 2 column tabular
\newcolumntype{s}{p{0.2\textwidth-4\tabcolsep}}
\newcolumntype{b}{p{0.8\textwidth-4\tabcolsep}}

% commands for headers and sub-headers in document style
% usage: \header{...} ; \subheader{...}
\newcommand*{\header}[1]{\textbf{\Large#1}\vspace{0.5em}\hrule\vspace{0.5em}}
\newcommand*{\subheader}[1]{\textbf{\large#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem is with this command 
% Usage is \tablelist{<column type>}{<title>}{<list contents>}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand*{\tablelist}[3]{
    \noindent
    \begin{tabular}{#1}
    \subheader{#2} \\
    #3
    \end{tabular}
    }

\begin{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 2-Column Environment Begins
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\noindent
\begin{tabular}{S|B}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Left-Column Environment
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\header{Header1}
\tablelist{s}{List}{item 1\\ item 2\\} % warning appears here
\tablelist{s}{List}{item 1\\ item 2\\}

&
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Right-Column Environment
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\header{Header2}
\tablelist{b}{List}{item 1\\ item 2\\} % no warning here when above is commented out
\tablelist{b}{List}{item 1\\ item 2\\}
\end{tabular}

\end{document}

Note: I thought it might have been because I was trimming too much off with the -4\tabcolsep although changing this results in the hbox being both overfull and underfull at the same time

Jan
  • 5,293
  • You can use an itemize environment in any tabular column, which is able to wrap lines, as the p, m and b-columns. So, without any great changes on your side, there is already the possibility to create more than one line in a tabular. You can use \newline in a cell to wrap the line, without beginning a new table row. Have you read http://tex.stackexchange.com/questions/78796/difference-between-and-tabularnewline ? – Jan Dec 30 '16 at 02:25
  • Thanks @Jan, \newline works great. Ideally I wanted the input to the list command to look like item 1\\ item 2\\ and not item1 \newline item2 \newline although its not that a big deal. Thing is, I still have the \hbox undefull error (even just using \newline and no nested table - note that this only occurs when placed in the command). Btw, I would like to stay away from using itemize because I need to use these columns for more than just lists later and also don't want to have to change the itemize formatting to clean up the bullets and reduce the spacing. – Stephan GM Dec 30 '16 at 02:49
  • fine. :-) I still haven't understood, why you are nesting a single column tabular in you tabular. Normally underfull hboxes arouse, when LaTeX was not able to do the justification. Maybe you should define your new column types S, B, s and b with something like >{\raggedright}. That may help. Just a guess. – Jan Dec 30 '16 at 02:56
  • \raggedright worked, warning is gone! If you want to put it as an answer I'll be glad to accept :) – Stephan GM Dec 30 '16 at 02:58

1 Answers1

2

Normally underfull hboxes arise when LaTeX is not able to do the justification. Maybe you should define your new column types S, B, s and b with something like >{\raggedright}

\newcolumntype{B}{>{\raggedright\arraybackslash}p{0.8\textwidth-2\tabcolsep-1.25\arrayrulewidth}}
egreg
  • 1,121,712
Jan
  • 5,293