1

I'd like to have a table, at the end of the page, centered, with the total width of the paragraph and each of its 3 columns exactly a third of the width.

Here is what I have so far:

\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

You could use tabularx for that (equal column widths):

\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}
1

It's easy with 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}

Note that the syntax for table doesn't require braces around the contents (they're actually wrong).

1
  • Just to mention it: w is relatively new (2018) and does actually resemble the OP better than the X column because it does not act as a parbox. – TeXnician Sep 27 '18 at 10:24
0

if you like to use tabu (not recommended, better is use tabularx as TeXnician suggested in his answer) than you should use X column types:

\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}

this gives:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.