# How to italicise multiple words but not the commas between them?

For example, I have this sentence:

GeneA, GeneB, and GeneC have been found to have a role in RNA metabolism.

This is what I would like, format-wise:

GeneA, GeneB, and GeneC have been found to have a role in RNA metabolism.

I can achieve this with:

\textit{GeneA}, \textit{GeneB}, and \textit{GeneC} have been found to have a role in RNA metabolism.

Is there a way to italicise a list of words, but leaving the comma out as textit also italicises the commas? i.e.

\italiciselist{GeneA, GeneB}, and \textit{GeneC} have been found to have a role in RNA metabolism.

It's not a problem with 2 or 3 words needing italicising, but when it's longer, it would be much easier with a function which takes more than one word.

• or \newcommand\z[1]{\textit{Gene#1}} then \z{A}, \z{B}, \z{C} – David Carlisle Oct 7 '20 at 10:21

From the example below, copy the lines between \makeatletter and \makeatother (inclusively) to the preamble of your document. They define your command \italiciselist.

\documentclass{article}
\makeatletter
\newcommand\italiciselist[1]{%
\def\il@sep{}%
\@for\il@gene:=#1\do{%
\il@sep\textit{\il@gene}%
\def\il@sep{, }%
}%
}
\makeatother
\begin{document}
\italiciselist{GeneA,GeneB}, and \textit{GeneC} have been found to have a role in RNA metabolism.
\end{document}