3
\documentclass{article}
\usepackage{booktabs}
\newcommand{\head}[1]{\textnormal{\textbf{#1}}}
\newcommand{\normal}[1]{\multicolumn{1}{l}{#1}}
\begin{document}
\begin{tabular}{@{}l*{2}{>{\textbackslash\ttfamily}l}l<{Example text}@{}}
  \toprule[1.5pt]
  & \multicolumn{2}{c}{\head{Input}} & \multicolumn{1}{c}{\head{Output}}\\
  & \normal{\head{Command}} & \normal{\head{Declaration}} & \normal{} \\
  \cmidrule(lr){2-3}\cmidrule(l){4-4}
  Family & textrm & rmfamily & \rmfamily\\
  & textsf & sffamily & \sffamily\\
  & texttt & ttfamily & \ttfamily\\
  \bottomrule[1.5pt]
\end{tabular}
\end{document}

The above snippet generates an error regarding

\begin{tabular}{@{}l*{2}{>{\textbackslash\ttfamily}l}l<{Example text}@{}}

And, I don't understand the error. It says "ERROR: LaTeX Error: Illegal character in array arg." What is wrong?

5

The insertion of content at the start or end of a column entry is performed by >{<start>} or <{<end>}. This functionality is supplied by the array package, which you've not included:

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage{array}
\newcommand{\head}[1]{\textnormal{\textbf{#1}}}
\newcommand{\normal}[1]{\multicolumn{1}{l}{#1}}
\begin{document}
\begin{tabular}{@{}l*{2}{>{\textbackslash\ttfamily}l}l<{Example text}@{}}
  \toprule[1.5pt]
  & \multicolumn{2}{c}{\head{Input}} & \multicolumn{1}{c}{\head{Output}}\\
  & \normal{\head{Command}} & \normal{\head{Declaration}} & \normal{} \\
  \cmidrule(lr){2-3}\cmidrule(l){4-4}
  Family & textrm & rmfamily & \rmfamily\\
  & textsf & sffamily & \sffamily\\
  & texttt & ttfamily & \ttfamily\\
  \bottomrule[1.5pt]
\end{tabular}
\end{document}
4
  • Ah, right.... How can I prevent this mistake from happening again? – crocket Dec 4 '15 at 7:16
  • 6
    @crocket: Get a tattoo that reads "Remember to include \usepackage{array}"? – Werner Dec 4 '15 at 7:17
  • You mean there is no solution in LaTeX. – crocket Dec 4 '15 at 7:17
  • @crocket: It is functionality added in addition to the default, so it is supplied as "an extension" through a package. Some packages include array by default, like \usepackage{tabularx}... Some document classes also add this functionality. As of new, there's not much more one can do than remembering it... – Werner Dec 4 '15 at 7:24

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.