General ⇒ Problem with tabular, left-align and widths
-
- Posts: 6
- Joined: Thu May 29, 2008 9:45 am
Problem with tabular, left-align and widths
Dear all,
I would like to use tabular environment. But I don't like justified-text in columns by using like as follows:
\begin{tabular}{p{0.18\linewidth} p{0.38\linewidth} p{0.38\linewidth}}
...
\end{tabular}
So, the code should be:
\begin{tabular}{l{0.18\linewidth} l{0.38\linewidth} l{0.38\linewidth}}
...
\end{tabular}
(l here is l in letter not 1-one, not slash)
But I got the error:
! LaTeX Error: Illegal character in array arg.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.4 ...th} l{0.38\linewidth} l{0.38\linewidth}@{}}
Could any one help me to solve this problem?
Thanks,
I would like to use tabular environment. But I don't like justified-text in columns by using like as follows:
\begin{tabular}{p{0.18\linewidth} p{0.38\linewidth} p{0.38\linewidth}}
...
\end{tabular}
So, the code should be:
\begin{tabular}{l{0.18\linewidth} l{0.38\linewidth} l{0.38\linewidth}}
...
\end{tabular}
(l here is l in letter not 1-one, not slash)
But I got the error:
! LaTeX Error: Illegal character in array arg.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.4 ...th} l{0.38\linewidth} l{0.38\linewidth}@{}}
Could any one help me to solve this problem?
Thanks,
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Problem with tabular, left-align and widths
I'm not sure if I understood you right. So I worked out an example that shows whether I did.
There may be some warning because of filling the lines in the single columns. You can see the resulting document in the attachment.
Best regards
Thorsten
Code: Select all
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage[bindingoffset=1cm,centering,includeheadfoot,margin=2cm]{geometry}
\usepackage{array}
\usepackage{txfonts} % Postscript font package (Times style)
\begin{document}
\begin{centering}
\begin{tabular}{>{\raggedright}p{0.18\linewidth}>{\raggedright}p{0.38\linewidth}>{\raggedright}p{0.38\linewidth}}
The quick brown fox jumps over the lazy dog &
The quick brown fox jumps over the lazy dog &
The quick brown fox jumps over the lazy dog
\end{tabular}
\end{centering}
\end{document}
Best regards
Thorsten
- Attachments
-
- olatex_77411.pdf
- A tabular with left aligned columns and line break.
- (12.75 KiB) Downloaded 1513 times
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Problem with tabular, left-align and widths
Try replacing, e.g., p{0.18\linewidth} with >{\raggedright}p{0.18\linewidth} in the preamble of your tabular environment. This requires loading the array package.
You even can define a new column type:
\newcolumntype{P}[1]{>{\raggedright}p{#1\linewidth}} and write \begin{tabular}[P{0.18}P{0.38}P{0.38}}
B.A.
You even can define a new column type:
\newcolumntype{P}[1]{>{\raggedright}p{#1\linewidth}} and write \begin{tabular}[P{0.18}P{0.38}P{0.38}}
B.A.
-
- Posts: 6
- Joined: Thu May 29, 2008 9:45 am
Re: Problem with tabular, left-align and widths
Thank your for your quick response.
Your code works with only one row. When I add one more row like below:
\begin{tabular}{>{\raggedright}p{0.18\linewidth}>{\raggedright}p{0.38\linewidth}>{\raggedright}p{0.38\linewidth}}
The quick brown fox jumps over the lazy dog &
The quick brown fox jumps over the lazy dog &
The quick brown fox jumps over the lazy dog\\
The quick brown fox jumps over the lazy dog &
The quick brown fox jumps over the lazy dog &
The quick brown fox jumps over the lazy dog
\end{tabular}
the the error is:
! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate
l.16 ... quick brown fox jumps over the lazy dog &
Any ideas?
Thanks,
Your code works with only one row. When I add one more row like below:
\begin{tabular}{>{\raggedright}p{0.18\linewidth}>{\raggedright}p{0.38\linewidth}>{\raggedright}p{0.38\linewidth}}
The quick brown fox jumps over the lazy dog &
The quick brown fox jumps over the lazy dog &
The quick brown fox jumps over the lazy dog\\
The quick brown fox jumps over the lazy dog &
The quick brown fox jumps over the lazy dog &
The quick brown fox jumps over the lazy dog
\end{tabular}
the the error is:
! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate
l.16 ... quick brown fox jumps over the lazy dog &
Any ideas?
Thanks,
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Problem with tabular, left-align and widths
Replace \\ by \tabularnewline. The ragged2e package (part of the ms bundle) offers more capability. You then could replace \raggedright by \Raggedright and keep the \\ for the new tabular line.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
- Stefan Kottwitz
- Site Admin
- Posts: 10340
- Joined: Mon Mar 10, 2008 9:44 pm
Problem with tabular, left-align and widths
Hi mayngontay,
the code above working if you insert \arraybackslash:
Stefan
the code above working if you insert \arraybackslash:
Code: Select all
\begin{tabular}{>{\raggedright}p{0.18\linewidth}>{\raggedright}p{0.38\linewidth}>{\raggedright\arraybackslash}p{0.38\linewidth}}
LaTeX.org admin
Problem with tabular, left-align and widths
Hi there,
I am also not sure that I understood you correcly, but i think that what bothers you is the fact that you cannot simulatiously set the width and the justification of a column in a table. I had a similar problem in the past. The most reasonable solution I found to it was the tabularx package. In this package you fix the whole width of a table and than you either specify for a column to be l(left), c(entered), r(ight) or you just write X. The width of the colums, that have the X specification will be determined automatically and will depend on the whole width of the table. However, you can also specify the justification of these columns by using the following command: (choose between \reggedright, \reggedleft or \centering).
I have attached the documentation of the package, you can download the package from ctan.
I am also not sure that I understood you correcly, but i think that what bothers you is the fact that you cannot simulatiously set the width and the justification of a column in a table. I had a similar problem in the past. The most reasonable solution I found to it was the tabularx package. In this package you fix the whole width of a table and than you either specify for a column to be l(left), c(entered), r(ight) or you just write X. The width of the colums, that have the X specification will be determined automatically and will depend on the whole width of the table. However, you can also specify the justification of these columns by using the following command:
Code: Select all
>{\raggedright\arraybackslash}X
I have attached the documentation of the package, you can download the package from ctan.
- Attachments
-
- tabularx.pdf
- The documentation to the tabularx package.
- (179.06 KiB) Downloaded 1019 times
-
- Posts: 6
- Joined: Thu May 29, 2008 9:45 am
Problem with tabular, left-align and widths
Dear all,
The problem has been solved from the fifth post by localghost.
I know that there are other options proposed by balf, Stefan_K, and avp3000 to solve this issue.
Thank you (localghost, balf, Stefan_K, and avp3000) very much.
What you gave me is beyond what I expected.
Regards,
The problem has been solved from the fifth post by localghost.
I know that there are other options proposed by balf, Stefan_K, and avp3000 to solve this issue.
Thank you (localghost, balf, Stefan_K, and avp3000) very much.
What you gave me is beyond what I expected.

Regards,