2

I want to create a table with 100% width? The first two columns should have a minimum width and the last column should have the rest width. The text in the last column (except the first cell) should be left aligned.

\documentclass[draft=on]{scrbook}
\usepackage{blindtext}
\usepackage{tabularx}

\begin{document}
\begin{tabularx}{\textwidth}{ccX}
  A & B & \multicolumn{1}{c}{C} \\
  A & B & \blindtext
\end{tabularx}
\end{document}
  • Your description mentions 3 columns; your code shows 5. Am I missing something? – Gonzalo Medina Aug 14 '13 at 3:17
3

I wasn't sure about the "minimum width" column specification. Two possible options: the first one has two c type columns and an X column; the second one has two p{...} columns with centered content and an X column. Both tabularxs span the whole \textwidth (notice \noindent):

\documentclass{article}
\usepackage{showframe}
\usepackage{blindtext}
\usepackage{tabularx}

\newcolumntype{C}[1]{>{\centering}p{#1}}

\begin{document}
\noindent\frame{\begin{tabularx}{\textwidth}{cc>{\raggedright\arraybackslash}X}
  A & B & \multicolumn{1}{c}{C} \\
  A & B & \blindtext
\end{tabularx}}

\noindent\frame{\begin{tabularx}{\textwidth}{C{2cm}C{3cm}>{\raggedright\arraybackslash}X}
  A & B & \multicolumn{1}{c}{C} \\
  A & B & \blindtext
\end{tabularx}}

\end{document}

enter image description here

I added the showframe package and a frame around each table (using \frame) as visual guidelines. You can safely delete those in your code.

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.