我希望在页面末尾有一个居中放置的表格,其总宽度为段落宽度,并且其 3 列中的每一列的宽度都恰好是该段落宽度的三分之一。
以下是我目前所掌握的信息:
\documentclass[a4paper,twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[portuguese]{babel}
\title{Title}
\usepackage{tabu}
\usepackage{lipsum}
\begin{document}
\lipsum[1-4]
\hfill
\begin{table}[!b]{
\begin{tabu} to \textwidth {ccc}
\multicolumn{2}{c}{ \vspace{3ex}A } & B \\
\rule{1cm}{0.4pt} & \rule{1cm}{0.4pt} & \rule{1cm}{0.4pt} \\
\scriptsize aaa & \scriptsize bbb & \scriptsize ccc
\end{tabu}
}
\end{table}
\end{document}
答案1
您可以使用tabularx
它(相等的列宽):
\documentclass[a4paper,twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[portuguese]{babel}
\title{Title}
\usepackage{tabularx}
\usepackage{array}
\usepackage{lipsum}
\begin{document}
\lipsum[1-4]
\hfill
\begin{table}[!b]
\begin{tabularx}{\textwidth}{*3{>{\centering\arraybackslash}X}}
\multicolumn{2}{c}{\vspace{3ex}A} & B \\
\rule{1cm}{0.4pt} & \rule{1cm}{0.4pt} & \rule{1cm}{0.4pt} \\
\scriptsize aaa & \scriptsize bbb & \scriptsize ccc
\end{tabularx}
\end{table}
\end{document}
答案2
很简单,使用array
:
\documentclass[a4paper]{article}
\usepackage{array}
\begin{document}
\begin{table}[htbp]
\begin{tabular}{ *{3}{w{c}{\dimexpr0.33333\textwidth-2\tabcolsep}} }
\multicolumn{2}{c}{A} & B \\
\rule{1cm}{0.4pt} & \rule{1cm}{0.4pt} & \rule{1cm}{0.4pt} \\
\scriptsize aaa & \scriptsize bbb & \scriptsize ccc
\end{tabular}
\end{table}
\end{document}
请注意,的语法table
不需要用括号括住内容(这实际上是错误的)。
答案3
如果你喜欢使用tabu
(不推荐,最好使用tabularx
使用技术员X
在他的回答中建议)比使用列类型要好:
\documentclass[a4paper,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage[portuguese]{babel}
\title{Title}
\usepackage{tabu}
\usepackage{lipsum}
\begin{document}
\lipsum[1-4]
\begin{table}[!b]
\begin{tabu} to \textwidth {*{3}{X[c]}} % <---
\multicolumn{2}{c}{A} & B \\[3ex]
\rule{1cm}{0.4pt} & \rule{1cm}{0.4pt} & \rule{1cm}{0.4pt} \\
\scriptsize aaa & \scriptsize bbb & \scriptsize ccc
\end{tabu}
\end{table}
\end{document}
得出: