I have a created a command with an option, such as (just an example):


I want to apply this format to a full column in a tabular environment. With a simple color format I would usually do as follow :


How can I do something similar with my "form" command. I tried the following codes without any results:

\begin{tabular}{|>{\form{}}c|c|}   %compiles with no changes
\begin{tabular}{|>{\form}c|c|}     %compiles with no changes
\begin{tabular}{|>{\form{#1}}c|c|} %does not compile


  • Would it help if you define a new column type like \usepackage{array} \newcolumntype{C}{>{\color{red}\itshape}c} and use C instead of c in your table? – Arash Esbati Mar 8 '18 at 9:39

In this particular case, >{\color{red}\itshape}c is sufficient, but for more general situations you can use collcell:




  >{\collectcell\form}c<{\endcollectcell} % red italic
  >{\color{red}\itshape}c % red italic as well
abc & defghi \\
defghi & abc


enter image description here

  • @Mico , thanks to both of you, it works perfectly using the collectcell call. My actual form command is much more complex, that's why i need a command with an argument. Cheers. – Thomas Lesgourgues Mar 12 '18 at 10:09

The expression \begin{tabular}{|>{\form{#1}}c|c|} can't work because LaTeX is expecting not a formal argument ("#1") but a specific argument, say, "blurb". For instance, \begin{tabular}{|>{\form{blurb}}c|c|} works fine.

A full MWE (minimum working example):


aaa & bbb \\
ccc & ddd

Every cell in the first column of the table will receive the prefix "blurb", in blue and italics.

If, however, the objective is to make all cells in the first column blue and italic, it suffices to define \form as follows:


and to start the tabular environment as follows: \begin{tabular}{|>{\form}c|c|}.

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.