2

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.

1 Answers1

3

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}

enter image description here

gernot
  • 49,614