0

The following code is working well in a specified template:

\begin{table}[htbp]
\caption{Our title here...}
\centering
\begin{tabular}{@{}p{0.20\textwidth}*{4}{L{\dimexpr0.1\textwidth-2\tabcolsep\relax}}@{}}
\toprule
& \multicolumn{4}{c}{Project} \\
\cmidrule(l){2-5}
Metric & 1 & 2 & 3 & 4\\
\midrule
             XXXXXXXXX & No & No & Yes & No \\
             YYYYY YYYYYYYYY & Yes & No & Yes & No \\
             ZZZZZZZZZZZZZ & Yes & Yes & Yes & Yes \\
             TTTTTT TTTTT TTT & Yes & No & Yes & Yes \\
             MMMMMMMMMMMMMMMMM MMMM MMM & Yes & Yes & Yes & Yes \\
             SSSSSSSSSSSSSSS & Yes & No & No & Yes \\
             DDDDDDDDDDDDDD & Yes & Yes & No & Yes \\
             PPPPPPPPPP PPPPPP & No & No & Yes & No \\
\bottomrule
\end{tabular}
\label{tab:labelx}
\end{table}

When I put it in another template, I am getting the following error:

LaTeX Error: Illegal character in array arg.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.472 ...expr0.1\textwidth-2\tabcolsep\relax}}@{}}

? 
! Emergency stop.
 ...

Does anyone know why? I already tried some simple suggestions mentioned in similar questions here in StackOverflow. I am using Overleaf.

This is the preamble:

\NeedsTeXFormat{LaTeX2e}

% The following saves the original definitions of \geq and \leq (guide only).
\let\realgeq\geq
\let\realleq\leq

\documentclass{fac}
\usepackage{amssymb}
%\usepackage{tabularx}
%\usepackage{xcolor}
%\usepackage{array}
%\usepackage{booktabs}
%\usepackage[margin=1in]{geometry}
%\usepackage{array}
\usepackage{algorithmic}
\usepackage{algorithm2e}
\usepackage[utf8]{inputenc}
%\usepackage{natbib}

%\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\usepackage{graphicx}

\ifprodtf \else \usepackage{latexsym}\fi
6
  • 2
    How is the L column type defined? – Mico Nov 8 '19 at 12:56
  • Als, why not use 5 simple l type columns in your table? As far as I can see, there is no need to allow linebreaks since the entries are quite short. – leandriis Nov 8 '19 at 12:58
  • Hello there! This is Tom from the Overleaf Support Team. Please note that I removed the overleaf overleaf tag as this is not directly overleaf-related. To your problem: as others indicated, capital L in tabular specification is a user-defined, or possibly, class-defined thing. It seems that one your template defines it and another one does not. – yo' Nov 8 '19 at 12:59
  • @Mico , the style, in which the code works, is ws-ijseke. The style that is not working is fac. – Dalton Cézane Nov 8 '19 at 13:43
  • 1
    @DaltonCézane then please post a full (but minimal example), we cannot see what preamble, documentclass etc you are using so we cannot help you other in very general terms. – daleif Nov 8 '19 at 14:54
1

Neither ws-ijseke.cls nor fac.cls define a column type called L. Presumably, you had \usepackage{array} \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}} in the code that works and there two lines are now missing in the nor working code.

Adding the two lines, your code also works usinf fac.cls. Note that however, due to the choice of placeholders in the first column, there is an overlap of the contents of the first and second column. Also, why not simply use regular l type columns. The entries are not that long, so linebreaks are not necessary to make the table fit into the textwidth. If your first column happens to contain longer entries, you might consider using the tabularx package.

\documentclass{fac}
\usepackage{booktabs}

\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\begin{document}

\begin{table}
\caption{Our title here...}
\centering
\begin{tabular}{@{}p{0.20\textwidth}*{4}{L{\dimexpr0.1\textwidth-2\tabcolsep\relax}}@{}}
\toprule
& \multicolumn{4}{c}{Project} \\
\cmidrule(l){2-5}
Metric & 1 & 2 & 3 & 4\\
\midrule
             XXXXXXXXX & No & No & Yes & No \\
             YYYYY YYYYYYYYY & Yes & No & Yes & No \\
             ZZZZZZZZZZZZZ & Yes & Yes & Yes & Yes \\
             TTTTTT TTTTT TTT & Yes & No & Yes & Yes \\
             MMMMMMMMMMMMMMMMM MMMM MMM & Yes & Yes & Yes & Yes \\
             SSSSSSSSSSSSSSS & Yes & No & No & Yes \\
             DDDDDDDDDDDDDD & Yes & Yes & No & Yes \\
             PPPPPPPPPP PPPPPP & No & No & Yes & No \\
\bottomrule
\end{tabular}
\label{tab:labelx}
\end{table}

\begin{table}
\caption{Our title here...}
\centering
\begin{tabular}{@{}*{5}{l}@{}}
\toprule
& \multicolumn{4}{c}{Project} \\
\cmidrule(l){2-5}
Metric & 1 & 2 & 3 & 4\\
\midrule
             XXXXXXXXX & No & No & Yes & No \\
             YYYYY YYYYYYYYY & Yes & No & Yes & No \\
             ZZZZZZZZZZZZZ & Yes & Yes & Yes & Yes \\
             TTTTTT TTTTT TTT & Yes & No & Yes & Yes \\
             MMMMMMMMMMMMMMMMM MMMM MMM & Yes & Yes & Yes & Yes \\
             SSSSSSSSSSSSSSS & Yes & No & No & Yes \\
             DDDDDDDDDDDDDD & Yes & Yes & No & Yes \\
             PPPPPPPPPP PPPPPP & No & No & Yes & No \\
\bottomrule
\end{tabular}
\label{tab:labelx}
\end{table}

\end{document}

enter image description here

1
  • Thank you very much for your answer. When I add the array package, I receive the following error before \maketitle: Missing # inserted in alignment preamble.. – Dalton Cézane Nov 8 '19 at 18:59

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.