嵌套表格中的 \hbox 底部填充

嵌套表格中的 \hbox 底部填充

我有一个使用表格的两列布局(每列的宽度不同)。我希望能够使用跳过每列中的行\\。为了实现这一点,我使用了嵌套表格。嵌套表格只有一列,允许我使用转到下一行\\。我希望能够向每列添加列表。我创建了一个新命令来执行此操作(\tablelist)。问题是我收到了警告\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}

笔记:我认为这可能是因为我修剪了太多,-4\tabcolsep但改变这个结果会导致hbox同时过满和不足

答案1

通常,当 LaTeX 无法进行对齐时,就会出现水平盒子未满的情况。也许你应该定义新的列类型S、和B,例如sb>{\raggedright}

\newcolumntype{B}{>{\raggedright\arraybackslash}p{0.8\textwidth-2\tabcolsep-1.25\arrayrulewidth}}

相关内容