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}
1
  • Your description mentions 3 columns; your code shows 5. Am I missing something? Commented Aug 14, 2013 at 3:17

1 Answer 1

4

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .