For the first column, don't specify l
as the column type and then use a \parbox
(of width 3cm
) to typeset its material. Instead, use p{3cm}
directly as the column type specifier.
In view of the rather narrow measure that's set for the first column, I would use ragged-right rather than full (ie., left and right) justification.
\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{french}
\setotherlanguages{english,german,latin,italian,spanish,russian,greek}
\usepackage{tabularx}
\usepackage{ragged2e} % for "\RaggedRight" macro
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\usepackage{lipsum} % for filler text
\begin{document}
\noindent
\begin{tabularx}{\linewidth}{ @{}
>{\bfseries}P{3cm} | @{\hspace{.5em}}
X @{}}
\hline
Once upon a time, there was an enchanted castle \dots &
\lipsum*[1] \\
\hline
text & text \\
\end{tabularx}
\end{document}
Addendum to address @u2berggeist's follow-up question:
can you explain the necessity of the \arraybackslash
command in the column type definition
Let me begin with an excerpt from the user guide of the array
package:
\arraybackslash:
Restore \\
for use in array
and tabular
environment (after \raggedright
etc.).
This is admittedly rather terse. Let me attempt to provide a somewhat wordier explanation of the purpose of \arraybackslash
.
When using \newcolumntype
to define a new column type, the meaning of \\
gets changed (for reasons I admit to never having fully grasped). The upshot, though, is that \\
is no longer the macro that creates a line break; one has to use \tabularnewline
instead. The instruction \arraybackslash
simply restores the widely-expected behavior of \\
. (I don't think I've every met anyone who prefers to type \tabularnewline
over \\
...)
It is the case, in the code shown above, that there are no forced line breaks in the P
column (the first column). Hence, it was not strictly necessary to employ \arraybackslash
in the \newcolumntype
definition of P
. So why did I use \arraybackslash
anyway? I did it for two reasons.
First, it never hurts to do so -- unless one has a hankering for typing \tabularnewline
...
Second, if the P
column were used in the final column instead of in the first column, the failure to have employed \arraybackslash
in the \newcolumntype
instruction would generate some rather cryptic error messages which would certainly baffle everybody not named David Carlisle. The postings on this site often turn up in Google searches, even years after they were made. This answer, say, might turn up in a search for "latex table raggedright column". A casual reader of this answer might gladly note
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
and might even take note of the fact that it's necessary to load the ragged2e
package (as it defines \RaggedRight
). What a casual reader may well miss -- and, in fact, should be excused for having missed! -- is that in the tabularx
environment at hand, the P
column type doesn't get used in the final column. Had I posted
\newcolumntype{P}[1]{>{\RaggedRight}p{#1}}
the answer would have still "worked" for the given tabularx
environment; however, it would have needlessly risked creating huge amounts of frustration among future users who performed a web search with the terms "latex table raggedright column" and were interested in using the P
column type for the final, i.e., right-hand-most, column of their tabular
-like environment.
Did I succeed in answering your question?
Here is a solution. I redefine tabularx columns to incorporate the features of your C
column type, ans set tabularx wdth to \linewidth
:
\documentclass[a4paper]{article}
\usepackage{tabularx}
\usepackage{amssymb, amsmath, nccmath}
\renewcommand\tabularxcolumn[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
Classify the following numbers as whole, a proper fraction, an improper fraction, or a mixed number.
\begin{center}\renewcommand\arraystretch{1.25}
\begin{tabularx}{\linewidth}{|m{1.5cm}|*{11}{X|}}
\hline
Number Type & \(\mfrac{1}{3}\) & \(10\) & \(5\frac{2}{7}\) & \(\mfrac{2}{9}\) & \(\mfrac{10}{7}\) & \(2\) & \(0\) & \(1\frac{1}{2}\) & \(3\frac{4}{5}\) & \(\mfrac{8}{8}\) & \(\mfrac{3}{1}\) \\
\hline
Whole & & & & & & & & & & & \\
\hline
Proper & \checkmark & & & & & & & & & & \\
\hline
Improper & & & & & & & & & & & \\
\hline
Mixed & & & & & & & & & & & \\
\hline
\end{tabularx}
\end{center}
\end{document}
Best Answer
Don't adjust the width of the
X
-columns. Rather adjust the column that really want to be different and let theX
-columns spread out evenly to fill the remainder: