我正在使用p{}
格式来调整表格的宽度。
我期望使用{p{0.1\textwidth}||p{0.2\textwidth}|p{0.2\textwidth}|p{0.2\textwidth}|p{0.2\textwidth}}
会使表格宽度小于文本宽度(1 > 0.1 + 0.2*4),但结果不是我期望的。
可能出了什么问题?为什么表格的总宽度比文本宽度宽?
这是代码。
\documentclass[oneside, openany, 10pt]{article}
%\documentclass[article, oneside, openany, 10pt]{memoir}
\newcommand{\HRule}{\rule{1.0\textwidth}{0.5mm}}
\newcommand{\Hrule}{\rule{1.0\textwidth}{0.3mm}}
\makeatletter% since there's an at-sign (@) in the command name
\renewcommand{\@maketitle}{%
\parindent=0pt% don't indent paragraphs in the title block
\centering
{\Large \bfseries\textsc{\@title}}
\HRule\par%
\textit{\@author \hfill \@date}
\par
}
\author{prosseek}
\title{test}
\begin{document}
\maketitle
\begin{table}[hbtp]
\footnotesize
\centering
\begin{tabular}{p{0.1\textwidth}||p{0.2\textwidth}|p{0.2\textwidth}|p{0.2\textwidth}|p{0.2\textwidth}}
\hline
& Function & Pre conditions & Post conditions & Constraints \\
\hline\hline
R1 & An election official is assigned for each precinct & Precincts and
elections officials are created & Unique one on one mapping from an
election official to precinct & Before voting starts\\ \hline
\end{tabular}
\caption{Requirements before voting starts}
\label{eoRequirements}
\end{table}
\end{document}
答案1
有了马里奥的提示,我可以使用表格得到这个结果。
\maketitle
\begin{table}[hbtp]
\footnotesize
\centering
\begin{tabulary}{1.0\textwidth}{C||L|L|L|L}
\hline
& Function & Pre conditions & Post conditions & Constraints \\
\hline\hline
R1 & An election official is assigned for each precinct & Precincts and
elections officials are created & Unique one on one mapping from an
election official to precinct & Before voting starts\\ \hline
\end{tabulary}
\caption{Requirements before voting starts}
\label{eoRequirements}
\end{table}